1 /* This file is part of the KDE project
2 SPDX-FileCopyrightText: 2007 David Faure <faure@kde.org>
4 SPDX-License-Identifier: LGPL-2.0-or-later
7 #include "dolphinpart.h"
9 #include "dolphindebug.h"
10 #include "dolphinnewfilemenu.h"
11 #include "dolphinpart_ext.h"
12 #include "dolphinremoveaction.h"
13 #include "kitemviews/kfileitemmodel.h"
14 #include "views/dolphinnewfilemenuobserver.h"
15 #include "views/dolphinremoteencoding.h"
16 #include "views/dolphinview.h"
17 #include "views/dolphinviewactionhandler.h"
19 #include <KActionCollection>
20 #include <KAuthorized>
21 #include <KConfigGroup>
22 #include <KDialogJobUiDelegate>
24 #include <KFileItemListProperties>
25 #include <KIO/CommandLauncherJob>
26 #include <KIconLoader>
27 #include <KJobWidgets>
28 #include <KLocalizedString>
29 #include <KMessageBox>
30 #include <KMimeTypeEditor>
31 #include <KPluginFactory>
32 #include <KPluginMetaData>
33 #include <KSharedConfig>
34 #include <KTerminalLauncherJob>
36 #include <QActionGroup>
37 #include <QApplication>
40 #include <QInputDialog>
43 #include <QRegularExpression>
44 #include <QStandardPaths>
45 #include <QTextDocument>
47 #include <KPluginFactory>
50 K_PLUGIN_CLASS_WITH_JSON(DolphinPart
, "dolphinpart.json")
52 DolphinPart::DolphinPart(QWidget
*parentWidget
, QObject
*parent
, const KPluginMetaData
&metaData
, const QVariantList
&args
)
53 : KParts::ReadOnlyPart(parent
, metaData
)
54 , m_openTerminalAction(nullptr)
55 , m_removeAction(nullptr)
59 m_extension
= new DolphinPartBrowserExtension(this);
61 // make sure that other apps using this part find Dolphin's view-file-columns icons
62 KIconLoader::global()->addAppDir(QStringLiteral("dolphin"));
64 m_view
= new DolphinView(QUrl(), parentWidget
);
65 m_view
->setTabsForFilesEnabled(true);
68 connect(&DolphinNewFileMenuObserver::instance(), &DolphinNewFileMenuObserver::errorMessage
, this, &DolphinPart::slotErrorMessage
);
70 connect(m_view
, &DolphinView::directoryLoadingCompleted
, this, &KParts::ReadOnlyPart::completed
);
71 connect(m_view
, &DolphinView::directoryLoadingCompleted
, this, &DolphinPart::updatePasteAction
);
72 connect(m_view
, &DolphinView::directoryLoadingProgress
, this, &DolphinPart::updateProgress
);
73 connect(m_view
, &DolphinView::errorMessage
, this, &DolphinPart::slotErrorMessage
);
75 setXMLFile(QStringLiteral("dolphinpart.rc"));
77 connect(m_view
, &DolphinView::infoMessage
, this, &DolphinPart::slotMessage
);
78 connect(m_view
, &DolphinView::operationCompletedMessage
, this, &DolphinPart::slotMessage
);
79 connect(m_view
, &DolphinView::errorMessage
, this, &DolphinPart::slotErrorMessage
);
80 connect(m_view
, &DolphinView::itemActivated
, this, &DolphinPart::slotItemActivated
);
81 connect(m_view
, &DolphinView::itemsActivated
, this, &DolphinPart::slotItemsActivated
);
82 connect(m_view
, &DolphinView::statusBarTextChanged
, this, [this](const QString
&text
) {
83 const QString escapedText
= Qt::convertFromPlainText(text
);
84 Q_EMIT
ReadOnlyPart::setStatusBarText(QStringLiteral("<qt>%1</qt>").arg(escapedText
));
86 connect(m_view
, &DolphinView::tabRequested
, this, &DolphinPart::createNewWindow
);
87 connect(m_view
, &DolphinView::requestContextMenu
, this, &DolphinPart::slotOpenContextMenu
);
88 connect(m_view
, &DolphinView::selectionChanged
, m_extension
, &KParts::NavigationExtension::selectionInfo
);
89 connect(m_view
, &DolphinView::selectionChanged
, this, &DolphinPart::slotSelectionChanged
);
90 connect(m_view
, &DolphinView::requestItemInfo
, this, &DolphinPart::slotRequestItemInfo
);
91 connect(m_view
, &DolphinView::modeChanged
, this, &DolphinPart::viewModeChanged
); // relay signal
92 connect(m_view
, &DolphinView::redirection
, this, &DolphinPart::slotDirectoryRedirection
);
94 // Watch for changes that should result in updates to the
96 connect(m_view
, &DolphinView::itemCountChanged
, this, &DolphinPart::updateStatusBar
);
97 connect(m_view
, &DolphinView::selectionChanged
, this, &DolphinPart::updateStatusBar
);
99 m_actionHandler
= new DolphinViewActionHandler(actionCollection(), nullptr, this);
100 m_actionHandler
->setCurrentView(m_view
);
101 connect(m_actionHandler
, &DolphinViewActionHandler::createDirectoryTriggered
, this, &DolphinPart::createDirectory
);
103 m_remoteEncoding
= new DolphinRemoteEncoding(this, m_actionHandler
);
104 connect(this, &DolphinPart::aboutToOpenURL
, m_remoteEncoding
, &DolphinRemoteEncoding::slotAboutToOpenUrl
);
106 QClipboard
*clipboard
= QApplication::clipboard();
107 connect(clipboard
, &QClipboard::dataChanged
, this, &DolphinPart::updatePasteAction
);
109 // Create file info and listing filter extensions.
110 // NOTE: Listing filter needs to be instantiated after the creation of the view.
111 new DolphinPartFileInfoExtension(this);
113 new DolphinPartListingFilterExtension(this);
115 KDirLister
*lister
= m_view
->m_model
->m_dirLister
;
117 DolphinPartListingNotificationExtension
*notifyExt
= new DolphinPartListingNotificationExtension(this);
118 connect(lister
, &KDirLister::newItems
, notifyExt
, &DolphinPartListingNotificationExtension::slotNewItems
);
119 connect(lister
, &KDirLister::itemsDeleted
, notifyExt
, &DolphinPartListingNotificationExtension::slotItemsDeleted
);
121 qCWarning(DolphinDebug
) << "NULL KDirLister object! KParts::ListingNotificationExtension will NOT be supported";
125 m_actionHandler
->updateViewActions();
126 slotSelectionChanged(KFileItemList()); // initially disable selection-dependent actions
128 // Listen to events from the app so we can update the remove key by
129 // checking for a Shift key press.
130 qApp
->installEventFilter(this);
132 // TODO there was a "always open a new window" (when clicking on a directory) setting in konqueror
133 // (sort of spacial navigation)
136 DolphinPart::~DolphinPart()
140 void DolphinPart::createActions()
143 QAction
*newDirAction
= actionCollection()->action(QStringLiteral("create_dir"));
144 QAction
*newFileAction
= actionCollection()->action(QStringLiteral("create_file"));
145 m_newFileMenu
= new DolphinNewFileMenu(newDirAction
, newFileAction
, this);
146 m_newFileMenu
->setParentWidget(widget());
147 connect(m_newFileMenu
->menu(), &QMenu::aboutToShow
, this, &DolphinPart::updateNewMenu
);
149 QAction
*editMimeTypeAction
= actionCollection()->addAction(QStringLiteral("editMimeType"));
150 editMimeTypeAction
->setText(i18nc("@action:inmenu Edit", "&Edit File Type…"));
151 connect(editMimeTypeAction
, &QAction::triggered
, this, &DolphinPart::slotEditMimeType
);
153 QAction
*selectItemsMatching
= actionCollection()->addAction(QStringLiteral("select_items_matching"));
154 selectItemsMatching
->setText(i18nc("@action:inmenu Edit", "Select Items Matching…"));
155 actionCollection()->setDefaultShortcut(selectItemsMatching
, Qt::CTRL
| Qt::Key_S
);
156 connect(selectItemsMatching
, &QAction::triggered
, this, &DolphinPart::slotSelectItemsMatchingPattern
);
158 QAction
*unselectItemsMatching
= actionCollection()->addAction(QStringLiteral("unselect_items_matching"));
159 unselectItemsMatching
->setText(i18nc("@action:inmenu Edit", "Unselect Items Matching…"));
160 connect(unselectItemsMatching
, &QAction::triggered
, this, &DolphinPart::slotUnselectItemsMatchingPattern
);
162 KStandardAction::selectAll(m_view
, &DolphinView::selectAll
, actionCollection());
164 QAction
*unselectAll
= actionCollection()->addAction(QStringLiteral("unselect_all"));
165 unselectAll
->setText(i18nc("@action:inmenu Edit", "Unselect All"));
166 connect(unselectAll
, &QAction::triggered
, m_view
, &DolphinView::clearSelection
);
168 QAction
*invertSelection
= actionCollection()->addAction(QStringLiteral("invert_selection"));
169 invertSelection
->setText(i18nc("@action:inmenu Edit", "Invert Selection"));
170 actionCollection()->setDefaultShortcut(invertSelection
, Qt::CTRL
| Qt::SHIFT
| Qt::Key_A
);
171 connect(invertSelection
, &QAction::triggered
, m_view
, &DolphinView::invertSelection
);
173 // View menu: all done by DolphinViewActionHandler
177 QActionGroup
*goActionGroup
= new QActionGroup(this);
178 connect(goActionGroup
, &QActionGroup::triggered
, this, &DolphinPart::slotGoTriggered
);
180 createGoAction("go_applications", "start-here-kde", i18nc("@action:inmenu Go", "App&lications"), QStringLiteral("programs:/"), goActionGroup
);
181 createGoAction("go_network_folders", "folder-remote", i18nc("@action:inmenu Go", "&Network Folders"), QStringLiteral("remote:/"), goActionGroup
);
182 createGoAction("go_trash", "user-trash", i18nc("@action:inmenu Go", "Trash"), QStringLiteral("trash:/"), goActionGroup
);
183 createGoAction("go_autostart",
185 i18nc("@action:inmenu Go", "Autostart"),
186 QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation
) + "/autostart",
190 m_findFileAction
= KStandardAction::find(this, &DolphinPart::slotFindFile
, actionCollection());
191 m_findFileAction
->setText(i18nc("@action:inmenu Tools", "Find File…"));
194 if (KAuthorized::authorize(QStringLiteral("shell_access"))) {
195 m_openTerminalAction
= actionCollection()->addAction(QStringLiteral("open_terminal"));
196 m_openTerminalAction
->setIcon(QIcon::fromTheme(QStringLiteral("dialog-scripts")));
197 m_openTerminalAction
->setText(i18nc("@action:inmenu Tools", "Open &Terminal"));
198 connect(m_openTerminalAction
, &QAction::triggered
, this, &DolphinPart::slotOpenTerminal
);
199 actionCollection()->setDefaultShortcut(m_openTerminalAction
, Qt::Key_F4
);
204 void DolphinPart::createGoAction(const char *name
, const char *iconName
, const QString
&text
, const QString
&url
, QActionGroup
*actionGroup
)
206 QAction
*action
= actionCollection()->addAction(name
);
207 action
->setIcon(QIcon::fromTheme(iconName
));
208 action
->setText(text
);
209 action
->setData(url
);
210 action
->setActionGroup(actionGroup
);
213 void DolphinPart::slotGoTriggered(QAction
*action
)
215 const QString url
= action
->data().toString();
216 Q_EMIT m_extension
->openUrlRequest(QUrl(url
));
219 void DolphinPart::slotSelectionChanged(const KFileItemList
&selection
)
221 const bool hasSelection
= !selection
.isEmpty();
223 QAction
*renameAction
= actionCollection()->action(KStandardAction::name(KStandardAction::RenameFile
));
224 QAction
*moveToTrashAction
= actionCollection()->action(KStandardAction::name(KStandardAction::MoveToTrash
));
225 QAction
*deleteAction
= actionCollection()->action(KStandardAction::name(KStandardAction::DeleteFile
));
226 QAction
*editMimeTypeAction
= actionCollection()->action(QStringLiteral("editMimeType"));
227 QAction
*propertiesAction
= actionCollection()->action(QStringLiteral("properties"));
228 QAction
*deleteWithTrashShortcut
= actionCollection()->action(QStringLiteral("delete_shortcut")); // see DolphinViewActionHandler
231 stateChanged(QStringLiteral("has_no_selection"));
233 Q_EMIT m_extension
->enableAction("cut", false);
234 Q_EMIT m_extension
->enableAction("copy", false);
235 deleteWithTrashShortcut
->setEnabled(false);
236 editMimeTypeAction
->setEnabled(false);
238 stateChanged(QStringLiteral("has_selection"));
240 // TODO share this code with DolphinMainWindow::updateEditActions (and the desktop code)
242 KFileItemListProperties
capabilities(selection
);
243 const bool enableMoveToTrash
= capabilities
.isLocal() && capabilities
.supportsMoving();
245 renameAction
->setEnabled(capabilities
.supportsMoving());
246 moveToTrashAction
->setEnabled(enableMoveToTrash
);
247 deleteAction
->setEnabled(capabilities
.supportsDeleting());
248 deleteWithTrashShortcut
->setEnabled(capabilities
.supportsDeleting() && !enableMoveToTrash
);
249 editMimeTypeAction
->setEnabled(true);
250 propertiesAction
->setEnabled(true);
251 Q_EMIT m_extension
->enableAction("cut", capabilities
.supportsMoving());
252 Q_EMIT m_extension
->enableAction("copy", true);
256 void DolphinPart::updatePasteAction()
258 QPair
<bool, QString
> pasteInfo
= m_view
->pasteInfo();
259 Q_EMIT m_extension
->enableAction("paste", pasteInfo
.first
);
260 Q_EMIT m_extension
->setActionText("paste", pasteInfo
.second
);
263 QString
DolphinPart::urlToLocalFilePath(const QUrl
&url
)
265 KIO::StatJob
*statJob
= KIO::mostLocalUrl(url
);
266 KJobWidgets::setWindow(statJob
, widget());
268 QUrl localUrl
= statJob
->mostLocalUrl();
269 if (localUrl
.isLocalFile()) {
270 return localUrl
.toLocalFile();
275 bool DolphinPart::openUrl(const QUrl
&url
)
277 bool reload
= arguments().reload();
278 // A bit of a workaround so that changing the namefilter works: force reload.
279 // Otherwise DolphinView wouldn't relist the URL, so nothing would happen.
280 if (m_nameFilter
!= m_view
->nameFilter())
282 if (m_view
->url() == url
&& !reload
) { // DolphinView won't do anything in that case, so don't emit started
285 setUrl(url
); // remember url at the KParts level
286 setLocalFilePath(urlToLocalFilePath(url
)); // remember local path at the KParts level
287 QUrl
visibleUrl(url
);
288 if (!m_nameFilter
.isEmpty()) {
289 visibleUrl
.setPath(visibleUrl
.path() + '/' + m_nameFilter
);
291 QString prettyUrl
= visibleUrl
.toDisplayString(QUrl::PreferLocalFile
);
292 Q_EMIT
setWindowCaption(prettyUrl
);
293 Q_EMIT m_extension
->setLocationBarUrl(prettyUrl
);
294 Q_EMIT
started(nullptr); // get the wheel to spin
295 m_view
->setNameFilter(m_nameFilter
);
298 Q_EMIT
aboutToOpenURL();
301 // Disable "Find File" and "Open Terminal" actions for non-file URLs,
302 // e.g. ftp, smb, etc. #279283
303 const bool isLocalUrl
= !(localFilePath().isEmpty());
304 m_findFileAction
->setEnabled(isLocalUrl
);
305 if (m_openTerminalAction
) {
306 m_openTerminalAction
->setEnabled(isLocalUrl
);
311 void DolphinPart::slotMessage(const QString
&msg
)
313 Q_EMIT
setStatusBarText(msg
);
316 void DolphinPart::slotErrorMessage(const QString
&msg
)
318 qCDebug(DolphinDebug
) << msg
;
319 Q_EMIT
canceled(msg
);
320 //KMessageBox::error(m_view, msg);
323 void DolphinPart::slotRequestItemInfo(const KFileItem
&item
)
325 Q_EMIT m_extension
->mouseOverInfo(item
);
329 const QString escapedText
= Qt::convertFromPlainText(item
.getStatusBarInfo());
330 Q_EMIT
ReadOnlyPart::setStatusBarText(QStringLiteral("<qt>%1</qt>").arg(escapedText
));
334 void DolphinPart::slotItemActivated(const KFileItem
&item
)
336 KParts::OpenUrlArguments args
;
337 // Forget about the known mimetype if a target URL is used.
338 // Testcase: network:/ with a item (mimetype "inode/some-foo-service") pointing to a http URL (html)
339 if (item
.targetUrl() == item
.url()) {
340 args
.setMimeType(item
.mimetype());
343 Q_EMIT m_extension
->openUrlRequest(item
.targetUrl(), args
);
346 void DolphinPart::slotItemsActivated(const KFileItemList
&items
)
348 for (const KFileItem
&item
: items
) {
349 slotItemActivated(item
);
353 void DolphinPart::createNewWindow(const QUrl
&url
)
355 // TODO: Check issue N176832 for the missing QAIV signal; task 177399 - maybe this code
356 // should be moved into DolphinPart::slotItemActivated()
357 Q_EMIT m_extension
->createNewWindow(url
);
360 void DolphinPart::slotOpenContextMenu(const QPoint
&pos
, const KFileItem
&_item
, const KFileItemList
&selectedItems
, const QUrl
&)
362 KParts::NavigationExtension::PopupFlags popupFlags
=
363 KParts::NavigationExtension::DefaultPopupItems
| KParts::NavigationExtension::ShowProperties
| KParts::NavigationExtension::ShowUrlOperations
;
365 KFileItem
item(_item
);
367 if (item
.isNull()) { // viewport context menu
368 item
= m_view
->rootItem();
370 item
= KFileItem(url());
372 item
.setUrl(url()); // ensure we use the view url, not the canonical path (#213799)
376 if (selectedItems
.isEmpty()) {
379 items
= selectedItems
;
382 KFileItemListProperties
capabilities(items
);
384 KParts::NavigationExtension::ActionGroupMap actionGroups
;
385 QList
<QAction
*> editActions
;
386 editActions
+= m_view
->versionControlActions(m_view
->selectedItems());
388 if (!_item
.isNull()) { // only for context menu on one or more items
389 const bool supportsMoving
= capabilities
.supportsMoving();
391 if (capabilities
.supportsDeleting()) {
392 const bool showDeleteAction
=
393 (KSharedConfig::openConfig()->group(QStringLiteral("KDE")).readEntry("ShowDeleteCommand", false) || !item
.isLocalFile());
394 const bool showMoveToTrashAction
= capabilities
.isLocal() && supportsMoving
;
396 if (showDeleteAction
&& showMoveToTrashAction
) {
397 delete m_removeAction
;
398 m_removeAction
= nullptr;
399 editActions
.append(actionCollection()->action(KStandardAction::name(KStandardAction::MoveToTrash
)));
400 editActions
.append(actionCollection()->action(KStandardAction::name(KStandardAction::DeleteFile
)));
401 } else if (showDeleteAction
&& !showMoveToTrashAction
) {
402 editActions
.append(actionCollection()->action(KStandardAction::name(KStandardAction::DeleteFile
)));
405 m_removeAction
= new DolphinRemoveAction(this, actionCollection());
406 editActions
.append(m_removeAction
);
407 m_removeAction
->update();
410 popupFlags
|= KParts::NavigationExtension::NoDeletion
;
413 if (supportsMoving
) {
414 editActions
.append(actionCollection()->action(KStandardAction::name(KStandardAction::RenameFile
)));
417 // Normally KonqPopupMenu only shows the "Create new" submenu in the current view
418 // since otherwise the created file would not be visible.
419 // But in treeview mode we should allow it.
420 if (m_view
->itemsExpandable())
421 popupFlags
|= KParts::NavigationExtension::ShowCreateDirectory
;
424 actionGroups
.insert(QStringLiteral("editactions"), editActions
);
426 Q_EMIT m_extension
->popupMenu(pos
, items
, KParts::OpenUrlArguments(), popupFlags
, actionGroups
);
429 void DolphinPart::slotDirectoryRedirection(const QUrl
&oldUrl
, const QUrl
&newUrl
)
431 qCDebug(DolphinDebug
) << oldUrl
<< newUrl
<< "currentUrl=" << url();
432 if (oldUrl
.matches(url(), QUrl::StripTrailingSlash
/* #207572 */)) {
433 KParts::ReadOnlyPart::setUrl(newUrl
);
434 const QString prettyUrl
= newUrl
.toDisplayString(QUrl::PreferLocalFile
);
435 Q_EMIT m_extension
->setLocationBarUrl(prettyUrl
);
439 void DolphinPart::slotEditMimeType()
441 const KFileItemList items
= m_view
->selectedItems();
442 if (!items
.isEmpty()) {
443 KMimeTypeEditor::editMimeType(items
.first().mimetype(), m_view
);
447 void DolphinPart::slotSelectItemsMatchingPattern()
449 openSelectionDialog(i18nc("@title:window", "Select"), i18n("Select all items matching this pattern:"), true);
452 void DolphinPart::slotUnselectItemsMatchingPattern()
454 openSelectionDialog(i18nc("@title:window", "Unselect"), i18n("Unselect all items matching this pattern:"), false);
457 void DolphinPart::openSelectionDialog(const QString
&title
, const QString
&text
, bool selectItems
)
459 auto *dialog
= new QInputDialog(m_view
);
460 dialog
->setAttribute(Qt::WA_DeleteOnClose
, true);
461 dialog
->setInputMode(QInputDialog::TextInput
);
462 dialog
->setWindowTitle(title
);
463 dialog
->setLabelText(text
);
465 const KConfigGroup group
= KSharedConfig::openConfig("dolphinpartrc")->group(QStringLiteral("Select Dialog"));
466 dialog
->setComboBoxEditable(true);
467 dialog
->setComboBoxItems(group
.readEntry("History", QStringList()));
469 dialog
->setTextValue(QStringLiteral("*"));
471 connect(dialog
, &QDialog::accepted
, this, [=, this]() {
472 const QString pattern
= dialog
->textValue();
473 if (!pattern
.isEmpty()) {
474 QStringList items
= dialog
->comboBoxItems();
475 items
.removeAll(pattern
);
476 items
.prepend(pattern
);
478 // Need to evaluate this again here, because the captured value is const
479 // (even if the const were removed from 'const KConfigGroup group =' above).
480 KConfigGroup group
= KSharedConfig::openConfig("dolphinpartrc")->group(QStringLiteral("Select Dialog"));
481 // Limit the size of the saved history.
482 group
.writeEntry("History", items
.mid(0, 10));
485 const QRegularExpression
patternRegExp(QRegularExpression::wildcardToRegularExpression(pattern
));
486 m_view
->selectItems(patternRegExp
, selectItems
);
493 void DolphinPart::setCurrentViewMode(const QString
&viewModeName
)
495 QAction
*action
= actionCollection()->action(viewModeName
);
500 QString
DolphinPart::currentViewMode() const
502 return m_actionHandler
->currentViewModeActionName();
505 void DolphinPart::setNameFilter(const QString
&nameFilter
)
507 // This is the "/home/dfaure/*.diff" kind of name filter (KDirLister::setNameFilter)
508 // which is unrelated to DolphinView::setNameFilter which is substring filtering in a proxy.
509 m_nameFilter
= nameFilter
;
510 // TODO save/restore name filter in saveState/restoreState like KonqDirPart did in kde3?
513 QString
DolphinPart::localFilePathOrHome() const
515 const QString localPath
= localFilePath();
516 if (!localPath
.isEmpty()) {
519 return QDir::homePath();
522 void DolphinPart::slotOpenTerminal()
524 auto job
= new KTerminalLauncherJob(QString());
525 job
->setWorkingDirectory(localFilePathOrHome());
529 void DolphinPart::slotFindFile()
531 KIO::CommandLauncherJob
*job
= new KIO::CommandLauncherJob(QStringLiteral("kfind"), {url().toString()}, this);
532 job
->setDesktopName(QStringLiteral("org.kde.kfind"));
533 job
->setUiDelegate(new KDialogJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled
, widget()));
537 void DolphinPart::updateNewMenu()
539 // As requested by KNewFileMenu :
540 m_newFileMenu
->checkUpToDate();
541 // And set the files that the menu apply on :
542 m_newFileMenu
->setWorkingDirectory(url());
545 void DolphinPart::updateStatusBar()
547 m_view
->requestStatusBarText();
550 void DolphinPart::updateProgress(int percent
)
552 Q_EMIT m_extension
->loadingProgress(percent
);
555 void DolphinPart::createDirectory()
557 m_newFileMenu
->setWorkingDirectory(url());
558 m_newFileMenu
->createDirectory();
561 void DolphinPart::setFilesToSelect(const QList
<QUrl
> &files
)
563 if (files
.isEmpty()) {
567 m_view
->markUrlsAsSelected(files
);
568 m_view
->markUrlAsCurrent(files
.at(0));
571 bool DolphinPart::eventFilter(QObject
*obj
, QEvent
*event
)
573 using ShiftState
= DolphinRemoveAction::ShiftState
;
574 const int type
= event
->type();
576 if ((type
== QEvent::KeyPress
|| type
== QEvent::KeyRelease
) && m_removeAction
) {
577 QMenu
*menu
= qobject_cast
<QMenu
*>(obj
);
578 if (menu
&& menu
->parent() == m_view
) {
579 QKeyEvent
*ev
= static_cast<QKeyEvent
*>(event
);
580 if (ev
->key() == Qt::Key_Shift
) {
581 m_removeAction
->update(type
== QEvent::KeyPress
? ShiftState::Pressed
: ShiftState::Released
);
586 return KParts::ReadOnlyPart::eventFilter(obj
, event
);
589 #include "dolphinpart.moc"
590 #include "moc_dolphinpart.cpp"