┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/views
diff options
context:
space:
mode:
authorMéven Car <[email protected]>2025-02-07 11:16:05 +0100
committerMéven Car <[email protected]>2025-02-08 09:43:09 +0100
commitc12946ee2ec8dbbb8645ca5763584574458a0a6c (patch)
tree60155025c6d2af3456830df4e69714c4b0d8c1c0 /src/views
parentd828d3a8b443b4c40e31fc72bc8d152e18737e1c (diff)
Viewproperties: prevent loosing view settings
When they match the hardcoded internal settings, when they should be kept as long as they don't match the currently set default viewproperties. Is saved in metadata the diff with the hardcoded internal defaults still. A stable default reference allows to change defaults without changing existing saved viewproperties. CCBUG: 495878
Diffstat (limited to 'src/views')
-rw-r--r--src/views/viewproperties.cpp24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/views/viewproperties.cpp b/src/views/viewproperties.cpp
index 7e589019a..5dbdd938e 100644
--- a/src/views/viewproperties.cpp
+++ b/src/views/viewproperties.cpp
@@ -531,9 +531,27 @@ void ViewProperties::save()
const auto metaDataKey = QStringLiteral("kde.fm.viewproperties#1");
const auto items = m_node->items();
- const bool allDefault = std::all_of(items.cbegin(), items.cend(), [this](const KConfigSkeletonItem *item) {
- return item->name() == "Timestamp" || (item->name() == "Version" && m_node->version() == CurrentViewPropertiesVersion) || item->isDefault();
- });
+ const auto defaultConfig = defaultProperties();
+ bool allDefault = true;
+ for (const auto item : items) {
+ if (item->name() == "Timestamp") {
+ continue;
+ }
+ if (item->name() == "Version") {
+ if (m_node->version() != CurrentViewPropertiesVersion) {
+ allDefault = false;
+ break;
+ } else {
+ continue;
+ }
+ }
+ auto defaultItem = defaultConfig->findItem(item->name());
+ if (!defaultItem || defaultItem->property() != item->property()) {
+ allDefault = false;
+ break;
+ }
+ }
+
if (allDefault) {
if (metaData.hasAttribute(metaDataKey)) {
qCDebug(DolphinDebug) << "clearing extended attributes for " << m_filePath;