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_recycleBinEnabled = true;
|
||||||
m_masterKeyChangeRec = -1;
|
m_masterKeyChangeRec = -1;
|
||||||
m_masterKeyChangeForce = -1;
|
m_masterKeyChangeForce = -1;
|
||||||
m_historyMaxItems = 10;
|
m_historyMaxItems = defaultHistoryMaxItems;
|
||||||
m_historyMaxSize = 6291456;
|
m_historyMaxSize = defaultHistoryMaxSize;
|
||||||
|
|
||||||
QDateTime now = Tools::currentDateTimeUtc();
|
QDateTime now = Tools::currentDateTimeUtc();
|
||||||
m_nameChanged = now;
|
m_nameChanged = now;
|
||||||
@ -52,6 +52,9 @@ Metadata::Metadata(Database* parent)
|
|||||||
m_updateDatetime = true;
|
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)
|
template <class P, class V> bool Metadata::set(P& property, const V& value)
|
||||||
{
|
{
|
||||||
if (property != value) {
|
if (property != value) {
|
||||||
|
@ -69,6 +69,9 @@ public:
|
|||||||
int historyMaxSize() const;
|
int historyMaxSize() const;
|
||||||
QHash<QString, QString> customFields() const;
|
QHash<QString, QString> customFields() const;
|
||||||
|
|
||||||
|
static const int defaultHistoryMaxItems;
|
||||||
|
static const int defaultHistoryMaxSize;
|
||||||
|
|
||||||
void setGenerator(const QString& value);
|
void setGenerator(const QString& value);
|
||||||
void setName(const QString& value);
|
void setName(const QString& value);
|
||||||
void setNameChanged(const QDateTime& value);
|
void setNameChanged(const QDateTime& value);
|
||||||
|
@ -18,6 +18,8 @@
|
|||||||
#include "DatabaseSettingsWidget.h"
|
#include "DatabaseSettingsWidget.h"
|
||||||
#include "ui_DatabaseSettingsWidget.h"
|
#include "ui_DatabaseSettingsWidget.h"
|
||||||
|
|
||||||
|
#include "core/Metadata.h"
|
||||||
|
|
||||||
|
|
||||||
DatabaseSettingsWidget::DatabaseSettingsWidget(QWidget* parent)
|
DatabaseSettingsWidget::DatabaseSettingsWidget(QWidget* parent)
|
||||||
: DialogyWidget(parent)
|
: DialogyWidget(parent)
|
||||||
@ -27,6 +29,10 @@ DatabaseSettingsWidget::DatabaseSettingsWidget(QWidget* parent)
|
|||||||
|
|
||||||
connect(m_ui->buttonBox, SIGNAL(accepted()), SLOT(changeSettings()));
|
connect(m_ui->buttonBox, SIGNAL(accepted()), SLOT(changeSettings()));
|
||||||
connect(m_ui->buttonBox, SIGNAL(rejected()), SLOT(reject()));
|
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()
|
DatabaseSettingsWidget::~DatabaseSettingsWidget()
|
||||||
@ -35,7 +41,8 @@ DatabaseSettingsWidget::~DatabaseSettingsWidget()
|
|||||||
|
|
||||||
void DatabaseSettingsWidget::setForms(QString dbName, QString dbDescription,
|
void DatabaseSettingsWidget::setForms(QString dbName, QString dbDescription,
|
||||||
QString defaultUsername, bool recylceBinEnabled,
|
QString defaultUsername, bool recylceBinEnabled,
|
||||||
int transformRounds)
|
int transformRounds, int historyMaxItems,
|
||||||
|
int historyMaxSize)
|
||||||
{
|
{
|
||||||
m_ui->dbNameEdit->setText(dbName);
|
m_ui->dbNameEdit->setText(dbName);
|
||||||
m_ui->dbDescriptionEdit->setText(dbDescription);
|
m_ui->dbDescriptionEdit->setText(dbDescription);
|
||||||
@ -47,6 +54,22 @@ void DatabaseSettingsWidget::setForms(QString dbName, QString dbDescription,
|
|||||||
}
|
}
|
||||||
m_ui->defaultUsernameEdit->setText(defaultUsername);
|
m_ui->defaultUsernameEdit->setText(defaultUsername);
|
||||||
m_ui->transformRoundsSpinBox->setValue(transformRounds);
|
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();
|
m_ui->dbNameEdit->setFocus();
|
||||||
}
|
}
|
||||||
@ -76,6 +99,16 @@ bool DatabaseSettingsWidget::recylceBinEnabled()
|
|||||||
return m_recylceBinEnabled;
|
return m_recylceBinEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int DatabaseSettingsWidget::historyMaxItems()
|
||||||
|
{
|
||||||
|
return m_historyMaxItems;
|
||||||
|
}
|
||||||
|
|
||||||
|
int DatabaseSettingsWidget::historyMaxSize()
|
||||||
|
{
|
||||||
|
return m_historyMaxSize;
|
||||||
|
}
|
||||||
|
|
||||||
void DatabaseSettingsWidget::changeSettings()
|
void DatabaseSettingsWidget::changeSettings()
|
||||||
{
|
{
|
||||||
m_dbName = m_ui->dbNameEdit->text();
|
m_dbName = m_ui->dbNameEdit->text();
|
||||||
@ -88,6 +121,19 @@ void DatabaseSettingsWidget::changeSettings()
|
|||||||
m_recylceBinEnabled = false;
|
m_recylceBinEnabled = false;
|
||||||
}
|
}
|
||||||
m_transformRounds = m_ui->transformRoundsSpinBox->value();
|
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);
|
Q_EMIT editFinished(true);
|
||||||
}
|
}
|
||||||
@ -97,3 +143,23 @@ void DatabaseSettingsWidget::reject()
|
|||||||
Q_EMIT editFinished(false);
|
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,
|
void setForms(QString dbName, QString dbDescription,
|
||||||
QString defaultUsername, bool recylceBinEnabled,
|
QString defaultUsername, bool recylceBinEnabled,
|
||||||
int transformRounds);
|
int transformRounds, int historyMaxItems,
|
||||||
|
int historyMaxSize);
|
||||||
quint64 transformRounds();
|
quint64 transformRounds();
|
||||||
QString dbName();
|
QString dbName();
|
||||||
QString dbDescription();
|
QString dbDescription();
|
||||||
QString defaultUsername();
|
QString defaultUsername();
|
||||||
bool recylceBinEnabled();
|
bool recylceBinEnabled();
|
||||||
|
int historyMaxItems();
|
||||||
|
int historyMaxSize();
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void editFinished(bool accepted);
|
void editFinished(bool accepted);
|
||||||
@ -51,6 +54,8 @@ Q_SIGNALS:
|
|||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void changeSettings();
|
void changeSettings();
|
||||||
void reject();
|
void reject();
|
||||||
|
void toggleHistoryMaxItemsSpinBox(int state);
|
||||||
|
void toggleHistoryMaxSizeSpinBox(int state);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const QScopedPointer<Ui::DatabaseSettingsWidget> m_ui;
|
const QScopedPointer<Ui::DatabaseSettingsWidget> m_ui;
|
||||||
@ -60,6 +65,8 @@ private:
|
|||||||
QString m_defaultUsername;
|
QString m_defaultUsername;
|
||||||
bool m_recylceBinEnabled;
|
bool m_recylceBinEnabled;
|
||||||
quint64 m_transformRounds;
|
quint64 m_transformRounds;
|
||||||
|
int m_historyMaxItems;
|
||||||
|
int m_historyMaxSize;
|
||||||
|
|
||||||
Q_DISABLE_COPY(DatabaseSettingsWidget)
|
Q_DISABLE_COPY(DatabaseSettingsWidget)
|
||||||
};
|
};
|
||||||
|
@ -42,9 +42,6 @@
|
|||||||
<item row="1" column="1">
|
<item row="1" column="1">
|
||||||
<widget class="QLineEdit" name="dbNameEdit"/>
|
<widget class="QLineEdit" name="dbNameEdit"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="1">
|
|
||||||
<widget class="QLineEdit" name="dbDescriptionEdit"/>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="0">
|
<item row="2" column="0">
|
||||||
<widget class="QLabel" name="dbDescriptionLabel">
|
<widget class="QLabel" name="dbDescriptionLabel">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@ -52,6 +49,9 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QLineEdit" name="dbDescriptionEdit"/>
|
||||||
|
</item>
|
||||||
<item row="3" column="0">
|
<item row="3" column="0">
|
||||||
<widget class="QLabel" name="transformRoundsLabel">
|
<widget class="QLabel" name="transformRoundsLabel">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@ -75,13 +75,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</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">
|
<item row="4" column="0">
|
||||||
<widget class="QLabel" name="defaultUsernameLabel">
|
<widget class="QLabel" name="defaultUsernameLabel">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@ -89,8 +82,12 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="5" column="1">
|
<item row="4" column="1">
|
||||||
<widget class="QCheckBox" name="recycleBinEnabledCheckBox"/>
|
<widget class="QLineEdit" name="defaultUsernameEdit">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="5" column="0">
|
<item row="5" column="0">
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QLabel" name="label">
|
||||||
@ -99,6 +96,71 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</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>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
@ -276,6 +276,8 @@ void DatabaseWidget::updateSettings(bool accepted)
|
|||||||
m_db->metadata()->setDefaultUserName(m_databaseSettingsWidget->defaultUsername());
|
m_db->metadata()->setDefaultUserName(m_databaseSettingsWidget->defaultUsername());
|
||||||
m_db->metadata()->setRecycleBinEnabled(m_databaseSettingsWidget->recylceBinEnabled());
|
m_db->metadata()->setRecycleBinEnabled(m_databaseSettingsWidget->recylceBinEnabled());
|
||||||
m_db->metadata()->setName(m_databaseSettingsWidget->dbName());
|
m_db->metadata()->setName(m_databaseSettingsWidget->dbName());
|
||||||
|
m_db->metadata()->setHistoryMaxItems(m_databaseSettingsWidget->historyMaxItems());
|
||||||
|
m_db->metadata()->setHistoryMaxSize(m_databaseSettingsWidget->historyMaxSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
setCurrentIndex(0);
|
setCurrentIndex(0);
|
||||||
@ -303,7 +305,9 @@ void DatabaseWidget::switchToDatabaseSettings()
|
|||||||
m_db->metadata()->description(),
|
m_db->metadata()->description(),
|
||||||
m_db->metadata()->defaultUserName(),
|
m_db->metadata()->defaultUserName(),
|
||||||
m_db->metadata()->recycleBinEnabled(),
|
m_db->metadata()->recycleBinEnabled(),
|
||||||
m_db->transformRounds());
|
m_db->transformRounds(),
|
||||||
|
m_db->metadata()->historyMaxItems(),
|
||||||
|
m_db->metadata()->historyMaxSize());
|
||||||
setCurrentIndex(4);
|
setCurrentIndex(4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user