]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Add open containing folder options for files in recentlyused:/
authorMéven Car <meven@kde.org>
Wed, 6 Sep 2023 12:24:22 +0000 (14:24 +0200)
committerMéven Car <meven@kde.org>
Wed, 6 Sep 2023 12:39:15 +0000 (14:39 +0200)
src/dolphincontextmenu.cpp
src/dolphincontextmenu.h

index 705f8e4a5b3c64cc1b81accf4edb32640c257714..2eff1017f9d716adc01887f8f7f009b49a21e9e9 100644 (file)
@@ -75,6 +75,8 @@ void DolphinContextMenu::addAllActions()
         m_context |= SearchContext;
     } else if (scheme.contains(QLatin1String("timeline"))) {
         m_context |= TimelineContext;
+    } else if (scheme == QStringLiteral("recentlyused")) {
+        m_context |= RecentlyUsedContext;
     }
 
     if (!m_fileInfo.isNull() && !m_selectedItems.isEmpty()) {
@@ -182,6 +184,23 @@ void DolphinContextMenu::addDirectoryItemContextMenu()
     addSeparator();
 }
 
+void DolphinContextMenu::addOpenParentFolderActions()
+{
+    addAction(QIcon::fromTheme(QStringLiteral("document-open-folder")), i18nc("@action:inmenu", "Open Path"), [this]() {
+        m_mainWindow->changeUrl(KIO::upUrl(m_fileInfo.url()));
+        m_mainWindow->activeViewContainer()->view()->markUrlsAsSelected({m_fileInfo.url()});
+        m_mainWindow->activeViewContainer()->view()->markUrlAsCurrent(m_fileInfo.url());
+    });
+
+    addAction(QIcon::fromTheme(QStringLiteral("tab-new")), i18nc("@action:inmenu", "Open Path in New Tab"), [this]() {
+        m_mainWindow->openNewTab(KIO::upUrl(m_fileInfo.url()));
+    });
+
+    addAction(QIcon::fromTheme(QStringLiteral("window-new")), i18nc("@action:inmenu", "Open Path in New Window"), [this]() {
+        Dolphin::openNewWindow({m_fileInfo.url()}, m_mainWindow, Dolphin::OpenNewWindowFlag::Select);
+    });
+}
+
 void DolphinContextMenu::addItemContextMenu()
 {
     Q_ASSERT(!m_fileInfo.isNull());
@@ -194,22 +213,10 @@ void DolphinContextMenu::addItemContextMenu()
         // single files
         if (m_fileInfo.isDir()) {
             addDirectoryItemContextMenu();
-        } else if (m_context & TimelineContext || m_context & SearchContext) {
+        } else if (m_context & TimelineContext || m_context & SearchContext || m_context & RecentlyUsedContext) {
             addOpenWithActions();
 
-            addAction(QIcon::fromTheme(QStringLiteral("document-open-folder")), i18nc("@action:inmenu", "Open Path"), [this]() {
-                m_mainWindow->changeUrl(KIO::upUrl(m_fileInfo.url()));
-                m_mainWindow->activeViewContainer()->view()->markUrlsAsSelected({m_fileInfo.url()});
-                m_mainWindow->activeViewContainer()->view()->markUrlAsCurrent(m_fileInfo.url());
-            });
-
-            addAction(QIcon::fromTheme(QStringLiteral("tab-new")), i18nc("@action:inmenu", "Open Path in New Tab"), [this]() {
-                m_mainWindow->openNewTab(KIO::upUrl(m_fileInfo.url()));
-            });
-
-            addAction(QIcon::fromTheme(QStringLiteral("window-new")), i18nc("@action:inmenu", "Open Path in New Window"), [this]() {
-                Dolphin::openNewWindow({m_fileInfo.url()}, m_mainWindow, Dolphin::OpenNewWindowFlag::Select);
-            });
+            addOpenParentFolderActions();
 
             addSeparator();
         } else {
index 04b0697d0a243501d1ab9e6f033ab8e357da9e57..f60be558e8a087274bcd8ade34ad8c8464801774 100644 (file)
@@ -95,6 +95,9 @@ private:
     void addAdditionalActions(const KFileItemListProperties &props);
 
 private:
+    void addDirectoryItemContextMenu();
+    void addOpenParentFolderActions();
+
     struct Entry {
         int type;
         QString name;
@@ -110,6 +113,7 @@ private:
         TrashContext = 2,
         TimelineContext = 4,
         SearchContext = 8,
+        RecentlyUsedContext = 16,
     };
 
     DolphinMainWindow *m_mainWindow;
@@ -126,7 +130,6 @@ private:
     KFileCopyToMenu m_copyToMenu;
 
     DolphinRemoveAction *m_removeAction; // Action that represents either 'Move To Trash' or 'Delete'
-    void addDirectoryItemContextMenu();
     KFileItemActions *m_fileItemActions;
 };