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 <KMoreToolsMenuFactory>
32 #include <KPluginFactory>
33 #include <KPluginMetaData>
34 #include <KSharedConfig>
35 #include <KTerminalLauncherJob>
36 #include <kio_version.h>
38 #include <QActionGroup>
39 #include <QApplication>
42 #include <QInputDialog>
45 #include <QRegularExpression>
46 #include <QStandardPaths>
47 #include <QTextDocument>
49 #include <KPluginFactory>
51 K_PLUGIN_CLASS_WITH_JSON(DolphinPart
, "dolphinpart.json")
53 DolphinPart::DolphinPart(QWidget
*parentWidget
, QObject
*parent
, const KPluginMetaData
&metaData
, const QVariantList
&args
)
54 : KParts::ReadOnlyPart(parent
, metaData
)
55 , m_openTerminalAction(nullptr)
56 , m_removeAction(nullptr)
60 m_extension
= new DolphinPartBrowserExtension(this);
62 // make sure that other apps using this part find Dolphin's view-file-columns icons
63 KIconLoader::global()->addAppDir(QStringLiteral("dolphin"));
65 m_view
= new DolphinView(QUrl(), parentWidget
);
66 m_view
->setTabsForFilesEnabled(true);
69 connect(&DolphinNewFileMenuObserver::instance(), &DolphinNewFileMenuObserver::errorMessage
, this, &DolphinPart::slotErrorMessage
);
71 connect(m_view
, &DolphinView::directoryLoadingCompleted
, this, &KParts::ReadOnlyPart::completed
);
72 connect(m_view
, &DolphinView::directoryLoadingCompleted
, this, &DolphinPart::updatePasteAction
);
73 connect(m_view
, &DolphinView::directoryLoadingProgress
, this, &DolphinPart::updateProgress
);
74 connect(m_view
, &DolphinView::errorMessage
, this, &DolphinPart::slotErrorMessage
);
76 setXMLFile(QStringLiteral("dolphinpart.rc"));
78 connect(m_view
, &DolphinView::infoMessage
, this, &DolphinPart::slotMessage
);
79 connect(m_view
, &DolphinView::operationCompletedMessage
, this, &DolphinPart::slotMessage
);
80 connect(m_view
, &DolphinView::errorMessage
, this, &DolphinPart::slotErrorMessage
);
81 connect(m_view
, &DolphinView::itemActivated
, this, &DolphinPart::slotItemActivated
);
82 connect(m_view
, &DolphinView::itemsActivated
, this, &DolphinPart::slotItemsActivated
);
83 connect(m_view
, &DolphinView::statusBarTextChanged
, this, [this](const QString
&text
) {
84 const QString escapedText
= Qt::convertFromPlainText(text
);
85 Q_EMIT
ReadOnlyPart::setStatusBarText(QStringLiteral("<qt>%1</qt>").arg(escapedText
));
87 connect(m_view
, &DolphinView::tabRequested
, this, &DolphinPart::createNewWindow
);
88 connect(m_view
, &DolphinView::requestContextMenu
, this, &DolphinPart::slotOpenContextMenu
);
89 connect(m_view
, &DolphinView::selectionChanged
, m_extension
, &KParts::NavigationExtension::selectionInfo
);
90 connect(m_view
, &DolphinView::selectionChanged
, this, &DolphinPart::slotSelectionChanged
);
91 connect(m_view
, &DolphinView::requestItemInfo
, this, &DolphinPart::slotRequestItemInfo
);
92 connect(m_view
, &DolphinView::modeChanged
, this, &DolphinPart::viewModeChanged
); // relay signal
93 connect(m_view
, &DolphinView::redirection
, this, &DolphinPart::slotDirectoryRedirection
);
95 // Watch for changes that should result in updates to the
97 connect(m_view
, &DolphinView::itemCountChanged
, this, &DolphinPart::updateStatusBar
);
98 connect(m_view
, &DolphinView::selectionChanged
, this, &DolphinPart::updateStatusBar
);
100 m_actionHandler
= new DolphinViewActionHandler(actionCollection(), nullptr, this);
101 m_actionHandler
->setCurrentView(m_view
);
102 connect(m_actionHandler
, &DolphinViewActionHandler::createDirectoryTriggered
, this, &DolphinPart::createDirectory
);
104 m_remoteEncoding
= new DolphinRemoteEncoding(this, m_actionHandler
);
105 connect(this, &DolphinPart::aboutToOpenURL
, m_remoteEncoding
, &DolphinRemoteEncoding::slotAboutToOpenUrl
);
107 QClipboard
*clipboard
= QApplication::clipboard();
108 connect(clipboard
, &QClipboard::dataChanged
, this, &DolphinPart::updatePasteAction
);
110 // Create file info and listing filter extensions.
111 // NOTE: Listing filter needs to be instantiated after the creation of the view.
112 new DolphinPartFileInfoExtension(this);
114 new DolphinPartListingFilterExtension(this);
116 KDirLister
*lister
= m_view
->m_model
->m_dirLister
;
118 DolphinPartListingNotificationExtension
*notifyExt
= new DolphinPartListingNotificationExtension(this);
119 connect(lister
, &KDirLister::newItems
, notifyExt
, &DolphinPartListingNotificationExtension::slotNewItems
);
120 connect(lister
, &KDirLister::itemsDeleted
, notifyExt
, &DolphinPartListingNotificationExtension::slotItemsDeleted
);
122 qCWarning(DolphinDebug
) << "NULL KDirLister object! KParts::ListingNotificationExtension will NOT be supported";
126 m_actionHandler
->updateViewActions();
127 slotSelectionChanged(KFileItemList()); // initially disable selection-dependent actions
129 // Listen to events from the app so we can update the remove key by
130 // checking for a Shift key press.
131 qApp
->installEventFilter(this);
133 // TODO there was a "always open a new window" (when clicking on a directory) setting in konqueror
134 // (sort of spacial navigation)
137 DolphinPart::~DolphinPart()
141 void DolphinPart::createActions()
145 m_newFileMenu
= new DolphinNewFileMenu(actionCollection(), this);
146 m_newFileMenu
->setParentWidget(widget());
147 #if KIO_VERSION >= QT_VERSION_CHECK(5, 100, 0)
148 m_newFileMenu
->setNewFolderShortcutAction(actionCollection()->action("create_dir"));
150 connect(m_newFileMenu
->menu(), &QMenu::aboutToShow
, this, &DolphinPart::updateNewMenu
);
152 QAction
*editMimeTypeAction
= actionCollection()->addAction(QStringLiteral("editMimeType"));
153 editMimeTypeAction
->setText(i18nc("@action:inmenu Edit", "&Edit File Type..."));
154 connect(editMimeTypeAction
, &QAction::triggered
, this, &DolphinPart::slotEditMimeType
);
156 QAction
*selectItemsMatching
= actionCollection()->addAction(QStringLiteral("select_items_matching"));
157 selectItemsMatching
->setText(i18nc("@action:inmenu Edit", "Select Items Matching..."));
158 actionCollection()->setDefaultShortcut(selectItemsMatching
, Qt::CTRL
| Qt::Key_S
);
159 connect(selectItemsMatching
, &QAction::triggered
, this, &DolphinPart::slotSelectItemsMatchingPattern
);
161 QAction
*unselectItemsMatching
= actionCollection()->addAction(QStringLiteral("unselect_items_matching"));
162 unselectItemsMatching
->setText(i18nc("@action:inmenu Edit", "Unselect Items Matching..."));
163 connect(unselectItemsMatching
, &QAction::triggered
, this, &DolphinPart::slotUnselectItemsMatchingPattern
);
165 KStandardAction::selectAll(m_view
, &DolphinView::selectAll
, actionCollection());
167 QAction
*unselectAll
= actionCollection()->addAction(QStringLiteral("unselect_all"));
168 unselectAll
->setText(i18nc("@action:inmenu Edit", "Unselect All"));
169 connect(unselectAll
, &QAction::triggered
, m_view
, &DolphinView::clearSelection
);
171 QAction
*invertSelection
= actionCollection()->addAction(QStringLiteral("invert_selection"));
172 invertSelection
->setText(i18nc("@action:inmenu Edit", "Invert Selection"));
173 actionCollection()->setDefaultShortcut(invertSelection
, Qt::CTRL
| Qt::SHIFT
| Qt::Key_A
);
174 connect(invertSelection
, &QAction::triggered
, m_view
, &DolphinView::invertSelection
);
176 // View menu: all done by DolphinViewActionHandler
180 QActionGroup
*goActionGroup
= new QActionGroup(this);
181 connect(goActionGroup
, &QActionGroup::triggered
, this, &DolphinPart::slotGoTriggered
);
183 createGoAction("go_applications", "start-here-kde", i18nc("@action:inmenu Go", "App&lications"), QStringLiteral("programs:/"), goActionGroup
);
184 createGoAction("go_network_folders", "folder-remote", i18nc("@action:inmenu Go", "&Network Folders"), QStringLiteral("remote:/"), goActionGroup
);
185 createGoAction("go_trash", "user-trash", i18nc("@action:inmenu Go", "Trash"), QStringLiteral("trash:/"), goActionGroup
);
186 createGoAction("go_autostart",
188 i18nc("@action:inmenu Go", "Autostart"),
189 QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation
) + "/autostart",
193 m_findFileAction
= KStandardAction::find(this, &DolphinPart::slotFindFile
, actionCollection());
194 m_findFileAction
->setText(i18nc("@action:inmenu Tools", "Find File..."));
197 if (KAuthorized::authorize(QStringLiteral("shell_access"))) {
198 m_openTerminalAction
= actionCollection()->addAction(QStringLiteral("open_terminal"));
199 m_openTerminalAction
->setIcon(QIcon::fromTheme(QStringLiteral("dialog-scripts")));
200 m_openTerminalAction
->setText(i18nc("@action:inmenu Tools", "Open &Terminal"));
201 connect(m_openTerminalAction
, &QAction::triggered
, this, &DolphinPart::slotOpenTerminal
);
202 actionCollection()->setDefaultShortcut(m_openTerminalAction
, Qt::Key_F4
);
207 void DolphinPart::createGoAction(const char *name
, const char *iconName
, const QString
&text
, const QString
&url
, QActionGroup
*actionGroup
)
209 QAction
*action
= actionCollection()->addAction(name
);
210 action
->setIcon(QIcon::fromTheme(iconName
));
211 action
->setText(text
);
212 action
->setData(url
);
213 action
->setActionGroup(actionGroup
);
216 void DolphinPart::slotGoTriggered(QAction
*action
)
218 const QString url
= action
->data().toString();
219 Q_EMIT m_extension
->openUrlRequest(QUrl(url
));
222 void DolphinPart::slotSelectionChanged(const KFileItemList
&selection
)
224 const bool hasSelection
= !selection
.isEmpty();
226 QAction
*renameAction
= actionCollection()->action(KStandardAction::name(KStandardAction::RenameFile
));
227 QAction
*moveToTrashAction
= actionCollection()->action(KStandardAction::name(KStandardAction::MoveToTrash
));
228 QAction
*deleteAction
= actionCollection()->action(KStandardAction::name(KStandardAction::DeleteFile
));
229 QAction
*editMimeTypeAction
= actionCollection()->action(QStringLiteral("editMimeType"));
230 QAction
*propertiesAction
= actionCollection()->action(QStringLiteral("properties"));
231 QAction
*deleteWithTrashShortcut
= actionCollection()->action(QStringLiteral("delete_shortcut")); // see DolphinViewActionHandler
234 stateChanged(QStringLiteral("has_no_selection"));
236 Q_EMIT m_extension
->enableAction("cut", false);
237 Q_EMIT m_extension
->enableAction("copy", false);
238 deleteWithTrashShortcut
->setEnabled(false);
239 editMimeTypeAction
->setEnabled(false);
241 stateChanged(QStringLiteral("has_selection"));
243 // TODO share this code with DolphinMainWindow::updateEditActions (and the desktop code)
245 KFileItemListProperties
capabilities(selection
);
246 const bool enableMoveToTrash
= capabilities
.isLocal() && capabilities
.supportsMoving();
248 renameAction
->setEnabled(capabilities
.supportsMoving());
249 moveToTrashAction
->setEnabled(enableMoveToTrash
);
250 deleteAction
->setEnabled(capabilities
.supportsDeleting());
251 deleteWithTrashShortcut
->setEnabled(capabilities
.supportsDeleting() && !enableMoveToTrash
);
252 editMimeTypeAction
->setEnabled(true);
253 propertiesAction
->setEnabled(true);
254 Q_EMIT m_extension
->enableAction("cut", capabilities
.supportsMoving());
255 Q_EMIT m_extension
->enableAction("copy", true);
259 void DolphinPart::updatePasteAction()
261 QPair
<bool, QString
> pasteInfo
= m_view
->pasteInfo();
262 Q_EMIT m_extension
->enableAction("paste", pasteInfo
.first
);
263 Q_EMIT m_extension
->setActionText("paste", pasteInfo
.second
);
266 QString
DolphinPart::urlToLocalFilePath(const QUrl
&url
)
268 KIO::StatJob
*statJob
= KIO::mostLocalUrl(url
);
269 KJobWidgets::setWindow(statJob
, widget());
271 QUrl localUrl
= statJob
->mostLocalUrl();
272 if (localUrl
.isLocalFile()) {
273 return localUrl
.toLocalFile();
278 bool DolphinPart::openUrl(const QUrl
&url
)
280 bool reload
= arguments().reload();
281 // A bit of a workaround so that changing the namefilter works: force reload.
282 // Otherwise DolphinView wouldn't relist the URL, so nothing would happen.
283 if (m_nameFilter
!= m_view
->nameFilter())
285 if (m_view
->url() == url
&& !reload
) { // DolphinView won't do anything in that case, so don't emit started
288 setUrl(url
); // remember url at the KParts level
289 setLocalFilePath(urlToLocalFilePath(url
)); // remember local path at the KParts level
290 QUrl
visibleUrl(url
);
291 if (!m_nameFilter
.isEmpty()) {
292 visibleUrl
.setPath(visibleUrl
.path() + '/' + m_nameFilter
);
294 QString prettyUrl
= visibleUrl
.toDisplayString(QUrl::PreferLocalFile
);
295 Q_EMIT
setWindowCaption(prettyUrl
);
296 Q_EMIT m_extension
->setLocationBarUrl(prettyUrl
);
297 Q_EMIT
started(nullptr); // get the wheel to spin
298 m_view
->setNameFilter(m_nameFilter
);
301 Q_EMIT
aboutToOpenURL();
304 // Disable "Find File" and "Open Terminal" actions for non-file URLs,
305 // e.g. ftp, smb, etc. #279283
306 const bool isLocalUrl
= !(localFilePath().isEmpty());
307 m_findFileAction
->setEnabled(isLocalUrl
);
308 if (m_openTerminalAction
) {
309 m_openTerminalAction
->setEnabled(isLocalUrl
);
314 void DolphinPart::slotMessage(const QString
&msg
)
316 Q_EMIT
setStatusBarText(msg
);
319 void DolphinPart::slotErrorMessage(const QString
&msg
)
321 qCDebug(DolphinDebug
) << msg
;
322 Q_EMIT
canceled(msg
);
323 //KMessageBox::error(m_view, msg);
326 void DolphinPart::slotRequestItemInfo(const KFileItem
&item
)
328 Q_EMIT m_extension
->mouseOverInfo(item
);
332 const QString escapedText
= Qt::convertFromPlainText(item
.getStatusBarInfo());
333 Q_EMIT
ReadOnlyPart::setStatusBarText(QStringLiteral("<qt>%1</qt>").arg(escapedText
));
337 void DolphinPart::slotItemActivated(const KFileItem
&item
)
339 KParts::OpenUrlArguments args
;
340 // Forget about the known mimetype if a target URL is used.
341 // Testcase: network:/ with a item (mimetype "inode/some-foo-service") pointing to a http URL (html)
342 if (item
.targetUrl() == item
.url()) {
343 args
.setMimeType(item
.mimetype());
346 // Ideally, konqueror should be changed to not require trustedSource for directory views,
347 // since the idea was not to need BrowserArguments for non-browser stuff...
348 KParts::BrowserArguments browserArgs
;
349 browserArgs
.trustedSource
= true;
350 Q_EMIT m_extension
->openUrlRequest(item
.targetUrl(), args
, browserArgs
);
353 void DolphinPart::slotItemsActivated(const KFileItemList
&items
)
355 for (const KFileItem
&item
: items
) {
356 slotItemActivated(item
);
360 void DolphinPart::createNewWindow(const QUrl
&url
)
362 // TODO: Check issue N176832 for the missing QAIV signal; task 177399 - maybe this code
363 // should be moved into DolphinPart::slotItemActivated()
364 Q_EMIT m_extension
->createNewWindow(url
);
367 void DolphinPart::slotOpenContextMenu(const QPoint
&pos
, const KFileItem
&_item
, const KFileItemList
&selectedItems
, const QUrl
&)
369 KParts::NavigationExtension::PopupFlags popupFlags
=
370 KParts::NavigationExtension::DefaultPopupItems
| KParts::NavigationExtension::ShowProperties
| KParts::NavigationExtension::ShowUrlOperations
;
372 KFileItem
item(_item
);
374 if (item
.isNull()) { // viewport context menu
375 item
= m_view
->rootItem();
377 item
= KFileItem(url());
379 item
.setUrl(url()); // ensure we use the view url, not the canonical path (#213799)
383 if (selectedItems
.isEmpty()) {
386 items
= selectedItems
;
389 KFileItemListProperties
capabilities(items
);
391 KParts::NavigationExtension::ActionGroupMap actionGroups
;
392 QList
<QAction
*> editActions
;
393 editActions
+= m_view
->versionControlActions(m_view
->selectedItems());
395 if (!_item
.isNull()) { // only for context menu on one or more items
396 const bool supportsMoving
= capabilities
.supportsMoving();
398 if (capabilities
.supportsDeleting()) {
399 const bool showDeleteAction
= (KSharedConfig::openConfig()->group("KDE").readEntry("ShowDeleteCommand", false) || !item
.isLocalFile());
400 const bool showMoveToTrashAction
= capabilities
.isLocal() && supportsMoving
;
402 if (showDeleteAction
&& showMoveToTrashAction
) {
403 delete m_removeAction
;
404 m_removeAction
= nullptr;
405 editActions
.append(actionCollection()->action(KStandardAction::name(KStandardAction::MoveToTrash
)));
406 editActions
.append(actionCollection()->action(KStandardAction::name(KStandardAction::DeleteFile
)));
407 } else if (showDeleteAction
&& !showMoveToTrashAction
) {
408 editActions
.append(actionCollection()->action(KStandardAction::name(KStandardAction::DeleteFile
)));
411 m_removeAction
= new DolphinRemoveAction(this, actionCollection());
412 editActions
.append(m_removeAction
);
413 m_removeAction
->update();
416 popupFlags
|= KParts::NavigationExtension::NoDeletion
;
419 if (supportsMoving
) {
420 editActions
.append(actionCollection()->action(KStandardAction::name(KStandardAction::RenameFile
)));
423 // Normally KonqPopupMenu only shows the "Create new" submenu in the current view
424 // since otherwise the created file would not be visible.
425 // But in treeview mode we should allow it.
426 if (m_view
->itemsExpandable())
427 popupFlags
|= KParts::NavigationExtension::ShowCreateDirectory
;
430 actionGroups
.insert(QStringLiteral("editactions"), editActions
);
432 Q_EMIT m_extension
->popupMenu(pos
, items
, KParts::OpenUrlArguments(), KParts::BrowserArguments(), popupFlags
, actionGroups
);
435 void DolphinPart::slotDirectoryRedirection(const QUrl
&oldUrl
, const QUrl
&newUrl
)
437 qCDebug(DolphinDebug
) << oldUrl
<< newUrl
<< "currentUrl=" << url();
438 if (oldUrl
.matches(url(), QUrl::StripTrailingSlash
/* #207572 */)) {
439 KParts::ReadOnlyPart::setUrl(newUrl
);
440 const QString prettyUrl
= newUrl
.toDisplayString(QUrl::PreferLocalFile
);
441 Q_EMIT m_extension
->setLocationBarUrl(prettyUrl
);
445 void DolphinPart::slotEditMimeType()
447 const KFileItemList items
= m_view
->selectedItems();
448 if (!items
.isEmpty()) {
449 KMimeTypeEditor::editMimeType(items
.first().mimetype(), m_view
);
453 void DolphinPart::slotSelectItemsMatchingPattern()
455 openSelectionDialog(i18nc("@title:window", "Select"), i18n("Select all items matching this pattern:"), true);
458 void DolphinPart::slotUnselectItemsMatchingPattern()
460 openSelectionDialog(i18nc("@title:window", "Unselect"), i18n("Unselect all items matching this pattern:"), false);
463 void DolphinPart::openSelectionDialog(const QString
&title
, const QString
&text
, bool selectItems
)
465 auto *dialog
= new QInputDialog(m_view
);
466 dialog
->setAttribute(Qt::WA_DeleteOnClose
, true);
467 dialog
->setInputMode(QInputDialog::TextInput
);
468 dialog
->setWindowTitle(title
);
469 dialog
->setLabelText(text
);
471 const KConfigGroup group
= KSharedConfig::openConfig("dolphinpartrc")->group("Select Dialog");
472 dialog
->setComboBoxEditable(true);
473 dialog
->setComboBoxItems(group
.readEntry("History", QStringList()));
475 dialog
->setTextValue(QStringLiteral("*"));
477 connect(dialog
, &QDialog::accepted
, this, [=]() {
478 const QString pattern
= dialog
->textValue();
479 if (!pattern
.isEmpty()) {
480 QStringList items
= dialog
->comboBoxItems();
481 items
.removeAll(pattern
);
482 items
.prepend(pattern
);
484 // Need to evaluate this again here, because the captured value is const
485 // (even if the const were removed from 'const KConfigGroup group =' above).
486 KConfigGroup group
= KSharedConfig::openConfig("dolphinpartrc")->group("Select Dialog");
487 // Limit the size of the saved history.
488 group
.writeEntry("History", items
.mid(0, 10));
491 const QRegularExpression
patternRegExp(QRegularExpression::wildcardToRegularExpression(pattern
));
492 m_view
->selectItems(patternRegExp
, selectItems
);
499 void DolphinPart::setCurrentViewMode(const QString
&viewModeName
)
501 QAction
*action
= actionCollection()->action(viewModeName
);
506 QString
DolphinPart::currentViewMode() const
508 return m_actionHandler
->currentViewModeActionName();
511 void DolphinPart::setNameFilter(const QString
&nameFilter
)
513 // This is the "/home/dfaure/*.diff" kind of name filter (KDirLister::setNameFilter)
514 // which is unrelated to DolphinView::setNameFilter which is substring filtering in a proxy.
515 m_nameFilter
= nameFilter
;
516 // TODO save/restore name filter in saveState/restoreState like KonqDirPart did in kde3?
519 QString
DolphinPart::localFilePathOrHome() const
521 const QString localPath
= localFilePath();
522 if (!localPath
.isEmpty()) {
525 return QDir::homePath();
528 void DolphinPart::slotOpenTerminal()
530 auto job
= new KTerminalLauncherJob(QString());
531 job
->setWorkingDirectory(localFilePathOrHome());
535 void DolphinPart::slotFindFile()
538 KMoreToolsMenuFactory("dolphin/search-tools").fillMenuFromGroupingNames(&searchTools
, {"files-find"}, QUrl::fromLocalFile(localFilePathOrHome()));
539 QList
<QAction
*> actions
= searchTools
.actions();
540 if (!(actions
.isEmpty())) {
541 actions
.first()->trigger();
543 KIO::CommandLauncherJob
*job
= new KIO::CommandLauncherJob(QStringLiteral("kfind"), {url().toString()}, this);
544 job
->setDesktopName(QStringLiteral("org.kde.kfind"));
545 job
->setUiDelegate(new KDialogJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled
, widget()));
550 void DolphinPart::updateNewMenu()
552 // As requested by KNewFileMenu :
553 m_newFileMenu
->checkUpToDate();
554 // And set the files that the menu apply on :
555 #if KIO_VERSION >= QT_VERSION_CHECK(5, 97, 0)
556 m_newFileMenu
->setWorkingDirectory(url());
558 m_newFileMenu
->setPopupFiles(QList
<QUrl
>() << url());
562 void DolphinPart::updateStatusBar()
564 m_view
->requestStatusBarText();
567 void DolphinPart::updateProgress(int percent
)
569 Q_EMIT m_extension
->loadingProgress(percent
);
572 void DolphinPart::createDirectory()
574 #if KIO_VERSION >= QT_VERSION_CHECK(5, 97, 0)
575 m_newFileMenu
->setWorkingDirectory(url());
577 m_newFileMenu
->setPopupFiles(QList
<QUrl
>() << url());
579 m_newFileMenu
->createDirectory();
582 void DolphinPart::setFilesToSelect(const QList
<QUrl
> &files
)
584 if (files
.isEmpty()) {
588 m_view
->markUrlsAsSelected(files
);
589 m_view
->markUrlAsCurrent(files
.at(0));
592 bool DolphinPart::eventFilter(QObject
*obj
, QEvent
*event
)
594 using ShiftState
= DolphinRemoveAction::ShiftState
;
595 const int type
= event
->type();
597 if ((type
== QEvent::KeyPress
|| type
== QEvent::KeyRelease
) && m_removeAction
) {
598 QMenu
*menu
= qobject_cast
<QMenu
*>(obj
);
599 if (menu
&& menu
->parent() == m_view
) {
600 QKeyEvent
*ev
= static_cast<QKeyEvent
*>(event
);
601 if (ev
->key() == Qt::Key_Shift
) {
602 m_removeAction
->update(type
== QEvent::KeyPress
? ShiftState::Pressed
: ShiftState::Released
);
607 return KParts::ReadOnlyPart::eventFilter(obj
, event
);
610 #include "dolphinpart.moc"