From 4c2d4ded7461b330046c6d900d29097a767f2a22 Mon Sep 17 00:00:00 2001 From: Jonathan White Date: Sat, 28 Dec 2024 00:08:35 -0500 Subject: [PATCH] Prevent AltGr showing the menubar on Windows * Fixes #11549 --- src/gui/MainWindow.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 20872d82a5..871ab62085 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -2190,6 +2190,15 @@ bool MainWindowEventFilter::eventFilter(QObject* watched, QEvent* event) #endif } else if (eventType == QEvent::KeyRelease && watched == mainWindow) { auto keyEvent = dynamic_cast(event); +#ifdef Q_OS_WIN + // Windows translates AltGr into CTRL + ALT, this breaks using AltGr when the menubar is hidden + // Prevent this by activating the ALT cooldown to ignore the next key event which will be an ALT key + if (keyEvent->key() == Qt::Key_Control && keyEvent->modifiers() == Qt::AltModifier + && config()->get(Config::GUI_HideMenubar).toBool()) { + m_altCoolDown.start(); + return false; + } +#endif if (keyEvent->key() == Qt::Key_Alt && !keyEvent->modifiers() && config()->get(Config::GUI_HideMenubar).toBool() && !m_altCoolDown.isActive()) { auto menubar = mainWindow->m_ui->menubar;