Skip to content

Commit

Permalink
MythMusic: Add an exit prompt to the import screen
Browse files Browse the repository at this point in the history
This asks if you are sure you want to exit the import tracks screen if there
are tracks that haven't been imported yet. Once to often I've edited some
tracks metadata that are waiting to be imported only to accidentally exit
out of the screen before they've been imported.
  • Loading branch information
Paul Harrison committed Sep 20, 2011
1 parent c1bf1e7 commit 7a3ed33
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
31 changes: 31 additions & 0 deletions mythplugins/mythmusic/mythmusic/importmusic.cpp
Expand Up @@ -210,6 +210,31 @@ bool ImportMusicDialog::keyPressEvent(QKeyEvent *event)
{
showMenu();
}
else if (action == "ESCAPE" && !GetMythMainWindow()->IsExitingToMain())
{
bool found = false;
if (!m_tracks->empty())
{
uint track = 0;
while (track < m_tracks->size())
{
if (m_tracks->at(track)->isNewTune)
{
found = true;
break;
}
track++;
}

if (found)
{
QString msg = tr("You might have unsaved changes.\nAre you sure you want to exit this screen?");
ShowOkPopup(msg, this, SLOT(doExit(bool)), true);
}
}

handled = found;
}
else if (action == "1")
{
setCompilation();
Expand Down Expand Up @@ -313,6 +338,12 @@ bool ImportMusicDialog::Create()
return true;
}

void ImportMusicDialog::doExit(bool ok)
{
if (ok)
Close();
}

void ImportMusicDialog::locationPressed()
{
MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack");
Expand Down
1 change: 1 addition & 0 deletions mythplugins/mythmusic/mythmusic/importmusic.h
Expand Up @@ -66,6 +66,7 @@ class ImportMusicDialog : public MythScreenType
void prevPressed(void);
void showEditMetadataDialog(void);
void startScan(void);
void doExit(bool ok);

// popup menu
void showMenu(void);
Expand Down

0 comments on commit 7a3ed33

Please sign in to comment.