summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPino Toscano <pino@kde.org>2016-11-23 20:34:27 (GMT)
committerPino Toscano <pino@kde.org>2016-11-23 20:34:27 (GMT)
commitce6556a0d8b0fe8267444614b6ca7f5c31b0864f (patch)
treeab6631e515c6ace1e321d303e114c5852643746c
parent646da9e32f79839d9f3bee11d9ad24da38ac43f0 (diff)
Fix/simplify QDialogButtonBox usage
Since standard OK and Cancel buttons are used, just use the QDialogButtonBox API to add them only when needed. This avoids creating them manually.
-rw-r--r--part/overwritedialog.cpp9
-rw-r--r--part/overwritedialog.h3
2 files changed, 2 insertions, 10 deletions
diff --git a/part/overwritedialog.cpp b/part/overwritedialog.cpp
index 106932b..d815e01 100644
--- a/part/overwritedialog.cpp
+++ b/part/overwritedialog.cpp
@@ -31,9 +31,7 @@ using namespace Kerfuffle;
OverwriteDialog::OverwriteDialog(QWidget *parent, const QList<const Archive::Entry*> &entries, const QHash<QString, QIcon> &icons, bool error)
: QDialog(parent)
- , m_buttonBox(Qt::Horizontal)
- , m_okButton(i18n("OK"))
- , m_cancelButton(i18n("Cancel"))
+ , m_buttonBox(QDialogButtonBox::Cancel, Qt::Horizontal)
{
m_vBoxLayout.addLayout(&m_messageLayout);
m_vBoxLayout.addWidget(&m_entriesList);
@@ -46,12 +44,9 @@ OverwriteDialog::OverwriteDialog(QWidget *parent, const QList<const Archive::Ent
if (error) {
m_messageText.setText(i18n("Files with the following paths already exist. Remove them if you really want to overwrite."));
} else {
- m_okButton.setIcon(QIcon::fromTheme(QStringLiteral("dialog-ok")));
m_messageText.setText(i18n("Files with the following paths already exist. Do you want to continue overwriting them?"));
- m_buttonBox.addButton(&m_okButton, QDialogButtonBox::AcceptRole);
+ m_buttonBox.addButton(QDialogButtonBox::Ok);
}
- m_cancelButton.setIcon(QIcon::fromTheme(QStringLiteral("dialog-cancel")));
- m_buttonBox.addButton(&m_cancelButton, QDialogButtonBox::RejectRole);
connect(&m_buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
connect(&m_buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
diff --git a/part/overwritedialog.h b/part/overwritedialog.h
index f0ec4ac..973de5e 100644
--- a/part/overwritedialog.h
+++ b/part/overwritedialog.h
@@ -38,7 +38,6 @@
#include <QListWidget>
#include <QVBoxLayout>
#include <QHBoxLayout>
-#include <QPushButton>
#include <QDialogButtonBox>
class QUrl;
@@ -57,8 +56,6 @@ private:
QLabel m_messageText;
QListWidget m_entriesList;
QDialogButtonBox m_buttonBox;
- QPushButton m_okButton;
- QPushButton m_cancelButton;
};
#endif