Fix database master key dirtying

* When removing portions of the master key, the key is marked dirty for saving
* Properly clear password and other fields in edit entry widget and password widgets
This commit is contained in:
Jonathan White 2019-03-30 21:31:32 -04:00
parent edef225eab
commit cb2900f5a9
No known key found for this signature in database
GPG Key ID: 440FC65F2E0C6E01
4 changed files with 20 additions and 4 deletions

View File

@ -77,11 +77,8 @@ void DatabaseSettingsWidgetMasterKey::load(QSharedPointer<Database> db)
// database has no key, we are about to add a new one
m_passwordEditWidget->changeVisiblePage(KeyComponentWidget::Page::Edit);
m_passwordEditWidget->setPasswordVisible(true);
m_isDirty = true;
return;
}
bool isDirty = false;
bool hasAdditionalKeys = false;
for (const auto& key : m_db->key()->keys()) {
if (key->uuid() == PasswordKey::UUID) {
@ -103,7 +100,9 @@ void DatabaseSettingsWidgetMasterKey::load(QSharedPointer<Database> db)
setAdditionalKeyOptionsVisible(hasAdditionalKeys);
m_isDirty = isDirty;
connect(m_passwordEditWidget->findChild<QPushButton*>("removeButton"), SIGNAL(clicked()), SLOT(markDirty()));
connect(m_keyFileEditWidget->findChild<QPushButton*>("removeButton"), SIGNAL(clicked()), SLOT(markDirty()));
connect(m_yubiKeyEditWidget->findChild<QPushButton*>("removeButton"), SIGNAL(clicked()), SLOT(markDirty()));
}
void DatabaseSettingsWidgetMasterKey::initialize()

View File

@ -993,6 +993,13 @@ void EditEntryWidget::clear()
{
m_entry = nullptr;
m_db.reset();
m_mainUi->titleEdit->setText("");
m_mainUi->passwordEdit->setText("");
m_mainUi->passwordRepeatEdit->setText("");
m_mainUi->urlEdit->setText("");
m_mainUi->notesEdit->clear();
m_entryAttributes->clear();
m_advancedUi->attachmentsWidget->clearAttachments();
m_autoTypeAssoc->clear();

View File

@ -92,6 +92,15 @@ void PasswordEditWidget::initComponentEditWidget(QWidget* widget)
m_compUi->enterPasswordEdit->setFocus();
}
void PasswordEditWidget::hideEvent(QHideEvent* event)
{
if (!isVisible() && m_compUi->enterPasswordEdit) {
m_compUi->enterPasswordEdit->setText("");
}
QWidget::hideEvent(event);
}
bool PasswordEditWidget::validate(QString& errorMessage) const
{
if (m_compUi->enterPasswordEdit->text() != m_compUi->repeatPasswordEdit->text()) {

View File

@ -44,6 +44,7 @@ public:
protected:
QWidget* componentEditWidget() override;
void initComponentEditWidget(QWidget* widget) override;
void hideEvent(QHideEvent* event) override;
private slots:
void showPasswordGenerator();