From 00df73ced093b74b3e49c736e020d20ac1c54a32 Mon Sep 17 00:00:00 2001 From: Joe Harvell Date: Sat, 14 Mar 2015 22:06:53 -0500 Subject: [PATCH] Issue #270 - turning off key location memory Add general settting for whether or not to remember last key files --- src/core/Config.cpp | 1 + src/gui/DatabaseOpenWidget.cpp | 14 +++++++++----- src/gui/SettingsWidget.cpp | 2 ++ src/gui/SettingsWidgetGeneral.ui | 33 +++++++++++++++++++++----------- 4 files changed, 34 insertions(+), 16 deletions(-) diff --git a/src/core/Config.cpp b/src/core/Config.cpp index 48ea9f333..046a0fe50 100644 --- a/src/core/Config.cpp +++ b/src/core/Config.cpp @@ -89,6 +89,7 @@ void Config::init(const QString& fileName) m_settings.reset(new QSettings(fileName, QSettings::IniFormat)); m_defaults.insert("RememberLastDatabases", true); + m_defaults.insert("RememberLastKeyFiles", true); m_defaults.insert("OpenPreviousDatabasesOnStartup", true); m_defaults.insert("AutoSaveAfterEveryChange", false); m_defaults.insert("AutoSaveOnExit", false); diff --git a/src/gui/DatabaseOpenWidget.cpp b/src/gui/DatabaseOpenWidget.cpp index 81c195712..77614f52c 100644 --- a/src/gui/DatabaseOpenWidget.cpp +++ b/src/gui/DatabaseOpenWidget.cpp @@ -67,10 +67,12 @@ void DatabaseOpenWidget::load(const QString& filename) m_ui->labelFilename->setText(filename); - QHash lastKeyFiles = config()->get("LastKeyFiles").toHash(); - if (lastKeyFiles.contains(m_filename)) { - m_ui->checkKeyFile->setChecked(true); - m_ui->comboKeyFile->addItem(lastKeyFiles[m_filename].toString()); + if(config()->get("RememberLastKeyFiles").toBool()) { + QHash lastKeyFiles = config()->get("LastKeyFiles").toHash(); + if (lastKeyFiles.contains(m_filename)) { + m_ui->checkKeyFile->setChecked(true); + m_ui->comboKeyFile->addItem(lastKeyFiles[m_filename].toString()); + } } m_ui->editPassword->setFocus(); @@ -148,7 +150,9 @@ CompositeKey DatabaseOpenWidget::databaseKey() lastKeyFiles.remove(m_filename); } - config()->set("LastKeyFiles", lastKeyFiles); + if(config()->get("RememberLastKeyFiles").toBool()) { + config()->set("LastKeyFiles", lastKeyFiles); + } return masterKey; } diff --git a/src/gui/SettingsWidget.cpp b/src/gui/SettingsWidget.cpp index 33789ae7e..e774ed21a 100644 --- a/src/gui/SettingsWidget.cpp +++ b/src/gui/SettingsWidget.cpp @@ -63,6 +63,7 @@ SettingsWidget::~SettingsWidget() void SettingsWidget::loadSettings() { m_generalUi->rememberLastDatabasesCheckBox->setChecked(config()->get("RememberLastDatabases").toBool()); + m_generalUi->rememberLastKeyFilesCheckBox->setChecked(config()->get("RememberLastKeyFiles").toBool()); m_generalUi->openPreviousDatabasesOnStartupCheckBox->setChecked( config()->get("OpenPreviousDatabasesOnStartup").toBool()); m_generalUi->autoSaveAfterEveryChangeCheckBox->setChecked(config()->get("AutoSaveAfterEveryChange").toBool()); @@ -108,6 +109,7 @@ void SettingsWidget::loadSettings() void SettingsWidget::saveSettings() { config()->set("RememberLastDatabases", m_generalUi->rememberLastDatabasesCheckBox->isChecked()); + config()->set("RememberLastKeyFiles", m_generalUi->rememberLastKeyFilesCheckBox->isChecked()); config()->set("OpenPreviousDatabasesOnStartup", m_generalUi->openPreviousDatabasesOnStartupCheckBox->isChecked()); config()->set("AutoSaveAfterEveryChange", diff --git a/src/gui/SettingsWidgetGeneral.ui b/src/gui/SettingsWidgetGeneral.ui index 04c603a34..6f4ee660c 100644 --- a/src/gui/SettingsWidgetGeneral.ui +++ b/src/gui/SettingsWidgetGeneral.ui @@ -25,75 +25,85 @@ + + + Remember last key files + + + true + + + + Open previous databases on startup - + Automatically save on exit - + Automatically save after every change - + Minimize when copying to clipboard - + Use group icon on entry creation - + Global Auto-Type shortcut - + - + Use entry title to match windows for global auto-type - + Language - + - + Show a system tray icon - + false @@ -114,6 +124,7 @@ rememberLastDatabasesCheckBox + rememberLastKeyFilesCheckBox openPreviousDatabasesOnStartupCheckBox autoSaveOnExitCheckBox autoSaveAfterEveryChangeCheckBox