Skip to content
Browse files

Convert two busy dialogs in the CD ripping screen to mythui.

  • Loading branch information...
1 parent f7ad913 commit 66b3573fba19f310b09412ac5701ba8b711ccb4b @stuartm stuartm committed Dec 3, 2010
Showing with 41 additions and 36 deletions.
  1. +35 −34 mythplugins/mythmusic/mythmusic/cdrip.cpp
  2. +6 −2 mythplugins/mythmusic/mythmusic/cdrip.h
View
69 mythplugins/mythmusic/mythmusic/cdrip.cpp
@@ -44,6 +44,10 @@ using namespace std;
#include <mythuiprogressbar.h>
#include <mythuibuttonlist.h>
+// MythUI headers
+#include <mythtv/libmythui/mythscreenstack.h>
+#include <mythtv/libmythui/mythprogressdialog.h>
+
// MythMusic includes
#include "cdrip.h"
#include "cddecoder.h"
@@ -462,7 +466,8 @@ int CDRipperThread::ripTrack(QString &cddevice, Encoder *encoder, int tracknum)
///////////////////////////////////////////////////////////////////////////////
Ripper::Ripper(MythScreenStack *parent, QString device)
- : MythScreenType(parent, "ripcd")
+ : MythScreenType(parent, "ripcd"),
+ m_ejectThread(NULL), m_scanThread(NULL)
{
m_CDdevice = device;
@@ -594,18 +599,21 @@ bool Ripper::keyPressEvent(QKeyEvent *event)
void Ripper::startScanCD(void)
{
- MythBusyDialog *busy = new MythBusyDialog("Scanning CD. Please Wait ...");
- CDScannerThread *scanner = new CDScannerThread(this);
- busy->start();
- scanner->start();
+ if (m_scanThread)
+ return;
- while (!scanner->isFinished())
- {
- usleep(500);
- qApp->processEvents();
- }
+ QString message = QObject::tr("Scanning CD. Please Wait ...");
+ OpenBusyPopup(message);
+
+ m_scanThread = new CDScannerThread(this);
+ connect(m_scanThread, SIGNAL(finished()), SLOT(ScanFinished()));
+ m_scanThread->start();
+}
- delete scanner;
+void Ripper::ScanFinished()
+{
+ delete m_scanThread;
+ m_scanThread = NULL;
m_tracks->clear();
@@ -741,7 +749,7 @@ void Ripper::startScanCD(void)
BuildFocusList();
updateTrackList();
- busy->deleteLater();
+ CloseBusyPopup();
}
void Ripper::scanCD(void)
@@ -1148,14 +1156,6 @@ void Ripper::switchTitlesAndArtists()
}
}
-void Ripper::reject()
-{
- if (!GetMythMainWindow()->IsExitingToMain())
- startEjectCD();
-
- Close();
-}
-
void Ripper::startRipper(void)
{
if (m_tracks->size() == 0)
@@ -1200,23 +1200,24 @@ void Ripper::RipComplete(bool result)
void Ripper::startEjectCD()
{
- MythBusyDialog *busy
- = new MythBusyDialog(tr("Ejecting CD. Please Wait ..."));
- CDEjectorThread *ejector = new CDEjectorThread(this);
- busy->start();
- ejector->start();
+ if (m_ejectThread)
+ return;
- while (!ejector->isFinished())
- {
- usleep(500);
- qApp->processEvents();
- }
+ QString message = tr("Ejecting CD. Please Wait ...");
- delete ejector;
- busy->deleteLater();
+ OpenBusyPopup(message);
- if (class LCD * lcd = LCD::Get())
- lcd->switchToTime();
+ m_ejectThread = new CDEjectorThread(this);
+ connect(m_ejectThread, SIGNAL(finished()), SLOT(EjectFinished()));
+ m_ejectThread->start();
+}
+
+void Ripper::EjectFinished()
+{
+ delete m_ejectThread;
+ m_ejectThread = NULL;
+
+ CloseBusyPopup();
}
void Ripper::ejectCD()
View
8 mythplugins/mythmusic/mythmusic/cdrip.h
@@ -104,13 +104,14 @@ class Ripper : public MythScreenType
void yearChanged(void);
void compilationChanged(bool state);
void switchTitlesAndArtists();
- void reject();
void searchArtist(void);
void searchAlbum(void);
void searchGenre(void);
void RipComplete(bool result);
void toggleTrackActive(MythUIButtonListItem *);
void showEditMetadataDialog(MythUIButtonListItem *);
+ void EjectFinished(void);
+ void ScanFinished(void);
signals:
void ripFinished(void);
@@ -137,7 +138,7 @@ class Ripper : public MythScreenType
MythUIButtonList *m_trackList;
MythUIButtonList *m_qualityList;
- MythUIButton *m_switchTitleArtist;
+ MythUIButton *m_switchTitleArtist;
MythUIButton *m_scanButton;
MythUIButton *m_ripButton;
MythUIButton *m_searchArtistButton;
@@ -152,6 +153,9 @@ class Ripper : public MythScreenType
bool m_mediaMonitorActive;
QString m_CDdevice;
+
+ CDEjectorThread *m_ejectThread;
+ CDScannerThread *m_scanThread;
};

0 comments on commit 66b3573

Please sign in to comment.
Something went wrong with that request. Please try again.