diff --git a/src/gui/DatabaseWidget.cpp b/src/gui/DatabaseWidget.cpp index d71ba6feb..90868bd27 100644 --- a/src/gui/DatabaseWidget.cpp +++ b/src/gui/DatabaseWidget.cpp @@ -288,8 +288,12 @@ 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()); + if (m_db->metadata()->historyMaxItems() != m_databaseSettingsWidget->historyMaxItems() || + m_db->metadata()->historyMaxSize() != m_databaseSettingsWidget->historyMaxSize()) { + m_db->metadata()->setHistoryMaxItems(m_databaseSettingsWidget->historyMaxItems()); + m_db->metadata()->setHistoryMaxSize(m_databaseSettingsWidget->historyMaxSize()); + truncateHistories(); + } } setCurrentIndex(0); @@ -343,3 +347,13 @@ bool DatabaseWidget::canDeleteCurrentGoup() bool isRecycleBin = m_db->metadata()->recycleBin() == m_groupView->currentGroup(); return !isRootGroup && !isRecycleBin; } + +void DatabaseWidget::truncateHistories() +{ + QList allEntries = m_db->rootGroup()->entriesRecursive(false); + QListIterator i(allEntries); + while (i.hasNext()) { + Entry* entry = i.next(); + entry->truncateHistory(); + } +} diff --git a/src/gui/DatabaseWidget.h b/src/gui/DatabaseWidget.h index 4128cdcb7..a303aa56f 100644 --- a/src/gui/DatabaseWidget.h +++ b/src/gui/DatabaseWidget.h @@ -55,6 +55,7 @@ public: void setCurrentIndex(int index); DatabaseWidget::Mode currentMode(); + Q_SIGNALS: void closeRequest(); void currentModeChanged(DatabaseWidget::Mode mode); @@ -90,6 +91,8 @@ private: Entry* m_newEntry; Group* m_newParent; QLineEdit* m_searchEdit; + + void truncateHistories(); }; #endif // KEEPASSX_DATABASEWIDGET_H