From b0335359e59048a95346c7d3581180b79eefd2e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stig=20Bj=C3=B8rlykke?= Date: Fri, 10 Mar 2017 13:03:02 +0100 Subject: [PATCH] Qt: Give discard button focus (but not as default) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Tested-by: Petri Dish Buildbot Reviewed-by: Stig Bjørlykke --- ui/qt/capture_file_dialog.cpp | 3 +++ ui/qt/main_window.cpp | 3 +++ 2 files changed, 6 insertions(+) diff --git a/ui/qt/capture_file_dialog.cpp b/ui/qt/capture_file_dialog.cpp index d41587287e..39820acf89 100644 --- a/ui/qt/capture_file_dialog.cpp +++ b/ui/qt/capture_file_dialog.cpp @@ -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. diff --git a/ui/qt/main_window.cpp b/ui/qt/main_window.cpp index 4b23e92f69..567a8e8ff1 100644 --- a/ui/qt/main_window.cpp +++ b/ui/qt/main_window.cpp @@ -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.