Commit ce6556a0 authored by Pino Toscano's avatar Pino Toscano

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.
parent 646da9e3
......@@ -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);
......
......@@ -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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment