From 93423eda308122eba98b71d17284a3c59f0885cf Mon Sep 17 00:00:00 2001 From: varjolintu Date: Wed, 6 Aug 2025 21:59:26 +0300 Subject: [PATCH] Fix inheriting browser group settings --- src/core/Group.cpp | 20 +++++++++++++++++++- src/core/Group.h | 3 ++- src/gui/group/EditGroupWidget.cpp | 12 ++++++------ 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/src/core/Group.cpp b/src/core/Group.cpp index b7182740f..b06ac7727 100644 --- a/src/core/Group.cpp +++ b/src/core/Group.cpp @@ -1,6 +1,6 @@ /* + * Copyright (C) 2025 KeePassXC Team * Copyright (C) 2010 Felix Geyer - * Copyright (C) 2021 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 @@ -1142,6 +1142,24 @@ bool Group::resolveAutoTypeEnabled() const } } +bool Group::resolveBrowserOptionEnabled(const QString& option) const +{ + switch (resolveCustomDataTriState(option, true)) { + case Inherit: + if (!m_parent) { + return false; + } + return m_parent->resolveBrowserOptionEnabled(option); + case Enable: + return true; + case Disable: + return false; + default: + Q_ASSERT(false); + return false; + } +} + Entry* Group::addEntryWithPath(const QString& entryPath) { if (entryPath.isEmpty() || findEntryByPath(entryPath)) { diff --git a/src/core/Group.h b/src/core/Group.h index 95489bc59..01c0b2120 100644 --- a/src/core/Group.h +++ b/src/core/Group.h @@ -1,6 +1,6 @@ /* + * Copyright (C) 2025 KeePassXC Team * Copyright (C) 2010 Felix Geyer - * Copyright (C) 2021 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 @@ -94,6 +94,7 @@ public: Group::MergeMode mergeMode() const; bool resolveSearchingEnabled() const; bool resolveAutoTypeEnabled() const; + bool resolveBrowserOptionEnabled(const QString& option) const; Entry* lastTopVisibleEntry() const; bool isExpired() const; bool isRecycled() const; diff --git a/src/gui/group/EditGroupWidget.cpp b/src/gui/group/EditGroupWidget.cpp index bf38caf2e..4e406b0d0 100644 --- a/src/gui/group/EditGroupWidget.cpp +++ b/src/gui/group/EditGroupWidget.cpp @@ -1,6 +1,6 @@ /* + * Copyright (C) 2025 KeePassXC Team * Copyright (C) 2011 Felix Geyer - * Copyright (C) 2022 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 @@ -200,11 +200,11 @@ void EditGroupWidget::loadGroup(Group* group, bool create, const QSharedPointer< auto parent = group->parentGroup(); if (parent) { - inheritHideEntries = parent->resolveCustomDataTriState(BrowserService::OPTION_HIDE_ENTRY); - inheritSkipSubmit = parent->resolveCustomDataTriState(BrowserService::OPTION_SKIP_AUTO_SUBMIT); - inheritOnlyHttp = parent->resolveCustomDataTriState(BrowserService::OPTION_ONLY_HTTP_AUTH); - inheritNoHttp = parent->resolveCustomDataTriState(BrowserService::OPTION_NOT_HTTP_AUTH); - inheritOmitWww = parent->resolveCustomDataTriState(BrowserService::OPTION_OMIT_WWW); + inheritHideEntries = parent->resolveBrowserOptionEnabled(BrowserService::OPTION_HIDE_ENTRY); + inheritSkipSubmit = parent->resolveBrowserOptionEnabled(BrowserService::OPTION_SKIP_AUTO_SUBMIT); + inheritOnlyHttp = parent->resolveBrowserOptionEnabled(BrowserService::OPTION_ONLY_HTTP_AUTH); + inheritNoHttp = parent->resolveBrowserOptionEnabled(BrowserService::OPTION_NOT_HTTP_AUTH); + inheritOmitWww = parent->resolveBrowserOptionEnabled(BrowserService::OPTION_OMIT_WWW); inheritRestrictKey = parent->resolveCustomDataString(BrowserService::OPTION_RESTRICT_KEY); }