mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-12-27 08:19:47 -05:00
Add auto save on exit
This commit is contained in:
parent
e439e057a0
commit
bd5dd130e5
@ -72,6 +72,7 @@ Config::Config()
|
||||
m_defaults.insert("RememberLastDatabases", true);
|
||||
m_defaults.insert("ModifiedOnExpandedStateChanges", true);
|
||||
m_defaults.insert("AutoSaveAfterEveryChange", false);
|
||||
m_defaults.insert("AutoSaveOnExit", false);
|
||||
m_defaults.insert("security/clearclipboard", true);
|
||||
m_defaults.insert("security/clearclipboardtimeout", 10);
|
||||
}
|
||||
|
@ -210,16 +210,23 @@ bool DatabaseTabWidget::closeDatabase(Database* db)
|
||||
}
|
||||
}
|
||||
if (dbStruct.modified) {
|
||||
QMessageBox::StandardButton result =
|
||||
QMessageBox::question(
|
||||
this, tr("Save changes?"),
|
||||
tr("\"%1\" was modified.\nSave changes?").arg(dbName),
|
||||
QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel, QMessageBox::Yes);
|
||||
if (result == QMessageBox::Yes) {
|
||||
if(config()->get("AutoSaveOnExit").toBool())
|
||||
{
|
||||
saveDatabase(db);
|
||||
}
|
||||
else if (result == QMessageBox::Cancel) {
|
||||
return false;
|
||||
else
|
||||
{
|
||||
QMessageBox::StandardButton result =
|
||||
QMessageBox::question(
|
||||
this, tr("Save changes?"),
|
||||
tr("\"%1\" was modified.\nSave changes?").arg(dbName),
|
||||
QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel, QMessageBox::Yes);
|
||||
if (result == QMessageBox::Yes) {
|
||||
saveDatabase(db);
|
||||
}
|
||||
else if (result == QMessageBox::Cancel) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,9 @@ SettingsWidget::SettingsWidget(QWidget* parent)
|
||||
connect(this, SIGNAL(accepted()), SLOT(saveSettings()));
|
||||
connect(this, SIGNAL(rejected()), SLOT(reject()));
|
||||
|
||||
connect(m_generalUi->autoSaveAfterEveryChangeCheckBox, SIGNAL(toggled(bool)),
|
||||
this, SLOT(enableAutoSaveOnExit(bool)));
|
||||
|
||||
connect(m_secUi->clearClipboardCheckBox, SIGNAL(toggled(bool)),
|
||||
m_secUi->clearClipboardSpinBox, SLOT(setEnabled(bool)));
|
||||
}
|
||||
@ -51,6 +54,7 @@ void SettingsWidget::loadSettings()
|
||||
m_generalUi->rememberLastDatabasesCheckBox->setChecked(config()->get("RememberLastDatabases").toBool());
|
||||
m_generalUi->modifiedExpandedChangedCheckBox->setChecked(config()->get("ModifiedOnExpandedStateChanges").toBool());
|
||||
m_generalUi->autoSaveAfterEveryChangeCheckBox->setChecked(config()->get("AutoSaveAfterEveryChange").toBool());
|
||||
m_generalUi->autoSaveOnExitCheckBox->setChecked(config()->get("AutoSaveOnExit").toBool());
|
||||
m_secUi->clearClipboardCheckBox->setChecked(config()->get("security/clearclipboard").toBool());
|
||||
m_secUi->clearClipboardSpinBox->setValue(config()->get("security/clearclipboardtimeout").toInt());
|
||||
|
||||
@ -62,6 +66,7 @@ void SettingsWidget::saveSettings()
|
||||
config()->set("RememberLastDatabases", m_generalUi->rememberLastDatabasesCheckBox->isChecked());
|
||||
config()->set("ModifiedOnExpandedStateChanges", m_generalUi->modifiedExpandedChangedCheckBox->isChecked());
|
||||
config()->set("AutoSaveAfterEveryChange", m_generalUi->autoSaveAfterEveryChangeCheckBox->isChecked());
|
||||
config()->set("AutoSaveOnExit", m_generalUi->autoSaveOnExitCheckBox->isChecked());
|
||||
config()->set("security/clearclipboard", m_secUi->clearClipboardCheckBox->isChecked());
|
||||
config()->set("security/clearclipboardtimeout", m_secUi->clearClipboardSpinBox->value());
|
||||
|
||||
@ -72,3 +77,11 @@ void SettingsWidget::reject()
|
||||
{
|
||||
Q_EMIT editFinished(false);
|
||||
}
|
||||
|
||||
void SettingsWidget::enableAutoSaveOnExit(bool checked)
|
||||
{
|
||||
if(checked)
|
||||
m_generalUi->autoSaveOnExitCheckBox->setEnabled(false);
|
||||
else
|
||||
m_generalUi->autoSaveOnExitCheckBox->setEnabled(true);
|
||||
}
|
||||
|
@ -40,6 +40,7 @@ Q_SIGNALS:
|
||||
private Q_SLOTS:
|
||||
void saveSettings();
|
||||
void reject();
|
||||
void enableAutoSaveOnExit(bool checked);
|
||||
|
||||
private:
|
||||
QWidget* const m_secWidget;
|
||||
|
@ -31,13 +31,20 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<item row="3" column="0">
|
||||
<widget class="QCheckBox" name="autoSaveAfterEveryChangeCheckBox">
|
||||
<property name="text">
|
||||
<string>Automatically save after every change</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QCheckBox" name="autoSaveOnExitCheckBox">
|
||||
<property name="text">
|
||||
<string>Automatically save on exit</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
|
Loading…
Reference in New Issue
Block a user