From 7cfdd4758767e6c5a6fceb0cb5d12ef3b1c99b5d Mon Sep 17 00:00:00 2001 From: Dominik Riebeling Date: Sat, 2 May 2009 18:40:04 +0000 Subject: 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 --- rbutil/rbutilqt/progressloggergui.cpp | 37 +++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) (limited to 'rbutil/rbutilqt/progressloggergui.cpp') diff --git a/rbutil/rbutilqt/progressloggergui.cpp b/rbutil/rbutilqt/progressloggergui.cpp index a96778b..0358d75 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() { -- cgit v1.1