From 8a72e0d67cb208957842883433f8bcb3e9ceb558 Mon Sep 17 00:00:00 2001 From: trialuser02 Date: Sun, 2 Dec 2018 08:51:06 +0000 Subject: rdetect: cda support git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@8472 90c681e8-e032-0410-971d-27865f9a5e38 --- src/plugins/General/rdetect/removablehelper.cpp | 34 ++++++++++++++++++++----- src/plugins/General/rdetect/removablehelper.h | 1 + 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/src/plugins/General/rdetect/removablehelper.cpp b/src/plugins/General/rdetect/removablehelper.cpp index 8dcb16500..ec939d9aa 100644 --- a/src/plugins/General/rdetect/removablehelper.cpp +++ b/src/plugins/General/rdetect/removablehelper.cpp @@ -20,8 +20,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -106,16 +106,22 @@ void RemovableHelper::updateActions() QString dev_path; - qDebug() << storage.fileSystemType(); - if(m_detectRemovable && storage.bytesTotal() < 40000000000LL && (storage.fileSystemType() == "NTFS" || storage.fileSystemType() == "FAT32" || - storage.fileSystemType() == "CDFS" || storage.fileSystemType() == "UDF")) { dev_path = storage.rootPath(); } + else if(storage.fileSystemType() == "CDFS") + { + dev_path = storage.rootPath(); + if(isAudioCd(dev_path)) + { + dev_path = QString("cdda://%1").arg(dev_path); + dev_path = dev_path.left(dev_path.size() - 1); //remove trailing '/' + } + } else continue; @@ -123,15 +129,16 @@ void RemovableHelper::updateActions() { QAction *action = new QAction(this); QString actionText; - /*if (device->isAudio()) + if (dev_path.startsWith("cdda")) { actionText = QString(tr("Add CD \"%1\"")).arg(storage.displayName()); } - else*/ + else { actionText = QString(tr("Add Volume \"%1\"")).arg(storage.displayName()); } + if(storage.fileSystemType() == "CDFS") action->setIcon(qApp->style()->standardIcon(QStyle::SP_DriveCDIcon)); else if(storage.fileSystemType() == "UDF") @@ -154,7 +161,14 @@ void RemovableHelper::updateActions() foreach(const QStorageInfo &storage, volumes) { - if(storage.rootPath() == action->data().toString()) + QString dev_path = storage.rootPath(); + if(isAudioCd(dev_path)) + { + dev_path = QString("cdda://%1").arg(dev_path); + dev_path = dev_path.left(dev_path.size() - 1); //remove trailing '/' + } + + if(dev_path == action->data().toString()) { found = true; break; @@ -221,3 +235,9 @@ void RemovableHelper::removePath(const QString &path) } } +bool RemovableHelper::isAudioCd(const QString &path) +{ + QDir dir(path); + return !dir.entryInfoList(QStringList() << "*.cda").isEmpty(); +} + diff --git a/src/plugins/General/rdetect/removablehelper.h b/src/plugins/General/rdetect/removablehelper.h index c97b1b749..6ef31efb3 100644 --- a/src/plugins/General/rdetect/removablehelper.h +++ b/src/plugins/General/rdetect/removablehelper.h @@ -43,6 +43,7 @@ private: QAction *findAction(const QString &dev_path); void addPath(const QString &path); void removePath(const QString &path); + bool isAudioCd(const QString &path); QActionGroup *m_actions; bool m_detectCDA; -- cgit v1.2.3-13-gbd6f