Qt: Give discard button focus (but not as default)

Set focus to the discard button in the "Unsaved packet" and
"Unsaved comments" dialogs to enable spacebar for discard and
enter for save.

Bug: 13363
Change-Id: I576b02c4e3f0964aef56a0f1c06ed57c6ba683bf
Reviewed-on: https://code.wireshark.org/review/20485
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
This commit is contained in:
Stig Bjørlykke 2017-03-10 13:03:02 +01:00
parent f8abec1f37
commit b0335359e5
2 changed files with 6 additions and 0 deletions

View File

@ -167,6 +167,9 @@ check_savability_t CaptureFileDialog::checkSaveAsWithComments(QWidget *
msg_dialog.setDefaultButton(QMessageBox::Cancel);
}
discard_button->setAutoDefault(false);
discard_button->setFocus();
msg_dialog.exec();
/* According to the Qt doc:
* when using QMessageBox with custom buttons, exec() function returns an opaque value.

View File

@ -1741,6 +1741,9 @@ bool MainWindow::testCaptureFileClose(QString before_what, FileCloseContext cont
}
discard_button = msg_dialog.addButton(discard_button_text, QMessageBox::DestructiveRole);
discard_button->setAutoDefault(false);
discard_button->setFocus();
msg_dialog.exec();
/* According to the Qt doc:
* when using QMessageBox with custom buttons, exec() function returns an opaque value.