diff --git a/src/qt/qt_main.cpp b/src/qt/qt_main.cpp index 0443c8b00..b884920ad 100644 --- a/src/qt/qt_main.cpp +++ b/src/qt/qt_main.cpp @@ -585,7 +585,11 @@ main(int argc, char *argv[]) } if (!vmm_enabled) +#ifdef Q_OS_MACOS qt_set_sequence_auto_mnemonic(false); +#else + qt_set_sequence_auto_mnemonic(!!kbd_req_capture); +#endif app.setStyle(new StyleOverride()); bool startMaximized = window_remember && monitor_settings[0].mon_window_maximized; diff --git a/src/qt/qt_mainwindow.cpp b/src/qt/qt_mainwindow.cpp index 1b480152d..a77088742 100644 --- a/src/qt/qt_mainwindow.cpp +++ b/src/qt/qt_mainwindow.cpp @@ -92,6 +92,8 @@ extern bool cpu_thread_running; # include #endif +void qt_set_sequence_auto_mnemonic(bool b); + #include #include #include @@ -335,6 +337,16 @@ MainWindow::MainWindow(QWidget *parent) } ui->stackedWidget->unsetCursor(); } +#ifndef Q_OS_MACOS + if (kbd_req_capture) { + qt_set_sequence_auto_mnemonic(!mouse_capture); + /* Hack to get the menubar to update the internal Alt+shortcut table */ + if (!video_fullscreen) { + ui->menubar->hide(); + ui->menubar->show(); + } + } +#endif }); connect(qApp, &QGuiApplication::applicationStateChanged, [this](Qt::ApplicationState state) { @@ -1034,6 +1046,14 @@ void MainWindow::on_actionKeyboard_requires_capture_triggered() { kbd_req_capture ^= 1; +#ifndef Q_OS_MACOS + qt_set_sequence_auto_mnemonic(!!kbd_req_capture); + /* Hack to get the menubar to update the internal Alt+shortcut table */ + if (!video_fullscreen) { + ui->menubar->hide(); + ui->menubar->show(); + } +#endif } void @@ -1432,7 +1452,7 @@ MainWindow::eventFilter(QObject *receiver, QEvent *event) } - if (!dopause) { + if (!dopause && (!kbd_req_capture || mouse_capture)) { if (event->type() == QEvent::Shortcut) { auto shortcutEvent = (QShortcutEvent *) event; if (shortcutEvent->key() == ui->actionExit->shortcut()) { diff --git a/src/qt/qt_mainwindow.hpp b/src/qt/qt_mainwindow.hpp index 370d97d0e..5b132397f 100644 --- a/src/qt/qt_mainwindow.hpp +++ b/src/qt/qt_mainwindow.hpp @@ -85,7 +85,7 @@ private slots: void on_actionCtrl_Alt_Esc_triggered(); void on_actionHard_Reset_triggered(); void on_actionRight_CTRL_is_left_ALT_triggered(); - static void on_actionKeyboard_requires_capture_triggered(); + void on_actionKeyboard_requires_capture_triggered(); void on_actionResizable_window_triggered(bool checked); void on_actionInverted_VGA_monitor_triggered(); void on_action0_5x_triggered(); diff --git a/src/qt/qt_styleoverride.cpp b/src/qt/qt_styleoverride.cpp index 237149a01..adfae0734 100644 --- a/src/qt/qt_styleoverride.cpp +++ b/src/qt/qt_styleoverride.cpp @@ -24,6 +24,7 @@ extern "C" { #include <86box/86box.h> +#include <86box/plat.h> } #ifdef Q_OS_WINDOWS @@ -41,7 +42,7 @@ StyleOverride::styleHint( QStyleHintReturn *returnData) const { /* Disable using menu with alt key */ - if (!vmm_enabled && (hint == QStyle::SH_MenuBar_AltKeyNavigation)) + if (!vmm_enabled && (!kbd_req_capture || mouse_capture) && (hint == QStyle::SH_MenuBar_AltKeyNavigation)) return 0; return QProxyStyle::styleHint(hint, option, widget, returnData);