summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Thiago Macieira <thiago@macieira.org>2013-11-14 16:50:46 -0800
committerGravatar Thiago Macieira <thiago@macieira.org>2013-12-03 13:53:00 -0800
commitfa07f554e2894c7720a41c1fbb379743dd6c7285 (patch)
treede55d2e385b3a51845c84731a0c06207338d79c8 /qt-ui
parent481ddf43c6371f62fedce4ed6cae538d760a86b2 (diff)
downloadsubsurface-fa07f554e2894c7720a41c1fbb379743dd6c7285.tar.gz
Properly reset the state of the download dialog before dismissing
Re-enable buttons that should be enabled by default, disable the others, set the status to empty, make the progress bar go back to zero. Signed-off-by: Thiago Macieira <thiago@macieira.org>
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/subsurfacewebservices.cpp16
-rw-r--r--qt-ui/subsurfacewebservices.h2
2 files changed, 14 insertions, 4 deletions
diff --git a/qt-ui/subsurfacewebservices.cpp b/qt-ui/subsurfacewebservices.cpp
index 850e076f3..1f47d965b 100644
--- a/qt-ui/subsurfacewebservices.cpp
+++ b/qt-ui/subsurfacewebservices.cpp
@@ -115,6 +115,14 @@ QNetworkAccessManager *WebServices::manager()
return manager;
}
+void WebServices::resetState()
+{
+ ui.download->setEnabled(true);
+ ui.progressBar->reset();
+ ui.progressBar->setRange(0,1);
+ ui.status->setText(QString());
+}
+
// #
// #
// # Subsurface Web Service Implementation.
@@ -156,12 +164,13 @@ void SubsurfaceWebServices::buttonClicked(QAbstractButton* button)
s.sync();
hide();
close();
+ resetState();
}
break;
case QDialogButtonBox::RejectRole:
// we may want to clean up after ourselves
// reply->deleteLater();
- ui.progressBar->setMaximum(1);
+ resetState();
break;
case QDialogButtonBox::HelpRole:
QDesktopServices::openUrl(QUrl("http://api.hohndel.org"));
@@ -208,9 +217,8 @@ void SubsurfaceWebServices::downloadFinished()
void SubsurfaceWebServices::downloadError(QNetworkReply::NetworkError)
{
- ui.download->setEnabled(true);
- ui.progressBar->setRange(0,1);
- ui.status->setText(QString::number((int)QNetworkRequest::HttpStatusCodeAttribute));
+ resetState();
+ ui.status->setText(tr("Download error: %1").arg(reply->errorString()));
reply->deleteLater();
}
diff --git a/qt-ui/subsurfacewebservices.h b/qt-ui/subsurfacewebservices.h
index 0400fd503..0cd083001 100644
--- a/qt-ui/subsurfacewebservices.h
+++ b/qt-ui/subsurfacewebservices.h
@@ -25,6 +25,8 @@ private slots:
virtual void buttonClicked(QAbstractButton* button) = 0;
protected:
+ void resetState();
+
Ui::WebServices ui;
QNetworkReply *reply;
QByteArray downloadedData;