1
0
mirror of https://invent.kde.org/system/dolphin synced 2024-07-04 17:30:55 +00:00

Add open containing folder options for files in recentlyused:/

This commit is contained in:
Méven Car 2023-09-06 14:24:22 +02:00
parent 0e4d428e84
commit 3aa8cf00ee
2 changed files with 25 additions and 15 deletions

View 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 {

View 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;
};