summaryrefslogtreecommitdiffstats
path: root/src/sdk
diff options
context:
space:
mode:
authorKarsten Heimrich <karsten.heimrich@theqtcompany.com>2015-07-10 11:20:00 +0200
committerKarsten Heimrich <karsten.heimrich@theqtcompany.com>2015-07-14 11:43:50 +0000
commitdf9fdaf4ea0957328c37e0343c5deff480ad760a (patch)
tree56eb777e17fb6aa64c279cda780998a415518751 /src/sdk
parent5b28b048c499a0bff68c6543415a909740224734 (diff)
Rework handling of repository testing.
- Show message box on error/success. - Show informative text only if necessary. - Add option to enable/disable repo after test. Change-Id: I5608aa1c94f804db1754c9f789697eab614b21c6 Reviewed-by: Jarek Kobus <jaroslaw.kobus@theqtcompany.com>
Diffstat (limited to 'src/sdk')
-rw-r--r--src/sdk/settingsdialog.cpp36
1 files changed, 23 insertions, 13 deletions
diff --git a/src/sdk/settingsdialog.cpp b/src/sdk/settingsdialog.cpp
index bd81324de..c2e0cc27a 100644
--- a/src/sdk/settingsdialog.cpp
+++ b/src/sdk/settingsdialog.cpp
@@ -337,20 +337,30 @@ void SettingsDialog::testRepository()
testJob.waitForFinished();
current->setRepository(testJob.repository());
- if (testJob.error() > KDJob::NoError) {
- QMessageBox msgBox(this);
- msgBox.setIcon(QMessageBox::Question);
- msgBox.setWindowModality(Qt::WindowModal);
- msgBox.setDetailedText(testJob.errorString());
- msgBox.setText(tr("There was an error testing this repository."));
- msgBox.setInformativeText(tr("Do you want to disable the tested repository?"));
-
- msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
- msgBox.setDefaultButton(QMessageBox::Yes);
-
- if (msgBox.exec() == QMessageBox::Yes)
- current->setData(1, Qt::CheckStateRole, Qt::Unchecked);
+ QMessageBox msgBox(this);
+ msgBox.setIcon(QMessageBox::Question);
+ msgBox.setWindowModality(Qt::WindowModal);
+ msgBox.setDetailedText(testJob.errorString());
+
+ const bool isError = (testJob.error() > KDJob::NoError);
+ const bool isEnabled = current->data(1, Qt::CheckStateRole).toBool();
+
+ msgBox.setText(isError
+ ? tr("An error occurred while testing this repository.")
+ : tr("The repository was tested successfully."));
+
+ const bool showQuestion = (isError == isEnabled);
+ msgBox.setStandardButtons(showQuestion ? QMessageBox::Yes | QMessageBox::No
+ : QMessageBox::Close);
+ msgBox.setDefaultButton(showQuestion ? QMessageBox::Yes : QMessageBox::Close);
+ if (showQuestion) {
+ msgBox.setInformativeText(isEnabled
+ ? tr("Do you want to disable the repository?")
+ : tr("Do you want to enable the repository?")
+ );
}
+ if (msgBox.exec() == QMessageBox::Yes)
+ current->setData(1, Qt::CheckStateRole, (!isEnabled) ? Qt::Checked : Qt::Unchecked);
m_ui->tabWidget->setEnabled(true);
m_ui->buttonBox->setEnabled(true);