]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphincontextmenu.cpp
Revert "D-Bus activation systemd service"
[dolphin.git] / src / dolphincontextmenu.cpp
index e80283c58b84b57c9e3b0315938b2bad1b177d8f..d15e668b1cac6f5542233737fbbb0261a8ef713d 100644 (file)
@@ -1,22 +1,8 @@
-  /***************************************************************************
- *   Copyright (C) 2006 by Peter Penz (peter.penz@gmx.at) and              *
- *   Cvetoslav Ludmiloff                                                   *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU General Public License     *
- *   along with this program; if not, write to the                         *
- *   Free Software Foundation, Inc.,                                       *
- *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
- ***************************************************************************/
+/*
+ * SPDX-FileCopyrightText: 2006 Peter Penz (peter.penz@gmx.at) and Cvetoslav Ludmiloff
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
 
 #include "dolphincontextmenu.h"
 
@@ -50,7 +36,6 @@
 #include <QApplication>
 #include <QClipboard>
 #include <QKeyEvent>
-#include <QMenu>
 #include <QMenuBar>
 #include <QMimeDatabase>
 
@@ -178,7 +163,7 @@ void DolphinContextMenu::openTrashItemContextMenu()
     if (exec(m_pos) == restoreAction) {
         QList<QUrl> selectedUrls;
         selectedUrls.reserve(m_selectedItems.count());
-        foreach (const KFileItem &item, m_selectedItems) {
+        for (const KFileItem &item : qAsConst(m_selectedItems)) {
             selectedUrls.append(item.url());
         }
 
@@ -349,11 +334,9 @@ void DolphinContextMenu::openViewportContextMenu()
     newFileMenu->setPopupFiles(QList<QUrl>() << m_baseUrl);
     addMenu(newFileMenu->menu());
 
-    // Don't show "Open With" menu items if the current dir is empty, because there's
-    // generally no app that can do anything interesting with an empty directory
-    if (view->itemsCount() != 0) {
-        addOpenWithActions(fileItemActions);
-    }
+    // Show "open with" menu items even if the dir is empty, because there are legitimate
+    // use cases for this, such as opening an empty dir in Kate or VSCode or something
+    addOpenWithActions(fileItemActions);
 
     QAction* pasteAction = createPasteAction();
     addAction(pasteAction);
@@ -392,9 +375,12 @@ void DolphinContextMenu::insertDefaultItemActions(const KFileItemListProperties&
 {
     const KActionCollection* collection = m_mainWindow->actionCollection();
 
-    // Insert 'Cut', 'Copy' and 'Paste'
+    // Insert 'Cut', 'Copy', 'Copy Location' and 'Paste'
     addAction(collection->action(KStandardAction::name(KStandardAction::Cut)));
     addAction(collection->action(KStandardAction::name(KStandardAction::Copy)));
+    QAction* copyPathAction = collection->action(QString("copy_location"));
+    copyPathAction->setEnabled(m_selectedItems.size() == 1);
+    addAction(copyPathAction);
     addAction(createPasteAction());
     addAction(m_mainWindow->actionCollection()->action(QStringLiteral("duplicate")));