mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
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>
This commit is contained in:
parent
481ddf43c6
commit
fa07f554e2
2 changed files with 14 additions and 4 deletions
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,8 @@ private slots:
|
|||
virtual void buttonClicked(QAbstractButton* button) = 0;
|
||||
|
||||
protected:
|
||||
void resetState();
|
||||
|
||||
Ui::WebServices ui;
|
||||
QNetworkReply *reply;
|
||||
QByteArray downloadedData;
|
||||
|
|
Loading…
Reference in a new issue