X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/bcde430bd532436db31a16f6efff46b32ab38bc1..f3b4d53720e2b8ab9c20eb9fb9e05fcc2386b5cf:/src/dolphincontextmenu.cpp diff --git a/src/dolphincontextmenu.cpp b/src/dolphincontextmenu.cpp index 34d2102ef..3ce1d1d51 100644 --- a/src/dolphincontextmenu.cpp +++ b/src/dolphincontextmenu.cpp @@ -7,6 +7,7 @@ #include "dolphincontextmenu.h" #include "dolphin_contextmenusettings.h" +#include "dolphin_generalsettings.h" #include "dolphinmainwindow.h" #include "dolphinnewfilemenu.h" #include "dolphinplacesmodelsingleton.h" @@ -357,7 +358,7 @@ void DolphinContextMenu::insertDefaultItemActions(const KFileItemListProperties addSeparator(); // Insert 'Move to Trash' and/or 'Delete' - const bool showDeleteAction = (KSharedConfig::openConfig()->group("KDE").readEntry("ShowDeleteCommand", false) || !properties.isLocal()); + const bool showDeleteAction = (KSharedConfig::openConfig()->group(QStringLiteral("KDE")).readEntry("ShowDeleteCommand", false) || !properties.isLocal()); const bool showMoveToTrashAction = (properties.isLocal() && properties.supportsMoving()); if (showDeleteAction && showMoveToTrashAction) { @@ -380,9 +381,8 @@ bool DolphinContextMenu::placeExists(const QUrl &url) const { const KFilePlacesModel *placesModel = DolphinPlacesModelSingleton::instance().placesModel(); - const auto &matchedPlaces = placesModel->match(placesModel->index(0, 0), KFilePlacesModel::UrlRole, url, 1, Qt::MatchExactly); - - return !matchedPlaces.isEmpty(); + QModelIndex url_index = placesModel->closestItem(url); + return url_index.isValid() && placesModel->url(url_index).matches(url, QUrl::StripTrailingSlash); } QAction *DolphinContextMenu::createPasteAction() @@ -439,6 +439,23 @@ void DolphinContextMenu::addOpenWithActions() { // insert 'Open With...' action or sub menu m_fileItemActions->insertOpenWithActionsTo(nullptr, this, QStringList{qApp->desktopFileName()}); + + // For a single file, hint in "Open with" menu that middle-clicking would open it in the secondary app. + // (Unless middle-clicking would open it as a folder in a new tab (e.g. archives).) + const QUrl &url = DolphinView::openItemAsFolderUrl(m_fileInfo, GeneralSettings::browseThroughArchives()); + if (m_selectedItems.count() == 1 && url.isEmpty()) { + if (QAction *openWithSubMenu = findChild(QStringLiteral("openWith_submenu"))) { + Q_ASSERT(openWithSubMenu->menu()); + Q_ASSERT(!openWithSubMenu->menu()->isEmpty()); + + auto *secondaryApp = openWithSubMenu->menu()->actions().first(); + // Add it like a keyboard shortcut, Qt uses \t as a separator. + if (!secondaryApp->text().contains(QLatin1Char('\t'))) { + secondaryApp->setText(secondaryApp->text() + QLatin1Char('\t') + + i18nc("@action:inmenu Shortcut, middle click to trigger menu item, keep short", "Middle Click")); + } + } + } } void DolphinContextMenu::addAdditionalActions(const KFileItemListProperties &props) @@ -454,6 +471,7 @@ void DolphinContextMenu::addAdditionalActions(const KFileItemListProperties &pro const DolphinView *view = m_mainWindow->activeViewContainer()->view(); const QList versionControlActions = view->versionControlActions(m_selectedItems); if (!versionControlActions.isEmpty()) { + addSeparator(); addActions(versionControlActions); addSeparator(); }