From 3df6bacc90c62d52965ad6fc2d48c196f546c4a2 Mon Sep 17 00:00:00 2001 From: László Hevér Date: Thu, 5 Feb 2026 13:35:14 +0000 Subject: Dynamic view should weight folders. Folders are less important than images or videos so they should weight less. BUG: 508304 --- src/views/dolphinview.cpp | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) (limited to 'src/views/dolphinview.cpp') diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp index ec012c679..e33158882 100644 --- a/src/views/dolphinview.cpp +++ b/src/views/dolphinview.cpp @@ -2431,6 +2431,8 @@ void DolphinView::applyDynamicView() uint imageAndVideoCount = 0; uint checkedItems = 0; + uint checkedItemDir = 0; + constexpr float folderWeight = 1.00/3; const uint totalItems = itemsCount(); const KFileItemList itemList = items(); bool applyDynamicView = false; @@ -2444,23 +2446,27 @@ void DolphinView::applyDynamicView() } for (const auto &file : itemList) { - ++checkedItems; + if (file.isFile()) { + ++checkedItems; #if QT_VERSION >= QT_VERSION_CHECK(6, 8, 0) - const QString type = file.mimetype().slice(0, 5); + const QString type = file.mimetype().slice(0, 5); #else - const QString type = file.mimetype().sliced(0, 5); + const QString type = file.mimetype().sliced(0, 5); #endif - if (type == "image" || type == "video") { - ++imageAndVideoCount; - // if 2/3 or more of the items are images/videos, dynamic view should be applied - applyDynamicView = imageAndVideoCount >= (totalItems * 2 / 3); - if (applyDynamicView) { - break; + if (type == "image" || type == "video") { + ++imageAndVideoCount; + // if 2/3 or more of the items are images/videos, dynamic view should be applied + applyDynamicView = imageAndVideoCount >= ((totalItems - (checkedItemDir * (1 - folderWeight))) * 2 / 3); + if (applyDynamicView) { + break; + } + } else if (checkedItems - imageAndVideoCount > (totalItems - (checkedItemDir * (1 - folderWeight))) / 3) { + // if more than a third of the checked files are not media files, return + return; } - } else if (checkedItems - imageAndVideoCount > totalItems / 3) { - // if more than a third of the checked files are not media files, return - return; + } else { + ++checkedItemDir; } } -- cgit v1.3