mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2026-03-11 08:54:48 +00:00
Fix menubar toggle to react only on Alt
This commit is contained in:
parent
5bd42c4725
commit
330e78a3fc
2 changed files with 15 additions and 1 deletions
|
|
@ -2270,8 +2270,21 @@ bool MainWindowEventFilter::eventFilter(QObject* watched, QEvent* event)
|
|||
}
|
||||
}
|
||||
#endif
|
||||
} else if (eventType == QEvent::KeyPress) {
|
||||
auto keyEvent = static_cast<QKeyEvent*>(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<QKeyEvent*>(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);
|
||||
|
|
|
|||
|
|
@ -220,6 +220,7 @@ public:
|
|||
private:
|
||||
QTimer m_menubarTimer;
|
||||
QTimer m_altCoolDown;
|
||||
bool m_altKeyAlone = false;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue