From 91dbd3a20428be53e5b7b28e01fc91431e3ccc9f Mon Sep 17 00:00:00 2001 From: sawinglogz <3787776-sawinglogz@users.noreply.gitlab.com> Date: Sat, 18 Jan 2020 17:01:35 -0500 Subject: [PATCH] Fix the display of Preferences menu shortcut on macOS. It was appearing only on first launch, when OSCAR was asking where to store its data. Now it appears consistently. --- oscar/mainwindow.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/oscar/mainwindow.cpp b/oscar/mainwindow.cpp index 11b52e8b..f7187a17 100644 --- a/oscar/mainwindow.cpp +++ b/oscar/mainwindow.cpp @@ -130,6 +130,12 @@ void MainWindow::SetupGUI() #ifdef Q_OS_MAC ui->action_About->setMenuRole(QAction::ApplicationSpecificRole); ui->action_Preferences->setMenuRole(QAction::ApplicationSpecificRole); + + // For some reason, setShortcuts won't change the text of the menu item unless Qt has had a chance + // to do something first. Without the processEvents() call it still installs the shortcut, but + // not visible. (Any preceding UI such as QMessageBox seems to have the same effect.) + QApplication::processEvents(); + ui->action_Preferences->setShortcuts(QKeySequence::Preferences); #endif