]> cloud.milkyroute.net Git - dolphin.git/commitdiff
[ViewProperties] Apply better default roles for special views
authorKai Uwe Broulik <kde@privat.broulik.de>
Fri, 25 Mar 2022 17:42:13 +0000 (18:42 +0100)
committerKai Uwe Broulik <kde@privat.broulik.de>
Mon, 28 Mar 2022 12:56:49 +0000 (14:56 +0200)
This adds the following additional special view modes (some of them were
already there but broken because they weren't applied, or were
changed to have better defaults now that they are actually used):

* Recent Files and Recent Documents, timeline:
  Details view with grouped sorting enabled and Name, Path, Modified
* Search For Images:
  Icon view with Name, Dimensions, Date Time of the Picture
* Search For Audio:
  Details view with Name, Artist, Album, Duration
* Search For Videos:
  Icon view with just Name
* Search For everything else, including Documents:
  Details view with Name, Path, Modified
* Trash:
  Details view with Name, (Original) Path, Deletion Time

BUG: 400969
BUG: 340393
BUG: 186376
FIXED-IN: 22.04.0

src/views/viewproperties.cpp

index 0274d509549e48f6a63b476b7f5df826df0619ed..e6dbcd81179b353437cbc7ba902d14f0aaa469ca 100644 (file)
@@ -37,7 +37,8 @@ ViewProperties::ViewProperties(const QUrl& url) :
 {
     GeneralSettings* settings = GeneralSettings::self();
     const bool useGlobalViewProps = settings->globalViewProps() || url.isEmpty();
-    bool useDetailsViewWithPath = false;
+    bool useSearchView = false;
+    bool useTrashView = false;
     bool useRecentDocumentsView = false;
     bool useDownloadsView = false;
 
@@ -48,16 +49,19 @@ ViewProperties::ViewProperties(const QUrl& url) :
         m_filePath = destinationDir(QStringLiteral("global"));
     } else if (url.scheme().contains(QLatin1String("search"))) {
         m_filePath = destinationDir(QStringLiteral("search/")) + directoryHashForUrl(url);
-        useDetailsViewWithPath = true;
+        useSearchView = true;
     } else if (url.scheme() == QLatin1String("trash")) {
         m_filePath = destinationDir(QStringLiteral("trash"));
-        useDetailsViewWithPath = true;
+        useTrashView = true;
     } else if (url.scheme() == QLatin1String("recentdocuments")) {
         m_filePath = destinationDir(QStringLiteral("recentdocuments"));
         useRecentDocumentsView = true;
     } else if (url.scheme() == QLatin1String("recentlyused")) {
         m_filePath = destinationDir(QStringLiteral("recentlyused"));
         useRecentDocumentsView = true;
+    } else if (url.scheme() == QLatin1String("timeline")) {
+        m_filePath = destinationDir(QStringLiteral("timeline"));
+        useRecentDocumentsView = true;
     } else if (url.isLocalFile()) {
         m_filePath = url.toLocalFile();
 
@@ -93,23 +97,40 @@ ViewProperties::ViewProperties(const QUrl& url) :
 
     // If the .directory file does not exist or the timestamp is too old,
     // use default values instead.
-    const bool useDefaultProps = (!useGlobalViewProps || useDetailsViewWithPath) &&
+    const bool useDefaultProps = (!useGlobalViewProps || useSearchView || useTrashView || useRecentDocumentsView || useDownloadsView) &&
                                  (!QFile::exists(file) ||
                                   (m_node->timestamp() < settings->viewPropsTimestamp()));
     if (useDefaultProps) {
-        if (useDetailsViewWithPath) {
+        if (useSearchView) {
+            const QString path = url.path();
+
+            if (path == QLatin1String("/images")) {
+                setViewMode(DolphinView::IconsView);
+                setPreviewsShown(true);
+                setVisibleRoles({"text", "dimensions", "imageDateTime"});
+            } else if (path == QLatin1String("/audio")) {
+                setViewMode(DolphinView::DetailsView);
+                setVisibleRoles({"text", "artist", "album", "duration"});
+            } else if (path == QLatin1String("/videos")) {
+                setViewMode(DolphinView::IconsView);
+                setPreviewsShown(true);
+                setVisibleRoles({"text"});
+            } else {
+                setViewMode(DolphinView::DetailsView);
+                setVisibleRoles({"text", "path", "modificationtime"});
+            }
+        } else if (useTrashView) {
             setViewMode(DolphinView::DetailsView);
-            setVisibleRoles({"path"});
+            setVisibleRoles({"text", "path", "deletiontime"});
         } else if (useRecentDocumentsView || useDownloadsView) {
             setSortRole(QByteArrayLiteral("modificationtime"));
             setSortOrder(Qt::DescendingOrder);
+            setSortFoldersFirst(false);
+            setGroupedSorting(true);
 
             if (useRecentDocumentsView) {
                 setViewMode(DolphinView::DetailsView);
-                setVisibleRoles({QByteArrayLiteral("path")});
-            } else if (useDownloadsView) {
-                setSortFoldersFirst(false);
-                setGroupedSorting(true);
+                setVisibleRoles({"text", "path", "modificationtime"});
             }
         } else {
             // The global view-properties act as default for directories without