Prevent AltGr showing the menubar on Windows

* Fixes #11549
This commit is contained in:
Jonathan White 2024-12-28 00:08:35 -05:00
parent 0b5ae1775c
commit 253bb42ac0

View File

@ -2210,6 +2210,15 @@ bool MainWindowEventFilter::eventFilter(QObject* watched, QEvent* event)
#endif
} else if (eventType == QEvent::KeyRelease && watched == mainWindow) {
auto keyEvent = dynamic_cast<QKeyEvent*>(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;