Skip to content

Commit 8904293

Browse files
varjolintuvarjolintu
authored andcommitted
Fix setting browser related values to customData (#13026)
Co-authored-by: varjolintu <sami.vanttinen@ahmala.org>
1 parent 6baaec2 commit 8904293

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

src/core/CustomData.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2024 KeePassXC Team <team@keepassxc.org>
2+
* Copyright (C) 2026 KeePassXC Team <team@keepassxc.org>
33
*
44
* This program is free software: you can redistribute it and/or modify
55
* it under the terms of the GNU General Public License as published by
@@ -149,7 +149,6 @@ void CustomData::copyDataFrom(const CustomData* other)
149149

150150
m_data = other->m_data;
151151

152-
updateLastModified();
153152
emit reset();
154153
emitModified();
155154
}

src/gui/entry/EditEntryWidget.cpp

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -351,25 +351,31 @@ void EditEntryWidget::updateBrowser()
351351
return;
352352
}
353353

354+
auto changeValue = [&](const QString& option, const bool newValue) {
355+
// If value is false and no customData exists, make no edits
356+
if (!m_customData->hasKey(option) && !newValue) {
357+
return;
358+
}
359+
360+
// If customData exists, set the value
361+
m_customData->set(option, (newValue ? TRUE_STR : FALSE_STR));
362+
};
363+
354364
// Only update the custom data if no group level settings are used (checkbox is enabled)
355365
if (m_browserUi->hideEntryCheckbox->isEnabled()) {
356-
auto hide = m_browserUi->hideEntryCheckbox->isChecked();
357-
m_customData->set(BrowserService::OPTION_HIDE_ENTRY, (hide ? TRUE_STR : FALSE_STR));
366+
changeValue(BrowserService::OPTION_HIDE_ENTRY, m_browserUi->hideEntryCheckbox->isChecked());
358367
}
359368

360369
if (m_browserUi->skipAutoSubmitCheckbox->isEnabled()) {
361-
auto skip = m_browserUi->skipAutoSubmitCheckbox->isChecked();
362-
m_customData->set(BrowserService::OPTION_SKIP_AUTO_SUBMIT, (skip ? TRUE_STR : FALSE_STR));
370+
changeValue(BrowserService::OPTION_SKIP_AUTO_SUBMIT, m_browserUi->skipAutoSubmitCheckbox->isChecked());
363371
}
364372

365373
if (m_browserUi->onlyHttpAuthCheckbox->isEnabled()) {
366-
auto onlyHttpAuth = m_browserUi->onlyHttpAuthCheckbox->isChecked();
367-
m_customData->set(BrowserService::OPTION_ONLY_HTTP_AUTH, (onlyHttpAuth ? TRUE_STR : FALSE_STR));
374+
changeValue(BrowserService::OPTION_ONLY_HTTP_AUTH, m_browserUi->onlyHttpAuthCheckbox->isChecked());
368375
}
369376

370377
if (m_browserUi->notHttpAuthCheckbox->isEnabled()) {
371-
auto notHttpAuth = m_browserUi->notHttpAuthCheckbox->isChecked();
372-
m_customData->set(BrowserService::OPTION_NOT_HTTP_AUTH, (notHttpAuth ? TRUE_STR : FALSE_STR));
378+
changeValue(BrowserService::OPTION_NOT_HTTP_AUTH, m_browserUi->notHttpAuthCheckbox->isChecked());
373379
}
374380
}
375381

@@ -803,7 +809,6 @@ void EditEntryWidget::addKeyToAgent()
803809

804810
if (!sshAgent()->addIdentity(key, settings, m_db->uuid())) {
805811
showMessage(sshAgent()->errorString(), MessageWidget::Error);
806-
return;
807812
}
808813
}
809814

@@ -817,7 +822,6 @@ void EditEntryWidget::removeKeyFromAgent()
817822

818823
if (!sshAgent()->removeIdentity(key)) {
819824
showMessage(sshAgent()->errorString(), MessageWidget::Error);
820-
return;
821825
}
822826
}
823827

@@ -1040,6 +1044,7 @@ void EditEntryWidget::setForms(Entry* entry, bool restore)
10401044
setupBrowser();
10411045
}
10421046

1047+
m_browserSettingsChanged = false;
10431048
auto hideEntriesCheckBoxEnabled = true;
10441049
auto skipAutoSubmitCheckBoxEnabled = true;
10451050
auto onlyHttpAuthCheckBoxEnabled = true;

0 commit comments

Comments
 (0)