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 "kitemviews/private/kfileitemmodeldirlister.h"
15 #include "views/dolphinnewfilemenuobserver.h"
16 #include "views/dolphinremoteencoding.h"
17 #include "views/dolphinview.h"
18 #include "views/dolphinviewactionhandler.h"
20 #include <KPluginMetaData>
21 #include <KActionCollection>
22 #include <KAuthorized>
23 #include <KConfigGroup>
24 #include <KDialogJobUiDelegate>
25 #include <KFileItemListProperties>
26 #include <KIconLoader>
27 #include <KJobWidgets>
28 #include <KLocalizedString>
29 #include <KMessageBox>
30 #include <KMimeTypeEditor>
31 #include <KNS3/KMoreToolsMenuFactory>
32 #include <KPluginFactory>
33 #include <KIO/CommandLauncherJob>
34 #include <KSharedConfig>
35 #include <KToolInvocation>
37 #include <QActionGroup>
38 #include <QApplication>
41 #include <QInputDialog>
44 #include <QRegularExpression>
45 #include <QStandardPaths>
46 #include <QTextDocument>
48 K_PLUGIN_CLASS_WITH_JSON(DolphinPart
, "dolphinpart.json")
50 DolphinPart::DolphinPart(QWidget
* parentWidget
, QObject
* parent
,
51 const KPluginMetaData
& metaData
, const QVariantList
& args
)
52 : KParts::ReadOnlyPart(parent
)
53 ,m_openTerminalAction(nullptr)
54 ,m_removeAction(nullptr)
57 setMetaData(metaData
);
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
,
69 this, &DolphinPart::slotErrorMessage
);
71 connect(m_view
, &DolphinView::directoryLoadingCompleted
, this, QOverload
<>::of(&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
,
79 this, &DolphinPart::slotMessage
);
80 connect(m_view
, &DolphinView::operationCompletedMessage
,
81 this, &DolphinPart::slotMessage
);
82 connect(m_view
, &DolphinView::errorMessage
,
83 this, &DolphinPart::slotErrorMessage
);
84 connect(m_view
, &DolphinView::itemActivated
,
85 this, &DolphinPart::slotItemActivated
);
86 connect(m_view
, &DolphinView::itemsActivated
,
87 this, &DolphinPart::slotItemsActivated
);
88 connect(m_view
, &DolphinView::tabRequested
,
89 this, &DolphinPart::createNewWindow
);
90 connect(m_view
, &DolphinView::requestContextMenu
,
91 this, &DolphinPart::slotOpenContextMenu
);
92 connect(m_view
, &DolphinView::selectionChanged
,
93 m_extension
, QOverload
<const KFileItemList
&>::of(&KParts::BrowserExtension::selectionInfo
));
94 connect(m_view
, &DolphinView::selectionChanged
,
95 this, &DolphinPart::slotSelectionChanged
);
96 connect(m_view
, &DolphinView::requestItemInfo
,
97 this, &DolphinPart::slotRequestItemInfo
);
98 connect(m_view
, &DolphinView::modeChanged
,
99 this, &DolphinPart::viewModeChanged
); // relay signal
100 connect(m_view
, &DolphinView::redirection
,
101 this, &DolphinPart::slotDirectoryRedirection
);
103 // Watch for changes that should result in updates to the
105 connect(m_view
, &DolphinView::itemCountChanged
, this, &DolphinPart::updateStatusBar
);
106 connect(m_view
, &DolphinView::selectionChanged
, this, &DolphinPart::updateStatusBar
);
108 m_actionHandler
= new DolphinViewActionHandler(actionCollection(), this);
109 m_actionHandler
->setCurrentView(m_view
);
110 connect(m_actionHandler
, &DolphinViewActionHandler::createDirectoryTriggered
, this, &DolphinPart::createDirectory
);
112 m_remoteEncoding
= new DolphinRemoteEncoding(this, m_actionHandler
);
113 connect(this, &DolphinPart::aboutToOpenURL
,
114 m_remoteEncoding
, &DolphinRemoteEncoding::slotAboutToOpenUrl
);
116 QClipboard
* clipboard
= QApplication::clipboard();
117 connect(clipboard
, &QClipboard::dataChanged
,
118 this, &DolphinPart::updatePasteAction
);
120 // Create file info and listing filter extensions.
121 // NOTE: Listing filter needs to be instantiated after the creation of the view.
122 new DolphinPartFileInfoExtension(this);
124 new DolphinPartListingFilterExtension(this);
126 KDirLister
* lister
= m_view
->m_model
->m_dirLister
;
128 DolphinPartListingNotificationExtension
* notifyExt
= new DolphinPartListingNotificationExtension(this);
129 connect(lister
, &KDirLister::newItems
, notifyExt
, &DolphinPartListingNotificationExtension::slotNewItems
);
130 connect(lister
, &KDirLister::itemsDeleted
, notifyExt
, &DolphinPartListingNotificationExtension::slotItemsDeleted
);
132 qCWarning(DolphinDebug
) << "NULL KDirLister object! KParts::ListingNotificationExtension will NOT be supported";
136 m_actionHandler
->updateViewActions();
137 slotSelectionChanged(KFileItemList()); // initially disable selection-dependent actions
139 // Listen to events from the app so we can update the remove key by
140 // checking for a Shift key press.
141 qApp
->installEventFilter(this);
143 // TODO there was a "always open a new window" (when clicking on a directory) setting in konqueror
144 // (sort of spacial navigation)
146 loadPlugins(this, this, componentName());
149 DolphinPart::~DolphinPart()
153 void DolphinPart::createActions()
157 m_newFileMenu
= new DolphinNewFileMenu(actionCollection(), this);
158 m_newFileMenu
->setParentWidget(widget());
159 connect(m_newFileMenu
->menu(), &QMenu::aboutToShow
,
160 this, &DolphinPart::updateNewMenu
);
162 QAction
*editMimeTypeAction
= actionCollection()->addAction( QStringLiteral("editMimeType") );
163 editMimeTypeAction
->setText( i18nc("@action:inmenu Edit", "&Edit File Type..." ) );
164 connect(editMimeTypeAction
, &QAction::triggered
, this, &DolphinPart::slotEditMimeType
);
166 QAction
* selectItemsMatching
= actionCollection()->addAction(QStringLiteral("select_items_matching"));
167 selectItemsMatching
->setText(i18nc("@action:inmenu Edit", "Select Items Matching..."));
168 actionCollection()->setDefaultShortcut(selectItemsMatching
, Qt::CTRL
| Qt::Key_S
);
169 connect(selectItemsMatching
, &QAction::triggered
, this, &DolphinPart::slotSelectItemsMatchingPattern
);
171 QAction
* unselectItemsMatching
= actionCollection()->addAction(QStringLiteral("unselect_items_matching"));
172 unselectItemsMatching
->setText(i18nc("@action:inmenu Edit", "Unselect Items Matching..."));
173 connect(unselectItemsMatching
, &QAction::triggered
, this, &DolphinPart::slotUnselectItemsMatchingPattern
);
175 KStandardAction::selectAll(m_view
, &DolphinView::selectAll
, actionCollection());
177 QAction
* unselectAll
= actionCollection()->addAction(QStringLiteral("unselect_all"));
178 unselectAll
->setText(i18nc("@action:inmenu Edit", "Unselect All"));
179 connect(unselectAll
, &QAction::triggered
, m_view
, &DolphinView::clearSelection
);
181 QAction
* invertSelection
= actionCollection()->addAction(QStringLiteral("invert_selection"));
182 invertSelection
->setText(i18nc("@action:inmenu Edit", "Invert Selection"));
183 actionCollection()->setDefaultShortcut(invertSelection
, Qt::CTRL
| Qt::SHIFT
| Qt::Key_A
);
184 connect(invertSelection
, &QAction::triggered
, m_view
, &DolphinView::invertSelection
);
186 // View menu: all done by DolphinViewActionHandler
190 QActionGroup
* goActionGroup
= new QActionGroup(this);
191 connect(goActionGroup
, &QActionGroup::triggered
,
192 this, &DolphinPart::slotGoTriggered
);
194 createGoAction("go_applications", "start-here-kde",
195 i18nc("@action:inmenu Go", "App&lications"), QStringLiteral("programs:/"),
197 createGoAction("go_network_folders", "folder-remote",
198 i18nc("@action:inmenu Go", "&Network Folders"), QStringLiteral("remote:/"),
200 createGoAction("go_settings", "preferences-system",
201 i18nc("@action:inmenu Go", "Sett&ings"), QStringLiteral("settings:/"),
203 createGoAction("go_trash", "user-trash",
204 i18nc("@action:inmenu Go", "Trash"), QStringLiteral("trash:/"),
206 createGoAction("go_autostart", "",
207 i18nc("@action:inmenu Go", "Autostart"), QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation
) + "/autostart",
211 m_findFileAction
= KStandardAction::find(this, &DolphinPart::slotFindFile
, actionCollection());
212 m_findFileAction
->setText(i18nc("@action:inmenu Tools", "Find File..."));
215 if (KAuthorized::authorize(QStringLiteral("shell_access"))) {
216 m_openTerminalAction
= actionCollection()->addAction(QStringLiteral("open_terminal"));
217 m_openTerminalAction
->setIcon(QIcon::fromTheme(QStringLiteral("dialog-scripts")));
218 m_openTerminalAction
->setText(i18nc("@action:inmenu Tools", "Open &Terminal"));
219 connect(m_openTerminalAction
, &QAction::triggered
, this, &DolphinPart::slotOpenTerminal
);
220 actionCollection()->setDefaultShortcut(m_openTerminalAction
, Qt::Key_F4
);
225 void DolphinPart::createGoAction(const char* name
, const char* iconName
,
226 const QString
& text
, const QString
& url
,
227 QActionGroup
* actionGroup
)
229 QAction
* action
= actionCollection()->addAction(name
);
230 action
->setIcon(QIcon::fromTheme(iconName
));
231 action
->setText(text
);
232 action
->setData(url
);
233 action
->setActionGroup(actionGroup
);
236 void DolphinPart::slotGoTriggered(QAction
* action
)
238 const QString url
= action
->data().toString();
239 Q_EMIT m_extension
->openUrlRequest(QUrl(url
));
242 void DolphinPart::slotSelectionChanged(const KFileItemList
& selection
)
244 const bool hasSelection
= !selection
.isEmpty();
246 QAction
* renameAction
= actionCollection()->action(KStandardAction::name(KStandardAction::RenameFile
));
247 QAction
* moveToTrashAction
= actionCollection()->action(KStandardAction::name(KStandardAction::MoveToTrash
));
248 QAction
* deleteAction
= actionCollection()->action(KStandardAction::name(KStandardAction::DeleteFile
));
249 QAction
* editMimeTypeAction
= actionCollection()->action(QStringLiteral("editMimeType"));
250 QAction
* propertiesAction
= actionCollection()->action(QStringLiteral("properties"));
251 QAction
* deleteWithTrashShortcut
= actionCollection()->action(QStringLiteral("delete_shortcut")); // see DolphinViewActionHandler
254 stateChanged(QStringLiteral("has_no_selection"));
256 Q_EMIT m_extension
->enableAction("cut", false);
257 Q_EMIT m_extension
->enableAction("copy", false);
258 deleteWithTrashShortcut
->setEnabled(false);
259 editMimeTypeAction
->setEnabled(false);
261 stateChanged(QStringLiteral("has_selection"));
263 // TODO share this code with DolphinMainWindow::updateEditActions (and the desktop code)
265 KFileItemListProperties
capabilities(selection
);
266 const bool enableMoveToTrash
= capabilities
.isLocal() && capabilities
.supportsMoving();
268 renameAction
->setEnabled(capabilities
.supportsMoving());
269 moveToTrashAction
->setEnabled(enableMoveToTrash
);
270 deleteAction
->setEnabled(capabilities
.supportsDeleting());
271 deleteWithTrashShortcut
->setEnabled(capabilities
.supportsDeleting() && !enableMoveToTrash
);
272 editMimeTypeAction
->setEnabled(true);
273 propertiesAction
->setEnabled(true);
274 Q_EMIT m_extension
->enableAction("cut", capabilities
.supportsMoving());
275 Q_EMIT m_extension
->enableAction("copy", true);
279 void DolphinPart::updatePasteAction()
281 QPair
<bool, QString
> pasteInfo
= m_view
->pasteInfo();
282 Q_EMIT m_extension
->enableAction( "paste", pasteInfo
.first
);
283 Q_EMIT m_extension
->setActionText( "paste", pasteInfo
.second
);
286 QString
DolphinPart::urlToLocalFilePath(const QUrl
&url
)
288 KIO::StatJob
* statJob
= KIO::mostLocalUrl(url
);
289 KJobWidgets::setWindow(statJob
, widget());
291 QUrl localUrl
= statJob
->mostLocalUrl();
292 if (localUrl
.isLocalFile()) {
293 return localUrl
.toLocalFile();
298 bool DolphinPart::openUrl(const QUrl
&url
)
300 bool reload
= arguments().reload();
301 // A bit of a workaround so that changing the namefilter works: force reload.
302 // Otherwise DolphinView wouldn't relist the URL, so nothing would happen.
303 if (m_nameFilter
!= m_view
->nameFilter())
305 if (m_view
->url() == url
&& !reload
) { // DolphinView won't do anything in that case, so don't emit started
308 setUrl(url
); // remember url at the KParts level
309 setLocalFilePath(urlToLocalFilePath(url
)); // remember local path at the KParts level
310 QUrl
visibleUrl(url
);
311 if (!m_nameFilter
.isEmpty()) {
312 visibleUrl
.setPath(visibleUrl
.path() + '/' + m_nameFilter
);
314 QString prettyUrl
= visibleUrl
.toDisplayString(QUrl::PreferLocalFile
);
315 Q_EMIT
setWindowCaption(prettyUrl
);
316 Q_EMIT m_extension
->setLocationBarUrl(prettyUrl
);
317 Q_EMIT
started(nullptr); // get the wheel to spin
318 m_view
->setNameFilter(m_nameFilter
);
321 Q_EMIT
aboutToOpenURL();
324 // Disable "Find File" and "Open Terminal" actions for non-file URLs,
325 // e.g. ftp, smb, etc. #279283
326 const bool isLocalUrl
= !(localFilePath().isEmpty());
327 m_findFileAction
->setEnabled(isLocalUrl
);
328 if (m_openTerminalAction
) {
329 m_openTerminalAction
->setEnabled(isLocalUrl
);
334 void DolphinPart::slotMessage(const QString
& msg
)
336 Q_EMIT
setStatusBarText(msg
);
339 void DolphinPart::slotErrorMessage(const QString
& msg
)
341 qCDebug(DolphinDebug
) << msg
;
342 Q_EMIT
canceled(msg
);
343 //KMessageBox::error(m_view, msg);
346 void DolphinPart::slotRequestItemInfo(const KFileItem
& item
)
348 Q_EMIT m_extension
->mouseOverInfo(item
);
352 const QString escapedText
= Qt::convertFromPlainText(item
.getStatusBarInfo());
353 Q_EMIT
ReadOnlyPart::setStatusBarText(QStringLiteral("<qt>%1</qt>").arg(escapedText
));
357 void DolphinPart::slotItemActivated(const KFileItem
& item
)
359 KParts::OpenUrlArguments args
;
360 // Forget about the known mimetype if a target URL is used.
361 // Testcase: network:/ with a item (mimetype "inode/some-foo-service") pointing to a http URL (html)
362 if (item
.targetUrl() == item
.url()) {
363 args
.setMimeType(item
.mimetype());
366 // Ideally, konqueror should be changed to not require trustedSource for directory views,
367 // since the idea was not to need BrowserArguments for non-browser stuff...
368 KParts::BrowserArguments browserArgs
;
369 browserArgs
.trustedSource
= true;
370 Q_EMIT m_extension
->openUrlRequest(item
.targetUrl(), args
, browserArgs
);
373 void DolphinPart::slotItemsActivated(const KFileItemList
& items
)
375 for (const KFileItem
& item
: items
) {
376 slotItemActivated(item
);
380 void DolphinPart::createNewWindow(const QUrl
& url
)
382 // TODO: Check issue N176832 for the missing QAIV signal; task 177399 - maybe this code
383 // should be moved into DolphinPart::slotItemActivated()
384 Q_EMIT m_extension
->createNewWindow(url
);
387 void DolphinPart::slotOpenContextMenu(const QPoint
& pos
,
388 const KFileItem
& _item
,
390 const QList
<QAction
*>& customActions
)
392 KParts::BrowserExtension::PopupFlags popupFlags
= KParts::BrowserExtension::DefaultPopupItems
393 | KParts::BrowserExtension::ShowProperties
394 | KParts::BrowserExtension::ShowUrlOperations
;
396 KFileItem
item(_item
);
398 if (item
.isNull()) { // viewport context menu
399 item
= m_view
->rootItem();
401 item
= KFileItem(url());
403 item
.setUrl(url()); // ensure we use the view url, not the canonical path (#213799)
406 // TODO: We should change the signature of the slots (and signals) for being able
407 // to tell for which items we want a popup.
409 if (m_view
->selectedItems().isEmpty()) {
412 items
= m_view
->selectedItems();
415 KFileItemListProperties
capabilities(items
);
417 KParts::BrowserExtension::ActionGroupMap actionGroups
;
418 QList
<QAction
*> editActions
;
419 editActions
+= m_view
->versionControlActions(m_view
->selectedItems());
420 editActions
+= customActions
;
422 if (!_item
.isNull()) { // only for context menu on one or more items
423 const bool supportsMoving
= capabilities
.supportsMoving();
425 if (capabilities
.supportsDeleting()) {
426 const bool showDeleteAction
= (KSharedConfig::openConfig()->group("KDE").readEntry("ShowDeleteCommand", false) ||
427 !item
.isLocalFile());
428 const bool showMoveToTrashAction
= capabilities
.isLocal() && supportsMoving
;
430 if (showDeleteAction
&& showMoveToTrashAction
) {
431 delete m_removeAction
;
432 m_removeAction
= nullptr;
433 editActions
.append(actionCollection()->action(KStandardAction::name(KStandardAction::MoveToTrash
)));
434 editActions
.append(actionCollection()->action(KStandardAction::name(KStandardAction::DeleteFile
)));
435 } else if (showDeleteAction
&& !showMoveToTrashAction
) {
436 editActions
.append(actionCollection()->action(KStandardAction::name(KStandardAction::DeleteFile
)));
439 m_removeAction
= new DolphinRemoveAction(this, actionCollection());
440 editActions
.append(m_removeAction
);
441 m_removeAction
->update();
444 popupFlags
|= KParts::BrowserExtension::NoDeletion
;
447 if (supportsMoving
) {
448 editActions
.append(actionCollection()->action(KStandardAction::name(KStandardAction::RenameFile
)));
451 // Normally KonqPopupMenu only shows the "Create new" submenu in the current view
452 // since otherwise the created file would not be visible.
453 // But in treeview mode we should allow it.
454 if (m_view
->itemsExpandable())
455 popupFlags
|= KParts::BrowserExtension::ShowCreateDirectory
;
459 actionGroups
.insert(QStringLiteral("editactions"), editActions
);
461 Q_EMIT m_extension
->popupMenu(pos
,
463 KParts::OpenUrlArguments(),
464 KParts::BrowserArguments(),
469 void DolphinPart::slotDirectoryRedirection(const QUrl
&oldUrl
, const QUrl
&newUrl
)
471 qCDebug(DolphinDebug
) << oldUrl
<< newUrl
<< "currentUrl=" << url();
472 if (oldUrl
.matches(url(), QUrl::StripTrailingSlash
/* #207572 */)) {
473 KParts::ReadOnlyPart::setUrl(newUrl
);
474 const QString prettyUrl
= newUrl
.toDisplayString(QUrl::PreferLocalFile
);
475 Q_EMIT m_extension
->setLocationBarUrl(prettyUrl
);
480 void DolphinPart::slotEditMimeType()
482 const KFileItemList items
= m_view
->selectedItems();
483 if (!items
.isEmpty()) {
484 KMimeTypeEditor::editMimeType(items
.first().mimetype(), m_view
);
488 void DolphinPart::slotSelectItemsMatchingPattern()
490 openSelectionDialog(i18nc("@title:window", "Select"),
491 i18n("Select all items matching this pattern:"),
495 void DolphinPart::slotUnselectItemsMatchingPattern()
497 openSelectionDialog(i18nc("@title:window", "Unselect"),
498 i18n("Unselect all items matching this pattern:"),
502 void DolphinPart::openSelectionDialog(const QString
& title
, const QString
& text
, bool selectItems
)
504 auto *dialog
= new QInputDialog(m_view
);
505 dialog
->setAttribute(Qt::WA_DeleteOnClose
, true);
506 dialog
->setInputMode(QInputDialog::TextInput
);
507 dialog
->setWindowTitle(title
);
508 dialog
->setLabelText(text
);
510 const KConfigGroup group
= KSharedConfig::openConfig("dolphinpartrc")->group("Select Dialog");
511 dialog
->setComboBoxEditable(true);
512 dialog
->setComboBoxItems(group
.readEntry("History", QStringList()));
514 dialog
->setTextValue(QStringLiteral("*"));
516 connect(dialog
, &QDialog::accepted
, this, [=]() {
517 const QString pattern
= dialog
->textValue();
518 if (!pattern
.isEmpty()) {
519 QStringList items
= dialog
->comboBoxItems();
520 items
.removeAll(pattern
);
521 items
.prepend(pattern
);
523 // Need to evaluate this again here, because the captured value is const
524 // (even if the const were removed from 'const KConfigGroup group =' above).
525 KConfigGroup group
= KSharedConfig::openConfig("dolphinpartrc")->group("Select Dialog");
526 // Limit the size of the saved history.
527 group
.writeEntry("History", items
.mid(0, 10));
530 const QRegularExpression
patternRegExp(QRegularExpression::wildcardToRegularExpression(pattern
));
531 m_view
->selectItems(patternRegExp
, selectItems
);
538 void DolphinPart::setCurrentViewMode(const QString
& viewModeName
)
540 QAction
* action
= actionCollection()->action(viewModeName
);
545 QString
DolphinPart::currentViewMode() const
547 return m_actionHandler
->currentViewModeActionName();
550 void DolphinPart::setNameFilter(const QString
& nameFilter
)
552 // This is the "/home/dfaure/*.diff" kind of name filter (KDirLister::setNameFilter)
553 // which is unrelated to DolphinView::setNameFilter which is substring filtering in a proxy.
554 m_nameFilter
= nameFilter
;
555 // TODO save/restore name filter in saveState/restoreState like KonqDirPart did in kde3?
558 QString
DolphinPart::localFilePathOrHome() const
560 const QString localPath
= localFilePath();
561 if (!localPath
.isEmpty()) {
564 return QDir::homePath();
567 void DolphinPart::slotOpenTerminal()
569 KToolInvocation::invokeTerminal(QString(), localFilePathOrHome());
572 void DolphinPart::slotFindFile()
575 KMoreToolsMenuFactory("dolphin/search-tools").fillMenuFromGroupingNames(
576 &searchTools
, { "files-find" }, QUrl::fromLocalFile(localFilePathOrHome())
578 QList
<QAction
*> actions
= searchTools
.actions();
579 if (!(actions
.isEmpty())) {
580 actions
.first()->trigger();
582 KIO::CommandLauncherJob
*job
= new KIO::CommandLauncherJob(QStringLiteral("kfind"), {url().toString()}, this);
583 job
->setDesktopName(QStringLiteral("org.kde.kfind"));
584 job
->setUiDelegate(new KDialogJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled
, widget()));
589 void DolphinPart::updateNewMenu()
591 // As requested by KNewFileMenu :
592 m_newFileMenu
->checkUpToDate();
593 m_newFileMenu
->setViewShowsHiddenFiles(m_view
->hiddenFilesShown());
594 // And set the files that the menu apply on :
595 m_newFileMenu
->setPopupFiles(QList
<QUrl
>() << url());
598 void DolphinPart::updateStatusBar()
600 const QString escapedText
= Qt::convertFromPlainText(m_view
->statusBarText());
601 Q_EMIT
ReadOnlyPart::setStatusBarText(QStringLiteral("<qt>%1</qt>").arg(escapedText
));
604 void DolphinPart::updateProgress(int percent
)
606 Q_EMIT m_extension
->loadingProgress(percent
);
609 void DolphinPart::createDirectory()
611 m_newFileMenu
->setViewShowsHiddenFiles(m_view
->hiddenFilesShown());
612 m_newFileMenu
->setPopupFiles(QList
<QUrl
>() << url());
613 m_newFileMenu
->createDirectory();
616 void DolphinPart::setFilesToSelect(const QList
<QUrl
>& files
)
618 if (files
.isEmpty()) {
622 m_view
->markUrlsAsSelected(files
);
623 m_view
->markUrlAsCurrent(files
.at(0));
626 bool DolphinPart::eventFilter(QObject
* obj
, QEvent
* event
)
628 using ShiftState
= DolphinRemoveAction::ShiftState
;
629 const int type
= event
->type();
631 if ((type
== QEvent::KeyPress
|| type
== QEvent::KeyRelease
) && m_removeAction
) {
632 QMenu
* menu
= qobject_cast
<QMenu
*>(obj
);
633 if (menu
&& menu
->parent() == m_view
) {
634 QKeyEvent
* ev
= static_cast<QKeyEvent
*>(event
);
635 if (ev
->key() == Qt::Key_Shift
) {
636 m_removeAction
->update(type
== QEvent::KeyPress
? ShiftState::Pressed
: ShiftState::Released
);
641 return KParts::ReadOnlyPart::eventFilter(obj
, event
);
644 #include "dolphinpart.moc"