┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKai Uwe Broulik <[email protected]>2016-10-28 13:40:50 +0200
committerKai Uwe Broulik <[email protected]>2016-10-28 13:40:50 +0200
commit95e1505c9f01bdae2c1157be1bb6fa5b991c8fd4 (patch)
tree62e85dfbbf6cdd329ea1fb993c7687c74724a8e5 /src
parent8828e686e94056af17e0c13b7550451c881af060 (diff)
[Places Item Edit Dialog] Fix accepting dialog with Return
By setting a parent for the QDialogButtonBox we let QDialog handle everything by itself. Also, store the dialog button box as a member rather than just the OK button. This removes the need to set the OK button as default manually (which didn't work anyway) and fixes pressing Return while the input is focused erroneously opening the folder browser rather than accepting the dialog. REVIEW: 129213
Diffstat (limited to 'src')
-rw-r--r--src/panels/places/placesitemeditdialog.cpp17
-rw-r--r--src/panels/places/placesitemeditdialog.h4
2 files changed, 9 insertions, 12 deletions
diff --git a/src/panels/places/placesitemeditdialog.cpp b/src/panels/places/placesitemeditdialog.cpp
index 7d365310f..ffcac4c8f 100644
--- a/src/panels/places/placesitemeditdialog.cpp
+++ b/src/panels/places/placesitemeditdialog.cpp
@@ -47,7 +47,8 @@ PlacesItemEditDialog::PlacesItemEditDialog(QWidget* parent) :
m_urlEdit(0),
m_textEdit(0),
m_iconButton(0),
- m_appLocal(0)
+ m_appLocal(0),
+ m_buttonBox(nullptr)
{
}
@@ -106,7 +107,7 @@ bool PlacesItemEditDialog::event(QEvent* event)
void PlacesItemEditDialog::slotUrlChanged(const QString& text)
{
- m_okButton->setEnabled(!text.isEmpty());
+ m_buttonBox->button(QDialogButtonBox::Ok)->setEnabled(!text.isEmpty());
}
PlacesItemEditDialog::~PlacesItemEditDialog()
@@ -115,20 +116,16 @@ PlacesItemEditDialog::~PlacesItemEditDialog()
void PlacesItemEditDialog::initialize()
{
- QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel);
- m_okButton = buttonBox->button(QDialogButtonBox::Ok);
- m_okButton->setDefault(true);
- m_okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
- connect(buttonBox, &QDialogButtonBox::accepted, this, &PlacesItemEditDialog::accept);
- connect(buttonBox, &QDialogButtonBox::rejected, this, &PlacesItemEditDialog::reject);
+ m_buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel, this);
+ connect(m_buttonBox, &QDialogButtonBox::accepted, this, &PlacesItemEditDialog::accept);
+ connect(m_buttonBox, &QDialogButtonBox::rejected, this, &PlacesItemEditDialog::reject);
setModal(true);
- m_okButton->setDefault(true);
QVBoxLayout *mainLayout = new QVBoxLayout;
setLayout(mainLayout);
QWidget* mainWidget = new QWidget(this);
mainLayout->addWidget(mainWidget);
- mainLayout->addWidget(buttonBox);
+ mainLayout->addWidget(m_buttonBox);
QVBoxLayout* vBox = new QVBoxLayout(mainWidget);
diff --git a/src/panels/places/placesitemeditdialog.h b/src/panels/places/placesitemeditdialog.h
index 8a0dc0471..f2d69781a 100644
--- a/src/panels/places/placesitemeditdialog.h
+++ b/src/panels/places/placesitemeditdialog.h
@@ -31,7 +31,7 @@ class KIconButton;
class KUrlRequester;
class QLineEdit;
class QCheckBox;
-class QPushButton;
+class QDialogButtonBox;
class PlacesItemEditDialog: public QDialog
{
@@ -72,7 +72,7 @@ private:
QLineEdit* m_textEdit;
KIconButton* m_iconButton;
QCheckBox* m_appLocal;
- QPushButton *m_okButton;
+ QDialogButtonBox *m_buttonBox;
};
#endif