diff options
author | Lubomir I. Ivanov <neolit123@gmail.com> | 2013-12-09 19:23:32 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-12-09 18:40:52 +0100 |
commit | 7c4b083c2bfb53c2c666d99b94d12f588f606e71 (patch) | |
tree | ca871be8978534dab8c147a2619323b479db8ab6 | |
parent | 8f29df6e5aa555f28d88fb54da127a835a8629de (diff) | |
download | subsurface-7c4b083c2bfb53c2c666d99b94d12f588f606e71.tar.gz |
Divelogs.de: change the 'Apply' button to 'Done' for upload
Post downloading we have an 'Apply' button that can be clicked
to apply/merge the downloaded dives. When uploading we
rename the button to 'Done' and enable the button if the
upload was successful. The 'Cancel' button on the other hand
becomes disabled.
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | qt-ui/subsurfacewebservices.cpp | 19 | ||||
-rw-r--r-- | qt-ui/subsurfacewebservices.h | 2 |
2 files changed, 21 insertions, 0 deletions
diff --git a/qt-ui/subsurfacewebservices.cpp b/qt-ui/subsurfacewebservices.cpp index abd5f6fc4..d4a1428ee 100644 --- a/qt-ui/subsurfacewebservices.cpp +++ b/qt-ui/subsurfacewebservices.cpp @@ -200,6 +200,7 @@ WebServices::WebServices(QWidget* parent, Qt::WindowFlags f): QDialog(parent, f) connect(&timeout, SIGNAL(timeout()), this, SLOT(downloadTimedOut())); ui.buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false); timeout.setSingleShot(true); + defaultApplyText = ui.buttonBox->button(QDialogButtonBox::Apply)->text(); } void WebServices::hidePassword() @@ -281,6 +282,7 @@ void WebServices::resetState() ui.progressBar->reset(); ui.progressBar->setRange(0,1); ui.status->setText(QString()); + ui.buttonBox->button(QDialogButtonBox::Apply)->setText(defaultApplyText); } // # @@ -536,6 +538,8 @@ DivelogsDeWebServices* DivelogsDeWebServices::instance() void DivelogsDeWebServices::downloadDives() { + uploadMode = false; + resetState(); hideUpload(); exec(); } @@ -573,6 +577,10 @@ void DivelogsDeWebServices::uploadDives(QIODevice *dldContent) multipart = ∓ hideDownload(); resetState(); + uploadMode = true; + ui.buttonBox->button(QDialogButtonBox::Cancel)->setEnabled(true); + ui.buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false); + ui.buttonBox->button(QDialogButtonBox::Apply)->setText(tr("Done")); exec(); multipart = NULL; @@ -585,6 +593,7 @@ void DivelogsDeWebServices::uploadDives(QIODevice *dldContent) DivelogsDeWebServices::DivelogsDeWebServices(QWidget* parent, Qt::WindowFlags f): WebServices(parent, f) { + uploadMode = false; QSettings s; ui.userID->setText(s.value("divelogde_user").toString()); ui.password->setText(s.value("divelogde_pass").toString()); @@ -758,6 +767,9 @@ void DivelogsDeWebServices::uploadFinished() ui.progressBar->setRange(0,1); ui.upload->setEnabled(true); + ui.buttonBox->button(QDialogButtonBox::Cancel)->setEnabled(false); + ui.buttonBox->button(QDialogButtonBox::Apply)->setEnabled(true); + ui.buttonBox->button(QDialogButtonBox::Apply)->setText(tr("Done")); ui.status->setText(tr("Upload finished")); // check what the server sent us: it might contain @@ -807,6 +819,13 @@ void DivelogsDeWebServices::buttonClicked(QAbstractButton* button) ui.buttonBox->button(QDialogButtonBox::Apply)->setEnabled(false); switch(ui.buttonBox->buttonRole(button)){ case QDialogButtonBox::ApplyRole:{ + /* in 'uploadMode' button is called 'Done' and closes the dialog */ + if (uploadMode) { + hide(); + close(); + resetState(); + break; + } /* parse file and import dives */ char *error = NULL; parse_file(zipFile.fileName().toLocal8Bit().data(), &error); diff --git a/qt-ui/subsurfacewebservices.h b/qt-ui/subsurfacewebservices.h index 07f902b8f..f6b3ee263 100644 --- a/qt-ui/subsurfacewebservices.h +++ b/qt-ui/subsurfacewebservices.h @@ -41,6 +41,7 @@ protected: QNetworkReply *reply; QTimer timeout; QByteArray downloadedData; + QString defaultApplyText; }; class SubsurfaceWebServices : public WebServices { @@ -87,6 +88,7 @@ private: QHttpMultiPart *multipart; QTemporaryFile zipFile; + bool uploadMode; }; #endif |