summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndre Heinecke <aheinecke@intevation.de>2016-08-15 16:02:59 (GMT)
committerAndre Heinecke <aheinecke@intevation.de>2016-09-05 13:52:11 (GMT)
commitc47c6c2bf5f729f1c9dc95aa2a2ca8525a5181d7 (patch)
tree5f881af92c7f5b96b600420fd1acf93b7e00025d
parent2a0c578a0269a73d5a08792f477e2c64089c0de3 (diff)
Fix ok btn behavior for tasks without output
If there are no outputs the options "Ok" and "Cancel" don't make sense to have both. The ButtonBox accept is now also properly forwarded.
-rw-r--r--src/crypto/gui/decryptverifyfilesdialog.cpp20
-rw-r--r--src/crypto/gui/decryptverifyfilesdialog.h2
2 files changed, 14 insertions, 8 deletions
diff --git a/src/crypto/gui/decryptverifyfilesdialog.cpp b/src/crypto/gui/decryptverifyfilesdialog.cpp
index 1d4cb53..658f562 100644
--- a/src/crypto/gui/decryptverifyfilesdialog.cpp
+++ b/src/crypto/gui/decryptverifyfilesdialog.cpp
@@ -60,7 +60,7 @@ using namespace Kleo::Crypto;
using namespace Kleo::Crypto::Gui;
DecryptVerifyFilesDialog::DecryptVerifyFilesDialog(const boost::shared_ptr<TaskCollection> &coll, QWidget *parent)
- : QDialog(parent), m_tasks(coll), m_buttonBox(new QDialogButtonBox)
+ : QDialog(parent), m_tasks(coll), m_saveButton(QDialogButtonBox::NoButton), m_buttonBox(new QDialogButtonBox)
{
readConfig();
auto vLay = new QVBoxLayout(this);
@@ -105,19 +105,20 @@ DecryptVerifyFilesDialog::DecryptVerifyFilesDialog(const boost::shared_ptr<TaskC
}
if (hasOutputs) {
setWindowTitle(i18n("Decrypt/Verify Files"));
- m_okButton = QDialogButtonBox::SaveAll;
+ m_saveButton = QDialogButtonBox::SaveAll;
m_buttonBox->addButton(QDialogButtonBox::Discard);
connect(m_buttonBox, &QDialogButtonBox::accepted, this, &DecryptVerifyFilesDialog::checkAccept);
} else {
outLabel->setVisible(false);
m_outputLocationFNR->setVisible(false);
setWindowTitle(i18n("Verify Files"));
- m_okButton = QDialogButtonBox::Ok;
m_buttonBox->addButton(QDialogButtonBox::Close);
- connect(m_buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accepted);
+ connect(m_buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
+ }
+ if (m_saveButton) {
+ m_buttonBox->addButton(m_saveButton);
+ m_buttonBox->button(m_saveButton)->setEnabled(false);
}
- m_buttonBox->addButton(m_okButton);
- m_buttonBox->button(m_okButton)->setEnabled(false);
}
DecryptVerifyFilesDialog::~DecryptVerifyFilesDialog()
@@ -140,7 +141,12 @@ void DecryptVerifyFilesDialog::allDone()
m_progressLabelByTag.value(i)->setText(i18n("All operations completed."));
}
}
- m_buttonBox->button(m_okButton)->setEnabled(true);
+ if (m_saveButton != QDialogButtonBox::NoButton) {
+ m_buttonBox->button(m_saveButton)->setEnabled(true);
+ } else {
+ m_buttonBox->removeButton(m_buttonBox->button(QDialogButtonBox::Close));
+ m_buttonBox->addButton(QDialogButtonBox::Ok);
+ }
}
void DecryptVerifyFilesDialog::started(const boost::shared_ptr<Task> &task)
diff --git a/src/crypto/gui/decryptverifyfilesdialog.h b/src/crypto/gui/decryptverifyfilesdialog.h
index eac7afc..087e45b 100644
--- a/src/crypto/gui/decryptverifyfilesdialog.h
+++ b/src/crypto/gui/decryptverifyfilesdialog.h
@@ -89,7 +89,7 @@ private:
int m_lastErrorItemIndex;
ResultListWidget *m_resultList;
FileNameRequester *m_outputLocationFNR;
- QDialogButtonBox::StandardButton m_okButton;
+ QDialogButtonBox::StandardButton m_saveButton;
QDialogButtonBox *m_buttonBox;
};