From 2d41de5e7cd82ee46ef1966116ee508193ad0c00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20V=C3=A4nttinen?= Date: Sun, 8 Mar 2026 13:47:29 +0200 Subject: [PATCH] Fix setting browser related values to customData (#13026) Co-authored-by: varjolintu --- src/core/CustomData.cpp | 3 +-- src/gui/entry/EditEntryWidget.cpp | 25 +++++++++++++++---------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/core/CustomData.cpp b/src/core/CustomData.cpp index 37c197c73..9e4a1631f 100644 --- a/src/core/CustomData.cpp +++ b/src/core/CustomData.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2024 KeePassXC Team + * Copyright (C) 2026 KeePassXC Team * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -149,7 +149,6 @@ void CustomData::copyDataFrom(const CustomData* other) m_data = other->m_data; - updateLastModified(); emit reset(); emitModified(); } diff --git a/src/gui/entry/EditEntryWidget.cpp b/src/gui/entry/EditEntryWidget.cpp index d821296f1..8ed279f35 100644 --- a/src/gui/entry/EditEntryWidget.cpp +++ b/src/gui/entry/EditEntryWidget.cpp @@ -351,25 +351,31 @@ void EditEntryWidget::updateBrowser() return; } + auto changeValue = [&](const QString& option, const bool newValue) { + // If value is false and no customData exists, make no edits + if (!m_customData->hasKey(option) && !newValue) { + return; + } + + // If customData exists, set the value + m_customData->set(option, (newValue ? TRUE_STR : FALSE_STR)); + }; + // Only update the custom data if no group level settings are used (checkbox is enabled) if (m_browserUi->hideEntryCheckbox->isEnabled()) { - auto hide = m_browserUi->hideEntryCheckbox->isChecked(); - m_customData->set(BrowserService::OPTION_HIDE_ENTRY, (hide ? TRUE_STR : FALSE_STR)); + changeValue(BrowserService::OPTION_HIDE_ENTRY, m_browserUi->hideEntryCheckbox->isChecked()); } if (m_browserUi->skipAutoSubmitCheckbox->isEnabled()) { - auto skip = m_browserUi->skipAutoSubmitCheckbox->isChecked(); - m_customData->set(BrowserService::OPTION_SKIP_AUTO_SUBMIT, (skip ? TRUE_STR : FALSE_STR)); + changeValue(BrowserService::OPTION_SKIP_AUTO_SUBMIT, m_browserUi->skipAutoSubmitCheckbox->isChecked()); } if (m_browserUi->onlyHttpAuthCheckbox->isEnabled()) { - auto onlyHttpAuth = m_browserUi->onlyHttpAuthCheckbox->isChecked(); - m_customData->set(BrowserService::OPTION_ONLY_HTTP_AUTH, (onlyHttpAuth ? TRUE_STR : FALSE_STR)); + changeValue(BrowserService::OPTION_ONLY_HTTP_AUTH, m_browserUi->onlyHttpAuthCheckbox->isChecked()); } if (m_browserUi->notHttpAuthCheckbox->isEnabled()) { - auto notHttpAuth = m_browserUi->notHttpAuthCheckbox->isChecked(); - m_customData->set(BrowserService::OPTION_NOT_HTTP_AUTH, (notHttpAuth ? TRUE_STR : FALSE_STR)); + changeValue(BrowserService::OPTION_NOT_HTTP_AUTH, m_browserUi->notHttpAuthCheckbox->isChecked()); } } @@ -803,7 +809,6 @@ void EditEntryWidget::addKeyToAgent() if (!sshAgent()->addIdentity(key, settings, m_db->uuid())) { showMessage(sshAgent()->errorString(), MessageWidget::Error); - return; } } @@ -817,7 +822,6 @@ void EditEntryWidget::removeKeyFromAgent() if (!sshAgent()->removeIdentity(key)) { showMessage(sshAgent()->errorString(), MessageWidget::Error); - return; } } @@ -1040,6 +1044,7 @@ void EditEntryWidget::setForms(Entry* entry, bool restore) setupBrowser(); } + m_browserSettingsChanged = false; auto hideEntriesCheckBoxEnabled = true; auto skipAutoSubmitCheckBoxEnabled = true; auto onlyHttpAuthCheckBoxEnabled = true;