Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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
stuartm committed Jul 15, 2012
1 parent 49a7f31 commit d00d2a8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
16 changes: 11 additions & 5 deletions mythtv/libs/libmyth/mythmediamonitor.cpp
Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -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)
{
Expand All @@ -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");
Expand Down Expand Up @@ -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;
Expand Down
7 changes: 5 additions & 2 deletions mythtv/libs/libmyth/mythmediamonitor.h
Expand Up @@ -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);

Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythbase/mythcdrom-linux.cpp
Expand Up @@ -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())
{
Expand Down

0 comments on commit d00d2a8

Please sign in to comment.