mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-09-23 14:24:50 -04:00
Fix keyboard shortcuts when menubar is hidden (#12431)
--------- Co-authored-by: Jonathan White <support@dmapps.us>
This commit is contained in:
parent
83d1003ec2
commit
142454d08e
1 changed files with 20 additions and 8 deletions
|
@ -1672,9 +1672,16 @@ void MainWindow::applySettingsChanges()
|
||||||
m_inactivityTimer->deactivate();
|
m_inactivityTimer->deactivate();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_ui->actionShowToolbar->setChecked(!config()->get(Config::GUI_HideToolbar).toBool());
|
auto hideToolbar = config()->get(Config::GUI_HideToolbar).toBool();
|
||||||
m_ui->actionShowMenubar->setChecked(!config()->get(Config::GUI_HideMenubar).toBool());
|
auto hideMenubar = config()->get(Config::GUI_HideMenubar).toBool();
|
||||||
m_ui->menubar->setHidden(config()->get(Config::GUI_HideMenubar).toBool());
|
|
||||||
|
m_ui->actionShowToolbar->setChecked(!hideToolbar);
|
||||||
|
m_ui->actionShowMenubar->setChecked(!hideMenubar);
|
||||||
|
|
||||||
|
// When menubar is hidden with setHidden() the menu keyboard shortcuts are disabled on Wayland,
|
||||||
|
// so force height of 0 instead and use maximumHeight() > 0 instead of isVisible() elsewhere
|
||||||
|
m_ui->menubar->setMaximumHeight(hideMenubar ? 0 : QWIDGETSIZE_MAX);
|
||||||
|
|
||||||
m_ui->toolBar->setHidden(config()->get(Config::GUI_HideToolbar).toBool());
|
m_ui->toolBar->setHidden(config()->get(Config::GUI_HideToolbar).toBool());
|
||||||
auto movable = config()->get(Config::GUI_MovableToolbar).toBool();
|
auto movable = config()->get(Config::GUI_MovableToolbar).toBool();
|
||||||
m_ui->toolBar->setMovable(movable);
|
m_ui->toolBar->setMovable(movable);
|
||||||
|
@ -2187,10 +2194,11 @@ MainWindowEventFilter::MainWindowEventFilter(QObject* parent)
|
||||||
m_menubarTimer.setSingleShot(false);
|
m_menubarTimer.setSingleShot(false);
|
||||||
connect(&m_menubarTimer, &QTimer::timeout, this, [this] {
|
connect(&m_menubarTimer, &QTimer::timeout, this, [this] {
|
||||||
auto mainwindow = getMainWindow();
|
auto mainwindow = getMainWindow();
|
||||||
if (mainwindow && mainwindow->m_ui->menubar->isVisible() && config()->get(Config::GUI_HideMenubar).toBool()) {
|
if (mainwindow && mainwindow->m_ui->menubar->maximumHeight() > 0
|
||||||
|
&& config()->get(Config::GUI_HideMenubar).toBool()) {
|
||||||
// If the menu bar is visible with no active menu, hide it
|
// If the menu bar is visible with no active menu, hide it
|
||||||
if (!mainwindow->m_ui->menubar->activeAction()) {
|
if (!mainwindow->m_ui->menubar->activeAction()) {
|
||||||
mainwindow->m_ui->menubar->setVisible(false);
|
mainwindow->m_ui->menubar->setMaximumHeight(0);
|
||||||
m_altCoolDown.start();
|
m_altCoolDown.start();
|
||||||
m_menubarTimer.stop();
|
m_menubarTimer.stop();
|
||||||
}
|
}
|
||||||
|
@ -2249,9 +2257,13 @@ bool MainWindowEventFilter::eventFilter(QObject* watched, QEvent* event)
|
||||||
if (keyEvent->key() == Qt::Key_Alt && !keyEvent->modifiers() && config()->get(Config::GUI_HideMenubar).toBool()
|
if (keyEvent->key() == Qt::Key_Alt && !keyEvent->modifiers() && config()->get(Config::GUI_HideMenubar).toBool()
|
||||||
&& !m_altCoolDown.isActive()) {
|
&& !m_altCoolDown.isActive()) {
|
||||||
auto menubar = mainWindow->m_ui->menubar;
|
auto menubar = mainWindow->m_ui->menubar;
|
||||||
menubar->setVisible(!menubar->isVisible());
|
menubar->setMaximumHeight(menubar->maximumHeight() > 0 ? 0 : QWIDGETSIZE_MAX);
|
||||||
if (menubar->isVisible()) {
|
if (menubar->maximumHeight() > 0) {
|
||||||
|
QTimer::singleShot(0, [menubar, mainWindow] {
|
||||||
|
// Run this with a singleshot timer so it's after menubar->setMaximumHeight() has taken effect,
|
||||||
|
// otherwise it won't be selected and menubarTimer will hide the menubar instantly
|
||||||
menubar->setActiveAction(mainWindow->m_ui->menuFile->menuAction());
|
menubar->setActiveAction(mainWindow->m_ui->menuFile->menuAction());
|
||||||
|
});
|
||||||
m_menubarTimer.start();
|
m_menubarTimer.start();
|
||||||
} else {
|
} else {
|
||||||
m_menubarTimer.stop();
|
m_menubarTimer.stop();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue