mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-07-26 00:05:34 -04:00
QMenubar option to show/hide itself (#10341)
-------- Co-authored-by: Mikko Saarinki <mikko.saarinki@michaelkingston.fi> Co-authored-by: Jonathan White <support@dmapps.us>
This commit is contained in:
parent
4ef52c859b
commit
a542ded97c
5 changed files with 64 additions and 10 deletions
|
@ -3659,11 +3659,6 @@ This may cause the affected plugins to malfunction.</source>
|
||||||
<source>Confirm Overwrite Attachment</source>
|
<source>Confirm Overwrite Attachment</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
<message>
|
|
||||||
<source>Attachment "%1" already exists.
|
|
||||||
Would you like to overwrite the existing attachment?</source>
|
|
||||||
<translation type="unfinished"></translation>
|
|
||||||
</message>
|
|
||||||
<message>
|
<message>
|
||||||
<source>Confirm Attachment</source>
|
<source>Confirm Attachment</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
|
@ -3693,6 +3688,11 @@ Do you want to save the changes to your database?</source>
|
||||||
Error: %1</source>
|
Error: %1</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Attachment "%1" already exists.
|
||||||
|
Would you like to overwrite the existing attachment?</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>EntryAttributesModel</name>
|
<name>EntryAttributesModel</name>
|
||||||
|
@ -5465,6 +5465,10 @@ Are you sure you want to continue with this file?</source>
|
||||||
<source>Classic (Platform-native)</source>
|
<source>Classic (Platform-native)</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Show Menubar</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>Show Toolbar</source>
|
<source>Show Toolbar</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
|
@ -5815,6 +5819,10 @@ We recommend you use the AppImage available on our downloads page.</source>
|
||||||
<source>Set Theme: Classic</source>
|
<source>Set Theme: Classic</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Toggle Show Menubar</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
<message>
|
<message>
|
||||||
<source>Toggle Show Toolbar</source>
|
<source>Toggle Show Toolbar</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
|
|
|
@ -92,6 +92,7 @@ static const QHash<Config::ConfigKey, ConfigDirective> configStrings = {
|
||||||
|
|
||||||
// GUI
|
// GUI
|
||||||
{Config::GUI_Language, {QS("GUI/Language"), Roaming, QS("system")}},
|
{Config::GUI_Language, {QS("GUI/Language"), Roaming, QS("system")}},
|
||||||
|
{Config::GUI_HideMenubar, {QS("GUI/HideMenubar"), Roaming, false}},
|
||||||
{Config::GUI_HideToolbar, {QS("GUI/HideToolbar"), Roaming, false}},
|
{Config::GUI_HideToolbar, {QS("GUI/HideToolbar"), Roaming, false}},
|
||||||
{Config::GUI_MovableToolbar, {QS("GUI/MovableToolbar"), Roaming, false}},
|
{Config::GUI_MovableToolbar, {QS("GUI/MovableToolbar"), Roaming, false}},
|
||||||
{Config::GUI_HidePreviewPanel, {QS("GUI/HidePreviewPanel"), Roaming, false}},
|
{Config::GUI_HidePreviewPanel, {QS("GUI/HidePreviewPanel"), Roaming, false}},
|
||||||
|
|
|
@ -74,6 +74,7 @@ public:
|
||||||
LastDir,
|
LastDir,
|
||||||
|
|
||||||
GUI_Language,
|
GUI_Language,
|
||||||
|
GUI_HideMenubar,
|
||||||
GUI_HideToolbar,
|
GUI_HideToolbar,
|
||||||
GUI_MovableToolbar,
|
GUI_MovableToolbar,
|
||||||
GUI_HidePreviewPanel,
|
GUI_HidePreviewPanel,
|
||||||
|
|
|
@ -549,6 +549,7 @@ MainWindow::MainWindow()
|
||||||
m_ui->menubar->installEventFilter(eventFilter);
|
m_ui->menubar->installEventFilter(eventFilter);
|
||||||
m_ui->toolBar->installEventFilter(eventFilter);
|
m_ui->toolBar->installEventFilter(eventFilter);
|
||||||
m_ui->tabWidget->tabBar()->installEventFilter(eventFilter);
|
m_ui->tabWidget->tabBar()->installEventFilter(eventFilter);
|
||||||
|
installEventFilter(eventFilter);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef Q_OS_MACOS
|
#ifdef Q_OS_MACOS
|
||||||
|
@ -1632,6 +1633,7 @@ void MainWindow::applySettingsChanges()
|
||||||
m_inactivityTimer->deactivate();
|
m_inactivityTimer->deactivate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_ui->menubar->setHidden(config()->get(Config::GUI_HideMenubar).toBool());
|
||||||
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);
|
||||||
|
@ -1994,6 +1996,16 @@ void MainWindow::initViewMenu()
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
#ifdef Q_OS_MACOS
|
||||||
|
m_ui->actionShowMenubar->setVisible(false);
|
||||||
|
#else
|
||||||
|
m_ui->actionShowMenubar->setChecked(!config()->get(Config::GUI_HideMenubar).toBool());
|
||||||
|
connect(m_ui->actionShowMenubar, &QAction::toggled, this, [this](bool checked) {
|
||||||
|
config()->set(Config::GUI_HideMenubar, !checked);
|
||||||
|
applySettingsChanges();
|
||||||
|
});
|
||||||
|
#endif
|
||||||
|
|
||||||
m_ui->actionShowToolbar->setChecked(!config()->get(Config::GUI_HideToolbar).toBool());
|
m_ui->actionShowToolbar->setChecked(!config()->get(Config::GUI_HideToolbar).toBool());
|
||||||
connect(m_ui->actionShowToolbar, &QAction::toggled, this, [this](bool checked) {
|
connect(m_ui->actionShowToolbar, &QAction::toggled, this, [this](bool checked) {
|
||||||
config()->set(Config::GUI_HideToolbar, !checked);
|
config()->set(Config::GUI_HideToolbar, !checked);
|
||||||
|
@ -2099,6 +2111,9 @@ void MainWindow::initActionCollection()
|
||||||
m_ui->actionThemeDark,
|
m_ui->actionThemeDark,
|
||||||
m_ui->actionThemeClassic,
|
m_ui->actionThemeClassic,
|
||||||
m_ui->actionCompactMode,
|
m_ui->actionCompactMode,
|
||||||
|
#ifndef Q_OS_MACOS
|
||||||
|
m_ui->actionShowMenubar,
|
||||||
|
#endif
|
||||||
m_ui->actionShowToolbar,
|
m_ui->actionShowToolbar,
|
||||||
m_ui->actionShowPreviewPanel,
|
m_ui->actionShowPreviewPanel,
|
||||||
m_ui->actionAllowScreenCapture,
|
m_ui->actionAllowScreenCapture,
|
||||||
|
@ -2176,6 +2191,7 @@ MainWindowEventFilter::MainWindowEventFilter(QObject* parent)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MainWindow event filter to initiate empty-area drag on the toolbar, menubar, and tabbar.
|
* MainWindow event filter to initiate empty-area drag on the toolbar, menubar, and tabbar.
|
||||||
|
* Also shows menubar with Alt when menubar itself is hidden.
|
||||||
*/
|
*/
|
||||||
bool MainWindowEventFilter::eventFilter(QObject* watched, QEvent* event)
|
bool MainWindowEventFilter::eventFilter(QObject* watched, QEvent* event)
|
||||||
{
|
{
|
||||||
|
@ -2184,10 +2200,11 @@ bool MainWindowEventFilter::eventFilter(QObject* watched, QEvent* event)
|
||||||
return QObject::eventFilter(watched, event);
|
return QObject::eventFilter(watched, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event->type() == QEvent::MouseButtonPress) {
|
auto eventType = event->type();
|
||||||
|
if (eventType == QEvent::MouseButtonPress) {
|
||||||
|
auto mouseEvent = dynamic_cast<QMouseEvent*>(event);
|
||||||
if (watched == mainWindow->m_ui->menubar) {
|
if (watched == mainWindow->m_ui->menubar) {
|
||||||
auto* m = static_cast<QMouseEvent*>(event);
|
if (!mainWindow->m_ui->menubar->actionAt(mouseEvent->pos())) {
|
||||||
if (!mainWindow->m_ui->menubar->actionAt(m->pos())) {
|
|
||||||
mainWindow->windowHandle()->startSystemMove();
|
mainWindow->windowHandle()->startSystemMove();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -2197,12 +2214,24 @@ bool MainWindowEventFilter::eventFilter(QObject* watched, QEvent* event)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (watched == mainWindow->m_ui->tabWidget->tabBar()) {
|
} else if (watched == mainWindow->m_ui->tabWidget->tabBar()) {
|
||||||
auto* m = static_cast<QMouseEvent*>(event);
|
if (mainWindow->m_ui->tabWidget->tabBar()->tabAt(mouseEvent->pos()) == -1) {
|
||||||
if (mainWindow->m_ui->tabWidget->tabBar()->tabAt(m->pos()) == -1) {
|
|
||||||
mainWindow->windowHandle()->startSystemMove();
|
mainWindow->windowHandle()->startSystemMove();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (eventType == QEvent::KeyRelease) {
|
||||||
|
if (watched == mainWindow) {
|
||||||
|
auto keyEvent = dynamic_cast<QKeyEvent*>(event);
|
||||||
|
if (keyEvent->key() == Qt::Key_Alt && !keyEvent->modifiers()
|
||||||
|
&& config()->get(Config::GUI_HideMenubar).toBool()) {
|
||||||
|
auto menubar = mainWindow->m_ui->menubar;
|
||||||
|
menubar->setVisible(!menubar->isVisible());
|
||||||
|
if (menubar->isVisible()) {
|
||||||
|
menubar->setActiveAction(mainWindow->m_ui->menuFile->menuAction());
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return QObject::eventFilter(watched, event);
|
return QObject::eventFilter(watched, event);
|
||||||
|
|
|
@ -384,6 +384,7 @@
|
||||||
<addaction name="actionAlwaysOnTop"/>
|
<addaction name="actionAlwaysOnTop"/>
|
||||||
<addaction name="actionAllowScreenCapture"/>
|
<addaction name="actionAllowScreenCapture"/>
|
||||||
<addaction name="actionShowPreviewPanel"/>
|
<addaction name="actionShowPreviewPanel"/>
|
||||||
|
<addaction name="actionShowMenubar"/>
|
||||||
<addaction name="actionShowToolbar"/>
|
<addaction name="actionShowToolbar"/>
|
||||||
<addaction name="actionHideUsernames"/>
|
<addaction name="actionHideUsernames"/>
|
||||||
<addaction name="actionHidePasswords"/>
|
<addaction name="actionHidePasswords"/>
|
||||||
|
@ -1130,6 +1131,20 @@
|
||||||
<string>Set Theme: Classic</string>
|
<string>Set Theme: Classic</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionShowMenubar">
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Show Menubar</string>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Toggle Show Menubar</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
<action name="actionShowToolbar">
|
<action name="actionShowToolbar">
|
||||||
<property name="checkable">
|
<property name="checkable">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue