Permalink
Browse files

Only prompt the user to select from 'usable' media

If a user has multiple optical drives but only one or two contain discs
then there is no need to show all in the drive selection popup. In
cases where only one drive contains media this avoids showing the popup at all.
  • Loading branch information...
1 parent 49a7f31 commit d00d2a85a7d2a9cffe57ceadae9d8476b50e9e22 @stuartm stuartm committed Jul 15, 2012
View
16 mythtv/libs/libmyth/mythmediamonitor.cpp
@@ -134,7 +134,8 @@ static const QString DevName(MythMediaDevice *d)
*
* Has to iterate through all devices to check if any are suitable.
*/
-QList<MythMediaDevice*> MediaMonitor::GetRemovable(bool showMounted)
+QList<MythMediaDevice*> MediaMonitor::GetRemovable(bool showMounted,
+ bool showUsable)
{
QList <MythMediaDevice *> drives;
QList <MythMediaDevice *>::iterator it;
@@ -145,6 +146,9 @@ QList<MythMediaDevice*> MediaMonitor::GetRemovable(bool showMounted)
// By default, we only list CD/DVD devices.
// Caller can also request mounted drives to be listed (e.g. USB flash)
+ if (showUsable && !(*it)->isUsable())
+ continue;
+
if (QString(typeid(**it).name()).contains("MythCDROM") ||
(showMounted && (*it)->isMounted(false)))
drives.append(*it);
@@ -159,9 +163,11 @@ QList<MythMediaDevice*> MediaMonitor::GetRemovable(bool showMounted)
* prevent drawing a list if there is only one drive, et cetera
*/
MythMediaDevice * MediaMonitor::selectDrivePopup(const QString label,
- bool showMounted)
+ bool showMounted,
+ bool showUsable)
{
- QList <MythMediaDevice *> drives = GetRemovable(showMounted);
+ QList <MythMediaDevice *> drives = GetRemovable(showMounted,
+ showUsable);
if (drives.count() == 0)
{
@@ -183,8 +189,8 @@ MythMediaDevice * MediaMonitor::selectDrivePopup(const QString label,
return drives.front();
}
- QStringList buttonmsgs;
QList <MythMediaDevice *>::iterator it;
+ QStringList buttonmsgs;
for (it = drives.begin(); it != drives.end(); ++it)
buttonmsgs += DevName(*it);
buttonmsgs += tr("Cancel");
@@ -824,7 +830,7 @@ QString MediaMonitor::defaultDevice(QString dbSetting,
if (c_monitor)
{
- MythMediaDevice *d = c_monitor->selectDrivePopup(label);
+ MythMediaDevice *d = c_monitor->selectDrivePopup(label, false, true);
if (d == (MythMediaDevice *) -1) // User cancelled
d = NULL;
View
7 mythtv/libs/libmyth/mythmediamonitor.h
@@ -57,7 +57,8 @@ class MPUBLIC MediaMonitor : public QObject
// To safely dereference the pointers returned by this function
// first validate the pointer with ValidateAndLock(), if true is returned
// it is safe to dereference the pointer. When finished call Unlock()
- QList<MythMediaDevice*> GetRemovable(bool mounted=false);
+ QList<MythMediaDevice*> GetRemovable(bool showMounted = false,
+ bool showUsable = false);
QList<MythMediaDevice*> GetMedias(MythMediaType mediatype);
MythMediaDevice* GetMedia(const QString &path);
@@ -101,7 +102,9 @@ class MPUBLIC MediaMonitor : public QObject
static QString defaultDevice(const QString setting,
const QString label,
const char *hardCodedDefault);
- MythMediaDevice *selectDrivePopup(const QString label, bool mounted=false);
+ MythMediaDevice *selectDrivePopup(const QString label,
+ bool showMounted = false,
+ bool showUsable = false);
protected:
QMutex m_DevicesLock;
View
2 mythtv/libs/libmythbase/mythcdrom-linux.cpp
@@ -529,7 +529,7 @@ MythMediaStatus MythCDROMLinux::checkMedia()
if (isMounted())
onDeviceMounted();
else if (!mount()) // onDeviceMounted() called as side-effect
- return setStatus(MEDIASTAT_ERROR, OpenedHere);
+ return setStatus(MEDIASTAT_NOTMOUNTED, OpenedHere);
if (isMounted())
{

0 comments on commit d00d2a8

Please sign in to comment.