┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPan Zhang <[email protected]>2026-05-23 18:25:19 +0800
committerMéven Car <[email protected]>2026-05-23 10:25:19 +0000
commit2e665e1b513b3f7c082bedc8faaf47bee8008c73 (patch)
treebf25e8dbcd7e624ef3d6e0f1dd636d3e25b7c37c /src
parente08dd82415271b25e77a76c3fd0c3ecb049b0a0b (diff)
viewproperties: respect saved properties for special folders with global view props enabled
When "Use common display style for all folders" is enabled, the useDefaultSettings condition was always true because useGlobalViewProps was the first term in the OR chain. This caused special folders controlled by useSearchView, useTrashView, and useRecentDocumentsView to reset to their default view on every load, overriding any user customization. Restrict the unconditional default-apply to non-special folders only. For special folders, the existing timestamp-based check handles the logic correctly, and the fallback in the else branch still applies defaults when no saved properties exist (first visit). BUG: 520089
Diffstat (limited to 'src')
-rw-r--r--src/tests/viewpropertiestest.cpp28
-rw-r--r--src/views/viewproperties.cpp8
2 files changed, 34 insertions, 2 deletions
diff --git a/src/tests/viewpropertiestest.cpp b/src/tests/viewpropertiestest.cpp
index a39abaef2..c4cc9cc41 100644
--- a/src/tests/viewpropertiestest.cpp
+++ b/src/tests/viewpropertiestest.cpp
@@ -31,6 +31,7 @@ private Q_SLOTS:
void testExtendedAttributeFull();
void testUseAsDefaultViewSettings();
void testUseAsCustomDefaultViewSettings();
+ void testSpecialFolderPropsPreservedWithGlobalViewProps();
private:
bool m_globalViewProps;
@@ -444,6 +445,33 @@ void ViewPropertiesTest::testUseAsCustomDefaultViewSettings()
QCOMPARE(testDirProperties.data()->viewMode(), DolphinView::Mode::DetailsView);
}
+/**
+ * Test that special folders preserve user-customized view properties
+ * when global view props is enabled. Uses trash:/// as representative example.
+ */
+void ViewPropertiesTest::testSpecialFolderPropsPreservedWithGlobalViewProps()
+{
+ GeneralSettings::self()->setGlobalViewProps(true);
+ GeneralSettings::self()->save();
+
+ const QUrl trashUrl(QStringLiteral("trash:///"));
+
+ // First visit: customize the view mode to IconsView
+ // (trash default is DetailsView)
+ {
+ ViewProperties props(trashUrl);
+ QCOMPARE(props.viewMode(), DolphinView::DetailsView); // default
+ props.setViewMode(DolphinView::IconsView);
+ props.save();
+ }
+
+ // Second visit: the custom view mode should be preserved
+ {
+ ViewProperties props(trashUrl);
+ QCOMPARE(props.viewMode(), DolphinView::IconsView);
+ }
+}
+
QTEST_GUILESS_MAIN(ViewPropertiesTest)
#include "viewpropertiestest.moc"
diff --git a/src/views/viewproperties.cpp b/src/views/viewproperties.cpp
index 3d33a805b..c5e53586c 100644
--- a/src/views/viewproperties.cpp
+++ b/src/views/viewproperties.cpp
@@ -177,11 +177,15 @@ ViewProperties::ViewProperties(const QUrl &url)
auto propsOpt = loadProperties(m_filePath);
- bool useDefaultSettings = useGlobalViewProps ||
+ bool useDefaultSettings =
// If the props timestamp is too old,
// use default values instead.
(propsOpt && (!useGlobalViewProps || useSearchView || useTrashView || useRecentDocumentsView || useDownloadsView)
- && propsOpt->timestamp() < settings->viewPropsTimestamp());
+ && propsOpt->timestamp() < settings->viewPropsTimestamp())
+ // When global view props is on and this is a special folder (search, trash,
+ // recents/timeline, downloads), only apply defaults on the first visit.
+ // On subsequent visits the user's saved properties should be preserved.
+ || (useGlobalViewProps && !(useSearchView || useTrashView || useRecentDocumentsView || useDownloadsView));
if (propsOpt) {
m_node = propsOpt;