Qt: Re-enable menu keyboard navigation and mnemonics
when "Keyboard requries capture" is enabled and mouse isn't captured on Windows and Linux
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -92,6 +92,8 @@ extern bool cpu_thread_running;
|
||||
# include <QVulkanFunctions>
|
||||
#endif
|
||||
|
||||
void qt_set_sequence_auto_mnemonic(bool b);
|
||||
|
||||
#include <array>
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
@@ -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()) {
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user