Permalink
Browse files

MythMusic: Add an exit prompt to the import screen

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...
1 parent c1bf1e7 commit 7a3ed33708a010f657469fdcde41087f75cb8ab1 Paul Harrison committed Sep 20, 2011
Showing with 32 additions and 0 deletions.
  1. +31 −0 mythplugins/mythmusic/mythmusic/importmusic.cpp
  2. +1 −0 mythplugins/mythmusic/mythmusic/importmusic.h
View
31 mythplugins/mythmusic/mythmusic/importmusic.cpp
@@ -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();
@@ -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");
View
1 mythplugins/mythmusic/mythmusic/importmusic.h
@@ -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);

0 comments on commit 7a3ed33

Please sign in to comment.