From 3aa8cf00ee90b0414fa9b17f01eaade4507c4642 Mon Sep 17 00:00:00 2001 From: =?utf8?q?M=C3=A9ven=20Car?= Date: Wed, 6 Sep 2023 14:24:22 +0200 Subject: [PATCH] Add open containing folder options for files in recentlyused:/ --- src/dolphincontextmenu.cpp | 35 +++++++++++++++++++++-------------- src/dolphincontextmenu.h | 5 ++++- 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/src/dolphincontextmenu.cpp b/src/dolphincontextmenu.cpp index 705f8e4a5..2eff1017f 100644 --- a/src/dolphincontextmenu.cpp +++ b/src/dolphincontextmenu.cpp @@ -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 { diff --git a/src/dolphincontextmenu.h b/src/dolphincontextmenu.h index 04b0697d0..f60be558e 100644 --- a/src/dolphincontextmenu.h +++ b/src/dolphincontextmenu.h @@ -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; }; -- 2.47.3