Only try to click the focused button when pressing enter.

It makes no sense when pressing the escape button.
This commit is contained in:
Felix Geyer 2014-01-02 10:51:51 +01:00
parent 0cbf59209b
commit 41162ea2e8

View File

@ -60,10 +60,14 @@ void DialogyWidget::keyPressEvent(QKeyEvent* e)
bool DialogyWidget::clickButton(QDialogButtonBox::StandardButton standardButton) bool DialogyWidget::clickButton(QDialogButtonBox::StandardButton standardButton)
{ {
QPushButton* pb = qobject_cast<QPushButton*>(focusWidget()); QPushButton* pb;
if (pb && pb->isVisible() && pb->isEnabled() && pb->hasFocus()) {
pb->click(); if (standardButton == QDialogButtonBox::Ok) {
return true; pb = qobject_cast<QPushButton*>(focusWidget());
if (pb && pb->isVisible() && pb->isEnabled() && pb->hasFocus()) {
pb->click();
return true;
}
} }
QList<QDialogButtonBox*> buttonBoxes = findChildren<QDialogButtonBox*>(); QList<QDialogButtonBox*> buttonBoxes = findChildren<QDialogButtonBox*>();