diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2012-11-13 18:21:42 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2012-11-13 18:21:42 +0000 |
| commit | eefa924d43400b4ec01b633c972093ae000e433d (patch) | |
| tree | 6a3702624f6539dbf0e47b8a51fcb25a65ba0b2c /src/plugins/General/notifier/notifier.cpp | |
| parent | 639c76276c1c4c8c553eb8b54c057706a7f31e4a (diff) | |
| download | qmmp-eefa924d43400b4ec01b633c972093ae000e433d.tar.gz qmmp-eefa924d43400b4ec01b633c972093ae000e433d.tar.bz2 qmmp-eefa924d43400b4ec01b633c972093ae000e433d.zip | |
added latest psi/psi+ support (Closes issue 559)
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@2994 90c681e8-e032-0410-971d-27865f9a5e38
Diffstat (limited to 'src/plugins/General/notifier/notifier.cpp')
| -rw-r--r-- | src/plugins/General/notifier/notifier.cpp | 83 |
1 files changed, 37 insertions, 46 deletions
diff --git a/src/plugins/General/notifier/notifier.cpp b/src/plugins/General/notifier/notifier.cpp index abe875b0a..ed40ea9b9 100644 --- a/src/plugins/General/notifier/notifier.cpp +++ b/src/plugins/General/notifier/notifier.cpp @@ -42,45 +42,41 @@ Notifier::Notifier(QObject *parent) : QObject(parent) connect (m_core, SIGNAL(metaDataChanged ()), SLOT(showMetaData())); connect (m_core, SIGNAL(stateChanged (Qmmp::State)), SLOT(setState(Qmmp::State))); connect (m_core, SIGNAL(volumeChanged(int, int)), SLOT(showVolume(int, int))); - if(m_psi) //clear psi notification + + //psi tune files (thousands of them!) + QString psi_data_dir = qgetenv("PSIDATADIR"); + QString xdg_cache_home = qgetenv("XDG_CACHE_HOME"); + if(!psi_data_dir.isEmpty()) + m_psiTuneFiles << psi_data_dir+"/tune"; + else if(!xdg_cache_home.isEmpty()) + { + m_psiTuneFiles << xdg_cache_home+"/psi/tune"; + m_psiTuneFiles << xdg_cache_home+"/psi+/tune"; + } + else { - QFile::remove(QDir::homePath()+"/.psi/tune"); - QFile::remove(QDir::homePath()+"/.psi-plus/tune"); - QFile::remove(QDir::homePath()+"/.cache/Psi+/tune"); + m_psiTuneFiles << QDir::homePath()+"/.cache/psi/tune"; + m_psiTuneFiles << QDir::homePath()+"/.cache/psi+/tune"; } + //legacy psi support + m_psiTuneFiles << QDir::homePath()+"/.psi/tune"; + m_psiTuneFiles << QDir::homePath()+"/.psi-plus/tune"; + m_psiTuneFiles << QDir::homePath()+"/.cache/Psi+/tune"; + if (m_core->state() == Qmmp::Playing) //test message showMetaData(); } Notifier::~Notifier() { - if(m_psi) //clear psi notification - { - QFile::remove(QDir::homePath()+"/.psi/tune"); - QFile::remove(QDir::homePath()+"/.psi-plus/tune"); - QFile::remove(QDir::homePath()+"/.cache/Psi+/tune"); - } + removePsiTuneFiles(); } void Notifier::setState(Qmmp::State state) { - switch ((uint) state) + if(state == Qmmp::Stopped) { - case Qmmp::Playing: - case Qmmp::Paused: - { - break; - } - case Qmmp::Stopped: - { - if (m_psi) - { - QFile::remove(QDir::homePath()+"/.psi/tune"); - QFile::remove(QDir::homePath()+"/.psi-plus/tune"); - QFile::remove(QDir::homePath()+"/.cache/Psi+/tune"); - } - break; - } + removePsiTuneFiles(); } } @@ -103,32 +99,18 @@ void Notifier::showMetaData() data.append(m_core->metaData(Qmmp::TRACK).toUtf8()+"\n"); data.append(QString("%1").arg(m_core->totalTime()/1000).toUtf8()+"\n"); - QDir psi_dir(QDir::homePath()+"/.psi/"); - if(psi_dir.exists()) + foreach(QString path, m_psiTuneFiles) { - QFile file(QDir::homePath()+"/.psi/tune"); - file.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate); - file.write(data); - file.close(); - } + QDir tuneDir = QFileInfo(path).absoluteDir(); + if(!tuneDir.exists()) + continue; - QDir psi_plus_dir(QDir::homePath()+"/.psi-plus/"); - if(psi_plus_dir.exists()) - { - QFile file(QDir::homePath()+"/.psi-plus/tune"); - file.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate); - file.write(data); - file.close(); - } - QDir psi_plus_dir2(QDir::homePath()+"/.cache/Psi+/"); - if(psi_plus_dir2.exists()) - { - QFile file(QDir::homePath()+"/.cache/Psi+/tune"); + QFile file(path); file.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate); file.write(data); file.close(); + continue; } - } void Notifier::showVolume(int l, int r) @@ -145,3 +127,12 @@ void Notifier::showVolume(int l, int r) m_r = r; } } + +void Notifier::removePsiTuneFiles() +{ + if(m_psi) //clear psi notification + { + foreach(QString path, m_psiTuneFiles) + QFile::remove(path); + } +} |
