From 330e78a3fcc3bb1e67514c4957546dc364b3e3a6 Mon Sep 17 00:00:00 2001 From: xboxones1 <91512529+xboxones1@users.noreply.github.com> Date: Thu, 12 Feb 2026 14:48:38 +0000 Subject: [PATCH] Fix menubar toggle to react only on Alt --- src/gui/MainWindow.cpp | 15 ++++++++++++++- src/gui/MainWindow.h | 1 + 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 25b96c5ae..1056091d7 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -2270,8 +2270,21 @@ bool MainWindowEventFilter::eventFilter(QObject* watched, QEvent* event) } } #endif + } else if (eventType == QEvent::KeyPress) { + auto keyEvent = static_cast(event); + if (keyEvent->key() == Qt::Key_Alt) { + m_altKeyAlone = (keyEvent->modifiers() == Qt::AltModifier); + } else { + m_altKeyAlone = false; + } + return QObject::eventFilter(watched, event); } else if (eventType == QEvent::KeyRelease && watched == mainWindow) { auto keyEvent = dynamic_cast(event); + + if (keyEvent->key() != Qt::Key_Alt) { + m_altKeyAlone = false; + return QObject::eventFilter(watched, 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 @@ -2281,7 +2294,7 @@ bool MainWindowEventFilter::eventFilter(QObject* watched, QEvent* event) return false; } #endif - if (keyEvent->key() == Qt::Key_Alt && !keyEvent->modifiers() && config()->get(Config::GUI_HideMenubar).toBool() + if (keyEvent->key() == Qt::Key_Alt && m_altKeyAlone && config()->get(Config::GUI_HideMenubar).toBool() && !m_altCoolDown.isActive()) { auto menubar = mainWindow->m_ui->menubar; menubar->setMaximumHeight(menubar->maximumHeight() > 0 ? 0 : QWIDGETSIZE_MAX); diff --git a/src/gui/MainWindow.h b/src/gui/MainWindow.h index 8effd06f4..2b9803eb3 100644 --- a/src/gui/MainWindow.h +++ b/src/gui/MainWindow.h @@ -220,6 +220,7 @@ public: private: QTimer m_menubarTimer; QTimer m_altCoolDown; + bool m_altKeyAlone = false; }; /**