mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-02-03 10:00:04 -05:00
Multiple fixes to MainWindow and some cleanup
* Fix MainWindow startup when minimize to tray was enabled * Reduce duplicate code in DatabaseWidget.cpp * Fix snapcraft build dependencies * Add support for CTRL+TAB, CTRL+PGUP, CTRL+SHIFT+TAB, CTRL+PGDN to control database tabs from any focus location * Add CTRL+SHIFT+M shortcut to minimize to tray * Allow minimize instead of app exit without tray icon
This commit is contained in:
parent
c749f7018e
commit
a44138dd5c
@ -38,8 +38,8 @@ parts:
|
||||
- g++
|
||||
- libgcrypt20-dev
|
||||
- libqt5x11extras5-dev
|
||||
- libqt5svg5-dev
|
||||
- qtbase5-dev
|
||||
- qtsvg5-dev
|
||||
- qttools5-dev
|
||||
- qttools5-dev-tools
|
||||
- zlib1g-dev
|
||||
@ -59,6 +59,7 @@ parts:
|
||||
- libsodium23
|
||||
- libxtst6
|
||||
- libqt5x11extras5
|
||||
- libqt5svg5
|
||||
- libusb-1.0-0
|
||||
- qtwayland5
|
||||
override-build: |
|
||||
|
@ -71,20 +71,10 @@ void bootstrapApplication()
|
||||
void restoreMainWindowState(MainWindow& mainWindow)
|
||||
{
|
||||
// start minimized if configured
|
||||
bool minimizeOnStartup = config()->get("GUI/MinimizeOnStartup").toBool();
|
||||
bool minimizeToTray = config()->get("GUI/MinimizeToTray").toBool();
|
||||
#ifndef Q_OS_LINUX
|
||||
if (minimizeOnStartup) {
|
||||
#else
|
||||
// On some Linux systems, the window should NOT be minimized and hidden (i.e. not shown), at
|
||||
// the same time (which would happen if both minimize on startup and minimize to tray are set)
|
||||
// since otherwise it causes problems on restore as seen on issue #1595. Hiding it is enough.
|
||||
if (minimizeOnStartup && !minimizeToTray) {
|
||||
#endif
|
||||
mainWindow.setWindowState(Qt::WindowMinimized);
|
||||
}
|
||||
if (!(minimizeOnStartup && minimizeToTray)) {
|
||||
mainWindow.show();
|
||||
if (config()->get("GUI/MinimizeOnStartup").toBool()) {
|
||||
mainWindow.showMinimized();
|
||||
} else {
|
||||
mainWindow.bringToFront();
|
||||
}
|
||||
|
||||
if (config()->get("OpenPreviousDatabasesOnStartup").toBool()) {
|
||||
|
@ -159,7 +159,7 @@ void ApplicationSettingsWidget::loadSettings()
|
||||
m_generalUi->systrayShowCheckBox->setChecked(config()->get("GUI/ShowTrayIcon").toBool());
|
||||
m_generalUi->systrayDarkIconCheckBox->setChecked(config()->get("GUI/DarkTrayIcon").toBool());
|
||||
m_generalUi->systrayMinimizeToTrayCheckBox->setChecked(config()->get("GUI/MinimizeToTray").toBool());
|
||||
m_generalUi->systrayMinimizeOnCloseCheckBox->setChecked(config()->get("GUI/MinimizeOnClose").toBool());
|
||||
m_generalUi->minimizeOnCloseCheckBox->setChecked(config()->get("GUI/MinimizeOnClose").toBool());
|
||||
m_generalUi->systrayMinimizeOnStartup->setChecked(config()->get("GUI/MinimizeOnStartup").toBool());
|
||||
m_generalUi->autoTypeAskCheckBox->setChecked(config()->get("security/autotypeask").toBool());
|
||||
|
||||
@ -235,7 +235,7 @@ void ApplicationSettingsWidget::saveSettings()
|
||||
config()->set("GUI/ShowTrayIcon", m_generalUi->systrayShowCheckBox->isChecked());
|
||||
config()->set("GUI/DarkTrayIcon", m_generalUi->systrayDarkIconCheckBox->isChecked());
|
||||
config()->set("GUI/MinimizeToTray", m_generalUi->systrayMinimizeToTrayCheckBox->isChecked());
|
||||
config()->set("GUI/MinimizeOnClose", m_generalUi->systrayMinimizeOnCloseCheckBox->isChecked());
|
||||
config()->set("GUI/MinimizeOnClose", m_generalUi->minimizeOnCloseCheckBox->isChecked());
|
||||
config()->set("GUI/MinimizeOnStartup", m_generalUi->systrayMinimizeOnStartup->isChecked());
|
||||
|
||||
config()->set("security/autotypeask", m_generalUi->autoTypeAskCheckBox->isChecked());
|
||||
@ -299,5 +299,4 @@ void ApplicationSettingsWidget::enableSystray(bool checked)
|
||||
{
|
||||
m_generalUi->systrayDarkIconCheckBox->setEnabled(checked);
|
||||
m_generalUi->systrayMinimizeToTrayCheckBox->setEnabled(checked);
|
||||
m_generalUi->systrayMinimizeOnCloseCheckBox->setEnabled(checked);
|
||||
}
|
||||
|
@ -186,6 +186,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="minimizeOnCloseCheckBox">
|
||||
<property name="text">
|
||||
<string>Minimize instead of app exit</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="systrayShowCheckBox">
|
||||
<property name="text">
|
||||
@ -193,6 +200,42 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetMaximumSize</enum>
|
||||
</property>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="systrayDarkIconCheckBox">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Dark system tray icon</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="systraySettings" native="true">
|
||||
<layout class="QVBoxLayout" name="systrayLayout">
|
||||
@ -250,78 +293,6 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetMaximumSize</enum>
|
||||
</property>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="systrayMinimizeOnCloseCheckBox">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Hide window to system tray instead of app exit</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetMaximumSize</enum>
|
||||
</property>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Fixed</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="systrayDarkIconCheckBox">
|
||||
<property name="enabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Dark system tray icon</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -116,10 +116,8 @@ DatabaseWidget::DatabaseWidget(Database* db, QWidget* parent)
|
||||
m_previewView->hide();
|
||||
connect(this, SIGNAL(pressedEntry(Entry*)), m_previewView, SLOT(setEntry(Entry*)));
|
||||
connect(this, SIGNAL(pressedGroup(Group*)), m_previewView, SLOT(setGroup(Group*)));
|
||||
connect(this,
|
||||
SIGNAL(currentModeChanged(DatabaseWidget::Mode)),
|
||||
m_previewView,
|
||||
SLOT(setDatabaseMode(DatabaseWidget::Mode)));
|
||||
connect(this, SIGNAL(currentModeChanged(DatabaseWidget::Mode)),
|
||||
m_previewView, SLOT(setDatabaseMode(DatabaseWidget::Mode)));
|
||||
connect(m_previewView, SIGNAL(errorOccurred(QString)), this, SLOT(showErrorMessage(QString)));
|
||||
|
||||
auto* vLayout = new QVBoxLayout(rightHandSideWidget);
|
||||
@ -138,8 +136,6 @@ DatabaseWidget::DatabaseWidget(Database* db, QWidget* parent)
|
||||
|
||||
rightHandSideWidget->setLayout(vLayout);
|
||||
|
||||
setTabOrder(m_entryView, m_groupView);
|
||||
|
||||
m_mainSplitter->addWidget(m_groupView);
|
||||
m_mainSplitter->addWidget(rightHandSideWidget);
|
||||
|
||||
@ -1342,29 +1338,16 @@ QStringList DatabaseWidget::customEntryAttributes() const
|
||||
}
|
||||
|
||||
/*
|
||||
* Restores the focus on the group and entry that was focused
|
||||
* before the database was locked or reloaded.
|
||||
* Restores the focus on the group and entry provided
|
||||
*/
|
||||
void DatabaseWidget::restoreGroupEntryFocus(const QUuid& groupUuid, const QUuid& entryUuid)
|
||||
{
|
||||
Group* restoredGroup = nullptr;
|
||||
const QList<Group*> groups = m_db->rootGroup()->groupsRecursive(true);
|
||||
for (Group* group : groups) {
|
||||
if (group->uuid() == groupUuid) {
|
||||
restoredGroup = group;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (restoredGroup != nullptr) {
|
||||
m_groupView->setCurrentGroup(restoredGroup);
|
||||
|
||||
const QList<Entry*> entries = restoredGroup->entries();
|
||||
for (Entry* entry : entries) {
|
||||
if (entry->uuid() == entryUuid) {
|
||||
m_entryView->setCurrentEntry(entry);
|
||||
break;
|
||||
}
|
||||
auto group = m_db->resolveGroup(groupUuid);
|
||||
if (group) {
|
||||
m_groupView->setCurrentGroup(group);
|
||||
auto entry = group->findEntryByUuid(entryUuid);
|
||||
if (entry) {
|
||||
m_entryView->setCurrentEntry(entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,14 @@
|
||||
<ui version="4.0">
|
||||
<class>EntryPreviewWidget</class>
|
||||
<widget class="QWidget" name="EntryPreviewWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>280</width>
|
||||
<height>267</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_7">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
@ -107,6 +115,9 @@
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="entryTotpButton">
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::ClickFocus</enum>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Generate TOTP Token</string>
|
||||
</property>
|
||||
@ -120,6 +131,9 @@
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="entryCloseButton">
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::ClickFocus</enum>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Close</string>
|
||||
</property>
|
||||
@ -135,6 +149,9 @@
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QTabWidget" name="entryTabWidget">
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::ClickFocus</enum>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
@ -732,6 +749,13 @@
|
||||
<header>gui/widgets/ElidedLabel.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>entryTotpButton</tabstop>
|
||||
<tabstop>entryAutotypeTree</tabstop>
|
||||
<tabstop>entryTabWidget</tabstop>
|
||||
<tabstop>groupCloseButton</tabstop>
|
||||
<tabstop>groupTabWidget</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
@ -207,6 +207,11 @@ MainWindow::MainWindow()
|
||||
m_ui->actionEntryCopyURL->setShortcut(Qt::CTRL + Qt::ALT + Qt::Key_U);
|
||||
|
||||
new QShortcut(Qt::CTRL + Qt::Key_M, this, SLOT(showMinimized()));
|
||||
new QShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_M, this, SLOT(hideWindow()));
|
||||
new QShortcut(Qt::CTRL + Qt::Key_Tab, this, SLOT(selectNextDatabaseTab()));
|
||||
new QShortcut(Qt::CTRL + Qt::Key_PageUp, this, SLOT(selectNextDatabaseTab()));
|
||||
new QShortcut(Qt::CTRL + Qt::SHIFT + Qt::Key_Tab, this, SLOT(selectPreviousDatabaseTab()));
|
||||
new QShortcut(Qt::CTRL + Qt::Key_PageDown, this, SLOT(selectPreviousDatabaseTab()));
|
||||
|
||||
m_ui->actionDatabaseNew->setIcon(filePath()->icon("actions", "document-new"));
|
||||
m_ui->actionDatabaseOpen->setIcon(filePath()->icon("actions", "document-open"));
|
||||
@ -697,6 +702,30 @@ void MainWindow::databaseStatusChanged(DatabaseWidget*)
|
||||
updateTrayIcon();
|
||||
}
|
||||
|
||||
void MainWindow::selectNextDatabaseTab()
|
||||
{
|
||||
if (m_ui->stackedWidget->currentIndex() == DatabaseTabScreen) {
|
||||
int index = m_ui->tabWidget->currentIndex() + 1;
|
||||
if (index >= m_ui->tabWidget->count()) {
|
||||
m_ui->tabWidget->setCurrentIndex(0);
|
||||
} else {
|
||||
m_ui->tabWidget->setCurrentIndex(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::selectPreviousDatabaseTab()
|
||||
{
|
||||
if (m_ui->stackedWidget->currentIndex() == DatabaseTabScreen) {
|
||||
int index = m_ui->tabWidget->currentIndex() - 1;
|
||||
if (index < 0) {
|
||||
m_ui->tabWidget->setCurrentIndex(m_ui->tabWidget->count() - 1);
|
||||
} else {
|
||||
m_ui->tabWidget->setCurrentIndex(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::databaseTabChanged(int tabIndex)
|
||||
{
|
||||
if (tabIndex != -1 && m_ui->stackedWidget->currentIndex() == WelcomeScreen) {
|
||||
@ -716,15 +745,9 @@ void MainWindow::closeEvent(QCloseEvent* event)
|
||||
return;
|
||||
}
|
||||
|
||||
bool minimizeOnClose = isTrayIconEnabled() && config()->get("GUI/MinimizeOnClose").toBool();
|
||||
if (minimizeOnClose && !m_appExitCalled) {
|
||||
event->accept();
|
||||
if (config()->get("GUI/MinimizeOnClose").toBool() && !m_appExitCalled) {
|
||||
event->ignore();
|
||||
hideWindow();
|
||||
|
||||
if (config()->get("security/lockdatabaseminimize").toBool()) {
|
||||
m_ui->tabWidget->lockDatabases();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -908,7 +931,12 @@ void MainWindow::hideWindow()
|
||||
// TODO: Add an explanation for why this is also not done on Mac (or remove the check)
|
||||
setWindowState(windowState() | Qt::WindowMinimized);
|
||||
#endif
|
||||
QTimer::singleShot(0, this, SLOT(hide()));
|
||||
// Only hide if tray icon is active, otherwise window will be gone forever
|
||||
if (isTrayIconEnabled()) {
|
||||
hide();
|
||||
} else {
|
||||
showMinimized();
|
||||
}
|
||||
|
||||
if (config()->get("security/lockdatabaseminimize").toBool()) {
|
||||
m_ui->tabWidget->lockDatabases();
|
||||
|
@ -69,6 +69,8 @@ public slots:
|
||||
void hideGlobalMessage();
|
||||
void showYubiKeyPopup();
|
||||
void hideYubiKeyPopup();
|
||||
void hideWindow();
|
||||
void toggleWindow();
|
||||
void bringToFront();
|
||||
void closeAllDatabases();
|
||||
void lockAllDatabases();
|
||||
@ -103,13 +105,13 @@ private slots:
|
||||
void rememberOpenDatabases(const QString& filePath);
|
||||
void applySettingsChanges();
|
||||
void trayIconTriggered(QSystemTrayIcon::ActivationReason reason);
|
||||
void hideWindow();
|
||||
void toggleWindow();
|
||||
void lockDatabasesAfterInactivity();
|
||||
void forgetTouchIDAfterInactivity();
|
||||
void hideTabMessage();
|
||||
void handleScreenLock();
|
||||
void showErrorMessage(const QString& message);
|
||||
void selectNextDatabaseTab();
|
||||
void selectPreviousDatabaseTab();
|
||||
|
||||
private:
|
||||
static void setShortcut(QAction* action, QKeySequence::StandardKey standard, int fallback = 0);
|
||||
|
Loading…
x
Reference in New Issue
Block a user