2007-07-01 14:25:21 +00:00
|
|
|
/* This file is part of the KDE project
|
2020-08-25 17:07:38 +00:00
|
|
|
SPDX-FileCopyrightText: 2007 David Faure <faure@kde.org>
|
2007-07-01 14:25:21 +00:00
|
|
|
|
2020-08-25 17:07:38 +00:00
|
|
|
SPDX-License-Identifier: LGPL-2.0-or-later
|
2007-07-01 14:25:21 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "dolphinpart.h"
|
2007-07-02 17:24:54 +00:00
|
|
|
|
2018-03-04 13:38:16 +00:00
|
|
|
#include "dolphindebug.h"
|
|
|
|
#include "dolphinnewfilemenu.h"
|
|
|
|
#include "dolphinpart_ext.h"
|
|
|
|
#include "dolphinremoveaction.h"
|
|
|
|
#include "kitemviews/kfileitemmodel.h"
|
|
|
|
#include "views/dolphinnewfilemenuobserver.h"
|
|
|
|
#include "views/dolphinremoteencoding.h"
|
|
|
|
#include "views/dolphinview.h"
|
|
|
|
#include "views/dolphinviewactionhandler.h"
|
2007-11-23 11:50:00 +00:00
|
|
|
|
2011-02-04 14:43:21 +00:00
|
|
|
#include <KActionCollection>
|
2018-03-04 13:38:16 +00:00
|
|
|
#include <KAuthorized>
|
|
|
|
#include <KConfigGroup>
|
2020-04-13 22:11:16 +00:00
|
|
|
#include <KDialogJobUiDelegate>
|
2021-07-15 22:29:07 +00:00
|
|
|
#include <KDirLister>
|
2018-03-04 13:38:16 +00:00
|
|
|
#include <KFileItemListProperties>
|
2022-05-08 07:54:30 +00:00
|
|
|
#include <KIO/CommandLauncherJob>
|
2011-02-04 14:43:21 +00:00
|
|
|
#include <KIconLoader>
|
2018-03-04 13:38:16 +00:00
|
|
|
#include <KJobWidgets>
|
2014-10-18 12:42:41 +00:00
|
|
|
#include <KLocalizedString>
|
2011-02-04 14:43:21 +00:00
|
|
|
#include <KMessageBox>
|
2018-03-04 13:38:16 +00:00
|
|
|
#include <KMimeTypeEditor>
|
2022-05-08 07:54:30 +00:00
|
|
|
#include <KMoreToolsMenuFactory>
|
2011-02-04 14:43:21 +00:00
|
|
|
#include <KPluginFactory>
|
2022-05-08 07:54:30 +00:00
|
|
|
#include <KPluginMetaData>
|
2014-10-18 13:00:17 +00:00
|
|
|
#include <KSharedConfig>
|
2021-08-31 15:09:14 +00:00
|
|
|
#include <KTerminalLauncherJob>
|
2021-12-14 20:47:20 +00:00
|
|
|
#include <kio_version.h>
|
2009-03-21 11:49:10 +00:00
|
|
|
|
2007-11-15 20:04:05 +00:00
|
|
|
#include <QActionGroup>
|
2007-09-19 20:33:28 +00:00
|
|
|
#include <QApplication>
|
2007-11-15 20:04:05 +00:00
|
|
|
#include <QClipboard>
|
2012-04-11 14:06:18 +00:00
|
|
|
#include <QDir>
|
2014-12-14 18:05:53 +00:00
|
|
|
#include <QInputDialog>
|
2018-03-04 13:38:16 +00:00
|
|
|
#include <QKeyEvent>
|
|
|
|
#include <QMenu>
|
2019-12-24 15:15:44 +00:00
|
|
|
#include <QRegularExpression>
|
2018-03-04 13:38:16 +00:00
|
|
|
#include <QStandardPaths>
|
|
|
|
#include <QTextDocument>
|
2007-07-01 14:25:21 +00:00
|
|
|
|
2020-11-28 09:47:39 +00:00
|
|
|
K_PLUGIN_CLASS_WITH_JSON(DolphinPart, "dolphinpart.json")
|
2007-07-01 14:25:21 +00:00
|
|
|
|
2020-11-28 10:24:29 +00:00
|
|
|
DolphinPart::DolphinPart(QWidget *parentWidget, QObject *parent, const KPluginMetaData &metaData, const QVariantList &args)
|
2007-07-01 14:25:21 +00:00
|
|
|
: KParts::ReadOnlyPart(parent)
|
2017-11-21 09:52:14 +00:00
|
|
|
, m_openTerminalAction(nullptr)
|
|
|
|
, m_removeAction(nullptr)
|
2007-07-01 14:25:21 +00:00
|
|
|
{
|
|
|
|
Q_UNUSED(args)
|
2020-11-28 10:24:29 +00:00
|
|
|
setMetaData(metaData);
|
|
|
|
|
2007-07-02 17:24:54 +00:00
|
|
|
m_extension = new DolphinPartBrowserExtension(this);
|
2007-07-01 14:25:21 +00:00
|
|
|
|
2008-01-15 11:09:56 +00:00
|
|
|
// make sure that other apps using this part find Dolphin's view-file-columns icons
|
2016-03-16 21:17:37 +00:00
|
|
|
KIconLoader::global()->addAppDir(QStringLiteral("dolphin"));
|
2008-01-15 11:09:56 +00:00
|
|
|
|
2014-10-21 19:18:43 +00:00
|
|
|
m_view = new DolphinView(QUrl(), parentWidget);
|
2008-05-07 20:02:37 +00:00
|
|
|
m_view->setTabsForFilesEnabled(true);
|
2007-07-01 14:25:21 +00:00
|
|
|
setWidget(m_view);
|
2007-07-02 17:24:54 +00:00
|
|
|
|
2014-04-10 14:53:41 +00:00
|
|
|
connect(&DolphinNewFileMenuObserver::instance(), &DolphinNewFileMenuObserver::errorMessage, this, &DolphinPart::slotErrorMessage);
|
2013-08-28 16:46:45 +00:00
|
|
|
|
2021-11-11 19:27:47 +00:00
|
|
|
connect(m_view, &DolphinView::directoryLoadingCompleted, this, &KParts::ReadOnlyPart::completed);
|
2016-12-06 06:57:00 +00:00
|
|
|
connect(m_view, &DolphinView::directoryLoadingCompleted, this, &DolphinPart::updatePasteAction);
|
2014-04-10 14:53:41 +00:00
|
|
|
connect(m_view, &DolphinView::directoryLoadingProgress, this, &DolphinPart::updateProgress);
|
|
|
|
connect(m_view, &DolphinView::errorMessage, this, &DolphinPart::slotErrorMessage);
|
2011-01-09 13:58:35 +00:00
|
|
|
|
2016-03-16 21:17:37 +00:00
|
|
|
setXMLFile(QStringLiteral("dolphinpart.rc"));
|
2007-10-10 23:01:35 +00:00
|
|
|
|
2014-04-10 14:53:41 +00:00
|
|
|
connect(m_view, &DolphinView::infoMessage, this, &DolphinPart::slotMessage);
|
|
|
|
connect(m_view, &DolphinView::operationCompletedMessage, this, &DolphinPart::slotMessage);
|
|
|
|
connect(m_view, &DolphinView::errorMessage, this, &DolphinPart::slotErrorMessage);
|
|
|
|
connect(m_view, &DolphinView::itemActivated, this, &DolphinPart::slotItemActivated);
|
|
|
|
connect(m_view, &DolphinView::itemsActivated, this, &DolphinPart::slotItemsActivated);
|
2021-02-08 21:32:10 +00:00
|
|
|
connect(m_view, &DolphinView::statusBarTextChanged, this, [this](const QString &text) {
|
|
|
|
const QString escapedText = Qt::convertFromPlainText(text);
|
|
|
|
Q_EMIT ReadOnlyPart::setStatusBarText(QStringLiteral("<qt>%1</qt>").arg(escapedText));
|
|
|
|
});
|
2014-04-10 14:53:41 +00:00
|
|
|
connect(m_view, &DolphinView::tabRequested, this, &DolphinPart::createNewWindow);
|
|
|
|
connect(m_view, &DolphinView::requestContextMenu, this, &DolphinPart::slotOpenContextMenu);
|
2021-11-11 19:27:47 +00:00
|
|
|
connect(m_view, &DolphinView::selectionChanged, m_extension, &KParts::BrowserExtension::selectionInfo);
|
2014-04-10 14:53:41 +00:00
|
|
|
connect(m_view, &DolphinView::selectionChanged, this, &DolphinPart::slotSelectionChanged);
|
|
|
|
connect(m_view, &DolphinView::requestItemInfo, this, &DolphinPart::slotRequestItemInfo);
|
|
|
|
connect(m_view, &DolphinView::modeChanged, this, &DolphinPart::viewModeChanged); // relay signal
|
|
|
|
connect(m_view, &DolphinView::redirection, this, &DolphinPart::slotDirectoryRedirection);
|
2008-10-13 21:54:03 +00:00
|
|
|
|
2008-10-05 18:11:46 +00:00
|
|
|
// Watch for changes that should result in updates to the
|
|
|
|
// status bar text.
|
2014-04-10 14:53:41 +00:00
|
|
|
connect(m_view, &DolphinView::itemCountChanged, this, &DolphinPart::updateStatusBar);
|
|
|
|
connect(m_view, &DolphinView::selectionChanged, this, &DolphinPart::updateStatusBar);
|
2008-02-11 12:34:48 +00:00
|
|
|
|
2022-04-24 11:18:30 +00:00
|
|
|
m_actionHandler = new DolphinViewActionHandler(actionCollection(), nullptr, this);
|
2008-02-11 12:34:48 +00:00
|
|
|
m_actionHandler->setCurrentView(m_view);
|
2018-10-24 20:49:01 +00:00
|
|
|
connect(m_actionHandler, &DolphinViewActionHandler::createDirectoryTriggered, this, &DolphinPart::createDirectory);
|
2007-07-02 17:24:54 +00:00
|
|
|
|
2009-03-25 22:00:50 +00:00
|
|
|
m_remoteEncoding = new DolphinRemoteEncoding(this, m_actionHandler);
|
2014-04-10 14:53:41 +00:00
|
|
|
connect(this, &DolphinPart::aboutToOpenURL, m_remoteEncoding, &DolphinRemoteEncoding::slotAboutToOpenUrl);
|
2009-03-25 22:00:50 +00:00
|
|
|
|
2007-11-15 20:04:05 +00:00
|
|
|
QClipboard *clipboard = QApplication::clipboard();
|
2014-04-10 14:53:41 +00:00
|
|
|
connect(clipboard, &QClipboard::dataChanged, this, &DolphinPart::updatePasteAction);
|
2007-11-15 20:04:05 +00:00
|
|
|
|
2012-09-03 21:53:03 +00:00
|
|
|
// Create file info and listing filter extensions.
|
|
|
|
// NOTE: Listing filter needs to be instantiated after the creation of the view.
|
|
|
|
new DolphinPartFileInfoExtension(this);
|
2012-09-11 20:40:32 +00:00
|
|
|
|
2012-09-03 21:53:03 +00:00
|
|
|
new DolphinPartListingFilterExtension(this);
|
|
|
|
|
2012-09-05 02:26:28 +00:00
|
|
|
KDirLister *lister = m_view->m_model->m_dirLister;
|
|
|
|
if (lister) {
|
|
|
|
DolphinPartListingNotificationExtension *notifyExt = new DolphinPartListingNotificationExtension(this);
|
2014-04-10 14:53:41 +00:00
|
|
|
connect(lister, &KDirLister::newItems, notifyExt, &DolphinPartListingNotificationExtension::slotNewItems);
|
|
|
|
connect(lister, &KDirLister::itemsDeleted, notifyExt, &DolphinPartListingNotificationExtension::slotItemsDeleted);
|
2012-09-05 02:26:28 +00:00
|
|
|
} else {
|
2015-02-24 16:07:55 +00:00
|
|
|
qCWarning(DolphinDebug) << "NULL KDirLister object! KParts::ListingNotificationExtension will NOT be supported";
|
2012-09-05 02:26:28 +00:00
|
|
|
}
|
|
|
|
|
2007-10-10 23:01:35 +00:00
|
|
|
createActions();
|
2008-02-13 18:45:20 +00:00
|
|
|
m_actionHandler->updateViewActions();
|
2007-11-17 00:08:54 +00:00
|
|
|
slotSelectionChanged(KFileItemList()); // initially disable selection-dependent actions
|
2007-10-10 23:01:35 +00:00
|
|
|
|
2013-02-09 20:56:51 +00:00
|
|
|
// Listen to events from the app so we can update the remove key by
|
|
|
|
// checking for a Shift key press.
|
|
|
|
qApp->installEventFilter(this);
|
|
|
|
|
2007-07-02 17:24:54 +00:00
|
|
|
// TODO there was a "always open a new window" (when clicking on a directory) setting in konqueror
|
|
|
|
// (sort of spacial navigation)
|
2007-07-01 14:25:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DolphinPart::~DolphinPart()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-10-10 23:01:35 +00:00
|
|
|
void DolphinPart::createActions()
|
|
|
|
{
|
2008-06-05 19:19:14 +00:00
|
|
|
// Edit menu
|
|
|
|
|
2013-08-28 16:46:45 +00:00
|
|
|
m_newFileMenu = new DolphinNewFileMenu(actionCollection(), this);
|
2010-08-27 05:26:27 +00:00
|
|
|
m_newFileMenu->setParentWidget(widget());
|
2014-04-10 14:53:41 +00:00
|
|
|
connect(m_newFileMenu->menu(), &QMenu::aboutToShow, this, &DolphinPart::updateNewMenu);
|
2008-06-05 19:19:14 +00:00
|
|
|
|
2016-03-16 21:17:37 +00:00
|
|
|
QAction *editMimeTypeAction = actionCollection()->addAction(QStringLiteral("editMimeType"));
|
2023-06-29 22:42:34 +00:00
|
|
|
editMimeTypeAction->setText(i18nc("@action:inmenu Edit", "&Edit File Type…"));
|
2014-04-10 14:53:41 +00:00
|
|
|
connect(editMimeTypeAction, &QAction::triggered, this, &DolphinPart::slotEditMimeType);
|
2007-12-24 11:50:08 +00:00
|
|
|
|
2016-03-16 21:17:37 +00:00
|
|
|
QAction *selectItemsMatching = actionCollection()->addAction(QStringLiteral("select_items_matching"));
|
2023-06-29 22:42:34 +00:00
|
|
|
selectItemsMatching->setText(i18nc("@action:inmenu Edit", "Select Items Matching…"));
|
2020-12-09 06:55:44 +00:00
|
|
|
actionCollection()->setDefaultShortcut(selectItemsMatching, Qt::CTRL | Qt::Key_S);
|
2014-04-10 14:53:41 +00:00
|
|
|
connect(selectItemsMatching, &QAction::triggered, this, &DolphinPart::slotSelectItemsMatchingPattern);
|
2009-11-25 08:46:04 +00:00
|
|
|
|
2016-03-16 21:17:37 +00:00
|
|
|
QAction *unselectItemsMatching = actionCollection()->addAction(QStringLiteral("unselect_items_matching"));
|
2023-06-29 22:42:34 +00:00
|
|
|
unselectItemsMatching->setText(i18nc("@action:inmenu Edit", "Unselect Items Matching…"));
|
2014-04-10 14:53:41 +00:00
|
|
|
connect(unselectItemsMatching, &QAction::triggered, this, &DolphinPart::slotUnselectItemsMatchingPattern);
|
2009-11-25 08:46:04 +00:00
|
|
|
|
2018-03-10 19:50:29 +00:00
|
|
|
KStandardAction::selectAll(m_view, &DolphinView::selectAll, actionCollection());
|
2009-11-25 08:46:04 +00:00
|
|
|
|
2016-03-16 21:17:37 +00:00
|
|
|
QAction *unselectAll = actionCollection()->addAction(QStringLiteral("unselect_all"));
|
2009-11-25 08:46:04 +00:00
|
|
|
unselectAll->setText(i18nc("@action:inmenu Edit", "Unselect All"));
|
2014-04-10 14:53:41 +00:00
|
|
|
connect(unselectAll, &QAction::triggered, m_view, &DolphinView::clearSelection);
|
2009-11-25 08:46:04 +00:00
|
|
|
|
2016-03-16 21:17:37 +00:00
|
|
|
QAction *invertSelection = actionCollection()->addAction(QStringLiteral("invert_selection"));
|
2009-11-25 08:46:04 +00:00
|
|
|
invertSelection->setText(i18nc("@action:inmenu Edit", "Invert Selection"));
|
2020-12-09 06:55:44 +00:00
|
|
|
actionCollection()->setDefaultShortcut(invertSelection, Qt::CTRL | Qt::SHIFT | Qt::Key_A);
|
2014-04-10 14:53:41 +00:00
|
|
|
connect(invertSelection, &QAction::triggered, m_view, &DolphinView::invertSelection);
|
2009-11-25 08:46:04 +00:00
|
|
|
|
2008-02-11 12:34:48 +00:00
|
|
|
// View menu: all done by DolphinViewActionHandler
|
2008-01-28 11:33:49 +00:00
|
|
|
|
2007-12-24 11:17:16 +00:00
|
|
|
// Go menu
|
|
|
|
|
|
|
|
QActionGroup *goActionGroup = new QActionGroup(this);
|
2014-04-10 14:53:41 +00:00
|
|
|
connect(goActionGroup, &QActionGroup::triggered, this, &DolphinPart::slotGoTriggered);
|
2007-12-24 11:17:16 +00:00
|
|
|
|
2014-11-03 22:52:18 +00:00
|
|
|
createGoAction("go_applications", "start-here-kde", i18nc("@action:inmenu Go", "App&lications"), QStringLiteral("programs:/"), goActionGroup);
|
|
|
|
createGoAction("go_network_folders", "folder-remote", i18nc("@action:inmenu Go", "&Network Folders"), QStringLiteral("remote:/"), goActionGroup);
|
|
|
|
createGoAction("go_trash", "user-trash", i18nc("@action:inmenu Go", "Trash"), QStringLiteral("trash:/"), goActionGroup);
|
2007-12-24 11:17:16 +00:00
|
|
|
createGoAction("go_autostart",
|
|
|
|
"",
|
2014-04-06 01:32:55 +00:00
|
|
|
i18nc("@action:inmenu Go", "Autostart"),
|
|
|
|
QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + "/autostart",
|
2007-12-24 11:17:16 +00:00
|
|
|
goActionGroup);
|
2008-06-04 11:51:54 +00:00
|
|
|
|
|
|
|
// Tools menu
|
2018-03-10 19:50:29 +00:00
|
|
|
m_findFileAction = KStandardAction::find(this, &DolphinPart::slotFindFile, actionCollection());
|
2023-06-29 22:42:34 +00:00
|
|
|
m_findFileAction->setText(i18nc("@action:inmenu Tools", "Find File…"));
|
2011-04-10 16:32:53 +00:00
|
|
|
|
2018-01-21 11:15:07 +00:00
|
|
|
#ifndef Q_OS_WIN
|
2016-05-26 12:51:23 +00:00
|
|
|
if (KAuthorized::authorize(QStringLiteral("shell_access"))) {
|
2016-03-16 21:17:37 +00:00
|
|
|
m_openTerminalAction = actionCollection()->addAction(QStringLiteral("open_terminal"));
|
2019-09-05 15:30:06 +00:00
|
|
|
m_openTerminalAction->setIcon(QIcon::fromTheme(QStringLiteral("dialog-scripts")));
|
2012-07-18 02:47:10 +00:00
|
|
|
m_openTerminalAction->setText(i18nc("@action:inmenu Tools", "Open &Terminal"));
|
2014-04-10 14:53:41 +00:00
|
|
|
connect(m_openTerminalAction, &QAction::triggered, this, &DolphinPart::slotOpenTerminal);
|
2014-09-14 20:49:25 +00:00
|
|
|
actionCollection()->setDefaultShortcut(m_openTerminalAction, Qt::Key_F4);
|
2008-06-04 11:51:54 +00:00
|
|
|
}
|
2018-01-21 11:15:07 +00:00
|
|
|
#endif
|
2007-12-24 11:17:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinPart::createGoAction(const char *name, const char *iconName, const QString &text, const QString &url, QActionGroup *actionGroup)
|
|
|
|
{
|
2014-04-06 01:32:55 +00:00
|
|
|
QAction *action = actionCollection()->addAction(name);
|
|
|
|
action->setIcon(QIcon::fromTheme(iconName));
|
2007-12-24 11:17:16 +00:00
|
|
|
action->setText(text);
|
|
|
|
action->setData(url);
|
|
|
|
action->setActionGroup(actionGroup);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinPart::slotGoTriggered(QAction *action)
|
|
|
|
{
|
|
|
|
const QString url = action->data().toString();
|
2020-10-23 17:51:33 +00:00
|
|
|
Q_EMIT m_extension->openUrlRequest(QUrl(url));
|
2007-11-15 14:59:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinPart::slotSelectionChanged(const KFileItemList &selection)
|
|
|
|
{
|
2007-11-15 20:04:05 +00:00
|
|
|
const bool hasSelection = !selection.isEmpty();
|
2008-06-02 10:07:13 +00:00
|
|
|
|
2017-08-09 20:59:38 +00:00
|
|
|
QAction *renameAction = actionCollection()->action(KStandardAction::name(KStandardAction::RenameFile));
|
2017-07-18 22:00:37 +00:00
|
|
|
QAction *moveToTrashAction = actionCollection()->action(KStandardAction::name(KStandardAction::MoveToTrash));
|
2017-03-10 18:31:33 +00:00
|
|
|
QAction *deleteAction = actionCollection()->action(KStandardAction::name(KStandardAction::DeleteFile));
|
2016-03-16 21:17:37 +00:00
|
|
|
QAction *editMimeTypeAction = actionCollection()->action(QStringLiteral("editMimeType"));
|
|
|
|
QAction *propertiesAction = actionCollection()->action(QStringLiteral("properties"));
|
|
|
|
QAction *deleteWithTrashShortcut = actionCollection()->action(QStringLiteral("delete_shortcut")); // see DolphinViewActionHandler
|
2008-06-02 10:07:13 +00:00
|
|
|
|
2007-11-15 20:04:05 +00:00
|
|
|
if (!hasSelection) {
|
2016-03-16 21:17:37 +00:00
|
|
|
stateChanged(QStringLiteral("has_no_selection"));
|
2008-06-02 10:07:13 +00:00
|
|
|
|
2020-10-23 17:51:33 +00:00
|
|
|
Q_EMIT m_extension->enableAction("cut", false);
|
|
|
|
Q_EMIT m_extension->enableAction("copy", false);
|
2008-06-05 22:25:07 +00:00
|
|
|
deleteWithTrashShortcut->setEnabled(false);
|
2008-06-02 10:07:13 +00:00
|
|
|
editMimeTypeAction->setEnabled(false);
|
2007-11-15 14:59:02 +00:00
|
|
|
} else {
|
2016-03-16 21:17:37 +00:00
|
|
|
stateChanged(QStringLiteral("has_selection"));
|
2007-11-15 14:59:02 +00:00
|
|
|
|
2008-06-05 22:25:07 +00:00
|
|
|
// TODO share this code with DolphinMainWindow::updateEditActions (and the desktop code)
|
|
|
|
// in libkonq
|
2009-04-01 23:34:33 +00:00
|
|
|
KFileItemListProperties capabilities(selection);
|
2008-06-02 10:07:13 +00:00
|
|
|
const bool enableMoveToTrash = capabilities.isLocal() && capabilities.supportsMoving();
|
2008-06-04 11:51:54 +00:00
|
|
|
|
2008-06-02 10:07:13 +00:00
|
|
|
renameAction->setEnabled(capabilities.supportsMoving());
|
|
|
|
moveToTrashAction->setEnabled(enableMoveToTrash);
|
|
|
|
deleteAction->setEnabled(capabilities.supportsDeleting());
|
2008-06-05 22:25:07 +00:00
|
|
|
deleteWithTrashShortcut->setEnabled(capabilities.supportsDeleting() && !enableMoveToTrash);
|
2008-06-02 10:07:13 +00:00
|
|
|
editMimeTypeAction->setEnabled(true);
|
|
|
|
propertiesAction->setEnabled(true);
|
2020-10-23 17:51:33 +00:00
|
|
|
Q_EMIT m_extension->enableAction("cut", capabilities.supportsMoving());
|
|
|
|
Q_EMIT m_extension->enableAction("copy", true);
|
2007-11-15 14:59:02 +00:00
|
|
|
}
|
2007-11-15 20:04:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinPart::updatePasteAction()
|
|
|
|
{
|
|
|
|
QPair<bool, QString> pasteInfo = m_view->pasteInfo();
|
2020-10-23 17:51:33 +00:00
|
|
|
Q_EMIT m_extension->enableAction("paste", pasteInfo.first);
|
|
|
|
Q_EMIT m_extension->setActionText("paste", pasteInfo.second);
|
2007-10-10 23:01:35 +00:00
|
|
|
}
|
|
|
|
|
2020-03-10 16:11:49 +00:00
|
|
|
QString DolphinPart::urlToLocalFilePath(const QUrl &url)
|
|
|
|
{
|
|
|
|
KIO::StatJob *statJob = KIO::mostLocalUrl(url);
|
|
|
|
KJobWidgets::setWindow(statJob, widget());
|
|
|
|
statJob->exec();
|
|
|
|
QUrl localUrl = statJob->mostLocalUrl();
|
|
|
|
if (localUrl.isLocalFile()) {
|
|
|
|
return localUrl.toLocalFile();
|
|
|
|
}
|
|
|
|
return QString();
|
|
|
|
}
|
|
|
|
|
2014-04-10 01:02:40 +00:00
|
|
|
bool DolphinPart::openUrl(const QUrl &url)
|
2007-07-01 14:25:21 +00:00
|
|
|
{
|
2008-05-05 00:42:33 +00:00
|
|
|
bool reload = arguments().reload();
|
|
|
|
// A bit of a workaround so that changing the namefilter works: force reload.
|
|
|
|
// Otherwise DolphinView wouldn't relist the URL, so nothing would happen.
|
2011-01-09 13:58:35 +00:00
|
|
|
if (m_nameFilter != m_view->nameFilter())
|
2008-05-05 00:42:33 +00:00
|
|
|
reload = true;
|
2007-08-28 21:47:20 +00:00
|
|
|
if (m_view->url() == url && !reload) { // DolphinView won't do anything in that case, so don't emit started
|
|
|
|
return true;
|
|
|
|
}
|
2020-03-10 16:11:49 +00:00
|
|
|
setUrl(url); // remember url at the KParts level
|
|
|
|
setLocalFilePath(urlToLocalFilePath(url)); // remember local path at the KParts level
|
2014-10-21 19:18:43 +00:00
|
|
|
QUrl visibleUrl(url);
|
2008-05-05 00:42:33 +00:00
|
|
|
if (!m_nameFilter.isEmpty()) {
|
2014-10-21 19:18:43 +00:00
|
|
|
visibleUrl.setPath(visibleUrl.path() + '/' + m_nameFilter);
|
2008-05-05 00:42:33 +00:00
|
|
|
}
|
2014-10-21 19:18:43 +00:00
|
|
|
QString prettyUrl = visibleUrl.toDisplayString(QUrl::PreferLocalFile);
|
2020-10-23 17:51:33 +00:00
|
|
|
Q_EMIT setWindowCaption(prettyUrl);
|
|
|
|
Q_EMIT m_extension->setLocationBarUrl(prettyUrl);
|
|
|
|
Q_EMIT started(nullptr); // get the wheel to spin
|
2011-01-09 13:58:35 +00:00
|
|
|
m_view->setNameFilter(m_nameFilter);
|
2007-07-01 14:25:21 +00:00
|
|
|
m_view->setUrl(url);
|
2009-03-10 00:56:38 +00:00
|
|
|
updatePasteAction();
|
2020-10-23 17:51:33 +00:00
|
|
|
Q_EMIT aboutToOpenURL();
|
2007-08-28 21:47:20 +00:00
|
|
|
if (reload)
|
2007-07-02 17:24:54 +00:00
|
|
|
m_view->reload();
|
2012-07-18 02:47:10 +00:00
|
|
|
// Disable "Find File" and "Open Terminal" actions for non-file URLs,
|
|
|
|
// e.g. ftp, smb, etc. #279283
|
2020-03-10 16:11:49 +00:00
|
|
|
const bool isLocalUrl = !(localFilePath().isEmpty());
|
2012-07-18 02:47:10 +00:00
|
|
|
m_findFileAction->setEnabled(isLocalUrl);
|
|
|
|
if (m_openTerminalAction) {
|
|
|
|
m_openTerminalAction->setEnabled(isLocalUrl);
|
|
|
|
}
|
2007-07-01 14:25:21 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-07-29 21:56:37 +00:00
|
|
|
void DolphinPart::slotMessage(const QString &msg)
|
2007-07-02 17:24:54 +00:00
|
|
|
{
|
2020-10-23 17:51:33 +00:00
|
|
|
Q_EMIT setStatusBarText(msg);
|
2007-07-02 17:24:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinPart::slotErrorMessage(const QString &msg)
|
|
|
|
{
|
2015-02-24 16:07:55 +00:00
|
|
|
qCDebug(DolphinDebug) << msg;
|
2020-10-23 17:51:33 +00:00
|
|
|
Q_EMIT canceled(msg);
|
2010-08-30 08:56:19 +00:00
|
|
|
//KMessageBox::error(m_view, msg);
|
2007-07-02 17:24:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinPart::slotRequestItemInfo(const KFileItem &item)
|
|
|
|
{
|
2020-10-23 17:51:33 +00:00
|
|
|
Q_EMIT m_extension->mouseOverInfo(item);
|
2008-10-05 18:11:46 +00:00
|
|
|
if (item.isNull()) {
|
|
|
|
updateStatusBar();
|
|
|
|
} else {
|
2013-08-01 12:14:40 +00:00
|
|
|
const QString escapedText = Qt::convertFromPlainText(item.getStatusBarInfo());
|
2020-10-23 17:51:33 +00:00
|
|
|
Q_EMIT ReadOnlyPart::setStatusBarText(QStringLiteral("<qt>%1</qt>").arg(escapedText));
|
2008-10-05 18:11:46 +00:00
|
|
|
}
|
2007-07-02 17:24:54 +00:00
|
|
|
}
|
|
|
|
|
2011-08-29 18:13:39 +00:00
|
|
|
void DolphinPart::slotItemActivated(const KFileItem &item)
|
2007-08-28 17:50:54 +00:00
|
|
|
{
|
2008-01-04 14:40:31 +00:00
|
|
|
KParts::OpenUrlArguments args;
|
2010-07-09 13:15:02 +00:00
|
|
|
// Forget about the known mimetype if a target URL is used.
|
|
|
|
// Testcase: network:/ with a item (mimetype "inode/some-foo-service") pointing to a http URL (html)
|
|
|
|
if (item.targetUrl() == item.url()) {
|
|
|
|
args.setMimeType(item.mimetype());
|
|
|
|
}
|
2008-01-04 14:40:31 +00:00
|
|
|
|
|
|
|
// Ideally, konqueror should be changed to not require trustedSource for directory views,
|
|
|
|
// since the idea was not to need BrowserArguments for non-browser stuff...
|
|
|
|
KParts::BrowserArguments browserArgs;
|
|
|
|
browserArgs.trustedSource = true;
|
2020-10-23 17:51:33 +00:00
|
|
|
Q_EMIT m_extension->openUrlRequest(item.targetUrl(), args, browserArgs);
|
2008-04-23 20:57:58 +00:00
|
|
|
}
|
2008-01-04 14:40:31 +00:00
|
|
|
|
2012-12-13 21:54:09 +00:00
|
|
|
void DolphinPart::slotItemsActivated(const KFileItemList &items)
|
|
|
|
{
|
2020-10-23 17:48:22 +00:00
|
|
|
for (const KFileItem &item : items) {
|
2012-12-13 21:54:09 +00:00
|
|
|
slotItemActivated(item);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-10-20 22:27:42 +00:00
|
|
|
void DolphinPart::createNewWindow(const QUrl &url)
|
2008-04-23 20:57:58 +00:00
|
|
|
{
|
|
|
|
// TODO: Check issue N176832 for the missing QAIV signal; task 177399 - maybe this code
|
2011-08-29 18:13:39 +00:00
|
|
|
// should be moved into DolphinPart::slotItemActivated()
|
2020-10-23 17:51:33 +00:00
|
|
|
Q_EMIT m_extension->createNewWindow(url);
|
2007-08-28 17:50:54 +00:00
|
|
|
}
|
|
|
|
|
2011-10-08 19:40:34 +00:00
|
|
|
void DolphinPart::slotOpenContextMenu(const QPoint &pos, const KFileItem &_item, const KFileItemList &selectedItems, const QUrl &)
|
2007-08-28 19:48:36 +00:00
|
|
|
{
|
2007-10-01 17:06:34 +00:00
|
|
|
KParts::BrowserExtension::PopupFlags popupFlags =
|
|
|
|
KParts::BrowserExtension::DefaultPopupItems | KParts::BrowserExtension::ShowProperties | KParts::BrowserExtension::ShowUrlOperations;
|
2007-08-28 19:48:36 +00:00
|
|
|
|
2007-09-19 20:33:28 +00:00
|
|
|
KFileItem item(_item);
|
2007-08-28 19:48:36 +00:00
|
|
|
|
2007-09-19 20:33:28 +00:00
|
|
|
if (item.isNull()) { // viewport context menu
|
2011-01-09 13:58:35 +00:00
|
|
|
item = m_view->rootItem();
|
2008-06-02 02:50:36 +00:00
|
|
|
if (item.isNull())
|
2014-12-14 16:46:58 +00:00
|
|
|
item = KFileItem(url());
|
2009-11-14 01:51:08 +00:00
|
|
|
else
|
|
|
|
item.setUrl(url()); // ensure we use the view url, not the canonical path (#213799)
|
2007-09-19 20:33:28 +00:00
|
|
|
}
|
2007-08-28 19:48:36 +00:00
|
|
|
|
2010-03-14 13:18:09 +00:00
|
|
|
KFileItemList items;
|
2022-04-02 17:00:58 +00:00
|
|
|
if (selectedItems.isEmpty()) {
|
2010-03-14 13:18:09 +00:00
|
|
|
items.append(item);
|
|
|
|
} else {
|
2022-04-02 17:00:58 +00:00
|
|
|
items = selectedItems;
|
2010-03-14 13:18:09 +00:00
|
|
|
}
|
|
|
|
|
2009-11-10 00:07:36 +00:00
|
|
|
KFileItemListProperties capabilities(items);
|
|
|
|
|
2007-11-15 14:59:02 +00:00
|
|
|
KParts::BrowserExtension::ActionGroupMap actionGroups;
|
|
|
|
QList<QAction *> editActions;
|
2009-12-23 08:51:33 +00:00
|
|
|
editActions += m_view->versionControlActions(m_view->selectedItems());
|
2009-02-17 10:57:23 +00:00
|
|
|
|
2008-04-27 22:35:49 +00:00
|
|
|
if (!_item.isNull()) { // only for context menu on one or more items
|
2013-06-24 05:11:16 +00:00
|
|
|
const bool supportsMoving = capabilities.supportsMoving();
|
|
|
|
|
|
|
|
if (capabilities.supportsDeleting()) {
|
2014-10-07 05:38:16 +00:00
|
|
|
const bool showDeleteAction = (KSharedConfig::openConfig()->group("KDE").readEntry("ShowDeleteCommand", false) || !item.isLocalFile());
|
2013-06-24 05:11:16 +00:00
|
|
|
const bool showMoveToTrashAction = capabilities.isLocal() && supportsMoving;
|
|
|
|
|
|
|
|
if (showDeleteAction && showMoveToTrashAction) {
|
|
|
|
delete m_removeAction;
|
2017-11-21 09:52:14 +00:00
|
|
|
m_removeAction = nullptr;
|
2017-07-18 22:00:37 +00:00
|
|
|
editActions.append(actionCollection()->action(KStandardAction::name(KStandardAction::MoveToTrash)));
|
2017-03-10 18:31:33 +00:00
|
|
|
editActions.append(actionCollection()->action(KStandardAction::name(KStandardAction::DeleteFile)));
|
2013-06-24 05:11:16 +00:00
|
|
|
} else if (showDeleteAction && !showMoveToTrashAction) {
|
2017-03-10 18:31:33 +00:00
|
|
|
editActions.append(actionCollection()->action(KStandardAction::name(KStandardAction::DeleteFile)));
|
2013-06-24 05:11:16 +00:00
|
|
|
} else {
|
|
|
|
if (!m_removeAction)
|
|
|
|
m_removeAction = new DolphinRemoveAction(this, actionCollection());
|
|
|
|
editActions.append(m_removeAction);
|
|
|
|
m_removeAction->update();
|
|
|
|
}
|
|
|
|
} else {
|
2008-06-02 02:50:36 +00:00
|
|
|
popupFlags |= KParts::BrowserExtension::NoDeletion;
|
|
|
|
}
|
2008-06-04 11:51:54 +00:00
|
|
|
|
2009-11-10 00:07:36 +00:00
|
|
|
if (supportsMoving) {
|
2017-08-09 20:59:38 +00:00
|
|
|
editActions.append(actionCollection()->action(KStandardAction::name(KStandardAction::RenameFile)));
|
2009-11-10 00:07:36 +00:00
|
|
|
}
|
2007-11-17 00:53:45 +00:00
|
|
|
|
2009-11-10 00:07:36 +00:00
|
|
|
// Normally KonqPopupMenu only shows the "Create new" submenu in the current view
|
2008-10-13 21:54:03 +00:00
|
|
|
// since otherwise the created file would not be visible.
|
|
|
|
// But in treeview mode we should allow it.
|
|
|
|
if (m_view->itemsExpandable())
|
|
|
|
popupFlags |= KParts::BrowserExtension::ShowCreateDirectory;
|
2007-11-17 00:53:45 +00:00
|
|
|
}
|
2008-04-27 22:35:49 +00:00
|
|
|
|
2016-03-16 21:17:37 +00:00
|
|
|
actionGroups.insert(QStringLiteral("editactions"), editActions);
|
2009-02-17 10:57:23 +00:00
|
|
|
|
2020-10-23 17:51:33 +00:00
|
|
|
Q_EMIT m_extension->popupMenu(pos, items, KParts::OpenUrlArguments(), KParts::BrowserArguments(), popupFlags, actionGroups);
|
2007-08-28 19:48:36 +00:00
|
|
|
}
|
|
|
|
|
2014-10-20 22:27:42 +00:00
|
|
|
void DolphinPart::slotDirectoryRedirection(const QUrl &oldUrl, const QUrl &newUrl)
|
2009-01-16 13:21:33 +00:00
|
|
|
{
|
2015-02-24 16:07:55 +00:00
|
|
|
qCDebug(DolphinDebug) << oldUrl << newUrl << "currentUrl=" << url();
|
2014-10-20 22:27:42 +00:00
|
|
|
if (oldUrl.matches(url(), QUrl::StripTrailingSlash /* #207572 */)) {
|
2009-01-16 13:21:33 +00:00
|
|
|
KParts::ReadOnlyPart::setUrl(newUrl);
|
2014-10-20 22:27:42 +00:00
|
|
|
const QString prettyUrl = newUrl.toDisplayString(QUrl::PreferLocalFile);
|
2020-10-23 17:51:33 +00:00
|
|
|
Q_EMIT m_extension->setLocationBarUrl(prettyUrl);
|
2009-01-16 13:21:33 +00:00
|
|
|
}
|
2008-05-28 23:07:09 +00:00
|
|
|
}
|
|
|
|
|
2007-12-24 11:50:08 +00:00
|
|
|
void DolphinPart::slotEditMimeType()
|
|
|
|
{
|
|
|
|
const KFileItemList items = m_view->selectedItems();
|
|
|
|
if (!items.isEmpty()) {
|
2014-10-20 20:13:23 +00:00
|
|
|
KMimeTypeEditor::editMimeType(items.first().mimetype(), m_view);
|
2007-12-24 19:07:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-11-25 08:46:04 +00:00
|
|
|
void DolphinPart::slotSelectItemsMatchingPattern()
|
|
|
|
{
|
|
|
|
openSelectionDialog(i18nc("@title:window", "Select"), i18n("Select all items matching this pattern:"), true);
|
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinPart::slotUnselectItemsMatchingPattern()
|
|
|
|
{
|
|
|
|
openSelectionDialog(i18nc("@title:window", "Unselect"), i18n("Unselect all items matching this pattern:"), false);
|
|
|
|
}
|
|
|
|
|
2010-11-04 17:27:11 +00:00
|
|
|
void DolphinPart::openSelectionDialog(const QString &title, const QString &text, bool selectItems)
|
2009-11-25 08:46:04 +00:00
|
|
|
{
|
2020-09-23 11:07:29 +00:00
|
|
|
auto *dialog = new QInputDialog(m_view);
|
|
|
|
dialog->setAttribute(Qt::WA_DeleteOnClose, true);
|
|
|
|
dialog->setInputMode(QInputDialog::TextInput);
|
|
|
|
dialog->setWindowTitle(title);
|
|
|
|
dialog->setLabelText(text);
|
|
|
|
|
|
|
|
const KConfigGroup group = KSharedConfig::openConfig("dolphinpartrc")->group("Select Dialog");
|
|
|
|
dialog->setComboBoxEditable(true);
|
|
|
|
dialog->setComboBoxItems(group.readEntry("History", QStringList()));
|
|
|
|
|
|
|
|
dialog->setTextValue(QStringLiteral("*"));
|
|
|
|
|
|
|
|
connect(dialog, &QDialog::accepted, this, [=]() {
|
|
|
|
const QString pattern = dialog->textValue();
|
|
|
|
if (!pattern.isEmpty()) {
|
|
|
|
QStringList items = dialog->comboBoxItems();
|
|
|
|
items.removeAll(pattern);
|
|
|
|
items.prepend(pattern);
|
|
|
|
|
|
|
|
// Need to evaluate this again here, because the captured value is const
|
|
|
|
// (even if the const were removed from 'const KConfigGroup group =' above).
|
|
|
|
KConfigGroup group = KSharedConfig::openConfig("dolphinpartrc")->group("Select Dialog");
|
|
|
|
// Limit the size of the saved history.
|
|
|
|
group.writeEntry("History", items.mid(0, 10));
|
|
|
|
group.sync();
|
|
|
|
|
|
|
|
const QRegularExpression patternRegExp(QRegularExpression::wildcardToRegularExpression(pattern));
|
|
|
|
m_view->selectItems(patternRegExp, selectItems);
|
|
|
|
}
|
|
|
|
});
|
2009-11-25 08:46:04 +00:00
|
|
|
|
2020-09-23 11:07:29 +00:00
|
|
|
dialog->open();
|
2009-11-25 08:46:04 +00:00
|
|
|
}
|
|
|
|
|
2008-02-13 18:45:20 +00:00
|
|
|
void DolphinPart::setCurrentViewMode(const QString &viewModeName)
|
|
|
|
{
|
|
|
|
QAction *action = actionCollection()->action(viewModeName);
|
|
|
|
Q_ASSERT(action);
|
|
|
|
action->trigger();
|
|
|
|
}
|
|
|
|
|
|
|
|
QString DolphinPart::currentViewMode() const
|
|
|
|
{
|
|
|
|
return m_actionHandler->currentViewModeActionName();
|
|
|
|
}
|
|
|
|
|
2008-05-05 00:42:33 +00:00
|
|
|
void DolphinPart::setNameFilter(const QString &nameFilter)
|
|
|
|
{
|
|
|
|
// This is the "/home/dfaure/*.diff" kind of name filter (KDirLister::setNameFilter)
|
|
|
|
// which is unrelated to DolphinView::setNameFilter which is substring filtering in a proxy.
|
|
|
|
m_nameFilter = nameFilter;
|
|
|
|
// TODO save/restore name filter in saveState/restoreState like KonqDirPart did in kde3?
|
|
|
|
}
|
|
|
|
|
2020-03-10 16:11:49 +00:00
|
|
|
QString DolphinPart::localFilePathOrHome() const
|
|
|
|
{
|
|
|
|
const QString localPath = localFilePath();
|
|
|
|
if (!localPath.isEmpty()) {
|
|
|
|
return localPath;
|
|
|
|
}
|
|
|
|
return QDir::homePath();
|
|
|
|
}
|
|
|
|
|
2008-06-04 11:51:54 +00:00
|
|
|
void DolphinPart::slotOpenTerminal()
|
|
|
|
{
|
2021-08-31 15:09:14 +00:00
|
|
|
auto job = new KTerminalLauncherJob(QString());
|
|
|
|
job->setWorkingDirectory(localFilePathOrHome());
|
|
|
|
job->start();
|
2008-06-05 19:19:14 +00:00
|
|
|
}
|
|
|
|
|
2011-04-10 16:32:53 +00:00
|
|
|
void DolphinPart::slotFindFile()
|
|
|
|
{
|
2019-11-17 17:14:27 +00:00
|
|
|
QMenu searchTools;
|
|
|
|
KMoreToolsMenuFactory("dolphin/search-tools").fillMenuFromGroupingNames(&searchTools, {"files-find"}, QUrl::fromLocalFile(localFilePathOrHome()));
|
|
|
|
QList<QAction *> actions = searchTools.actions();
|
|
|
|
if (!(actions.isEmpty())) {
|
|
|
|
actions.first()->trigger();
|
|
|
|
} else {
|
2020-04-13 22:11:16 +00:00
|
|
|
KIO::CommandLauncherJob *job = new KIO::CommandLauncherJob(QStringLiteral("kfind"), {url().toString()}, this);
|
|
|
|
job->setDesktopName(QStringLiteral("org.kde.kfind"));
|
|
|
|
job->setUiDelegate(new KDialogJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled, widget()));
|
|
|
|
job->start();
|
2019-11-17 17:14:27 +00:00
|
|
|
}
|
2011-04-10 16:32:53 +00:00
|
|
|
}
|
|
|
|
|
2008-06-05 19:19:14 +00:00
|
|
|
void DolphinPart::updateNewMenu()
|
|
|
|
{
|
2010-01-26 12:04:56 +00:00
|
|
|
// As requested by KNewFileMenu :
|
2010-08-27 05:26:27 +00:00
|
|
|
m_newFileMenu->checkUpToDate();
|
2008-06-05 19:19:14 +00:00
|
|
|
// And set the files that the menu apply on :
|
2021-12-14 20:47:20 +00:00
|
|
|
#if KIO_VERSION >= QT_VERSION_CHECK(5, 97, 0)
|
|
|
|
m_newFileMenu->setWorkingDirectory(url());
|
|
|
|
#else
|
2019-12-06 12:31:43 +00:00
|
|
|
m_newFileMenu->setPopupFiles(QList<QUrl>() << url());
|
2021-12-14 20:47:20 +00:00
|
|
|
#endif
|
2008-06-04 11:51:54 +00:00
|
|
|
}
|
|
|
|
|
2008-10-05 18:11:46 +00:00
|
|
|
void DolphinPart::updateStatusBar()
|
|
|
|
{
|
2021-02-08 21:32:10 +00:00
|
|
|
m_view->requestStatusBarText();
|
2008-10-05 18:11:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void DolphinPart::updateProgress(int percent)
|
|
|
|
{
|
2020-10-23 17:51:33 +00:00
|
|
|
Q_EMIT m_extension->loadingProgress(percent);
|
2008-10-05 18:11:46 +00:00
|
|
|
}
|
|
|
|
|
2009-03-26 18:44:36 +00:00
|
|
|
void DolphinPart::createDirectory()
|
|
|
|
{
|
2021-12-14 20:47:20 +00:00
|
|
|
#if KIO_VERSION >= QT_VERSION_CHECK(5, 97, 0)
|
|
|
|
m_newFileMenu->setWorkingDirectory(url());
|
|
|
|
#else
|
2019-12-06 12:31:43 +00:00
|
|
|
m_newFileMenu->setPopupFiles(QList<QUrl>() << url());
|
2021-12-14 20:47:20 +00:00
|
|
|
#endif
|
2010-08-27 05:26:27 +00:00
|
|
|
m_newFileMenu->createDirectory();
|
2009-03-26 18:44:36 +00:00
|
|
|
}
|
|
|
|
|
2014-10-20 22:27:42 +00:00
|
|
|
void DolphinPart::setFilesToSelect(const QList<QUrl> &files)
|
2010-01-27 23:55:55 +00:00
|
|
|
{
|
2012-08-27 17:55:17 +00:00
|
|
|
if (files.isEmpty()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-01-27 23:55:55 +00:00
|
|
|
m_view->markUrlsAsSelected(files);
|
2012-08-27 17:55:17 +00:00
|
|
|
m_view->markUrlAsCurrent(files.at(0));
|
2010-01-27 23:55:55 +00:00
|
|
|
}
|
|
|
|
|
2013-02-09 20:56:51 +00:00
|
|
|
bool DolphinPart::eventFilter(QObject *obj, QEvent *event)
|
|
|
|
{
|
2017-08-24 16:33:27 +00:00
|
|
|
using ShiftState = DolphinRemoveAction::ShiftState;
|
2013-02-09 20:56:51 +00:00
|
|
|
const int type = event->type();
|
|
|
|
|
|
|
|
if ((type == QEvent::KeyPress || type == QEvent::KeyRelease) && m_removeAction) {
|
|
|
|
QMenu *menu = qobject_cast<QMenu *>(obj);
|
|
|
|
if (menu && menu->parent() == m_view) {
|
|
|
|
QKeyEvent *ev = static_cast<QKeyEvent *>(event);
|
|
|
|
if (ev->key() == Qt::Key_Shift) {
|
2017-08-24 16:33:27 +00:00
|
|
|
m_removeAction->update(type == QEvent::KeyPress ? ShiftState::Pressed : ShiftState::Released);
|
2013-02-09 20:56:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return KParts::ReadOnlyPart::eventFilter(obj, event);
|
|
|
|
}
|
|
|
|
|
2007-07-01 14:25:21 +00:00
|
|
|
#include "dolphinpart.moc"
|
2023-07-04 20:07:48 +00:00
|
|
|
#include "moc_dolphinpart.cpp"
|