mirror of
https://invent.kde.org/system/dolphin
synced 2024-09-12 12:54:29 +00:00
[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
This commit is contained in:
parent
8828e686e9
commit
95e1505c9f
|
@ -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);
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue