diff --git a/src/core/Config.cpp b/src/core/Config.cpp index d9c737eb8..bad86a3e2 100644 --- a/src/core/Config.cpp +++ b/src/core/Config.cpp @@ -101,6 +101,7 @@ void Config::init(const QString& fileName) m_defaults.insert("security/clearclipboardtimeout", 10); m_defaults.insert("security/lockdatabaseidle", false); m_defaults.insert("security/lockdatabaseidlesec", 10); + m_defaults.insert("security/lockdatabaseminimize", false); m_defaults.insert("security/passwordscleartext", false); m_defaults.insert("security/autotypeask", true); m_defaults.insert("GUI/Language", "system"); diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 031a6bc7c..455d050ef 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -516,6 +516,11 @@ void MainWindow::closeEvent(QCloseEvent* event) { event->ignore(); hide(); + + if (config()->get("security/lockdatabaseminimize").toBool()) { + m_ui->tabWidget->lockDatabases(); + } + return; } @@ -534,12 +539,17 @@ void MainWindow::closeEvent(QCloseEvent* event) void MainWindow::changeEvent(QEvent* event) { - if ((event->type() == QEvent::WindowStateChange) && isMinimized() - && isTrayIconEnabled() && m_trayIcon && m_trayIcon->isVisible() - && config()->get("GUI/MinimizeToTray").toBool()) - { - event->ignore(); - QTimer::singleShot(0, this, SLOT(hide())); + if ((event->type() == QEvent::WindowStateChange) && isMinimized()) { + if (isTrayIconEnabled() && m_trayIcon && m_trayIcon->isVisible() + && config()->get("GUI/MinimizeToTray").toBool()) + { + event->ignore(); + QTimer::singleShot(0, this, SLOT(hide())); + } + + if (config()->get("security/lockdatabaseminimize").toBool()) { + m_ui->tabWidget->lockDatabases(); + } } else { QMainWindow::changeEvent(event); @@ -674,6 +684,10 @@ void MainWindow::toggleWindow() { if ((QApplication::activeWindow() == this) && isVisible() && !isMinimized()) { hide(); + + if (config()->get("security/lockdatabaseminimize").toBool()) { + m_ui->tabWidget->lockDatabases(); + } } else { ensurePolished(); diff --git a/src/gui/SettingsWidget.cpp b/src/gui/SettingsWidget.cpp index e0db81344..79ae0aa6d 100644 --- a/src/gui/SettingsWidget.cpp +++ b/src/gui/SettingsWidget.cpp @@ -142,6 +142,7 @@ void SettingsWidget::loadSettings() m_secUi->lockDatabaseIdleCheckBox->setChecked(config()->get("security/lockdatabaseidle").toBool()); m_secUi->lockDatabaseIdleSpinBox->setValue(config()->get("security/lockdatabaseidlesec").toInt()); + m_secUi->lockDatabaseMinimizeCheckBox->setChecked(config()->get("security/lockdatabaseminimize").toBool()); m_secUi->passwordCleartextCheckBox->setChecked(config()->get("security/passwordscleartext").toBool()); @@ -185,6 +186,7 @@ void SettingsWidget::saveSettings() config()->set("security/lockdatabaseidle", m_secUi->lockDatabaseIdleCheckBox->isChecked()); config()->set("security/lockdatabaseidlesec", m_secUi->lockDatabaseIdleSpinBox->value()); + config()->set("security/lockdatabaseminimize", m_secUi->lockDatabaseMinimizeCheckBox->isChecked()); config()->set("security/passwordscleartext", m_secUi->passwordCleartextCheckBox->isChecked()); diff --git a/src/gui/SettingsWidgetSecurity.ui b/src/gui/SettingsWidgetSecurity.ui index b52e86238..cb0da3fda 100644 --- a/src/gui/SettingsWidgetSecurity.ui +++ b/src/gui/SettingsWidgetSecurity.ui @@ -58,13 +58,20 @@ + + + Lock databases after minimizing the window + + + + Show passwords in cleartext by default - + Always ask before performing auto-type