diff options
| author | László Hevér <[email protected]> | 2026-02-05 13:35:14 +0000 |
|---|---|---|
| committer | Méven Car <[email protected]> | 2026-02-05 13:35:14 +0000 |
| commit | 3df6bacc90c62d52965ad6fc2d48c196f546c4a2 (patch) | |
| tree | dcea888f564fd0ea616e04fcd84f0000b470c843 | |
| parent | 17e55c976581aa58b4500e426fb2925a3d45c308 (diff) | |
Dynamic view should weight folders.
Folders are less important than images or videos so they should weight less.
BUG: 508304
| -rw-r--r-- | src/views/dolphinview.cpp | 30 |
1 files changed, 18 insertions, 12 deletions
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; } } |
