Qt: allow keyboard navigation in Unsaved packets dialog

Currently the "Continue without Saving" button is visually highlighted
in the "Unsaved packets..." dialog, but pressing Enter triggers "Save"
instead. Even after changing button focus with arrow or tab keys,
pressing Enter will not confirm the action (but Spacebar does).
Restore the expected behavior for Linux and Windows, but preserve the
fix for macOS since (for which this was originally added).

Bug: 14531
Change-Id: Ic20fc5809b55949f6fd960bcb32618a4fa7fd1e9
Fixes: v2.3.0rc0-2672-gb0335359e5 ("Qt: Give discard button focus (but not as default)")
Reviewed-on: https://code.wireshark.org/review/26511
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
This commit is contained in:
Peter Wu 2018-03-16 21:04:34 +01:00 committed by Alexis La Goutte
parent dd8789036f
commit 56425fce7c
2 changed files with 4 additions and 0 deletions

View File

@ -154,8 +154,10 @@ check_savability_t CaptureFileDialog::checkSaveAsWithComments(QWidget *
msg_dialog.setDefaultButton(QMessageBox::Cancel);
}
#if defined(Q_OS_MAC)
discard_button->setAutoDefault(false);
discard_button->setFocus();
#endif
msg_dialog.exec();
/* According to the Qt doc:

View File

@ -1803,8 +1803,10 @@ bool MainWindow::testCaptureFileClose(QString before_what, FileCloseContext cont
}
discard_button = msg_dialog.addButton(discard_button_text, QMessageBox::DestructiveRole);
#if defined(Q_OS_MAC)
discard_button->setAutoDefault(false);
discard_button->setFocus();
#endif
msg_dialog.exec();
/* According to the Qt doc: