Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/keepassxreboot/keepassxc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorJonathan White <support@dmapps.us>2021-10-01 23:56:49 +0300
committerJonathan White <support@dmapps.us>2021-10-09 18:12:25 +0300
commitf2aa32c7b06a83a4faa819d09c2e7a4e5e6478df (patch)
tree6539e8acb832f4019e0c7be918bd2992de9ccc69 /src/gui
parent484bc5dd018b041ea78affb3ca42e5c57a0d42ba (diff)
Add direct write save option
* Closes #6335 * Modify application settings presentation to allow for alternative saving strategies * Transition Database::save calls to using flags to control saving behavior. Reduces boolean flags on function call. * Made direct write save option a local setting to prevent unintentional carry over between platforms.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/ApplicationSettingsWidget.cpp8
-rw-r--r--src/gui/ApplicationSettingsWidgetGeneral.ui75
-rw-r--r--src/gui/DatabaseWidget.cpp18
3 files changed, 79 insertions, 22 deletions
diff --git a/src/gui/ApplicationSettingsWidget.cpp b/src/gui/ApplicationSettingsWidget.cpp
index e26163f9f..100258120 100644
--- a/src/gui/ApplicationSettingsWidget.cpp
+++ b/src/gui/ApplicationSettingsWidget.cpp
@@ -109,6 +109,8 @@ ApplicationSettingsWidget::ApplicationSettingsWidget(QWidget* parent)
connect(m_generalUi->systrayShowCheckBox, SIGNAL(toggled(bool)), SLOT(systrayToggled(bool)));
connect(m_generalUi->rememberLastDatabasesCheckBox, SIGNAL(toggled(bool)), SLOT(rememberDatabasesToggled(bool)));
connect(m_generalUi->resetSettingsButton, SIGNAL(clicked()), SLOT(resetSettings()));
+ connect(m_generalUi->useAlternativeSaveCheckBox, SIGNAL(toggled(bool)),
+ m_generalUi->alternativeSaveComboBox, SLOT(setEnabled(bool)));
connect(m_secUi->clearClipboardCheckBox, SIGNAL(toggled(bool)),
m_secUi->clearClipboardSpinBox, SLOT(setEnabled(bool)));
@@ -186,7 +188,8 @@ void ApplicationSettingsWidget::loadSettings()
m_generalUi->autoSaveOnExitCheckBox->setChecked(config()->get(Config::AutoSaveOnExit).toBool());
m_generalUi->autoSaveNonDataChangesCheckBox->setChecked(config()->get(Config::AutoSaveNonDataChanges).toBool());
m_generalUi->backupBeforeSaveCheckBox->setChecked(config()->get(Config::BackupBeforeSave).toBool());
- m_generalUi->useAtomicSavesCheckBox->setChecked(config()->get(Config::UseAtomicSaves).toBool());
+ m_generalUi->useAlternativeSaveCheckBox->setChecked(!config()->get(Config::UseAtomicSaves).toBool());
+ m_generalUi->alternativeSaveComboBox->setCurrentIndex(config()->get(Config::UseDirectWriteSaves).toBool() ? 1 : 0);
m_generalUi->autoReloadOnChangeCheckBox->setChecked(config()->get(Config::AutoReloadOnChange).toBool());
m_generalUi->minimizeAfterUnlockCheckBox->setChecked(config()->get(Config::MinimizeAfterUnlock).toBool());
m_generalUi->minimizeOnOpenUrlCheckBox->setChecked(config()->get(Config::MinimizeOnOpenUrl).toBool());
@@ -323,7 +326,8 @@ void ApplicationSettingsWidget::saveSettings()
config()->set(Config::AutoSaveOnExit, m_generalUi->autoSaveOnExitCheckBox->isChecked());
config()->set(Config::AutoSaveNonDataChanges, m_generalUi->autoSaveNonDataChangesCheckBox->isChecked());
config()->set(Config::BackupBeforeSave, m_generalUi->backupBeforeSaveCheckBox->isChecked());
- config()->set(Config::UseAtomicSaves, m_generalUi->useAtomicSavesCheckBox->isChecked());
+ config()->set(Config::UseAtomicSaves, !m_generalUi->useAlternativeSaveCheckBox->isChecked());
+ config()->set(Config::UseDirectWriteSaves, m_generalUi->alternativeSaveComboBox->currentIndex() == 1);
config()->set(Config::AutoReloadOnChange, m_generalUi->autoReloadOnChangeCheckBox->isChecked());
config()->set(Config::MinimizeAfterUnlock, m_generalUi->minimizeAfterUnlockCheckBox->isChecked());
config()->set(Config::MinimizeOnOpenUrl, m_generalUi->minimizeOnOpenUrlCheckBox->isChecked());
diff --git a/src/gui/ApplicationSettingsWidgetGeneral.ui b/src/gui/ApplicationSettingsWidgetGeneral.ui
index dc55d30cb..0e18dfde6 100644
--- a/src/gui/ApplicationSettingsWidgetGeneral.ui
+++ b/src/gui/ApplicationSettingsWidgetGeneral.ui
@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>605</width>
- <height>1279</height>
+ <height>968</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3" stretch="0">
@@ -59,7 +59,7 @@
<x>0</x>
<y>0</y>
<width>581</width>
- <height>1235</height>
+ <height>924</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_8">
@@ -265,29 +265,79 @@
</widget>
</item>
<item>
- <widget class="QCheckBox" name="backupBeforeSaveCheckBox">
+ <widget class="QCheckBox" name="autoReloadOnChangeCheckBox">
<property name="text">
- <string>Backup database file before saving</string>
+ <string>Automatically reload the database when modified externally</string>
</property>
</widget>
</item>
<item>
- <widget class="QCheckBox" name="autoReloadOnChangeCheckBox">
+ <widget class="QCheckBox" name="backupBeforeSaveCheckBox">
<property name="text">
- <string>Automatically reload the database when modified externally</string>
+ <string>Backup database file before saving</string>
</property>
</widget>
</item>
<item>
- <widget class="QCheckBox" name="useAtomicSavesCheckBox">
+ <widget class="QCheckBox" name="useAlternativeSaveCheckBox">
<property name="text">
- <string>Safely save database files (disable if experiencing problems with Dropbox, etc.)</string>
- </property>
- <property name="checked">
- <bool>true</bool>
+ <string>Use alternative saving method (may solve problems with Dropbox, Google Drive, GVFS, etc.)</string>
</property>
</widget>
</item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_3">
+ <property name="spacing">
+ <number>0</number>
+ </property>
+ <item>
+ <spacer name="horizontalSpacer_8">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Fixed</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>30</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QComboBox" name="alternativeSaveComboBox">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <item>
+ <property name="text">
+ <string>Temporary file moved into place</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Directly write to database file (dangerous)</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_7">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
</layout>
</widget>
</item>
@@ -1046,8 +1096,7 @@
<tabstop>autoSaveOnExitCheckBox</tabstop>
<tabstop>autoSaveNonDataChangesCheckBox</tabstop>
<tabstop>backupBeforeSaveCheckBox</tabstop>
- <tabstop>autoReloadOnChangeCheckBox</tabstop>
- <tabstop>useAtomicSavesCheckBox</tabstop>
+ <tabstop>useAlternativeSaveCheckBox</tabstop>
<tabstop>useGroupIconOnEntryCreationCheckBox</tabstop>
<tabstop>minimizeOnOpenUrlCheckBox</tabstop>
<tabstop>hideWindowOnCopyCheckBox</tabstop>
diff --git a/src/gui/DatabaseWidget.cpp b/src/gui/DatabaseWidget.cpp
index 5e7044c78..50a379fb3 100644
--- a/src/gui/DatabaseWidget.cpp
+++ b/src/gui/DatabaseWidget.cpp
@@ -1867,16 +1867,20 @@ bool DatabaseWidget::performSave(QString& errorMessage, const QString& fileName)
m_groupView->setDisabled(true);
QApplication::processEvents();
+ Database::SaveAction saveAction = Database::Atomic;
+ if (!config()->get(Config::UseAtomicSaves).toBool()) {
+ if (config()->get(Config::UseDirectWriteSaves).toBool()) {
+ saveAction = Database::DirectWrite;
+ } else {
+ saveAction = Database::TempFile;
+ }
+ }
+
bool ok;
if (fileName.isEmpty()) {
- ok = m_db->save(&errorMessage,
- config()->get(Config::UseAtomicSaves).toBool(),
- config()->get(Config::BackupBeforeSave).toBool());
+ ok = m_db->save(saveAction, config()->get(Config::BackupBeforeSave).toBool(), &errorMessage);
} else {
- ok = m_db->saveAs(fileName,
- &errorMessage,
- config()->get(Config::UseAtomicSaves).toBool(),
- config()->get(Config::BackupBeforeSave).toBool());
+ ok = m_db->saveAs(fileName, saveAction, config()->get(Config::BackupBeforeSave).toBool(), &errorMessage);
}
// Return control