diff options
| author | Nate Graham <[email protected]> | 2019-09-01 15:01:57 -0600 |
|---|---|---|
| committer | Nate Graham <[email protected]> | 2019-09-01 15:04:45 -0600 |
| commit | 7cad80b292ef4ff89db5d6da924e75db4624d711 (patch) | |
| tree | c44436bcbdf964909e8341beac2a45cd02991e2c /src/dolphincontextmenu.cpp | |
| parent | 3a7586907ed834fb3c09d47e047da305a25374a2 (diff) | |
Add "Add to Places" action to file menu
Summary:
It's recommended that actions available in context menus be available in the main menu
as well for discoverability's sake. This patch does so for the "Add to Places" action.
The action is moved over to the main window, and accessed in the context menu via the
actionCollection it lives in.
BUG: 390757
FIXED-IN: 19.08.0
Test Plan:
- Action still works
- Action still appears in context menu when relevant
- Action in the File menu only becomes enabled when only a single directory is selected or nothing is selected
{F7143876}
{F7143877}
{F7143878}
{F7143879}
Reviewers: #dolphin, elvisangelaccio
Reviewed By: #dolphin, elvisangelaccio
Subscribers: elvisangelaccio, kfm-devel
Tags: #dolphin
Differential Revision: https://phabricator.kde.org/D22149
Diffstat (limited to 'src/dolphincontextmenu.cpp')
| -rw-r--r-- | src/dolphincontextmenu.cpp | 36 |
1 files changed, 4 insertions, 32 deletions
diff --git a/src/dolphincontextmenu.cpp b/src/dolphincontextmenu.cpp index 1dfbe054d..7e6a45171 100644 --- a/src/dolphincontextmenu.cpp +++ b/src/dolphincontextmenu.cpp @@ -1,4 +1,4 @@ -/*************************************************************************** + /*************************************************************************** * Copyright (C) 2006 by Peter Penz ([email protected]) and * * Cvetoslav Ludmiloff * * * @@ -192,7 +192,6 @@ void DolphinContextMenu::openItemContextMenu() QAction* openParentAction = nullptr; QAction* openParentInNewWindowAction = nullptr; QAction* openParentInNewTabAction = nullptr; - QAction* addToPlacesAction = nullptr; const KFileItemListProperties& selectedItemsProps = selectedItemsProperties(); KFileItemActions fileItemActions; @@ -210,9 +209,7 @@ void DolphinContextMenu::openItemContextMenu() // insert 'Add to Places' entry if (!placeExists(m_fileInfo.url())) { - addToPlacesAction = addAction(QIcon::fromTheme(QStringLiteral("bookmark-new")), - i18nc("@action:inmenu Add selected folder to places", - "Add to Places")); + addAction(m_mainWindow->actionCollection()->action(QStringLiteral("add_to_places"))); } addSeparator(); @@ -314,14 +311,7 @@ void DolphinContextMenu::openItemContextMenu() QAction* activatedAction = exec(m_pos); if (activatedAction) { - if (activatedAction == addToPlacesAction) { - const QUrl selectedUrl(m_fileInfo.url()); - if (selectedUrl.isValid()) { - PlacesItemModel model; - const QString text = selectedUrl.fileName(); - model.createPlacesItem(text, selectedUrl, KIO::iconNameForUrl(selectedUrl)); - } - } else if (activatedAction == openParentAction) { + if (activatedAction == openParentAction) { m_command = OpenParentFolder; } else if (activatedAction == openParentInNewWindowAction) { m_command = OpenParentFolderInNewWindow; @@ -365,10 +355,8 @@ void DolphinContextMenu::openViewportContextMenu() addAction(m_mainWindow->actionCollection()->action(QStringLiteral("new_tab"))); // Insert 'Add to Places' entry if exactly one item is selected - QAction* addToPlacesAction = nullptr; if (!placeExists(m_mainWindow->activeViewContainer()->url())) { - addToPlacesAction = addAction(QIcon::fromTheme(QStringLiteral("bookmark-new")), - i18nc("@action:inmenu Add current folder to places", "Add to Places")); + addAction(m_mainWindow->actionCollection()->action(QStringLiteral("add_to_places"))); } addSeparator(); @@ -395,22 +383,6 @@ void DolphinContextMenu::openViewportContextMenu() addAction(propertiesAction); addShowMenuBarAction(); - - QAction* action = exec(m_pos); - if (addToPlacesAction && (action == addToPlacesAction)) { - const DolphinViewContainer* container = m_mainWindow->activeViewContainer(); - const QUrl url = container->url(); - if (url.isValid()) { - PlacesItemModel model; - QString icon; - if (container->isSearchModeEnabled()) { - icon = QStringLiteral("folder-saved-search-symbolic"); - } else { - icon = KIO::iconNameForUrl(url); - } - model.createPlacesItem(container->placesText(), url, icon); - } - } } void DolphinContextMenu::insertDefaultItemActions(const KFileItemListProperties& properties) |
