mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-10-01 01:26:01 -04:00
Add gui option for history max items and size to database settings widget.
This commit is contained in:
parent
1a74feb253
commit
1c24b2c5c4
@ -31,8 +31,8 @@ Metadata::Metadata(Database* parent)
|
||||
m_recycleBinEnabled = true;
|
||||
m_masterKeyChangeRec = -1;
|
||||
m_masterKeyChangeForce = -1;
|
||||
m_historyMaxItems = 10;
|
||||
m_historyMaxSize = 6291456;
|
||||
m_historyMaxItems = defaultHistoryMaxItems;
|
||||
m_historyMaxSize = defaultHistoryMaxSize;
|
||||
|
||||
QDateTime now = Tools::currentDateTimeUtc();
|
||||
m_nameChanged = now;
|
||||
@ -52,6 +52,9 @@ Metadata::Metadata(Database* parent)
|
||||
m_updateDatetime = true;
|
||||
}
|
||||
|
||||
const int Metadata::defaultHistoryMaxItems = 10;
|
||||
const int Metadata::defaultHistoryMaxSize = 6291456;
|
||||
|
||||
template <class P, class V> bool Metadata::set(P& property, const V& value)
|
||||
{
|
||||
if (property != value) {
|
||||
|
@ -69,6 +69,9 @@ public:
|
||||
int historyMaxSize() const;
|
||||
QHash<QString, QString> customFields() const;
|
||||
|
||||
static const int defaultHistoryMaxItems;
|
||||
static const int defaultHistoryMaxSize;
|
||||
|
||||
void setGenerator(const QString& value);
|
||||
void setName(const QString& value);
|
||||
void setNameChanged(const QDateTime& value);
|
||||
|
@ -18,6 +18,8 @@
|
||||
#include "DatabaseSettingsWidget.h"
|
||||
#include "ui_DatabaseSettingsWidget.h"
|
||||
|
||||
#include "core/Metadata.h"
|
||||
|
||||
|
||||
DatabaseSettingsWidget::DatabaseSettingsWidget(QWidget* parent)
|
||||
: DialogyWidget(parent)
|
||||
@ -27,6 +29,10 @@ DatabaseSettingsWidget::DatabaseSettingsWidget(QWidget* parent)
|
||||
|
||||
connect(m_ui->buttonBox, SIGNAL(accepted()), SLOT(changeSettings()));
|
||||
connect(m_ui->buttonBox, SIGNAL(rejected()), SLOT(reject()));
|
||||
connect(m_ui->historyMaxItemsCheckBox, SIGNAL(stateChanged(int)),
|
||||
this, SLOT(toggleHistoryMaxItemsSpinBox(int)));
|
||||
connect(m_ui->historyMaxSizeCheckBox, SIGNAL(stateChanged(int)),
|
||||
this, SLOT(toggleHistoryMaxSizeSpinBox(int)));
|
||||
}
|
||||
|
||||
DatabaseSettingsWidget::~DatabaseSettingsWidget()
|
||||
@ -35,7 +41,8 @@ DatabaseSettingsWidget::~DatabaseSettingsWidget()
|
||||
|
||||
void DatabaseSettingsWidget::setForms(QString dbName, QString dbDescription,
|
||||
QString defaultUsername, bool recylceBinEnabled,
|
||||
int transformRounds)
|
||||
int transformRounds, int historyMaxItems,
|
||||
int historyMaxSize)
|
||||
{
|
||||
m_ui->dbNameEdit->setText(dbName);
|
||||
m_ui->dbDescriptionEdit->setText(dbDescription);
|
||||
@ -47,6 +54,22 @@ void DatabaseSettingsWidget::setForms(QString dbName, QString dbDescription,
|
||||
}
|
||||
m_ui->defaultUsernameEdit->setText(defaultUsername);
|
||||
m_ui->transformRoundsSpinBox->setValue(transformRounds);
|
||||
if (historyMaxItems > -1) {
|
||||
m_ui->historyMaxItemsSpinBox->setValue(historyMaxItems);
|
||||
m_ui->historyMaxItemsCheckBox->setChecked(true);
|
||||
}
|
||||
else {
|
||||
m_ui->historyMaxItemsSpinBox->setValue(Metadata::defaultHistoryMaxItems);
|
||||
m_ui->historyMaxItemsCheckBox->setChecked(false);
|
||||
}
|
||||
if (historyMaxSize > -1) {
|
||||
m_ui->historyMaxSizeSpinBox->setValue(historyMaxSize);
|
||||
m_ui->historyMaxSizeCheckBox->setChecked(true);
|
||||
}
|
||||
else {
|
||||
m_ui->historyMaxSizeSpinBox->setValue(Metadata::defaultHistoryMaxSize);
|
||||
m_ui->historyMaxSizeCheckBox->setChecked(false);
|
||||
}
|
||||
|
||||
m_ui->dbNameEdit->setFocus();
|
||||
}
|
||||
@ -76,6 +99,16 @@ bool DatabaseSettingsWidget::recylceBinEnabled()
|
||||
return m_recylceBinEnabled;
|
||||
}
|
||||
|
||||
int DatabaseSettingsWidget::historyMaxItems()
|
||||
{
|
||||
return m_historyMaxItems;
|
||||
}
|
||||
|
||||
int DatabaseSettingsWidget::historyMaxSize()
|
||||
{
|
||||
return m_historyMaxSize;
|
||||
}
|
||||
|
||||
void DatabaseSettingsWidget::changeSettings()
|
||||
{
|
||||
m_dbName = m_ui->dbNameEdit->text();
|
||||
@ -88,6 +121,19 @@ void DatabaseSettingsWidget::changeSettings()
|
||||
m_recylceBinEnabled = false;
|
||||
}
|
||||
m_transformRounds = m_ui->transformRoundsSpinBox->value();
|
||||
if (m_ui->historyMaxItemsCheckBox->isChecked()) {
|
||||
m_historyMaxItems = m_ui->historyMaxItemsSpinBox->value();
|
||||
}
|
||||
else {
|
||||
m_historyMaxItems = -1;
|
||||
}
|
||||
if (m_ui->historyMaxSizeCheckBox->isChecked()) {
|
||||
m_historyMaxSize = m_ui->historyMaxSizeSpinBox->value();
|
||||
}
|
||||
else {
|
||||
m_historyMaxSize = -1;
|
||||
}
|
||||
|
||||
|
||||
Q_EMIT editFinished(true);
|
||||
}
|
||||
@ -97,3 +143,23 @@ void DatabaseSettingsWidget::reject()
|
||||
Q_EMIT editFinished(false);
|
||||
}
|
||||
|
||||
void DatabaseSettingsWidget::toggleHistoryMaxItemsSpinBox(int state)
|
||||
{
|
||||
if (state == Qt::Checked) {
|
||||
m_ui->historyMaxItemsSpinBox->setEnabled(true);
|
||||
}
|
||||
else {
|
||||
m_ui->historyMaxItemsSpinBox->setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
||||
void DatabaseSettingsWidget::toggleHistoryMaxSizeSpinBox(int state)
|
||||
{
|
||||
if (state == Qt::Checked) {
|
||||
m_ui->historyMaxSizeSpinBox->setEnabled(true);
|
||||
}
|
||||
else {
|
||||
m_ui->historyMaxSizeSpinBox->setEnabled(false);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -38,12 +38,15 @@ public:
|
||||
|
||||
void setForms(QString dbName, QString dbDescription,
|
||||
QString defaultUsername, bool recylceBinEnabled,
|
||||
int transformRounds);
|
||||
int transformRounds, int historyMaxItems,
|
||||
int historyMaxSize);
|
||||
quint64 transformRounds();
|
||||
QString dbName();
|
||||
QString dbDescription();
|
||||
QString defaultUsername();
|
||||
bool recylceBinEnabled();
|
||||
int historyMaxItems();
|
||||
int historyMaxSize();
|
||||
|
||||
Q_SIGNALS:
|
||||
void editFinished(bool accepted);
|
||||
@ -51,6 +54,8 @@ Q_SIGNALS:
|
||||
private Q_SLOTS:
|
||||
void changeSettings();
|
||||
void reject();
|
||||
void toggleHistoryMaxItemsSpinBox(int state);
|
||||
void toggleHistoryMaxSizeSpinBox(int state);
|
||||
|
||||
private:
|
||||
const QScopedPointer<Ui::DatabaseSettingsWidget> m_ui;
|
||||
@ -60,6 +65,8 @@ private:
|
||||
QString m_defaultUsername;
|
||||
bool m_recylceBinEnabled;
|
||||
quint64 m_transformRounds;
|
||||
int m_historyMaxItems;
|
||||
int m_historyMaxSize;
|
||||
|
||||
Q_DISABLE_COPY(DatabaseSettingsWidget)
|
||||
};
|
||||
|
@ -42,9 +42,6 @@
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="dbNameEdit"/>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="dbDescriptionEdit"/>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="dbDescriptionLabel">
|
||||
<property name="text">
|
||||
@ -52,6 +49,9 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="dbDescriptionEdit"/>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="transformRoundsLabel">
|
||||
<property name="text">
|
||||
@ -75,13 +75,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QLineEdit" name="defaultUsernameEdit">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="defaultUsernameLabel">
|
||||
<property name="text">
|
||||
@ -89,8 +82,12 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QCheckBox" name="recycleBinEnabledCheckBox"/>
|
||||
<item row="4" column="1">
|
||||
<widget class="QLineEdit" name="defaultUsernameEdit">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
@ -99,6 +96,71 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QCheckBox" name="recycleBinEnabledCheckBox"/>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="historyMaxSizeLabel">
|
||||
<property name="text">
|
||||
<string>History max size:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="historyMaxSizeCheckBox">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="historyMaxSizeSpinBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>2000000000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="historyMaxItemsLabel">
|
||||
<property name="text">
|
||||
<string>History max items:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="historyMaxItemsCheckBox">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="historyMaxItemsSpinBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>2000000000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
|
@ -276,6 +276,8 @@ void DatabaseWidget::updateSettings(bool accepted)
|
||||
m_db->metadata()->setDefaultUserName(m_databaseSettingsWidget->defaultUsername());
|
||||
m_db->metadata()->setRecycleBinEnabled(m_databaseSettingsWidget->recylceBinEnabled());
|
||||
m_db->metadata()->setName(m_databaseSettingsWidget->dbName());
|
||||
m_db->metadata()->setHistoryMaxItems(m_databaseSettingsWidget->historyMaxItems());
|
||||
m_db->metadata()->setHistoryMaxSize(m_databaseSettingsWidget->historyMaxSize());
|
||||
}
|
||||
|
||||
setCurrentIndex(0);
|
||||
@ -303,7 +305,9 @@ void DatabaseWidget::switchToDatabaseSettings()
|
||||
m_db->metadata()->description(),
|
||||
m_db->metadata()->defaultUserName(),
|
||||
m_db->metadata()->recycleBinEnabled(),
|
||||
m_db->transformRounds());
|
||||
m_db->transformRounds(),
|
||||
m_db->metadata()->historyMaxItems(),
|
||||
m_db->metadata()->historyMaxSize());
|
||||
setCurrentIndex(4);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user