Added automatically saving DB after change

This commit is contained in:
Thom Troy 2012-06-10 15:28:46 +01:00 committed by Florian Geyer
parent 871cdc5bb8
commit 17f4e23215
4 changed files with 27 additions and 0 deletions

View File

@ -71,6 +71,7 @@ Config::Config()
m_defaults.insert("RememberLastDatabases", true);
m_defaults.insert("ModifiedOnExpandedStateChanges", true);
m_defaults.insert("AutoSaveAfterEveryChange", false);
m_defaults.insert("security/clearclipboard", true);
m_defaults.insert("security/clearclipboardtimeout", 10);
}

View File

@ -523,8 +523,17 @@ void DatabaseTabWidget::modified()
{
Q_ASSERT(qobject_cast<Database*>(sender()));
if (config()->get("AutoSaveAfterEveryChange").toBool()) {
config()->set("LastDatabases", QVariant());
}
Database* db = static_cast<Database*>(sender());
DatabaseManagerStruct& dbStruct = m_dbList[db];
if (config()->get("AutoSaveAfterEveryChange").toBool() && dbStruct.file) {
saveDatabase(db);
return;
}
if (!dbStruct.modified) {
dbStruct.modified = true;
updateTabName(db);

View File

@ -50,6 +50,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_secUi->clearClipboardCheckBox->setChecked(config()->get("security/clearclipboard").toBool());
m_secUi->clearClipboardSpinBox->setValue(config()->get("security/clearclipboardtimeout").toInt());
@ -60,6 +61,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("security/clearclipboard", m_secUi->clearClipboardCheckBox->isChecked());
config()->set("security/clearclipboardtimeout", m_secUi->clearClipboardSpinBox->value());

View File

@ -2,6 +2,14 @@
<ui version="4.0">
<class>SettingsWidgetGeneral</class>
<widget class="QWidget" name="SettingsWidgetGeneral">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>354</width>
<height>104</height>
</rect>
</property>
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QCheckBox" name="rememberLastDatabasesCheckBox">
@ -23,6 +31,13 @@
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="autoSaveAfterEveryChangeCheckBox">
<property name="text">
<string>Automatically save after every change</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>