summaryrefslogtreecommitdiffstats
path: root/rbutil
diff options
context:
space:
mode:
authorDominik Riebeling <Dominik.Riebeling@gmail.com>2009-05-02 18:40:04 +0000
committerDominik Riebeling <Dominik.Riebeling@gmail.com>2009-05-02 18:40:04 +0000
commit7cfdd4758767e6c5a6fceb0cb5d12ef3b1c99b5d (patch)
tree9814a23e24cd9be26f0009835a463b5a9c097f7f /rbutil
parentb10ba5e8b34eaac0c4b72bcf3be3db180c43126a (diff)
downloadrockbox-7cfdd4758767e6c5a6fceb0cb5d12ef3b1c99b5d.tar.gz
rockbox-7cfdd4758767e6c5a6fceb0cb5d12ef3b1c99b5d.tar.bz2
rockbox-7cfdd4758767e6c5a6fceb0cb5d12ef3b1c99b5d.zip
Clean up ProgressLogger state handling:
- use better names for member functions - don't emit aborted() when exiting a successful log git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20844 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'rbutil')
-rw-r--r--rbutil/rbutilqt/base/uninstall.cpp4
-rw-r--r--rbutil/rbutilqt/install.cpp8
-rw-r--r--rbutil/rbutilqt/installtalkwindow.cpp2
-rw-r--r--rbutil/rbutilqt/progressloggergui.cpp37
-rw-r--r--rbutil/rbutilqt/progressloggergui.h4
-rw-r--r--rbutil/rbutilqt/progressloggerinterface.h4
-rw-r--r--rbutil/rbutilqt/rbutilqt.cpp32
-rw-r--r--rbutil/rbutilqt/talkfile.cpp8
-rw-r--r--rbutil/rbutilqt/themesinstallwindow.cpp10
-rw-r--r--rbutil/rbutilqt/voicefile.cpp20
-rw-r--r--rbutil/rbutilqt/zipinstaller.cpp14
11 files changed, 80 insertions, 63 deletions
diff --git a/rbutil/rbutilqt/base/uninstall.cpp b/rbutil/rbutilqt/base/uninstall.cpp
index ae5ece7da5..b7a63edcd5 100644
--- a/rbutil/rbutilqt/base/uninstall.cpp
+++ b/rbutil/rbutilqt/base/uninstall.cpp
@@ -36,7 +36,7 @@ void Uninstaller::deleteAll(ProgressloggerInterface* dp)
m_dp->setProgressMax(1);
m_dp->setProgressValue(1);
m_dp->addItem(tr("Finished Uninstallation"),LOGOK);
- m_dp->abort();
+ m_dp->setFinished();
}
void Uninstaller::uninstall(ProgressloggerInterface* dp)
@@ -110,7 +110,7 @@ void Uninstaller::uninstall(ProgressloggerInterface* dp)
m_dp->setProgressMax(1);
m_dp->setProgressValue(1);
m_dp->addItem(tr("Uninstallation finished"),LOGOK);
- m_dp->abort();
+ m_dp->setFinished();
}
QStringList Uninstaller::getAllSections()
diff --git a/rbutil/rbutilqt/install.cpp b/rbutil/rbutilqt/install.cpp
index 2332a713c4..946c7013fa 100644
--- a/rbutil/rbutilqt/install.cpp
+++ b/rbutil/rbutilqt/install.cpp
@@ -96,7 +96,7 @@ void Install::accept()
// show dialog with error if mount point is wrong
if(!QFileInfo(mountPoint).isDir()) {
logger->addItem(tr("Mount point is wrong!"),LOGERROR);
- logger->abort();
+ logger->setFinished();
return;
}
@@ -141,7 +141,7 @@ void Install::accept()
== QMessageBox::Abort)
{
logger->addItem(tr("Aborted!"),LOGERROR);
- logger->abort();
+ logger->setFinished();
return;
}
}
@@ -170,7 +170,7 @@ void Install::accept()
else
{
logger->addItem(tr("Backup failed!"),LOGERROR);
- logger->abort();
+ logger->setFinished();
return;
}
}
@@ -212,7 +212,7 @@ void Install::done(bool error)
if(error)
{
- logger->abort();
+ logger->setFinished();
return;
}
diff --git a/rbutil/rbutilqt/installtalkwindow.cpp b/rbutil/rbutilqt/installtalkwindow.cpp
index 041b8f2885..cfe38ed2b9 100644
--- a/rbutil/rbutilqt/installtalkwindow.cpp
+++ b/rbutil/rbutilqt/installtalkwindow.cpp
@@ -84,7 +84,7 @@ void InstallTalkWindow::accept()
if(!QFileInfo(folderToTalk).isDir())
{
logger->addItem(tr("The Folder to Talk is wrong!"),LOGERROR);
- logger->abort();
+ logger->setFinished();
return;
}
diff --git a/rbutil/rbutilqt/progressloggergui.cpp b/rbutil/rbutilqt/progressloggergui.cpp
index a96778bc11..0358d75096 100644
--- a/rbutil/rbutilqt/progressloggergui.cpp
+++ b/rbutil/rbutilqt/progressloggergui.cpp
@@ -25,7 +25,7 @@ ProgressLoggerGui::ProgressLoggerGui(QWidget* parent): ProgressloggerInterface(p
downloadProgress->setModal(true);
dp.setupUi(downloadProgress);
dp.listProgress->setAlternatingRowColors(true);
- connect(dp.buttonAbort, SIGNAL(clicked()), this, SLOT(abort()));
+ setRunning();
}
void ProgressLoggerGui::addItem(const QString &text)
@@ -87,22 +87,39 @@ void ProgressLoggerGui::setProgressVisible(bool b)
}
-void ProgressLoggerGui::abort()
+/** Set logger into "running" state -- the reporting process is still running.
+ * Display "Abort" and emit the aborted() signal on button press.
+ */
+void ProgressLoggerGui::setRunning()
+{
+ dp.buttonAbort->setText(tr("&Abort"));
+ dp.buttonAbort->setIcon(QIcon(QString::fromUtf8(":/icons/process-stop.png")));
+
+ // make sure to not close the window on button press.
+ disconnect(dp.buttonAbort, SIGNAL(clicked()), downloadProgress, SLOT(close()));
+ // emit aborted() once button is pressed but not closed().
+ disconnect(dp.buttonAbort, SIGNAL(clicked()), this, SIGNAL(closed()));
+ connect(dp.buttonAbort, SIGNAL(clicked()), this, SIGNAL(aborted()));
+
+}
+
+
+/** Set logger into "finished" state -- the reporting process is finished.
+ * Display "Ok". Don't emit aborted() as there is nothing running left.
+ * Close logger on button press and emit closed().
+ */
+void ProgressLoggerGui::setFinished()
{
dp.buttonAbort->setText(tr("&Ok"));
dp.buttonAbort->setIcon(QIcon(QString::fromUtf8(":/icons/go-next.png")));
- disconnect(dp.buttonAbort, SIGNAL(clicked()), this, SLOT(abort()));
+
+ // close the window on button press.
connect(dp.buttonAbort, SIGNAL(clicked()), downloadProgress, SLOT(close()));
+ // emit closed() once button is pressed but not aborted().
+ disconnect(dp.buttonAbort, SIGNAL(clicked()), this, SIGNAL(aborted()));
connect(dp.buttonAbort, SIGNAL(clicked()), this, SIGNAL(closed()));
- emit aborted();
}
-void ProgressLoggerGui::undoAbort()
-{
- dp.buttonAbort->setText(tr("&Abort"));
- dp.buttonAbort->setIcon(QIcon(QString::fromUtf8(":/icons/process-stop.png")));
- connect(dp.buttonAbort, SIGNAL(clicked()), this, SLOT(abort()));
-}
void ProgressLoggerGui::close()
{
diff --git a/rbutil/rbutilqt/progressloggergui.h b/rbutil/rbutilqt/progressloggergui.h
index c1fdf0c7c6..c5e8c449ce 100644
--- a/rbutil/rbutilqt/progressloggergui.h
+++ b/rbutil/rbutilqt/progressloggergui.h
@@ -46,10 +46,10 @@ public slots:
virtual void addItem(const QString &text, int flag); //! add a string to the list
virtual void setProgress(int, int); //! set progress bar
- virtual void abort();
- virtual void undoAbort();
virtual void close();
virtual void show();
+ virtual void setRunning();
+ virtual void setFinished();
private:
Ui::ProgressLoggerFrm dp;
diff --git a/rbutil/rbutilqt/progressloggerinterface.h b/rbutil/rbutilqt/progressloggerinterface.h
index 2459228e79..4a8fd831f1 100644
--- a/rbutil/rbutilqt/progressloggerinterface.h
+++ b/rbutil/rbutilqt/progressloggerinterface.h
@@ -49,10 +49,10 @@ public slots:
virtual void addItem(const QString &text)=0; //! add a string to the progress
virtual void addItem(const QString &text, int flag)=0; //! add a string to the list, with icon
- virtual void abort()=0;
- virtual void undoAbort()=0;
virtual void close()=0;
virtual void show()=0;
+ virtual void setRunning()=0;
+ virtual void setFinished()=0;
private:
diff --git a/rbutil/rbutilqt/rbutilqt.cpp b/rbutil/rbutilqt/rbutilqt.cpp
index e126b0ec45..d36f9637c0 100644
--- a/rbutil/rbutilqt/rbutilqt.cpp
+++ b/rbutil/rbutilqt/rbutilqt.cpp
@@ -393,7 +393,7 @@ void RbUtilQt::completeInstall()
if(smallInstallInner())
return;
- logger->undoAbort();
+ logger->setRunning();
// Fonts
m_error = false;
m_installed = false;
@@ -406,7 +406,7 @@ void RbUtilQt::completeInstall()
QApplication::processEvents();
}
if(m_error) return;
- logger->undoAbort();
+ logger->setRunning();
// Doom
if(hasDoom())
@@ -459,7 +459,7 @@ bool RbUtilQt::smallInstallInner()
// show dialog with error if mount point is wrong
if(!QFileInfo(mountpoint).isDir()) {
logger->addItem(tr("Mount point is wrong!"),LOGERROR);
- logger->abort();
+ logger->setFinished();
return true;
}
// Bootloader
@@ -469,7 +469,7 @@ bool RbUtilQt::smallInstallInner()
m_installed = false;
m_auto = true;
if(!installBootloaderAuto()) {
- logger->abort();
+ logger->setFinished();
return true;
}
else
@@ -480,7 +480,7 @@ bool RbUtilQt::smallInstallInner()
}
m_auto = false;
if(m_error) return true;
- logger->undoAbort();
+ logger->setRunning();
}
// Rockbox
@@ -533,7 +533,7 @@ bool RbUtilQt::installAuto()
QMessageBox::Ok | QMessageBox::Abort, QMessageBox::Abort) == QMessageBox::Abort)
{
logger->addItem(tr("Aborted!"), LOGERROR);
- logger->abort();
+ logger->setFinished();
return false;
}
}
@@ -568,7 +568,7 @@ bool RbUtilQt::installAuto()
else
{
logger->addItem(tr("Backup failed!"),LOGERROR);
- logger->abort();
+ logger->setFinished();
return false;
}
}
@@ -647,7 +647,7 @@ void RbUtilQt::installBootloader()
}
else {
logger->addItem(tr("No install method known."), LOGERROR);
- logger->abort();
+ logger->setFinished();
return;
}
@@ -749,7 +749,7 @@ void RbUtilQt::installBootloader()
// the bootloader install class does NOT use any GUI stuff.
// All messages are passed via signals.
- connect(bl, SIGNAL(done(bool)), logger, SLOT(abort()));
+ connect(bl, SIGNAL(done(bool)), logger, SLOT(setFinished()));
connect(bl, SIGNAL(done(bool)), this, SLOT(installBootloaderPost(bool)));
connect(bl, SIGNAL(logItem(QString, int)), logger, SLOT(addItem(QString, int)));
connect(bl, SIGNAL(logProgress(int, int)), logger, SLOT(setProgress(int, int)));
@@ -762,7 +762,7 @@ void RbUtilQt::installBootloader()
tr("Could not create backup file. Continue?"),
QMessageBox::No | QMessageBox::Yes)
== QMessageBox::No) {
- logger->abort();
+ logger->setFinished();
return;
}
}
@@ -990,7 +990,7 @@ void RbUtilQt::uninstallBootloader(void)
}
else {
logger->addItem(tr("No uninstall method known."), LOGERROR);
- logger->abort();
+ logger->setFinished();
return;
}
@@ -1011,7 +1011,7 @@ void RbUtilQt::uninstallBootloader(void)
int result;
result = bl->uninstall();
- logger->abort();
+ logger->setFinished();
}
@@ -1079,7 +1079,7 @@ void RbUtilQt::installPortable(void)
// check mountpoint
if(!QFileInfo(settings->value(RbSettings::Mountpoint).toString()).isDir()) {
logger->addItem(tr("Mount point is wrong!"),LOGERROR);
- logger->abort();
+ logger->setFinished();
return;
}
@@ -1093,7 +1093,7 @@ void RbUtilQt::installPortable(void)
settings->value(RbSettings::Mountpoint).toString()
+ "/RockboxUtility.exe")) {
logger->addItem(tr("Error installing Rockbox Utility"), LOGERROR);
- logger->abort();
+ logger->setFinished();
return;
}
logger->addItem(tr("Installing user configuration"), LOGINFO);
@@ -1101,11 +1101,11 @@ void RbUtilQt::installPortable(void)
settings->value(RbSettings::Mountpoint).toString()
+ "/RockboxUtility.ini")) {
logger->addItem(tr("Error installing user configuration"), LOGERROR);
- logger->abort();
+ logger->setFinished();
return;
}
logger->addItem(tr("Successfully installed Rockbox Utility."), LOGOK);
- logger->abort();
+ logger->setFinished();
logger->setProgressMax(1);
logger->setProgressValue(1);
diff --git a/rbutil/rbutilqt/talkfile.cpp b/rbutil/rbutilqt/talkfile.cpp
index fd6f4a2109..d41cb4f440 100644
--- a/rbutil/rbutilqt/talkfile.cpp
+++ b/rbutil/rbutilqt/talkfile.cpp
@@ -47,7 +47,7 @@ bool TalkFileCreator::createTalkFiles(ProgressloggerInterface* logger)
{
m_logger->addItem(errStr.trimmed(),LOGERROR);
m_logger->addItem(tr("Init of TTS engine failed"),LOGERROR);
- m_logger->abort();
+ m_logger->setFinished();
return false;
}
@@ -58,7 +58,7 @@ bool TalkFileCreator::createTalkFiles(ProgressloggerInterface* logger)
if(!m_enc->start())
{
m_logger->addItem(tr("Init of Encoder engine failed"),LOGERROR);
- m_logger->abort();
+ m_logger->setFinished();
m_tts->stop();
return false;
}
@@ -147,7 +147,7 @@ bool TalkFileCreator::createTalkFiles(ProgressloggerInterface* logger)
m_logger->addItem(tr("Finished creating Talk files"),LOGOK);
m_logger->setProgressMax(1);
m_logger->setProgressValue(1);
- m_logger->abort();
+ m_logger->setFinished();
return true;
}
@@ -182,7 +182,7 @@ void TalkFileCreator::doAbort(QStringList cleanupList)
cleanup(cleanupList);
m_logger->setProgressMax(1);
m_logger->setProgressValue(0);
- m_logger->abort();
+ m_logger->setFinished();
m_tts->stop();
m_enc->stop();
}
diff --git a/rbutil/rbutilqt/themesinstallwindow.cpp b/rbutil/rbutilqt/themesinstallwindow.cpp
index 75d3eeb698..56a917cfc6 100644
--- a/rbutil/rbutilqt/themesinstallwindow.cpp
+++ b/rbutil/rbutilqt/themesinstallwindow.cpp
@@ -101,7 +101,7 @@ void ThemesInstallWindow::downloadDone(bool error)
"Please check your network and proxy settings.")
.arg(getter->errorString()), LOGERROR);
getter->abort();
- logger->abort();
+ logger->setFinished();
disconnect(getter, SIGNAL(done(bool)), this, SLOT(downloadDone(bool)));
connect(logger, SIGNAL(closed()), this, SLOT(close()));
return;
@@ -111,12 +111,12 @@ void ThemesInstallWindow::downloadDone(bool error)
qDebug() << "error!";
logger->addItem(tr("the following error occured:\n%1")
.arg(iniDetails.value("error/description", "unknown error").toString()), LOGERROR);
- logger->abort();
+ logger->setFinished();
connect(logger, SIGNAL(closed()), this, SLOT(close()));
return;
}
logger->addItem(tr("done."), LOGOK);
- logger->abort();
+ logger->setFinished();
logger->close();
// setup list
@@ -289,7 +289,7 @@ void ThemesInstallWindow::show()
void ThemesInstallWindow::abort()
{
igetter.abort();
- logger->abort();
+ logger->setFinished();
this->close();
}
@@ -326,7 +326,7 @@ void ThemesInstallWindow::accept()
// show dialog with error if mount point is wrong
if(!QFileInfo(mountPoint).isDir()) {
logger->addItem(tr("Mount point is wrong!"),LOGERROR);
- logger->abort();
+ logger->setFinished();
return;
}
diff --git a/rbutil/rbutilqt/voicefile.cpp b/rbutil/rbutilqt/voicefile.cpp
index c38977af96..dd547773b8 100644
--- a/rbutil/rbutilqt/voicefile.cpp
+++ b/rbutil/rbutilqt/voicefile.cpp
@@ -54,7 +54,7 @@ bool VoiceFileCreator::createVoiceFile(ProgressloggerInterface* logger)
if(!info.open())
{
m_logger->addItem(tr("could not find rockbox-info.txt"),LOGERROR);
- m_logger->abort();
+ m_logger->setFinished();
emit done(false);
return false;
}
@@ -101,14 +101,14 @@ void VoiceFileCreator::downloadDone(bool error)
m_logger->setProgressValue(max);
if(getter->httpResponse() != 200 && !getter->isCached()) {
m_logger->addItem(tr("Download error: received HTTP error %1.").arg(getter->httpResponse()),LOGERROR);
- m_logger->abort();
+ m_logger->setFinished();
emit done(false);
return;
}
if(getter->isCached()) m_logger->addItem(tr("Cached file used."), LOGINFO);
if(error) {
m_logger->addItem(tr("Download error: %1").arg(getter->errorString()),LOGERROR);
- m_logger->abort();
+ m_logger->setFinished();
emit done(false);
return;
}
@@ -122,7 +122,7 @@ void VoiceFileCreator::downloadDone(bool error)
if(!genlang.open(QIODevice::ReadOnly))
{
m_logger->addItem(tr("failed to open downloaded file"),LOGERROR);
- m_logger->abort();
+ m_logger->setFinished();
emit done(false);
return;
}
@@ -136,7 +136,7 @@ void VoiceFileCreator::downloadDone(bool error)
{
m_logger->addItem(errStr,LOGERROR);
m_logger->addItem(tr("Init of TTS engine failed"),LOGERROR);
- m_logger->abort();
+ m_logger->setFinished();
emit done(false);
return;
}
@@ -149,7 +149,7 @@ void VoiceFileCreator::downloadDone(bool error)
{
m_logger->addItem(tr("Init of Encoder engine failed"),LOGERROR);
m_tts->stop();
- m_logger->abort();
+ m_logger->setFinished();
emit done(false);
return;
}
@@ -191,7 +191,7 @@ void VoiceFileCreator::downloadDone(bool error)
if(voicepairs.size() == 0)
{
m_logger->addItem(tr("The downloaded file was empty!"),LOGERROR);
- m_logger->abort();
+ m_logger->setFinished();
m_tts->stop();
emit done(false);
return;
@@ -207,7 +207,7 @@ void VoiceFileCreator::downloadDone(bool error)
if(m_abort)
{
m_logger->addItem("aborted.",LOGERROR);
- m_logger->abort();
+ m_logger->setFinished();
m_tts->stop();
emit done(false);
return;
@@ -256,7 +256,7 @@ void VoiceFileCreator::downloadDone(bool error)
if (ids2 == NULL)
{
m_logger->addItem(tr("Error opening downloaded file"),LOGERROR);
- m_logger->abort();
+ m_logger->setFinished();
emit done(false);
return;
}
@@ -287,7 +287,7 @@ void VoiceFileCreator::downloadDone(bool error)
m_logger->setProgressMax(100);
m_logger->setProgressValue(100);
m_logger->addItem(tr("successfully created."),LOGOK);
- m_logger->abort();
+ m_logger->setFinished();
emit done(true);
}
diff --git a/rbutil/rbutilqt/zipinstaller.cpp b/rbutil/rbutilqt/zipinstaller.cpp
index 9723e10e69..deff52768a 100644
--- a/rbutil/rbutilqt/zipinstaller.cpp
+++ b/rbutil/rbutilqt/zipinstaller.cpp
@@ -59,7 +59,7 @@ void ZipInstaller::installContinue()
}
else {
m_dp->addItem(tr("Installation finished successfully."),LOGOK);
- m_dp->abort();
+ m_dp->setFinished();
emit done(false);
return;
@@ -112,14 +112,14 @@ void ZipInstaller::downloadDone(bool error)
m_dp->setProgressValue(max);
if(getter->httpResponse() != 200 && !getter->isCached()) {
m_dp->addItem(tr("Download error: received HTTP error %1.").arg(getter->httpResponse()),LOGERROR);
- m_dp->abort();
+ m_dp->setFinished();
emit done(true);
return;
}
if(getter->isCached()) m_dp->addItem(tr("Cached file used."), LOGINFO);
if(error) {
m_dp->addItem(tr("Download error: %1").arg(getter->errorString()),LOGERROR);
- m_dp->abort();
+ m_dp->setFinished();
emit done(true);
return;
}
@@ -143,7 +143,7 @@ void ZipInstaller::downloadDone(bool error)
.arg(uz.formatError(ec)),LOGERROR);
m_dp->setProgressMax(1);
m_dp->setProgressValue(1);
- m_dp->abort();
+ m_dp->setFinished();
emit done(true);
return;
}
@@ -153,7 +153,7 @@ void ZipInstaller::downloadDone(bool error)
// cluster sizes on the player).
if(filesystemFree(m_mountpoint) < (uz.totalSize() + 1000000)) {
m_dp->addItem(tr("Not enough disk space! Aborting."), LOGERROR);
- m_dp->abort();
+ m_dp->setFinished();
m_dp->setProgressMax(1);
m_dp->setProgressValue(1);
emit done(true);
@@ -164,7 +164,7 @@ void ZipInstaller::downloadDone(bool error)
if(ec != UnZip::Ok) {
m_dp->addItem(tr("Extracting failed: %1.")
.arg(uz.formatError(ec)),LOGERROR);
- m_dp->abort();
+ m_dp->setFinished();
m_dp->setProgressMax(1);
m_dp->setProgressValue(1);
@@ -188,7 +188,7 @@ void ZipInstaller::downloadDone(bool error)
QFile(m_mountpoint + m_target).remove();
if(!downloadFile->copy(m_mountpoint + m_target)) {
m_dp->addItem(tr("Installing file failed."), LOGERROR);
- m_dp->abort();
+ m_dp->setFinished();
emit done(true);
return;
}