2020-08-25 17:07:38 +00:00
|
|
|
/*
|
|
|
|
* SPDX-FileCopyrightText: 2006 Peter Penz (peter.penz@gmx.at) and Cvetoslav Ludmiloff
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
2006-11-21 06:02:05 +00:00
|
|
|
|
|
|
|
#include "dolphincontextmenu.h"
|
|
|
|
|
2018-03-04 13:38:16 +00:00
|
|
|
#include "dolphin_generalsettings.h"
|
2007-01-21 21:20:37 +00:00
|
|
|
#include "dolphinmainwindow.h"
|
2010-08-27 05:26:27 +00:00
|
|
|
#include "dolphinnewfilemenu.h"
|
2019-06-07 08:37:06 +00:00
|
|
|
#include "dolphinplacesmodelsingleton.h"
|
2013-02-09 20:56:51 +00:00
|
|
|
#include "dolphinremoveaction.h"
|
2018-03-04 13:38:16 +00:00
|
|
|
#include "dolphinviewcontainer.h"
|
|
|
|
#include "panels/places/placesitem.h"
|
|
|
|
#include "panels/places/placesitemmodel.h"
|
Add Trash (empty, isEmpty, emptinessChanged)
Summary: Add `Trash` class to handle all trash operations.
Reviewers: elvisangelaccio, markg, ngraham
Reviewed By: elvisangelaccio, markg, ngraham
Subscribers: ngraham, markg, rkflx, elvisangelaccio, #dolphin
Differential Revision: https://phabricator.kde.org/D11012
2018-03-03 16:44:56 +00:00
|
|
|
#include "trash/dolphintrash.h"
|
2018-03-04 13:38:16 +00:00
|
|
|
#include "views/dolphinview.h"
|
|
|
|
#include "views/viewmodecontroller.h"
|
2007-01-21 21:20:37 +00:00
|
|
|
|
2018-03-04 13:38:16 +00:00
|
|
|
#include <KActionCollection>
|
2011-02-11 18:33:29 +00:00
|
|
|
#include <KFileItemActions>
|
|
|
|
#include <KFileItemListProperties>
|
2014-08-21 20:01:23 +00:00
|
|
|
#include <KIO/EmptyTrashJob>
|
|
|
|
#include <KIO/JobUiDelegate>
|
2014-10-21 18:44:37 +00:00
|
|
|
#include <KIO/Paste>
|
2018-03-04 13:38:16 +00:00
|
|
|
#include <KIO/RestoreJob>
|
2014-08-17 09:07:42 +00:00
|
|
|
#include <KJobWidgets>
|
2018-03-04 13:38:16 +00:00
|
|
|
#include <KLocalizedString>
|
2011-02-10 09:59:35 +00:00
|
|
|
#include <KNewFileMenu>
|
2016-06-08 13:30:52 +00:00
|
|
|
#include <KPluginMetaData>
|
2011-02-11 18:33:29 +00:00
|
|
|
#include <KService>
|
|
|
|
#include <KStandardAction>
|
2011-03-27 17:27:27 +00:00
|
|
|
#include <KToolBar>
|
2006-11-21 06:02:05 +00:00
|
|
|
|
2014-10-21 18:44:37 +00:00
|
|
|
#include <QApplication>
|
|
|
|
#include <QClipboard>
|
2014-11-02 16:03:18 +00:00
|
|
|
#include <QKeyEvent>
|
2018-03-04 13:38:16 +00:00
|
|
|
#include <QMenuBar>
|
2016-08-23 15:58:48 +00:00
|
|
|
#include <QMimeDatabase>
|
2014-10-21 18:44:37 +00:00
|
|
|
|
2007-03-15 22:42:21 +00:00
|
|
|
DolphinContextMenu::DolphinContextMenu(DolphinMainWindow* parent,
|
2011-10-08 19:40:34 +00:00
|
|
|
const QPoint& pos,
|
2007-08-13 21:57:20 +00:00
|
|
|
const KFileItem& fileInfo,
|
2014-10-21 19:18:43 +00:00
|
|
|
const QUrl& baseUrl) :
|
2014-10-10 21:36:36 +00:00
|
|
|
QMenu(parent),
|
2011-10-08 19:40:34 +00:00
|
|
|
m_pos(pos),
|
2007-05-06 17:41:49 +00:00
|
|
|
m_mainWindow(parent),
|
|
|
|
m_fileInfo(fileInfo),
|
|
|
|
m_baseUrl(baseUrl),
|
2017-11-21 09:52:14 +00:00
|
|
|
m_baseFileItem(nullptr),
|
2010-10-25 13:45:34 +00:00
|
|
|
m_selectedItems(),
|
2017-11-03 07:01:02 +00:00
|
|
|
m_selectedItemsProperties(nullptr),
|
2009-01-19 14:33:10 +00:00
|
|
|
m_context(NoContext),
|
2009-02-11 20:45:12 +00:00
|
|
|
m_copyToMenu(parent),
|
2010-09-17 19:47:01 +00:00
|
|
|
m_customActions(),
|
2013-06-24 05:11:16 +00:00
|
|
|
m_command(None),
|
2017-11-21 09:52:14 +00:00
|
|
|
m_removeAction(nullptr)
|
2006-11-21 06:02:05 +00:00
|
|
|
{
|
2007-03-25 06:44:28 +00:00
|
|
|
// The context menu either accesses the URLs of the selected items
|
|
|
|
// or the items itself. To increase the performance both lists are cached.
|
2009-07-23 06:10:01 +00:00
|
|
|
const DolphinView* view = m_mainWindow->activeViewContainer()->view();
|
2007-03-25 06:44:28 +00:00
|
|
|
m_selectedItems = view->selectedItems();
|
2006-11-21 06:02:05 +00:00
|
|
|
}
|
|
|
|
|
2007-03-17 20:42:26 +00:00
|
|
|
DolphinContextMenu::~DolphinContextMenu()
|
2007-06-20 20:44:18 +00:00
|
|
|
{
|
2018-07-18 22:43:25 +00:00
|
|
|
delete m_baseFileItem;
|
|
|
|
m_baseFileItem = nullptr;
|
2010-10-25 13:45:34 +00:00
|
|
|
delete m_selectedItemsProperties;
|
2017-11-03 07:01:02 +00:00
|
|
|
m_selectedItemsProperties = nullptr;
|
2007-06-20 20:44:18 +00:00
|
|
|
}
|
2007-03-17 20:42:26 +00:00
|
|
|
|
2009-02-11 20:45:12 +00:00
|
|
|
void DolphinContextMenu::setCustomActions(const QList<QAction*>& actions)
|
|
|
|
{
|
|
|
|
m_customActions = actions;
|
|
|
|
}
|
|
|
|
|
2010-09-22 20:24:49 +00:00
|
|
|
DolphinContextMenu::Command DolphinContextMenu::open()
|
2006-11-21 06:02:05 +00:00
|
|
|
{
|
2007-03-15 21:24:41 +00:00
|
|
|
// get the context information
|
2019-11-29 16:59:21 +00:00
|
|
|
const auto scheme = m_baseUrl.scheme();
|
|
|
|
if (scheme == QLatin1String("trash")) {
|
2007-03-15 21:24:41 +00:00
|
|
|
m_context |= TrashContext;
|
2019-12-23 10:44:58 +00:00
|
|
|
} else if (scheme.contains(QLatin1String("search"))) {
|
2019-11-29 16:59:21 +00:00
|
|
|
m_context |= SearchContext;
|
2019-12-23 10:44:58 +00:00
|
|
|
} else if (scheme.contains(QLatin1String("timeline"))) {
|
2019-11-29 16:59:21 +00:00
|
|
|
m_context |= TimelineContext;
|
2006-11-21 06:02:05 +00:00
|
|
|
}
|
2007-03-15 21:24:41 +00:00
|
|
|
|
2009-07-23 06:14:57 +00:00
|
|
|
if (!m_fileInfo.isNull() && !m_selectedItems.isEmpty()) {
|
2007-03-15 21:24:41 +00:00
|
|
|
m_context |= ItemContext;
|
|
|
|
// TODO: handle other use cases like devices + desktop files
|
2007-04-09 19:12:54 +00:00
|
|
|
}
|
2007-03-15 21:24:41 +00:00
|
|
|
|
|
|
|
// open the corresponding popup for the context
|
|
|
|
if (m_context & TrashContext) {
|
|
|
|
if (m_context & ItemContext) {
|
|
|
|
openTrashItemContextMenu();
|
2007-04-09 19:12:54 +00:00
|
|
|
} else {
|
2007-03-15 21:24:41 +00:00
|
|
|
openTrashContextMenu();
|
|
|
|
}
|
2007-04-09 19:12:54 +00:00
|
|
|
} else if (m_context & ItemContext) {
|
2006-11-21 06:02:05 +00:00
|
|
|
openItemContextMenu();
|
2007-04-09 19:12:54 +00:00
|
|
|
} else {
|
2007-03-15 21:24:41 +00:00
|
|
|
Q_ASSERT(m_context == NoContext);
|
|
|
|
openViewportContextMenu();
|
|
|
|
}
|
2010-09-22 20:24:49 +00:00
|
|
|
|
|
|
|
return m_command;
|
2006-11-21 06:02:05 +00:00
|
|
|
}
|
|
|
|
|
2013-05-04 18:31:02 +00:00
|
|
|
void DolphinContextMenu::keyPressEvent(QKeyEvent *ev)
|
2010-09-20 19:52:40 +00:00
|
|
|
{
|
2013-06-24 05:11:16 +00:00
|
|
|
if (m_removeAction && ev->key() == Qt::Key_Shift) {
|
2017-08-24 16:33:27 +00:00
|
|
|
m_removeAction->update(DolphinRemoveAction::ShiftState::Pressed);
|
2013-05-04 18:31:02 +00:00
|
|
|
}
|
2014-10-10 21:36:36 +00:00
|
|
|
QMenu::keyPressEvent(ev);
|
2010-09-20 19:52:40 +00:00
|
|
|
}
|
|
|
|
|
2013-05-04 18:31:02 +00:00
|
|
|
void DolphinContextMenu::keyReleaseEvent(QKeyEvent *ev)
|
2010-09-17 22:23:11 +00:00
|
|
|
{
|
2013-06-24 05:11:16 +00:00
|
|
|
if (m_removeAction && ev->key() == Qt::Key_Shift) {
|
2017-08-24 16:33:27 +00:00
|
|
|
m_removeAction->update(DolphinRemoveAction::ShiftState::Released);
|
2013-05-04 18:31:02 +00:00
|
|
|
}
|
2014-10-10 21:36:36 +00:00
|
|
|
QMenu::keyReleaseEvent(ev);
|
2010-09-17 22:23:11 +00:00
|
|
|
}
|
|
|
|
|
2007-03-15 21:24:41 +00:00
|
|
|
void DolphinContextMenu::openTrashContextMenu()
|
|
|
|
{
|
|
|
|
Q_ASSERT(m_context & TrashContext);
|
|
|
|
|
2016-03-16 21:17:37 +00:00
|
|
|
QAction* emptyTrashAction = new QAction(QIcon::fromTheme(QStringLiteral("trash-empty")), i18nc("@action:inmenu", "Empty Trash"), this);
|
Add Trash (empty, isEmpty, emptinessChanged)
Summary: Add `Trash` class to handle all trash operations.
Reviewers: elvisangelaccio, markg, ngraham
Reviewed By: elvisangelaccio, markg, ngraham
Subscribers: ngraham, markg, rkflx, elvisangelaccio, #dolphin
Differential Revision: https://phabricator.kde.org/D11012
2018-03-03 16:44:56 +00:00
|
|
|
emptyTrashAction->setEnabled(!Trash::isEmpty());
|
2013-05-04 18:31:02 +00:00
|
|
|
addAction(emptyTrashAction);
|
2007-03-15 21:24:41 +00:00
|
|
|
|
2010-09-17 19:47:01 +00:00
|
|
|
addCustomActions();
|
2009-02-11 20:45:12 +00:00
|
|
|
|
2016-03-16 21:17:37 +00:00
|
|
|
QAction* propertiesAction = m_mainWindow->actionCollection()->action(QStringLiteral("properties"));
|
2013-05-04 18:31:02 +00:00
|
|
|
addAction(propertiesAction);
|
2007-03-15 21:24:41 +00:00
|
|
|
|
2011-03-27 17:27:27 +00:00
|
|
|
addShowMenuBarAction();
|
|
|
|
|
2013-05-04 18:31:02 +00:00
|
|
|
if (exec(m_pos) == emptyTrashAction) {
|
Add Trash (empty, isEmpty, emptinessChanged)
Summary: Add `Trash` class to handle all trash operations.
Reviewers: elvisangelaccio, markg, ngraham
Reviewed By: elvisangelaccio, markg, ngraham
Subscribers: ngraham, markg, rkflx, elvisangelaccio, #dolphin
Differential Revision: https://phabricator.kde.org/D11012
2018-03-03 16:44:56 +00:00
|
|
|
Trash::empty(m_mainWindow);
|
2007-03-15 21:24:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinContextMenu::openTrashItemContextMenu()
|
|
|
|
{
|
|
|
|
Q_ASSERT(m_context & TrashContext);
|
|
|
|
Q_ASSERT(m_context & ItemContext);
|
|
|
|
|
2018-12-10 18:19:55 +00:00
|
|
|
QAction* restoreAction = new QAction(QIcon::fromTheme("restoration"), i18nc("@action:inmenu", "Restore"), m_mainWindow);
|
2013-05-04 18:31:02 +00:00
|
|
|
addAction(restoreAction);
|
2007-03-15 21:24:41 +00:00
|
|
|
|
2017-03-10 18:31:33 +00:00
|
|
|
QAction* deleteAction = m_mainWindow->actionCollection()->action(KStandardAction::name(KStandardAction::DeleteFile));
|
2013-05-04 18:31:02 +00:00
|
|
|
addAction(deleteAction);
|
2007-03-15 21:24:41 +00:00
|
|
|
|
2016-03-16 21:17:37 +00:00
|
|
|
QAction* propertiesAction = m_mainWindow->actionCollection()->action(QStringLiteral("properties"));
|
2013-05-04 18:31:02 +00:00
|
|
|
addAction(propertiesAction);
|
2007-03-15 21:24:41 +00:00
|
|
|
|
2013-05-04 18:31:02 +00:00
|
|
|
if (exec(m_pos) == restoreAction) {
|
2014-10-21 19:18:43 +00:00
|
|
|
QList<QUrl> selectedUrls;
|
2016-03-16 21:17:37 +00:00
|
|
|
selectedUrls.reserve(m_selectedItems.count());
|
2010-10-25 13:45:34 +00:00
|
|
|
foreach (const KFileItem &item, m_selectedItems) {
|
|
|
|
selectedUrls.append(item.url());
|
|
|
|
}
|
|
|
|
|
2014-08-17 09:07:42 +00:00
|
|
|
KIO::RestoreJob *job = KIO::restoreFromTrash(selectedUrls);
|
|
|
|
KJobWidgets::setWindow(job, m_mainWindow);
|
|
|
|
job->uiDelegate()->setAutoErrorHandlingEnabled(true);
|
2007-03-15 21:24:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-29 16:59:21 +00:00
|
|
|
void DolphinContextMenu::addDirectoryItemContextMenu(KFileItemActions &fileItemActions)
|
|
|
|
{
|
|
|
|
// insert 'Open in new window' and 'Open in new tab' entries
|
|
|
|
|
|
|
|
const KFileItemListProperties& selectedItemsProps = selectedItemsProperties();
|
|
|
|
|
|
|
|
addAction(m_mainWindow->actionCollection()->action(QStringLiteral("open_in_new_tab")));
|
Swap "Open in New Window" and "Open in New Tab" in context menus
Summary:
Since Dolphin's default behaviour became opening in new tabs rather than in new windows
(a very positive change, in my opinion), I always find myself accidentally opening folders
in new windows from the context menu. This is because in most browsers with tab workflow
(e.g. Firefox, Chromium, Falkon) the top context menu action is opening in a new tab, and
my muscle memory plays a bad trick :) I'm aware of middle-clicking, but I find it
inconvenient with my touchpad.
I suspect I'm probably not alone in that, so I think it makes sense to swap these actions
in Dolphin to match widely used apps.
Test Plan:
Open Dolphin, right click folders in the main view and in the Places panel, ensure the
actions are indeed swapped
Reviewers: #vdg, ndavis, #dolphin, ngraham
Reviewed By: #vdg, ndavis, #dolphin, ngraham
Subscribers: ngraham, ndavis, kfm-devel
Tags: #dolphin
Differential Revision: https://phabricator.kde.org/D27318
2020-02-11 11:36:19 +00:00
|
|
|
addAction(m_mainWindow->actionCollection()->action(QStringLiteral("open_in_new_window")));
|
2019-11-29 16:59:21 +00:00
|
|
|
|
|
|
|
// Insert 'Open With' entries
|
|
|
|
addOpenWithActions(fileItemActions);
|
|
|
|
|
|
|
|
// set up 'Create New' menu
|
|
|
|
DolphinNewFileMenu* newFileMenu = new DolphinNewFileMenu(m_mainWindow->actionCollection(), m_mainWindow);
|
|
|
|
const DolphinView* view = m_mainWindow->activeViewContainer()->view();
|
|
|
|
newFileMenu->setViewShowsHiddenFiles(view->hiddenFilesShown());
|
|
|
|
newFileMenu->checkUpToDate();
|
2019-12-06 12:31:43 +00:00
|
|
|
newFileMenu->setPopupFiles(QList<QUrl>() << m_fileInfo.url());
|
2019-11-29 16:59:21 +00:00
|
|
|
newFileMenu->setEnabled(selectedItemsProps.supportsWriting());
|
|
|
|
connect(newFileMenu, &DolphinNewFileMenu::fileCreated, newFileMenu, &DolphinNewFileMenu::deleteLater);
|
|
|
|
connect(newFileMenu, &DolphinNewFileMenu::directoryCreated, newFileMenu, &DolphinNewFileMenu::deleteLater);
|
|
|
|
|
|
|
|
QMenu* menu = newFileMenu->menu();
|
|
|
|
menu->setTitle(i18nc("@title:menu Create new folder, file, link, etc.", "Create New"));
|
|
|
|
menu->setIcon(QIcon::fromTheme(QStringLiteral("document-new")));
|
|
|
|
addMenu(menu);
|
|
|
|
|
|
|
|
addSeparator();
|
|
|
|
}
|
|
|
|
|
2007-03-15 21:24:41 +00:00
|
|
|
void DolphinContextMenu::openItemContextMenu()
|
|
|
|
{
|
2007-08-13 21:57:20 +00:00
|
|
|
Q_ASSERT(!m_fileInfo.isNull());
|
2007-03-15 21:24:41 +00:00
|
|
|
|
2017-11-03 07:01:02 +00:00
|
|
|
QAction* openParentAction = nullptr;
|
|
|
|
QAction* openParentInNewWindowAction = nullptr;
|
|
|
|
QAction* openParentInNewTabAction = nullptr;
|
2013-06-24 05:11:16 +00:00
|
|
|
const KFileItemListProperties& selectedItemsProps = selectedItemsProperties();
|
|
|
|
|
Move "Open" actions to the top of the context menu for files
Summary:
This patch moves the "Open", "Open With", and "Open in" items to the top of the context menu to reap the following benefits:
- Move the "Open" and "Open With" items closer to the top since they're commonly used items, and right now they're buried in the middle of the menu
- Group related functionality
- Consistency with other common platforms (macOS Finder and Windows Explorer both have these items at the top of the context menu)
For folders, the "Open With" entries are moved higher, but not all the way to the top, since the "open in New tab/folder" entries are more useful.
Test Plan:
Tested all menu items in the context menu for files, folders, and links; all still work.
Context menu for single file:
{F5806809}
Context menu for multiple files:
{F5806810}
Context menu for single folder:
{F5806811}
Context menu for multiple folders:
{F5806812}
Context menu for symlink to folder:
{F5806815}
Reviewers: #dolphin, #vdg, elvisangelaccio, abetts
Reviewed By: #dolphin, #vdg, elvisangelaccio, abetts
Subscribers: markg, abetts, elvisangelaccio
Differential Revision: https://phabricator.kde.org/D11884
2018-04-02 14:05:47 +00:00
|
|
|
KFileItemActions fileItemActions;
|
|
|
|
fileItemActions.setParentWidget(m_mainWindow);
|
|
|
|
fileItemActions.setItemListProperties(selectedItemsProps);
|
|
|
|
|
2010-10-25 13:45:34 +00:00
|
|
|
if (m_selectedItems.count() == 1) {
|
2019-11-29 16:59:21 +00:00
|
|
|
// single files
|
2018-03-21 23:00:17 +00:00
|
|
|
if (m_fileInfo.isDir()) {
|
2019-11-29 16:59:21 +00:00
|
|
|
addDirectoryItemContextMenu(fileItemActions);
|
|
|
|
} else if (m_context & TimelineContext || m_context & SearchContext) {
|
2018-05-14 22:51:11 +00:00
|
|
|
addOpenWithActions(fileItemActions);
|
|
|
|
|
2016-03-16 21:17:37 +00:00
|
|
|
openParentAction = new QAction(QIcon::fromTheme(QStringLiteral("document-open-folder")),
|
2014-09-09 13:31:55 +00:00
|
|
|
i18nc("@action:inmenu",
|
|
|
|
"Open Path"),
|
|
|
|
this);
|
|
|
|
addAction(openParentAction);
|
|
|
|
|
2016-03-16 21:17:37 +00:00
|
|
|
openParentInNewWindowAction = new QAction(QIcon::fromTheme(QStringLiteral("window-new")),
|
2010-09-22 20:24:49 +00:00
|
|
|
i18nc("@action:inmenu",
|
2010-10-05 14:40:42 +00:00
|
|
|
"Open Path in New Window"),
|
2010-09-22 20:24:49 +00:00
|
|
|
this);
|
2013-05-04 18:31:02 +00:00
|
|
|
addAction(openParentInNewWindowAction);
|
2010-09-22 20:24:49 +00:00
|
|
|
|
2016-03-16 21:17:37 +00:00
|
|
|
openParentInNewTabAction = new QAction(QIcon::fromTheme(QStringLiteral("tab-new")),
|
2010-09-22 20:24:49 +00:00
|
|
|
i18nc("@action:inmenu",
|
2010-10-05 14:40:42 +00:00
|
|
|
"Open Path in New Tab"),
|
2010-09-22 20:24:49 +00:00
|
|
|
this);
|
2013-05-04 18:31:02 +00:00
|
|
|
addAction(openParentInNewTabAction);
|
2010-09-22 20:24:49 +00:00
|
|
|
|
Move "Open" actions to the top of the context menu for files
Summary:
This patch moves the "Open", "Open With", and "Open in" items to the top of the context menu to reap the following benefits:
- Move the "Open" and "Open With" items closer to the top since they're commonly used items, and right now they're buried in the middle of the menu
- Group related functionality
- Consistency with other common platforms (macOS Finder and Windows Explorer both have these items at the top of the context menu)
For folders, the "Open With" entries are moved higher, but not all the way to the top, since the "open in New tab/folder" entries are more useful.
Test Plan:
Tested all menu items in the context menu for files, folders, and links; all still work.
Context menu for single file:
{F5806809}
Context menu for multiple files:
{F5806810}
Context menu for single folder:
{F5806811}
Context menu for multiple folders:
{F5806812}
Context menu for symlink to folder:
{F5806815}
Reviewers: #dolphin, #vdg, elvisangelaccio, abetts
Reviewed By: #dolphin, #vdg, elvisangelaccio, abetts
Subscribers: markg, abetts, elvisangelaccio
Differential Revision: https://phabricator.kde.org/D11884
2018-04-02 14:05:47 +00:00
|
|
|
addSeparator();
|
|
|
|
} else {
|
|
|
|
// Insert 'Open With" entries
|
|
|
|
addOpenWithActions(fileItemActions);
|
|
|
|
}
|
|
|
|
if (m_fileInfo.isLink()) {
|
|
|
|
addAction(m_mainWindow->actionCollection()->action(QStringLiteral("show_target")));
|
2013-05-22 19:47:14 +00:00
|
|
|
addSeparator();
|
|
|
|
}
|
|
|
|
} else {
|
2019-11-29 16:59:21 +00:00
|
|
|
// multiple files
|
2013-05-22 19:47:14 +00:00
|
|
|
bool selectionHasOnlyDirs = true;
|
2019-11-29 16:59:21 +00:00
|
|
|
for (const auto &item : qAsConst(m_selectedItems)) {
|
2014-10-21 19:18:43 +00:00
|
|
|
const QUrl& url = DolphinView::openItemAsFolderUrl(item);
|
2013-05-28 15:31:14 +00:00
|
|
|
if (url.isEmpty()) {
|
2013-05-22 19:47:14 +00:00
|
|
|
selectionHasOnlyDirs = false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (selectionHasOnlyDirs) {
|
|
|
|
// insert 'Open in new tab' entry
|
2016-03-16 21:17:37 +00:00
|
|
|
addAction(m_mainWindow->actionCollection()->action(QStringLiteral("open_in_new_tabs")));
|
2010-09-21 19:56:35 +00:00
|
|
|
}
|
Move "Open" actions to the top of the context menu for files
Summary:
This patch moves the "Open", "Open With", and "Open in" items to the top of the context menu to reap the following benefits:
- Move the "Open" and "Open With" items closer to the top since they're commonly used items, and right now they're buried in the middle of the menu
- Group related functionality
- Consistency with other common platforms (macOS Finder and Windows Explorer both have these items at the top of the context menu)
For folders, the "Open With" entries are moved higher, but not all the way to the top, since the "open in New tab/folder" entries are more useful.
Test Plan:
Tested all menu items in the context menu for files, folders, and links; all still work.
Context menu for single file:
{F5806809}
Context menu for multiple files:
{F5806810}
Context menu for single folder:
{F5806811}
Context menu for multiple folders:
{F5806812}
Context menu for symlink to folder:
{F5806815}
Reviewers: #dolphin, #vdg, elvisangelaccio, abetts
Reviewed By: #dolphin, #vdg, elvisangelaccio, abetts
Subscribers: markg, abetts, elvisangelaccio
Differential Revision: https://phabricator.kde.org/D11884
2018-04-02 14:05:47 +00:00
|
|
|
// Insert 'Open With" entries
|
|
|
|
addOpenWithActions(fileItemActions);
|
2008-10-25 10:32:55 +00:00
|
|
|
}
|
2010-09-22 20:24:49 +00:00
|
|
|
|
2013-06-24 05:11:16 +00:00
|
|
|
insertDefaultItemActions(selectedItemsProps);
|
2007-03-16 00:24:56 +00:00
|
|
|
|
Clean up hamburger menu and viewport and single-folder context menus
Summary:
Dolphin's hamburger and context menus have grown organically over time,
becoming a bit messy and somewhat visually overwhelming. This makes them
harder to parse and more intimidating to use.
This patch cleans up the hamburger menu and viewport and single-folder context
menus to group items more logically, and remove items that aren't actually relevant
to the context.
The hamburger menu part of the patch is fairly significant, and draws from the
principle of only showing actions with a global scope that are not already accessible
from another visible method (e.g. via the default toolbar). In the end, it manages to be
shorter than the current hamburger menu with expose actions that are more relevant.
A visible method to display context-specific actions should be explored separately
(see https://bugs.kde.org/show_bug.cgi?id=411500).
Depends on D23945
Test Plan:
Before, hamburger menu: {F7334178}
After, hamburger menu: {F7350958}
Before, viewport: {F7324802}
After, viewport: {F7330109}
Before, one folder selected: {F7324798}
After, one folder selected: {F7341163}
No change for the context menus shown when selecting a single item, multiple items, or multiple folders
Reviewers: #vdg, #dolphin, meven, elvisangelaccio, GB_2
Reviewed By: #vdg, #dolphin, meven, elvisangelaccio, GB_2
Subscribers: GB_2, mmustac, elvisangelaccio, meven, ndavis, kfm-devel
Tags: #dolphin
Differential Revision: https://phabricator.kde.org/D23757
2019-09-06 16:08:58 +00:00
|
|
|
// insert 'Add to Places' entry if appropriate
|
|
|
|
if (m_selectedItems.count() == 1) {
|
|
|
|
if (m_fileInfo.isDir()) {
|
|
|
|
if (!placeExists(m_fileInfo.url())) {
|
|
|
|
addAction(m_mainWindow->actionCollection()->action(QStringLiteral("add_to_places")));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-04 18:31:02 +00:00
|
|
|
addSeparator();
|
2007-03-15 21:24:41 +00:00
|
|
|
|
Move "Open" actions to the top of the context menu for files
Summary:
This patch moves the "Open", "Open With", and "Open in" items to the top of the context menu to reap the following benefits:
- Move the "Open" and "Open With" items closer to the top since they're commonly used items, and right now they're buried in the middle of the menu
- Group related functionality
- Consistency with other common platforms (macOS Finder and Windows Explorer both have these items at the top of the context menu)
For folders, the "Open With" entries are moved higher, but not all the way to the top, since the "open in New tab/folder" entries are more useful.
Test Plan:
Tested all menu items in the context menu for files, folders, and links; all still work.
Context menu for single file:
{F5806809}
Context menu for multiple files:
{F5806810}
Context menu for single folder:
{F5806811}
Context menu for multiple folders:
{F5806812}
Context menu for symlink to folder:
{F5806815}
Reviewers: #dolphin, #vdg, elvisangelaccio, abetts
Reviewed By: #dolphin, #vdg, elvisangelaccio, abetts
Subscribers: markg, abetts, elvisangelaccio
Differential Revision: https://phabricator.kde.org/D11884
2018-04-02 14:05:47 +00:00
|
|
|
fileItemActions.addServiceActionsTo(this);
|
2017-06-06 17:16:34 +00:00
|
|
|
fileItemActions.addPluginActionsTo(this);
|
2010-10-25 13:45:34 +00:00
|
|
|
|
|
|
|
addVersionControlPluginActions();
|
2009-07-22 19:26:25 +00:00
|
|
|
|
2009-02-11 20:45:12 +00:00
|
|
|
// insert 'Copy To' and 'Move To' sub menus
|
2011-11-06 10:58:48 +00:00
|
|
|
if (GeneralSettings::showCopyMoveMenu()) {
|
2015-02-04 07:56:17 +00:00
|
|
|
m_copyToMenu.setUrls(m_selectedItems.urlList());
|
2013-06-24 05:11:16 +00:00
|
|
|
m_copyToMenu.setReadOnly(!selectedItemsProps.supportsWriting());
|
2015-02-04 07:56:17 +00:00
|
|
|
m_copyToMenu.setAutoErrorHandlingEnabled(true);
|
2013-05-04 18:31:02 +00:00
|
|
|
m_copyToMenu.addActionsTo(this);
|
2010-08-27 05:26:27 +00:00
|
|
|
}
|
|
|
|
|
2007-03-17 20:42:26 +00:00
|
|
|
// insert 'Properties...' entry
|
2018-12-06 21:10:58 +00:00
|
|
|
addSeparator();
|
2016-03-16 21:17:37 +00:00
|
|
|
QAction* propertiesAction = m_mainWindow->actionCollection()->action(QStringLiteral("properties"));
|
2013-05-04 18:31:02 +00:00
|
|
|
addAction(propertiesAction);
|
2007-03-15 21:24:41 +00:00
|
|
|
|
2013-05-04 18:31:02 +00:00
|
|
|
QAction* activatedAction = exec(m_pos);
|
2011-02-09 18:21:58 +00:00
|
|
|
if (activatedAction) {
|
2019-09-01 21:01:57 +00:00
|
|
|
if (activatedAction == openParentAction) {
|
2014-09-09 13:31:55 +00:00
|
|
|
m_command = OpenParentFolder;
|
2010-09-22 20:24:49 +00:00
|
|
|
} else if (activatedAction == openParentInNewWindowAction) {
|
|
|
|
m_command = OpenParentFolderInNewWindow;
|
|
|
|
} else if (activatedAction == openParentInNewTabAction) {
|
|
|
|
m_command = OpenParentFolderInNewTab;
|
2007-03-15 21:24:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-11-21 06:02:05 +00:00
|
|
|
void DolphinContextMenu::openViewportContextMenu()
|
|
|
|
{
|
2009-11-18 22:27:31 +00:00
|
|
|
const DolphinView* view = m_mainWindow->activeViewContainer()->view();
|
2010-08-27 05:26:27 +00:00
|
|
|
|
Move "Open" actions to the top of the context menu for files
Summary:
This patch moves the "Open", "Open With", and "Open in" items to the top of the context menu to reap the following benefits:
- Move the "Open" and "Open With" items closer to the top since they're commonly used items, and right now they're buried in the middle of the menu
- Group related functionality
- Consistency with other common platforms (macOS Finder and Windows Explorer both have these items at the top of the context menu)
For folders, the "Open With" entries are moved higher, but not all the way to the top, since the "open in New tab/folder" entries are more useful.
Test Plan:
Tested all menu items in the context menu for files, folders, and links; all still work.
Context menu for single file:
{F5806809}
Context menu for multiple files:
{F5806810}
Context menu for single folder:
{F5806811}
Context menu for multiple folders:
{F5806812}
Context menu for symlink to folder:
{F5806815}
Reviewers: #dolphin, #vdg, elvisangelaccio, abetts
Reviewed By: #dolphin, #vdg, elvisangelaccio, abetts
Subscribers: markg, abetts, elvisangelaccio
Differential Revision: https://phabricator.kde.org/D11884
2018-04-02 14:05:47 +00:00
|
|
|
// Insert 'Open With' entries
|
2018-09-05 10:25:39 +00:00
|
|
|
KFileItem baseItem = view->rootItem();
|
|
|
|
if (baseItem.isNull() || baseItem.url() != m_baseUrl) {
|
|
|
|
baseItem = baseFileItem();
|
|
|
|
}
|
|
|
|
|
|
|
|
const KFileItemListProperties baseUrlProperties(KFileItemList() << baseItem);
|
Move "Open" actions to the top of the context menu for files
Summary:
This patch moves the "Open", "Open With", and "Open in" items to the top of the context menu to reap the following benefits:
- Move the "Open" and "Open With" items closer to the top since they're commonly used items, and right now they're buried in the middle of the menu
- Group related functionality
- Consistency with other common platforms (macOS Finder and Windows Explorer both have these items at the top of the context menu)
For folders, the "Open With" entries are moved higher, but not all the way to the top, since the "open in New tab/folder" entries are more useful.
Test Plan:
Tested all menu items in the context menu for files, folders, and links; all still work.
Context menu for single file:
{F5806809}
Context menu for multiple files:
{F5806810}
Context menu for single folder:
{F5806811}
Context menu for multiple folders:
{F5806812}
Context menu for symlink to folder:
{F5806815}
Reviewers: #dolphin, #vdg, elvisangelaccio, abetts
Reviewed By: #dolphin, #vdg, elvisangelaccio, abetts
Subscribers: markg, abetts, elvisangelaccio
Differential Revision: https://phabricator.kde.org/D11884
2018-04-02 14:05:47 +00:00
|
|
|
KFileItemActions fileItemActions;
|
|
|
|
fileItemActions.setParentWidget(m_mainWindow);
|
|
|
|
fileItemActions.setItemListProperties(baseUrlProperties);
|
2019-04-08 22:03:48 +00:00
|
|
|
|
Clean up hamburger menu and viewport and single-folder context menus
Summary:
Dolphin's hamburger and context menus have grown organically over time,
becoming a bit messy and somewhat visually overwhelming. This makes them
harder to parse and more intimidating to use.
This patch cleans up the hamburger menu and viewport and single-folder context
menus to group items more logically, and remove items that aren't actually relevant
to the context.
The hamburger menu part of the patch is fairly significant, and draws from the
principle of only showing actions with a global scope that are not already accessible
from another visible method (e.g. via the default toolbar). In the end, it manages to be
shorter than the current hamburger menu with expose actions that are more relevant.
A visible method to display context-specific actions should be explored separately
(see https://bugs.kde.org/show_bug.cgi?id=411500).
Depends on D23945
Test Plan:
Before, hamburger menu: {F7334178}
After, hamburger menu: {F7350958}
Before, viewport: {F7324802}
After, viewport: {F7330109}
Before, one folder selected: {F7324798}
After, one folder selected: {F7341163}
No change for the context menus shown when selecting a single item, multiple items, or multiple folders
Reviewers: #vdg, #dolphin, meven, elvisangelaccio, GB_2
Reviewed By: #vdg, #dolphin, meven, elvisangelaccio, GB_2
Subscribers: GB_2, mmustac, elvisangelaccio, meven, ndavis, kfm-devel
Tags: #dolphin
Differential Revision: https://phabricator.kde.org/D23757
2019-09-06 16:08:58 +00:00
|
|
|
// Set up and insert 'Create New' menu
|
|
|
|
KNewFileMenu* newFileMenu = m_mainWindow->newFileMenu();
|
|
|
|
newFileMenu->setViewShowsHiddenFiles(view->hiddenFilesShown());
|
|
|
|
newFileMenu->checkUpToDate();
|
2019-12-06 12:31:43 +00:00
|
|
|
newFileMenu->setPopupFiles(QList<QUrl>() << m_baseUrl);
|
Clean up hamburger menu and viewport and single-folder context menus
Summary:
Dolphin's hamburger and context menus have grown organically over time,
becoming a bit messy and somewhat visually overwhelming. This makes them
harder to parse and more intimidating to use.
This patch cleans up the hamburger menu and viewport and single-folder context
menus to group items more logically, and remove items that aren't actually relevant
to the context.
The hamburger menu part of the patch is fairly significant, and draws from the
principle of only showing actions with a global scope that are not already accessible
from another visible method (e.g. via the default toolbar). In the end, it manages to be
shorter than the current hamburger menu with expose actions that are more relevant.
A visible method to display context-specific actions should be explored separately
(see https://bugs.kde.org/show_bug.cgi?id=411500).
Depends on D23945
Test Plan:
Before, hamburger menu: {F7334178}
After, hamburger menu: {F7350958}
Before, viewport: {F7324802}
After, viewport: {F7330109}
Before, one folder selected: {F7324798}
After, one folder selected: {F7341163}
No change for the context menus shown when selecting a single item, multiple items, or multiple folders
Reviewers: #vdg, #dolphin, meven, elvisangelaccio, GB_2
Reviewed By: #vdg, #dolphin, meven, elvisangelaccio, GB_2
Subscribers: GB_2, mmustac, elvisangelaccio, meven, ndavis, kfm-devel
Tags: #dolphin
Differential Revision: https://phabricator.kde.org/D23757
2019-09-06 16:08:58 +00:00
|
|
|
addMenu(newFileMenu->menu());
|
|
|
|
|
2020-10-13 00:16:53 +00:00
|
|
|
// 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);
|
2020-02-09 15:58:10 +00:00
|
|
|
|
Clean up hamburger menu and viewport and single-folder context menus
Summary:
Dolphin's hamburger and context menus have grown organically over time,
becoming a bit messy and somewhat visually overwhelming. This makes them
harder to parse and more intimidating to use.
This patch cleans up the hamburger menu and viewport and single-folder context
menus to group items more logically, and remove items that aren't actually relevant
to the context.
The hamburger menu part of the patch is fairly significant, and draws from the
principle of only showing actions with a global scope that are not already accessible
from another visible method (e.g. via the default toolbar). In the end, it manages to be
shorter than the current hamburger menu with expose actions that are more relevant.
A visible method to display context-specific actions should be explored separately
(see https://bugs.kde.org/show_bug.cgi?id=411500).
Depends on D23945
Test Plan:
Before, hamburger menu: {F7334178}
After, hamburger menu: {F7350958}
Before, viewport: {F7324802}
After, viewport: {F7330109}
Before, one folder selected: {F7324798}
After, one folder selected: {F7341163}
No change for the context menus shown when selecting a single item, multiple items, or multiple folders
Reviewers: #vdg, #dolphin, meven, elvisangelaccio, GB_2
Reviewed By: #vdg, #dolphin, meven, elvisangelaccio, GB_2
Subscribers: GB_2, mmustac, elvisangelaccio, meven, ndavis, kfm-devel
Tags: #dolphin
Differential Revision: https://phabricator.kde.org/D23757
2019-09-06 16:08:58 +00:00
|
|
|
QAction* pasteAction = createPasteAction();
|
|
|
|
addAction(pasteAction);
|
2010-10-09 15:39:41 +00:00
|
|
|
|
Clean up hamburger menu and viewport and single-folder context menus
Summary:
Dolphin's hamburger and context menus have grown organically over time,
becoming a bit messy and somewhat visually overwhelming. This makes them
harder to parse and more intimidating to use.
This patch cleans up the hamburger menu and viewport and single-folder context
menus to group items more logically, and remove items that aren't actually relevant
to the context.
The hamburger menu part of the patch is fairly significant, and draws from the
principle of only showing actions with a global scope that are not already accessible
from another visible method (e.g. via the default toolbar). In the end, it manages to be
shorter than the current hamburger menu with expose actions that are more relevant.
A visible method to display context-specific actions should be explored separately
(see https://bugs.kde.org/show_bug.cgi?id=411500).
Depends on D23945
Test Plan:
Before, hamburger menu: {F7334178}
After, hamburger menu: {F7350958}
Before, viewport: {F7324802}
After, viewport: {F7330109}
Before, one folder selected: {F7324798}
After, one folder selected: {F7341163}
No change for the context menus shown when selecting a single item, multiple items, or multiple folders
Reviewers: #vdg, #dolphin, meven, elvisangelaccio, GB_2
Reviewed By: #vdg, #dolphin, meven, elvisangelaccio, GB_2
Subscribers: GB_2, mmustac, elvisangelaccio, meven, ndavis, kfm-devel
Tags: #dolphin
Differential Revision: https://phabricator.kde.org/D23757
2019-09-06 16:08:58 +00:00
|
|
|
// Insert 'Add to Places' entry if it's not already in the places panel
|
2010-10-09 15:39:41 +00:00
|
|
|
if (!placeExists(m_mainWindow->activeViewContainer()->url())) {
|
2019-09-01 21:01:57 +00:00
|
|
|
addAction(m_mainWindow->actionCollection()->action(QStringLiteral("add_to_places")));
|
2010-10-09 15:39:41 +00:00
|
|
|
}
|
2013-05-04 18:31:02 +00:00
|
|
|
addSeparator();
|
2006-11-21 06:02:05 +00:00
|
|
|
|
Add 'Sort By' and 'View Mode' into Dolphin file context menus
Summary: This adds the 'Sort By' and 'View Mode' options into the context menu of Dolphin within the file browser. I keep looking for these option (especially sort by) in the Context Menu, and keep forgetting to go to the menu. It also makes the order of "View Mode" and "Sort By" options consistent in the control menu
Test Plan: Made sure that the options appeared when right clicking on an empty space.
Reviewers: #dolphin, ngraham, elvisangelaccio
Reviewed By: #dolphin, ngraham, elvisangelaccio
Subscribers: question, markg, elvisangelaccio, mmustac, rkflx, ngraham, kfm-devel, #dolphin
Tags: #dolphin
Differential Revision: https://phabricator.kde.org/D12911
2018-06-02 14:38:01 +00:00
|
|
|
// Insert 'Sort By' and 'View Mode'
|
|
|
|
addAction(m_mainWindow->actionCollection()->action(QStringLiteral("sort")));
|
|
|
|
addAction(m_mainWindow->actionCollection()->action(QStringLiteral("view_mode")));
|
|
|
|
|
|
|
|
addSeparator();
|
|
|
|
|
2010-10-25 13:45:34 +00:00
|
|
|
// Insert service actions
|
Move "Open" actions to the top of the context menu for files
Summary:
This patch moves the "Open", "Open With", and "Open in" items to the top of the context menu to reap the following benefits:
- Move the "Open" and "Open With" items closer to the top since they're commonly used items, and right now they're buried in the middle of the menu
- Group related functionality
- Consistency with other common platforms (macOS Finder and Windows Explorer both have these items at the top of the context menu)
For folders, the "Open With" entries are moved higher, but not all the way to the top, since the "open in New tab/folder" entries are more useful.
Test Plan:
Tested all menu items in the context menu for files, folders, and links; all still work.
Context menu for single file:
{F5806809}
Context menu for multiple files:
{F5806810}
Context menu for single folder:
{F5806811}
Context menu for multiple folders:
{F5806812}
Context menu for symlink to folder:
{F5806815}
Reviewers: #dolphin, #vdg, elvisangelaccio, abetts
Reviewed By: #dolphin, #vdg, elvisangelaccio, abetts
Subscribers: markg, abetts, elvisangelaccio
Differential Revision: https://phabricator.kde.org/D11884
2018-04-02 14:05:47 +00:00
|
|
|
fileItemActions.addServiceActionsTo(this);
|
2017-06-06 17:16:34 +00:00
|
|
|
fileItemActions.addPluginActionsTo(this);
|
2010-10-25 13:45:34 +00:00
|
|
|
|
|
|
|
addVersionControlPluginActions();
|
2009-02-11 20:45:12 +00:00
|
|
|
|
2010-09-17 19:47:01 +00:00
|
|
|
addCustomActions();
|
2006-11-21 06:02:05 +00:00
|
|
|
|
Clean up hamburger menu and viewport and single-folder context menus
Summary:
Dolphin's hamburger and context menus have grown organically over time,
becoming a bit messy and somewhat visually overwhelming. This makes them
harder to parse and more intimidating to use.
This patch cleans up the hamburger menu and viewport and single-folder context
menus to group items more logically, and remove items that aren't actually relevant
to the context.
The hamburger menu part of the patch is fairly significant, and draws from the
principle of only showing actions with a global scope that are not already accessible
from another visible method (e.g. via the default toolbar). In the end, it manages to be
shorter than the current hamburger menu with expose actions that are more relevant.
A visible method to display context-specific actions should be explored separately
(see https://bugs.kde.org/show_bug.cgi?id=411500).
Depends on D23945
Test Plan:
Before, hamburger menu: {F7334178}
After, hamburger menu: {F7350958}
Before, viewport: {F7324802}
After, viewport: {F7330109}
Before, one folder selected: {F7324798}
After, one folder selected: {F7341163}
No change for the context menus shown when selecting a single item, multiple items, or multiple folders
Reviewers: #vdg, #dolphin, meven, elvisangelaccio, GB_2
Reviewed By: #vdg, #dolphin, meven, elvisangelaccio, GB_2
Subscribers: GB_2, mmustac, elvisangelaccio, meven, ndavis, kfm-devel
Tags: #dolphin
Differential Revision: https://phabricator.kde.org/D23757
2019-09-06 16:08:58 +00:00
|
|
|
addSeparator();
|
|
|
|
|
2016-03-16 21:17:37 +00:00
|
|
|
QAction* propertiesAction = m_mainWindow->actionCollection()->action(QStringLiteral("properties"));
|
2013-05-04 18:31:02 +00:00
|
|
|
addAction(propertiesAction);
|
2010-11-17 19:10:23 +00:00
|
|
|
|
2011-03-27 17:27:27 +00:00
|
|
|
addShowMenuBarAction();
|
2019-09-04 09:36:42 +00:00
|
|
|
|
|
|
|
exec(m_pos);
|
2006-11-21 06:02:05 +00:00
|
|
|
}
|
|
|
|
|
2013-06-24 05:11:16 +00:00
|
|
|
void DolphinContextMenu::insertDefaultItemActions(const KFileItemListProperties& properties)
|
2006-11-21 06:02:05 +00:00
|
|
|
{
|
2007-03-17 20:42:26 +00:00
|
|
|
const KActionCollection* collection = m_mainWindow->actionCollection();
|
2006-11-21 06:02:05 +00:00
|
|
|
|
2020-08-26 00:37:31 +00:00
|
|
|
// Insert 'Cut', 'Copy', 'Copy Location' and 'Paste'
|
2013-05-04 18:31:02 +00:00
|
|
|
addAction(collection->action(KStandardAction::name(KStandardAction::Cut)));
|
|
|
|
addAction(collection->action(KStandardAction::name(KStandardAction::Copy)));
|
2020-06-29 22:27:33 +00:00
|
|
|
QAction* copyPathAction = collection->action(QString("copy_location"));
|
|
|
|
copyPathAction->setEnabled(m_selectedItems.size() == 1);
|
|
|
|
addAction(copyPathAction);
|
2013-05-04 18:31:02 +00:00
|
|
|
addAction(createPasteAction());
|
Add Duplicate feature
Summary: Adds a Duplicate feature to Dolphin, showing up as a menu item in the File menu that appears when one or more items are selected and the directory is writable. Duplicated items receive the names of the original files with " copy" appended before the file extension, if any.
Test Plan:
{F5201386} {F5201393}
Test cases:
- Try to duplicate when nothing is selected: **PASS**: menu item is grayed out
- Try to duplicate anything on a read-only local volume: **PASS**: menu item is grayed out
- Try to duplicate anything on a read-only samba share: **PASS**: menu item is grayed out
- Duplicate single local file on R/W volume: **PASS**: item is duplicated and named correctly
- Duplicate multiple local files on R/W volume: **PASS**: 3 items are duplicated, named correctly, and selected
- Duplicate single local directory on R/W volume: **PASS**: item is duplicated and named correctly, but a rename operation is not initiated
- Duplicate multiple local directories on R/W volume: **PASS**: 3 items are duplicated, named correctly, and selected
- Duplicate single file on R/W samba share: **PASS**: item is duplicated and correctly
- Duplicate multiple files on R/W samba share: **PASS**: 3 items are duplicated, named correctly, and selected
- Duplicate single directory on R/W samba share: **PASS**: item is duplicated and named correctly
- Duplicate multiple directory on R/W samba share: **PASS**: 3 items are duplicated, named correctly, and selected
- Try to undo a successful duplication: **PASS**: operation is undone
This is my first attempt at a big change like this and I'm sure it's full of issues. I will accept any and all suggestions for improvement. :)
Reviewers: #dolphin, #kde_applications, elvisangelaccio, dfaure, broulik, davidedmundson
Subscribers: kfm-devel, meven, markg, fazevedo, cfeck, #dolphin
Tags: #dolphin
Differential Revision: https://phabricator.kde.org/D8208
2019-12-20 17:07:25 +00:00
|
|
|
addAction(m_mainWindow->actionCollection()->action(QStringLiteral("duplicate")));
|
2006-11-21 06:02:05 +00:00
|
|
|
|
2013-05-04 18:31:02 +00:00
|
|
|
addSeparator();
|
2010-09-17 19:47:01 +00:00
|
|
|
|
|
|
|
// Insert 'Rename'
|
2017-08-09 20:59:38 +00:00
|
|
|
addAction(collection->action(KStandardAction::name(KStandardAction::RenameFile)));
|
2006-11-21 06:02:05 +00:00
|
|
|
|
2010-09-17 22:23:11 +00:00
|
|
|
// Insert 'Move to Trash' and/or 'Delete'
|
2018-11-19 13:08:19 +00:00
|
|
|
const bool showDeleteAction = (KSharedConfig::openConfig()->group("KDE").readEntry("ShowDeleteCommand", false) ||
|
|
|
|
!properties.isLocal());
|
|
|
|
const bool showMoveToTrashAction = (properties.isLocal() &&
|
|
|
|
properties.supportsMoving());
|
|
|
|
|
|
|
|
if (showDeleteAction && showMoveToTrashAction) {
|
|
|
|
delete m_removeAction;
|
|
|
|
m_removeAction = nullptr;
|
|
|
|
addAction(m_mainWindow->actionCollection()->action(KStandardAction::name(KStandardAction::MoveToTrash)));
|
|
|
|
addAction(m_mainWindow->actionCollection()->action(KStandardAction::name(KStandardAction::DeleteFile)));
|
|
|
|
} else if (showDeleteAction && !showMoveToTrashAction) {
|
|
|
|
addAction(m_mainWindow->actionCollection()->action(KStandardAction::name(KStandardAction::DeleteFile)));
|
|
|
|
} else {
|
|
|
|
if (!m_removeAction) {
|
|
|
|
m_removeAction = new DolphinRemoveAction(this, m_mainWindow->actionCollection());
|
2013-06-24 05:11:16 +00:00
|
|
|
}
|
2018-11-19 13:08:19 +00:00
|
|
|
addAction(m_removeAction);
|
|
|
|
m_removeAction->update();
|
2006-11-21 06:02:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-27 17:27:27 +00:00
|
|
|
void DolphinContextMenu::addShowMenuBarAction()
|
|
|
|
{
|
|
|
|
const KActionCollection* ac = m_mainWindow->actionCollection();
|
|
|
|
QAction* showMenuBar = ac->action(KStandardAction::name(KStandardAction::ShowMenubar));
|
|
|
|
if (!m_mainWindow->menuBar()->isVisible() && !m_mainWindow->toolBar()->isVisible()) {
|
2013-05-04 18:31:02 +00:00
|
|
|
addSeparator();
|
|
|
|
addAction(showMenuBar);
|
2011-03-27 17:27:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-10-21 19:18:43 +00:00
|
|
|
bool DolphinContextMenu::placeExists(const QUrl& url) const
|
2009-11-12 20:22:22 +00:00
|
|
|
{
|
2019-06-07 08:37:06 +00:00
|
|
|
const KFilePlacesModel* placesModel = DolphinPlacesModelSingleton::instance().placesModel();
|
|
|
|
|
|
|
|
const auto& matchedPlaces = placesModel->match(placesModel->index(0,0), KFilePlacesModel::UrlRole, url, 1, Qt::MatchExactly);
|
|
|
|
|
|
|
|
return !matchedPlaces.isEmpty();
|
2009-11-12 20:22:22 +00:00
|
|
|
}
|
|
|
|
|
2008-03-29 07:44:03 +00:00
|
|
|
QAction* DolphinContextMenu::createPasteAction()
|
|
|
|
{
|
2017-11-21 09:52:14 +00:00
|
|
|
QAction* action = nullptr;
|
2008-06-18 19:34:03 +00:00
|
|
|
const bool isDir = !m_fileInfo.isNull() && m_fileInfo.isDir();
|
|
|
|
if (isDir && (m_selectedItems.count() == 1)) {
|
2014-10-21 18:44:37 +00:00
|
|
|
const QMimeData *mimeData = QApplication::clipboard()->mimeData();
|
|
|
|
bool canPaste;
|
|
|
|
const QString text = KIO::pasteActionText(mimeData, &canPaste, m_fileInfo);
|
2016-03-16 21:17:37 +00:00
|
|
|
action = new QAction(QIcon::fromTheme(QStringLiteral("edit-paste")), text, this);
|
2014-10-21 18:44:37 +00:00
|
|
|
action->setEnabled(canPaste);
|
2014-04-10 14:53:41 +00:00
|
|
|
connect(action, &QAction::triggered, m_mainWindow, &DolphinMainWindow::pasteIntoFolder);
|
2008-03-29 07:44:03 +00:00
|
|
|
} else {
|
|
|
|
action = m_mainWindow->actionCollection()->action(KStandardAction::name(KStandardAction::Paste));
|
|
|
|
}
|
|
|
|
|
|
|
|
return action;
|
|
|
|
}
|
|
|
|
|
2012-01-14 19:02:11 +00:00
|
|
|
KFileItemListProperties& DolphinContextMenu::selectedItemsProperties() const
|
2010-10-25 13:45:34 +00:00
|
|
|
{
|
2011-02-09 18:21:58 +00:00
|
|
|
if (!m_selectedItemsProperties) {
|
2010-10-25 13:45:34 +00:00
|
|
|
m_selectedItemsProperties = new KFileItemListProperties(m_selectedItems);
|
|
|
|
}
|
|
|
|
return *m_selectedItemsProperties;
|
|
|
|
}
|
|
|
|
|
|
|
|
KFileItem DolphinContextMenu::baseFileItem()
|
2008-04-18 19:43:16 +00:00
|
|
|
{
|
2011-02-09 18:21:58 +00:00
|
|
|
if (!m_baseFileItem) {
|
2014-12-14 16:46:58 +00:00
|
|
|
m_baseFileItem = new KFileItem(m_baseUrl);
|
2008-04-18 19:43:16 +00:00
|
|
|
}
|
2010-10-25 13:45:34 +00:00
|
|
|
return *m_baseFileItem;
|
2008-04-18 19:43:16 +00:00
|
|
|
}
|
|
|
|
|
Move "Open" actions to the top of the context menu for files
Summary:
This patch moves the "Open", "Open With", and "Open in" items to the top of the context menu to reap the following benefits:
- Move the "Open" and "Open With" items closer to the top since they're commonly used items, and right now they're buried in the middle of the menu
- Group related functionality
- Consistency with other common platforms (macOS Finder and Windows Explorer both have these items at the top of the context menu)
For folders, the "Open With" entries are moved higher, but not all the way to the top, since the "open in New tab/folder" entries are more useful.
Test Plan:
Tested all menu items in the context menu for files, folders, and links; all still work.
Context menu for single file:
{F5806809}
Context menu for multiple files:
{F5806810}
Context menu for single folder:
{F5806811}
Context menu for multiple folders:
{F5806812}
Context menu for symlink to folder:
{F5806815}
Reviewers: #dolphin, #vdg, elvisangelaccio, abetts
Reviewed By: #dolphin, #vdg, elvisangelaccio, abetts
Subscribers: markg, abetts, elvisangelaccio
Differential Revision: https://phabricator.kde.org/D11884
2018-04-02 14:05:47 +00:00
|
|
|
void DolphinContextMenu::addOpenWithActions(KFileItemActions& fileItemActions)
|
2010-08-27 05:26:27 +00:00
|
|
|
{
|
|
|
|
// insert 'Open With...' action or sub menu
|
2018-03-21 14:53:59 +00:00
|
|
|
fileItemActions.addOpenWithActionsTo(this, QStringLiteral("DesktopEntryName != '%1'").arg(qApp->desktopFileName()));
|
2010-10-25 13:45:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinContextMenu::addVersionControlPluginActions()
|
2009-07-23 06:10:01 +00:00
|
|
|
{
|
|
|
|
const DolphinView* view = m_mainWindow->activeViewContainer()->view();
|
2009-08-13 20:48:58 +00:00
|
|
|
const QList<QAction*> versionControlActions = view->versionControlActions(m_selectedItems);
|
|
|
|
if (!versionControlActions.isEmpty()) {
|
2015-01-28 14:25:09 +00:00
|
|
|
addActions(versionControlActions);
|
2013-05-04 18:31:02 +00:00
|
|
|
addSeparator();
|
2009-07-23 06:10:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-09-17 19:47:01 +00:00
|
|
|
void DolphinContextMenu::addCustomActions()
|
2009-02-11 20:45:12 +00:00
|
|
|
{
|
2015-01-28 14:25:09 +00:00
|
|
|
addActions(m_customActions);
|
2010-09-17 19:47:01 +00:00
|
|
|
}
|
|
|
|
|