Skip to content

Commit

Permalink
Add autosaveDelay to DatabaseSettings
Browse files Browse the repository at this point in the history
Add metadata propery autosaveDelay to the gui in the DatabaseSettings widget under General.
User can change the delay in minutes.
Add new translation strings as well.

Part of issue keepassxreboot#8553
  • Loading branch information
jNullj committed Feb 19, 2023
1 parent 18916a1 commit de99863
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 1 deletion.
20 changes: 20 additions & 0 deletions share/translations/keepassxc_en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2029,6 +2029,26 @@ Entries deleted from the recycle bin are
removed from the database.</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Autosave delay since last change</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Autosave delay</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Autosave delay since last change in minutes</source>
<translation type="unfinished"></translation>
</message>
<message>
<source> min</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Autosave delay since last change checkbox</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>DatabaseSettingsWidgetKeeShare</name>
Expand Down
14 changes: 14 additions & 0 deletions src/gui/dbsettings/DatabaseSettingsWidgetGeneral.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ DatabaseSettingsWidgetGeneral::DatabaseSettingsWidgetGeneral(QWidget* parent)

connect(m_ui->historyMaxItemsCheckBox, SIGNAL(toggled(bool)), m_ui->historyMaxItemsSpinBox, SLOT(setEnabled(bool)));
connect(m_ui->historyMaxSizeCheckBox, SIGNAL(toggled(bool)), m_ui->historyMaxSizeSpinBox, SLOT(setEnabled(bool)));
connect(m_ui->autosaveDelayCheckBox, SIGNAL(toggled(bool)), m_ui->autosaveDelaySpinBox, SLOT(setEnabled(bool)));
}

DatabaseSettingsWidgetGeneral::~DatabaseSettingsWidgetGeneral() = default;
Expand Down Expand Up @@ -62,6 +63,13 @@ void DatabaseSettingsWidgetGeneral::initialize()
m_ui->historyMaxSizeSpinBox->setEnabled(false);
m_ui->historyMaxSizeCheckBox->setChecked(false);
}
if (meta->autosaveDelayMin() > 0) {
m_ui->autosaveDelaySpinBox->setValue(meta->autosaveDelayMin());
m_ui->autosaveDelayCheckBox->setChecked(true);
} else {
m_ui->autosaveDelayCheckBox->setChecked(false);
m_ui->autosaveDelaySpinBox->setEnabled(false);
}
}

void DatabaseSettingsWidgetGeneral::uninitialize()
Expand Down Expand Up @@ -132,6 +140,12 @@ bool DatabaseSettingsWidgetGeneral::save()
truncate = true;
}

int autosaveDelayMin = 0;
if (m_ui->autosaveDelayCheckBox->isChecked()) {
autosaveDelayMin = m_ui->autosaveDelaySpinBox->value();
}
meta->setAutosaveDelayMin(autosaveDelayMin);

if (truncate) {
const QList<Entry*> allEntries = m_db->rootGroup()->entriesRecursive(false);
for (Entry* entry : allEntries) {
Expand Down
54 changes: 53 additions & 1 deletion src/gui/dbsettings/DatabaseSettingsWidgetGeneral.ui
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>453</width>
<height>374</height>
<height>394</height>
</rect>
</property>
<property name="sizePolicy">
Expand Down Expand Up @@ -202,6 +202,58 @@ removed from the database.</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QCheckBox" name="autosaveDelayCheckBox">
<property name="toolTip">
<string>Autosave delay since last change</string>
</property>
<property name="accessibleName">
<string>Autosave delay since last change checkbox</string>
</property>
<property name="text">
<string>Autosave delay</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="autosaveDelaySpinBox">
<property name="toolTip">
<string>Autosave delay since last change in minutes</string>
</property>
<property name="accessibleName">
<string>Autosave delay since last change in minutes</string>
</property>
<property name="suffix">
<string> min</string>
</property>
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>420000000</number>
</property>
<property name="value">
<number>5</number>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<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>
Expand Down

0 comments on commit de99863

Please sign in to comment.