mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-12-25 15:29:44 -05:00
Update edit entry widget when backing entry changes
* Fixes #4060 * Also fix not emitting entryModified() when history is truncated. This possibly fixes other crashes with apply button when the history is truncated and then the history page is shown with a deleted entry.
This commit is contained in:
parent
2073f2ddc3
commit
9d10792640
@ -663,6 +663,7 @@ void Entry::truncateHistory()
|
||||
return;
|
||||
}
|
||||
|
||||
bool changed = false;
|
||||
int histMaxItems = db->metadata()->historyMaxItems();
|
||||
if (histMaxItems > -1) {
|
||||
int historyCount = 0;
|
||||
@ -674,6 +675,7 @@ void Entry::truncateHistory()
|
||||
if (historyCount > histMaxItems) {
|
||||
delete entry;
|
||||
i.remove();
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -697,9 +699,14 @@ void Entry::truncateHistory()
|
||||
if (size > histMaxSize) {
|
||||
delete historyItem;
|
||||
i.remove();
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (changed) {
|
||||
emit entryModified();
|
||||
}
|
||||
}
|
||||
|
||||
bool Entry::equals(const Entry* other, CompareItemOptions options) const
|
||||
|
@ -118,6 +118,14 @@ EditEntryWidget::EditEntryWidget(QWidget* parent)
|
||||
setupHistory();
|
||||
setupEntryUpdate();
|
||||
|
||||
m_entryModifiedTimer.setSingleShot(true);
|
||||
m_entryModifiedTimer.setInterval(0);
|
||||
connect(&m_entryModifiedTimer, &QTimer::timeout, this, [this] {
|
||||
if (isVisible() && m_entry) {
|
||||
setForms(m_entry);
|
||||
}
|
||||
});
|
||||
|
||||
connect(this, SIGNAL(accepted()), SLOT(acceptEntry()));
|
||||
connect(this, SIGNAL(rejected()), SLOT(cancel()));
|
||||
connect(this, SIGNAL(apply()), SLOT(commitEntry()));
|
||||
@ -785,6 +793,8 @@ void EditEntryWidget::loadEntry(Entry* entry,
|
||||
m_create = create;
|
||||
m_history = history;
|
||||
|
||||
connect(m_entry, &Entry::entryModified, this, [this] { m_entryModifiedTimer.start(); });
|
||||
|
||||
if (history) {
|
||||
setHeadline(QString("%1 \u2B29 %2").arg(parentName, tr("Entry history")));
|
||||
} else {
|
||||
@ -1130,6 +1140,10 @@ void EditEntryWidget::cancel()
|
||||
|
||||
void EditEntryWidget::clear()
|
||||
{
|
||||
if (m_entry) {
|
||||
m_entry->disconnect(this);
|
||||
}
|
||||
|
||||
m_entry = nullptr;
|
||||
m_db.reset();
|
||||
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include <QModelIndex>
|
||||
#include <QPointer>
|
||||
#include <QScopedPointer>
|
||||
#include <QTimer>
|
||||
|
||||
#include "config-keepassx.h"
|
||||
#include "gui/EditWidget.h"
|
||||
@ -198,6 +199,7 @@ private:
|
||||
QButtonGroup* const m_autoTypeWindowSequenceGroup;
|
||||
QCompleter* const m_usernameCompleter;
|
||||
QStringListModel* const m_usernameCompleterModel;
|
||||
QTimer m_entryModifiedTimer;
|
||||
|
||||
Q_DISABLE_COPY(EditEntryWidget)
|
||||
};
|
||||
|
@ -499,9 +499,9 @@ void TestGui::testEditEntry()
|
||||
// Confirm edit was made
|
||||
QCOMPARE(m_dbWidget->currentMode(), DatabaseWidget::Mode::ViewMode);
|
||||
QCOMPARE(entry->title(), QString("Sample Entry_test"));
|
||||
QCOMPARE(entry->foregroundColor(), fgColor);
|
||||
QCOMPARE(entry->foregroundColor().toUpper(), fgColor.toUpper());
|
||||
QCOMPARE(entryItem.data(Qt::ForegroundRole), QVariant(fgColor));
|
||||
QCOMPARE(entry->backgroundColor(), bgColor);
|
||||
QCOMPARE(entry->backgroundColor().toUpper(), bgColor.toUpper());
|
||||
QCOMPARE(entryItem.data(Qt::BackgroundRole), QVariant(bgColor));
|
||||
QCOMPARE(entry->historyItems().size(), ++editCount);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user