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 K_PLUGIN_CLASS_WITH_JSON(DolphinPart
, "dolphinpart.json")
51 DolphinPart::DolphinPart(QWidget
* parentWidget
, QObject
* parent
,
52 const KPluginMetaData
& metaData
, const QVariantList
& args
)
53 : KParts::ReadOnlyPart(parent
)
54 ,m_openTerminalAction(nullptr)
55 ,m_removeAction(nullptr)
58 setMetaData(metaData
);
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
,
70 this, &DolphinPart::slotErrorMessage
);
72 connect(m_view
, &DolphinView::directoryLoadingCompleted
, this, &KParts::ReadOnlyPart::completed
);
73 connect(m_view
, &DolphinView::directoryLoadingCompleted
, this, &DolphinPart::updatePasteAction
);
74 connect(m_view
, &DolphinView::directoryLoadingProgress
, this, &DolphinPart::updateProgress
);
75 connect(m_view
, &DolphinView::errorMessage
, this, &DolphinPart::slotErrorMessage
);
77 setXMLFile(QStringLiteral("dolphinpart.rc"));
79 connect(m_view
, &DolphinView::infoMessage
,
80 this, &DolphinPart::slotMessage
);
81 connect(m_view
, &DolphinView::operationCompletedMessage
,
82 this, &DolphinPart::slotMessage
);
83 connect(m_view
, &DolphinView::errorMessage
,
84 this, &DolphinPart::slotErrorMessage
);
85 connect(m_view
, &DolphinView::itemActivated
,
86 this, &DolphinPart::slotItemActivated
);
87 connect(m_view
, &DolphinView::itemsActivated
,
88 this, &DolphinPart::slotItemsActivated
);
89 connect(m_view
, &DolphinView::statusBarTextChanged
, this, [this](const QString
&text
) {
90 const QString escapedText
= Qt::convertFromPlainText(text
);
91 Q_EMIT
ReadOnlyPart::setStatusBarText(QStringLiteral("<qt>%1</qt>").arg(escapedText
));
93 connect(m_view
, &DolphinView::tabRequested
,
94 this, &DolphinPart::createNewWindow
);
95 connect(m_view
, &DolphinView::requestContextMenu
,
96 this, &DolphinPart::slotOpenContextMenu
);
97 connect(m_view
, &DolphinView::selectionChanged
,
98 m_extension
, &KParts::BrowserExtension::selectionInfo
);
99 connect(m_view
, &DolphinView::selectionChanged
,
100 this, &DolphinPart::slotSelectionChanged
);
101 connect(m_view
, &DolphinView::requestItemInfo
,
102 this, &DolphinPart::slotRequestItemInfo
);
103 connect(m_view
, &DolphinView::modeChanged
,
104 this, &DolphinPart::viewModeChanged
); // relay signal
105 connect(m_view
, &DolphinView::redirection
,
106 this, &DolphinPart::slotDirectoryRedirection
);
108 // Watch for changes that should result in updates to the
110 connect(m_view
, &DolphinView::itemCountChanged
, this, &DolphinPart::updateStatusBar
);
111 connect(m_view
, &DolphinView::selectionChanged
, this, &DolphinPart::updateStatusBar
);
113 m_actionHandler
= new DolphinViewActionHandler(actionCollection(), nullptr, this);
114 m_actionHandler
->setCurrentView(m_view
);
115 connect(m_actionHandler
, &DolphinViewActionHandler::createDirectoryTriggered
, this, &DolphinPart::createDirectory
);
117 m_remoteEncoding
= new DolphinRemoteEncoding(this, m_actionHandler
);
118 connect(this, &DolphinPart::aboutToOpenURL
,
119 m_remoteEncoding
, &DolphinRemoteEncoding::slotAboutToOpenUrl
);
121 QClipboard
* clipboard
= QApplication::clipboard();
122 connect(clipboard
, &QClipboard::dataChanged
,
123 this, &DolphinPart::updatePasteAction
);
125 // Create file info and listing filter extensions.
126 // NOTE: Listing filter needs to be instantiated after the creation of the view.
127 new DolphinPartFileInfoExtension(this);
129 new DolphinPartListingFilterExtension(this);
131 KDirLister
* lister
= m_view
->m_model
->m_dirLister
;
133 DolphinPartListingNotificationExtension
* notifyExt
= new DolphinPartListingNotificationExtension(this);
134 connect(lister
, &KDirLister::newItems
, notifyExt
, &DolphinPartListingNotificationExtension::slotNewItems
);
135 connect(lister
, &KDirLister::itemsDeleted
, notifyExt
, &DolphinPartListingNotificationExtension::slotItemsDeleted
);
137 qCWarning(DolphinDebug
) << "NULL KDirLister object! KParts::ListingNotificationExtension will NOT be supported";
141 m_actionHandler
->updateViewActions();
142 slotSelectionChanged(KFileItemList()); // initially disable selection-dependent actions
144 // Listen to events from the app so we can update the remove key by
145 // checking for a Shift key press.
146 qApp
->installEventFilter(this);
148 // TODO there was a "always open a new window" (when clicking on a directory) setting in konqueror
149 // (sort of spacial navigation)
152 DolphinPart::~DolphinPart()
156 void DolphinPart::createActions()
160 m_newFileMenu
= new DolphinNewFileMenu(actionCollection(), this);
161 m_newFileMenu
->setParentWidget(widget());
162 connect(m_newFileMenu
->menu(), &QMenu::aboutToShow
,
163 this, &DolphinPart::updateNewMenu
);
165 QAction
*editMimeTypeAction
= actionCollection()->addAction( QStringLiteral("editMimeType") );
166 editMimeTypeAction
->setText( i18nc("@action:inmenu Edit", "&Edit File Type..." ) );
167 connect(editMimeTypeAction
, &QAction::triggered
, this, &DolphinPart::slotEditMimeType
);
169 QAction
* selectItemsMatching
= actionCollection()->addAction(QStringLiteral("select_items_matching"));
170 selectItemsMatching
->setText(i18nc("@action:inmenu Edit", "Select Items Matching..."));
171 actionCollection()->setDefaultShortcut(selectItemsMatching
, Qt::CTRL
| Qt::Key_S
);
172 connect(selectItemsMatching
, &QAction::triggered
, this, &DolphinPart::slotSelectItemsMatchingPattern
);
174 QAction
* unselectItemsMatching
= actionCollection()->addAction(QStringLiteral("unselect_items_matching"));
175 unselectItemsMatching
->setText(i18nc("@action:inmenu Edit", "Unselect Items Matching..."));
176 connect(unselectItemsMatching
, &QAction::triggered
, this, &DolphinPart::slotUnselectItemsMatchingPattern
);
178 KStandardAction::selectAll(m_view
, &DolphinView::selectAll
, actionCollection());
180 QAction
* unselectAll
= actionCollection()->addAction(QStringLiteral("unselect_all"));
181 unselectAll
->setText(i18nc("@action:inmenu Edit", "Unselect All"));
182 connect(unselectAll
, &QAction::triggered
, m_view
, &DolphinView::clearSelection
);
184 QAction
* invertSelection
= actionCollection()->addAction(QStringLiteral("invert_selection"));
185 invertSelection
->setText(i18nc("@action:inmenu Edit", "Invert Selection"));
186 actionCollection()->setDefaultShortcut(invertSelection
, Qt::CTRL
| Qt::SHIFT
| Qt::Key_A
);
187 connect(invertSelection
, &QAction::triggered
, m_view
, &DolphinView::invertSelection
);
189 // View menu: all done by DolphinViewActionHandler
193 QActionGroup
* goActionGroup
= new QActionGroup(this);
194 connect(goActionGroup
, &QActionGroup::triggered
,
195 this, &DolphinPart::slotGoTriggered
);
197 createGoAction("go_applications", "start-here-kde",
198 i18nc("@action:inmenu Go", "App&lications"), QStringLiteral("programs:/"),
200 createGoAction("go_network_folders", "folder-remote",
201 i18nc("@action:inmenu Go", "&Network Folders"), QStringLiteral("remote:/"),
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
,
389 const KFileItemList
&selectedItems
,
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)
407 if (selectedItems
.isEmpty()) {
410 items
= selectedItems
;
413 KFileItemListProperties
capabilities(items
);
415 KParts::BrowserExtension::ActionGroupMap actionGroups
;
416 QList
<QAction
*> editActions
;
417 editActions
+= m_view
->versionControlActions(m_view
->selectedItems());
419 if (!_item
.isNull()) { // only for context menu on one or more items
420 const bool supportsMoving
= capabilities
.supportsMoving();
422 if (capabilities
.supportsDeleting()) {
423 const bool showDeleteAction
= (KSharedConfig::openConfig()->group("KDE").readEntry("ShowDeleteCommand", false) ||
424 !item
.isLocalFile());
425 const bool showMoveToTrashAction
= capabilities
.isLocal() && supportsMoving
;
427 if (showDeleteAction
&& showMoveToTrashAction
) {
428 delete m_removeAction
;
429 m_removeAction
= nullptr;
430 editActions
.append(actionCollection()->action(KStandardAction::name(KStandardAction::MoveToTrash
)));
431 editActions
.append(actionCollection()->action(KStandardAction::name(KStandardAction::DeleteFile
)));
432 } else if (showDeleteAction
&& !showMoveToTrashAction
) {
433 editActions
.append(actionCollection()->action(KStandardAction::name(KStandardAction::DeleteFile
)));
436 m_removeAction
= new DolphinRemoveAction(this, actionCollection());
437 editActions
.append(m_removeAction
);
438 m_removeAction
->update();
441 popupFlags
|= KParts::BrowserExtension::NoDeletion
;
444 if (supportsMoving
) {
445 editActions
.append(actionCollection()->action(KStandardAction::name(KStandardAction::RenameFile
)));
448 // Normally KonqPopupMenu only shows the "Create new" submenu in the current view
449 // since otherwise the created file would not be visible.
450 // But in treeview mode we should allow it.
451 if (m_view
->itemsExpandable())
452 popupFlags
|= KParts::BrowserExtension::ShowCreateDirectory
;
456 actionGroups
.insert(QStringLiteral("editactions"), editActions
);
458 Q_EMIT m_extension
->popupMenu(pos
,
460 KParts::OpenUrlArguments(),
461 KParts::BrowserArguments(),
466 void DolphinPart::slotDirectoryRedirection(const QUrl
&oldUrl
, const QUrl
&newUrl
)
468 qCDebug(DolphinDebug
) << oldUrl
<< newUrl
<< "currentUrl=" << url();
469 if (oldUrl
.matches(url(), QUrl::StripTrailingSlash
/* #207572 */)) {
470 KParts::ReadOnlyPart::setUrl(newUrl
);
471 const QString prettyUrl
= newUrl
.toDisplayString(QUrl::PreferLocalFile
);
472 Q_EMIT m_extension
->setLocationBarUrl(prettyUrl
);
477 void DolphinPart::slotEditMimeType()
479 const KFileItemList items
= m_view
->selectedItems();
480 if (!items
.isEmpty()) {
481 KMimeTypeEditor::editMimeType(items
.first().mimetype(), m_view
);
485 void DolphinPart::slotSelectItemsMatchingPattern()
487 openSelectionDialog(i18nc("@title:window", "Select"),
488 i18n("Select all items matching this pattern:"),
492 void DolphinPart::slotUnselectItemsMatchingPattern()
494 openSelectionDialog(i18nc("@title:window", "Unselect"),
495 i18n("Unselect all items matching this pattern:"),
499 void DolphinPart::openSelectionDialog(const QString
& title
, const QString
& text
, bool selectItems
)
501 auto *dialog
= new QInputDialog(m_view
);
502 dialog
->setAttribute(Qt::WA_DeleteOnClose
, true);
503 dialog
->setInputMode(QInputDialog::TextInput
);
504 dialog
->setWindowTitle(title
);
505 dialog
->setLabelText(text
);
507 const KConfigGroup group
= KSharedConfig::openConfig("dolphinpartrc")->group("Select Dialog");
508 dialog
->setComboBoxEditable(true);
509 dialog
->setComboBoxItems(group
.readEntry("History", QStringList()));
511 dialog
->setTextValue(QStringLiteral("*"));
513 connect(dialog
, &QDialog::accepted
, this, [=]() {
514 const QString pattern
= dialog
->textValue();
515 if (!pattern
.isEmpty()) {
516 QStringList items
= dialog
->comboBoxItems();
517 items
.removeAll(pattern
);
518 items
.prepend(pattern
);
520 // Need to evaluate this again here, because the captured value is const
521 // (even if the const were removed from 'const KConfigGroup group =' above).
522 KConfigGroup group
= KSharedConfig::openConfig("dolphinpartrc")->group("Select Dialog");
523 // Limit the size of the saved history.
524 group
.writeEntry("History", items
.mid(0, 10));
527 const QRegularExpression
patternRegExp(QRegularExpression::wildcardToRegularExpression(pattern
));
528 m_view
->selectItems(patternRegExp
, selectItems
);
535 void DolphinPart::setCurrentViewMode(const QString
& viewModeName
)
537 QAction
* action
= actionCollection()->action(viewModeName
);
542 QString
DolphinPart::currentViewMode() const
544 return m_actionHandler
->currentViewModeActionName();
547 void DolphinPart::setNameFilter(const QString
& nameFilter
)
549 // This is the "/home/dfaure/*.diff" kind of name filter (KDirLister::setNameFilter)
550 // which is unrelated to DolphinView::setNameFilter which is substring filtering in a proxy.
551 m_nameFilter
= nameFilter
;
552 // TODO save/restore name filter in saveState/restoreState like KonqDirPart did in kde3?
555 QString
DolphinPart::localFilePathOrHome() const
557 const QString localPath
= localFilePath();
558 if (!localPath
.isEmpty()) {
561 return QDir::homePath();
564 void DolphinPart::slotOpenTerminal()
566 auto job
= new KTerminalLauncherJob(QString());
567 job
->setWorkingDirectory(localFilePathOrHome());
571 void DolphinPart::slotFindFile()
574 KMoreToolsMenuFactory("dolphin/search-tools").fillMenuFromGroupingNames(
575 &searchTools
, { "files-find" }, QUrl::fromLocalFile(localFilePathOrHome())
577 QList
<QAction
*> actions
= searchTools
.actions();
578 if (!(actions
.isEmpty())) {
579 actions
.first()->trigger();
581 KIO::CommandLauncherJob
*job
= new KIO::CommandLauncherJob(QStringLiteral("kfind"), {url().toString()}, this);
582 job
->setDesktopName(QStringLiteral("org.kde.kfind"));
583 job
->setUiDelegate(new KDialogJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled
, widget()));
588 void DolphinPart::updateNewMenu()
590 // As requested by KNewFileMenu :
591 m_newFileMenu
->checkUpToDate();
592 // And set the files that the menu apply on :
593 #if KIO_VERSION >= QT_VERSION_CHECK(5, 97, 0)
594 m_newFileMenu
->setWorkingDirectory(url());
596 m_newFileMenu
->setPopupFiles(QList
<QUrl
>() << url());
600 void DolphinPart::updateStatusBar()
602 m_view
->requestStatusBarText();
605 void DolphinPart::updateProgress(int percent
)
607 Q_EMIT m_extension
->loadingProgress(percent
);
610 void DolphinPart::createDirectory()
612 #if KIO_VERSION >= QT_VERSION_CHECK(5, 97, 0)
613 m_newFileMenu
->setWorkingDirectory(url());
615 m_newFileMenu
->setPopupFiles(QList
<QUrl
>() << url());
617 m_newFileMenu
->createDirectory();
620 void DolphinPart::setFilesToSelect(const QList
<QUrl
>& files
)
622 if (files
.isEmpty()) {
626 m_view
->markUrlsAsSelected(files
);
627 m_view
->markUrlAsCurrent(files
.at(0));
630 bool DolphinPart::eventFilter(QObject
* obj
, QEvent
* event
)
632 using ShiftState
= DolphinRemoveAction::ShiftState
;
633 const int type
= event
->type();
635 if ((type
== QEvent::KeyPress
|| type
== QEvent::KeyRelease
) && m_removeAction
) {
636 QMenu
* menu
= qobject_cast
<QMenu
*>(obj
);
637 if (menu
&& menu
->parent() == m_view
) {
638 QKeyEvent
* ev
= static_cast<QKeyEvent
*>(event
);
639 if (ev
->key() == Qt::Key_Shift
) {
640 m_removeAction
->update(type
== QEvent::KeyPress
? ShiftState::Pressed
: ShiftState::Released
);
645 return KParts::ReadOnlyPart::eventFilter(obj
, event
);
648 #include "dolphinpart.moc"