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"
|
2020-11-12 09:38:44 +00:00
|
|
|
#include "dolphin_contextmenusettings.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 <KFileItemListProperties>
|
2021-05-13 16:49:27 +00:00
|
|
|
#include <KHamburgerMenu>
|
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 <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,
|
2021-04-18 06:37:45 +00:00
|
|
|
const QUrl& baseUrl,
|
|
|
|
KFileItemActions *fileItemActions) :
|
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),
|
2021-04-18 06:37:45 +00:00
|
|
|
m_removeAction(nullptr),
|
|
|
|
m_fileItemActions(fileItemActions)
|
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();
|
2020-10-15 21:11:17 +00:00
|
|
|
|
2021-06-22 12:52:35 +00:00
|
|
|
QApplication::instance()->installEventFilter(this);
|
2021-05-13 16:49:27 +00:00
|
|
|
|
|
|
|
static_cast<KHamburgerMenu *>(m_mainWindow->actionCollection()->
|
|
|
|
action(QStringLiteral("hamburger_menu")))->addToMenu(this);
|
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
|
|
|
openViewportContextMenu();
|
|
|
|
}
|
2010-09-22 20:24:49 +00:00
|
|
|
|
|
|
|
return m_command;
|
2006-11-21 06:02:05 +00:00
|
|
|
}
|
|
|
|
|
2021-06-18 13:12:54 +00:00
|
|
|
bool DolphinContextMenu::eventFilter(QObject* object, QEvent* event)
|
2010-09-20 19:52:40 +00:00
|
|
|
{
|
2021-06-18 13:12:54 +00:00
|
|
|
Q_UNUSED(object)
|
2010-09-20 19:52:40 +00:00
|
|
|
|
2020-10-15 21:11:17 +00:00
|
|
|
if(event->type() == QEvent::KeyPress || event->type() == QEvent::KeyRelease) {
|
|
|
|
QKeyEvent* keyEvent = static_cast<QKeyEvent*>(event);
|
2021-06-18 13:12:54 +00:00
|
|
|
|
|
|
|
if (m_removeAction && keyEvent->key() == Qt::Key_Shift) {
|
|
|
|
if (event->type() == QEvent::KeyPress) {
|
2020-10-15 21:11:17 +00:00
|
|
|
m_removeAction->update(DolphinRemoveAction::ShiftState::Pressed);
|
|
|
|
} else {
|
|
|
|
m_removeAction->update(DolphinRemoveAction::ShiftState::Released);
|
|
|
|
}
|
|
|
|
}
|
2013-05-04 18:31:02 +00:00
|
|
|
}
|
2021-06-18 13:12:54 +00:00
|
|
|
|
|
|
|
return false;
|
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
|
|
|
|
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());
|
2020-10-23 17:48:22 +00:00
|
|
|
for (const KFileItem &item : qAsConst(m_selectedItems)) {
|
2010-10-25 13:45:34 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-18 06:37:45 +00:00
|
|
|
void DolphinContextMenu::addDirectoryItemContextMenu()
|
2019-11-29 16:59:21 +00:00
|
|
|
{
|
|
|
|
// insert 'Open in new window' and 'Open in new tab' entries
|
|
|
|
const KFileItemListProperties& selectedItemsProps = selectedItemsProperties();
|
2020-11-12 09:38:44 +00:00
|
|
|
if (ContextMenuSettings::showOpenInNewTab()) {
|
|
|
|
addAction(m_mainWindow->actionCollection()->action(QStringLiteral("open_in_new_tab")));
|
|
|
|
}
|
|
|
|
if (ContextMenuSettings::showOpenInNewWindow()) {
|
|
|
|
addAction(m_mainWindow->actionCollection()->action(QStringLiteral("open_in_new_window")));
|
|
|
|
}
|
2019-11-29 16:59:21 +00:00
|
|
|
|
|
|
|
// Insert 'Open With' entries
|
2021-04-18 06:37:45 +00:00
|
|
|
addOpenWithActions();
|
2019-11-29 16:59:21 +00:00
|
|
|
|
|
|
|
// set up 'Create New' menu
|
2020-11-12 09:38:44 +00:00
|
|
|
DolphinNewFileMenu* newFileMenu = new DolphinNewFileMenu(m_mainWindow->actionCollection(), m_mainWindow);
|
|
|
|
const DolphinView* view = m_mainWindow->activeViewContainer()->view();
|
|
|
|
newFileMenu->setViewShowsHiddenFiles(view->hiddenFilesShown());
|
|
|
|
newFileMenu->checkUpToDate();
|
|
|
|
newFileMenu->setPopupFiles(QList<QUrl>() << m_fileInfo.url());
|
|
|
|
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"));
|
2021-05-16 15:25:35 +00:00
|
|
|
menu->setIcon(QIcon::fromTheme(QStringLiteral("list-add")));
|
2020-11-12 09:38:44 +00:00
|
|
|
addMenu(menu);
|
|
|
|
|
|
|
|
addSeparator();
|
2019-11-29 16:59:21 +00:00
|
|
|
}
|
|
|
|
|
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();
|
|
|
|
|
2021-04-18 06:37:45 +00:00
|
|
|
|
|
|
|
m_fileItemActions->setItemListProperties(selectedItemsProps);
|
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
|
|
|
|
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()) {
|
2021-04-18 06:37:45 +00:00
|
|
|
addDirectoryItemContextMenu();
|
2019-11-29 16:59:21 +00:00
|
|
|
} else if (m_context & TimelineContext || m_context & SearchContext) {
|
2021-04-18 06:37:45 +00:00
|
|
|
addOpenWithActions();
|
2018-05-14 22:51:11 +00:00
|
|
|
|
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
|
2021-04-18 06:37:45 +00:00
|
|
|
addOpenWithActions();
|
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
|
|
|
}
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-12 09:38:44 +00:00
|
|
|
if (selectionHasOnlyDirs && ContextMenuSettings::showOpenInNewTab()) {
|
2013-05-22 19:47:14 +00:00
|
|
|
// 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
|
2021-04-18 06:37:45 +00:00
|
|
|
addOpenWithActions();
|
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
|
|
|
|
2021-04-18 06:37:45 +00:00
|
|
|
addAdditionalActions(selectedItemsProps);
|
2009-07-22 19:26:25 +00:00
|
|
|
|
2009-02-11 20:45:12 +00:00
|
|
|
// insert 'Copy To' and 'Move To' sub menus
|
2020-11-12 09:38:44 +00:00
|
|
|
if (ContextMenuSettings::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
|
|
|
|
2020-11-14 06:58:24 +00:00
|
|
|
const KFileItemListProperties baseUrlProperties(KFileItemList() << baseFileItem());
|
2021-04-18 06:37:45 +00:00
|
|
|
m_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
|
2021-04-18 06:37:45 +00:00
|
|
|
addOpenWithActions();
|
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();
|
2020-11-14 06:58:24 +00:00
|
|
|
if (pasteAction) {
|
|
|
|
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
|
2020-11-12 09:38:44 +00:00
|
|
|
if (ContextMenuSettings::showAddToPlaces() &&
|
|
|
|
!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'
|
2020-11-12 09:38:44 +00:00
|
|
|
if (ContextMenuSettings::showSortBy()) {
|
|
|
|
addAction(m_mainWindow->actionCollection()->action(QStringLiteral("sort")));
|
|
|
|
}
|
|
|
|
if (ContextMenuSettings::showViewMode()) {
|
|
|
|
addAction(m_mainWindow->actionCollection()->action(QStringLiteral("view_mode")));
|
|
|
|
}
|
|
|
|
if (ContextMenuSettings::showSortBy() || ContextMenuSettings::showViewMode()) {
|
|
|
|
addSeparator();
|
|
|
|
}
|
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
|
|
|
|
2021-04-18 06:37:45 +00:00
|
|
|
addAdditionalActions(baseUrlProperties);
|
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
|
|
|
|
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-11-12 09:38:44 +00:00
|
|
|
if (ContextMenuSettings::showCopyLocation()) {
|
|
|
|
QAction* copyPathAction = collection->action(QString("copy_location"));
|
|
|
|
copyPathAction->setEnabled(m_selectedItems.size() == 1);
|
|
|
|
addAction(copyPathAction);
|
|
|
|
}
|
2020-11-14 06:58:24 +00:00
|
|
|
QAction* pasteAction = createPasteAction();
|
|
|
|
if (pasteAction) {
|
|
|
|
addAction(pasteAction);
|
|
|
|
}
|
2020-11-12 09:38:44 +00:00
|
|
|
|
|
|
|
// Insert 'Duplicate Here'
|
|
|
|
if (ContextMenuSettings::showDuplicateHere()) {
|
|
|
|
addAction(m_mainWindow->actionCollection()->action(QStringLiteral("duplicate")));
|
|
|
|
}
|
2006-11-21 06:02:05 +00:00
|
|
|
|
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
|
|
|
|
2020-11-12 09:38:44 +00:00
|
|
|
// Insert 'Add to Places' entry if appropriate
|
|
|
|
if (ContextMenuSettings::showAddToPlaces() &&
|
|
|
|
m_selectedItems.count() == 1 &&
|
|
|
|
m_fileInfo.isDir() &&
|
|
|
|
!placeExists(m_fileInfo.url())) {
|
|
|
|
addAction(m_mainWindow->actionCollection()->action(QStringLiteral("add_to_places")));
|
2020-11-17 19:13:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
addSeparator();
|
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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;
|
2020-11-14 06:58:24 +00:00
|
|
|
KFileItem destItem;
|
2020-11-30 08:01:27 +00:00
|
|
|
if (!m_fileInfo.isNull() && m_selectedItems.count() <= 1) {
|
2020-11-14 06:58:24 +00:00
|
|
|
destItem = m_fileInfo;
|
2008-03-29 07:44:03 +00:00
|
|
|
} else {
|
2020-11-14 06:58:24 +00:00
|
|
|
destItem = baseFileItem();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!destItem.isNull() && destItem.isDir()) {
|
2020-11-30 08:01:27 +00:00
|
|
|
const QMimeData *mimeData = QApplication::clipboard()->mimeData();
|
|
|
|
bool canPaste;
|
|
|
|
const QString text = KIO::pasteActionText(mimeData, &canPaste, destItem);
|
|
|
|
if (canPaste) {
|
|
|
|
if (destItem == m_fileInfo) {
|
|
|
|
// if paste destination is a selected folder
|
|
|
|
action = new QAction(QIcon::fromTheme(QStringLiteral("edit-paste")), text, this);
|
2020-11-14 06:58:24 +00:00
|
|
|
connect(action, &QAction::triggered, m_mainWindow, &DolphinMainWindow::pasteIntoFolder);
|
|
|
|
} else {
|
2020-11-30 08:01:27 +00:00
|
|
|
action = m_mainWindow->actionCollection()->action(KStandardAction::name(KStandardAction::Paste));
|
2020-11-14 06:58:24 +00:00
|
|
|
}
|
|
|
|
}
|
2008-03-29 07:44:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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) {
|
2020-11-14 06:58:24 +00:00
|
|
|
const DolphinView* view = m_mainWindow->activeViewContainer()->view();
|
|
|
|
KFileItem baseItem = view->rootItem();
|
|
|
|
if (baseItem.isNull() || baseItem.url() != m_baseUrl) {
|
|
|
|
m_baseFileItem = new KFileItem(m_baseUrl);
|
|
|
|
} else {
|
|
|
|
m_baseFileItem = new KFileItem(baseItem);
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
2021-04-18 06:37:45 +00:00
|
|
|
void DolphinContextMenu::addOpenWithActions()
|
2010-08-27 05:26:27 +00:00
|
|
|
{
|
|
|
|
// insert 'Open With...' action or sub menu
|
2021-04-18 06:37:45 +00:00
|
|
|
m_fileItemActions->addOpenWithActionsTo(this, QStringLiteral("DesktopEntryName != '%1'").arg(qApp->desktopFileName()));
|
2010-10-25 13:45:34 +00:00
|
|
|
}
|
|
|
|
|
2020-11-22 21:19:21 +00:00
|
|
|
void DolphinContextMenu::addCustomActions()
|
2009-07-23 06:10:01 +00:00
|
|
|
{
|
2020-11-22 21:19:21 +00:00
|
|
|
addActions(m_customActions);
|
|
|
|
}
|
|
|
|
|
2021-04-18 06:37:45 +00:00
|
|
|
void DolphinContextMenu::addAdditionalActions(const KFileItemListProperties &props)
|
2020-11-22 21:19:21 +00:00
|
|
|
{
|
|
|
|
addSeparator();
|
|
|
|
|
|
|
|
QList<QAction *> additionalActions;
|
2021-04-29 07:53:29 +00:00
|
|
|
if (props.isDirectory() && props.isLocal() && ContextMenuSettings::showOpenTerminal()) {
|
2020-11-22 21:19:21 +00:00
|
|
|
additionalActions << m_mainWindow->actionCollection()->action(QStringLiteral("open_terminal"));
|
|
|
|
}
|
2021-04-18 06:37:45 +00:00
|
|
|
m_fileItemActions->addActionsTo(this, KFileItemActions::MenuActionSource::All, additionalActions);
|
2020-11-22 21:19:21 +00:00
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|