mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
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>
This commit is contained in:
parent
8f29df6e5a
commit
7c4b083c2b
2 changed files with 21 additions and 0 deletions
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue