#include "dolphincontextmenu.h"
#include "dolphin_contextmenusettings.h"
+#include "dolphin_generalsettings.h"
#include "dolphinmainwindow.h"
#include "dolphinnewfilemenu.h"
#include "dolphinplacesmodelsingleton.h"
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) {
{
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()
{
// 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<QAction *>(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)
const DolphinView *view = m_mainWindow->activeViewContainer()->view();
const QList<QAction *> versionControlActions = view->versionControlActions(m_selectedItems);
if (!versionControlActions.isEmpty()) {
+ addSeparator();
addActions(versionControlActions);
addSeparator();
}