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>
37 #include <QActionGroup>
38 #include <QApplication>
41 #include <QInputDialog>
44 #include <QRegularExpression>
45 #include <QStandardPaths>
46 #include <QTextDocument>
48 #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()
144 m_newFileMenu
= new DolphinNewFileMenu(actionCollection()->action(QStringLiteral("create_dir")), this);
145 m_newFileMenu
->setParentWidget(widget());
146 connect(m_newFileMenu
->menu(), &QMenu::aboutToShow
, this, &DolphinPart::updateNewMenu
);
148 QAction
*editMimeTypeAction
= actionCollection()->addAction(QStringLiteral("editMimeType"));
149 editMimeTypeAction
->setText(i18nc("@action:inmenu Edit", "&Edit File Type…"));
150 connect(editMimeTypeAction
, &QAction::triggered
, this, &DolphinPart::slotEditMimeType
);
152 QAction
*selectItemsMatching
= actionCollection()->addAction(QStringLiteral("select_items_matching"));
153 selectItemsMatching
->setText(i18nc("@action:inmenu Edit", "Select Items Matching…"));
154 actionCollection()->setDefaultShortcut(selectItemsMatching
, Qt::CTRL
| Qt::Key_S
);
155 connect(selectItemsMatching
, &QAction::triggered
, this, &DolphinPart::slotSelectItemsMatchingPattern
);
157 QAction
*unselectItemsMatching
= actionCollection()->addAction(QStringLiteral("unselect_items_matching"));
158 unselectItemsMatching
->setText(i18nc("@action:inmenu Edit", "Unselect Items Matching…"));
159 connect(unselectItemsMatching
, &QAction::triggered
, this, &DolphinPart::slotUnselectItemsMatchingPattern
);
161 KStandardAction::selectAll(m_view
, &DolphinView::selectAll
, actionCollection());
163 QAction
*unselectAll
= actionCollection()->addAction(QStringLiteral("unselect_all"));
164 unselectAll
->setText(i18nc("@action:inmenu Edit", "Unselect All"));
165 connect(unselectAll
, &QAction::triggered
, m_view
, &DolphinView::clearSelection
);
167 QAction
*invertSelection
= actionCollection()->addAction(QStringLiteral("invert_selection"));
168 invertSelection
->setText(i18nc("@action:inmenu Edit", "Invert Selection"));
169 actionCollection()->setDefaultShortcut(invertSelection
, Qt::CTRL
| Qt::SHIFT
| Qt::Key_A
);
170 connect(invertSelection
, &QAction::triggered
, m_view
, &DolphinView::invertSelection
);
172 // View menu: all done by DolphinViewActionHandler
176 QActionGroup
*goActionGroup
= new QActionGroup(this);
177 connect(goActionGroup
, &QActionGroup::triggered
, this, &DolphinPart::slotGoTriggered
);
179 createGoAction("go_applications", "start-here-kde", i18nc("@action:inmenu Go", "App&lications"), QStringLiteral("programs:/"), goActionGroup
);
180 createGoAction("go_network_folders", "folder-remote", i18nc("@action:inmenu Go", "&Network Folders"), QStringLiteral("remote:/"), goActionGroup
);
181 createGoAction("go_trash", "user-trash", i18nc("@action:inmenu Go", "Trash"), QStringLiteral("trash:/"), goActionGroup
);
182 createGoAction("go_autostart",
184 i18nc("@action:inmenu Go", "Autostart"),
185 QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation
) + "/autostart",
189 m_findFileAction
= KStandardAction::find(this, &DolphinPart::slotFindFile
, actionCollection());
190 m_findFileAction
->setText(i18nc("@action:inmenu Tools", "Find File…"));
193 if (KAuthorized::authorize(QStringLiteral("shell_access"))) {
194 m_openTerminalAction
= actionCollection()->addAction(QStringLiteral("open_terminal"));
195 m_openTerminalAction
->setIcon(QIcon::fromTheme(QStringLiteral("dialog-scripts")));
196 m_openTerminalAction
->setText(i18nc("@action:inmenu Tools", "Open &Terminal"));
197 connect(m_openTerminalAction
, &QAction::triggered
, this, &DolphinPart::slotOpenTerminal
);
198 actionCollection()->setDefaultShortcut(m_openTerminalAction
, Qt::Key_F4
);
203 void DolphinPart::createGoAction(const char *name
, const char *iconName
, const QString
&text
, const QString
&url
, QActionGroup
*actionGroup
)
205 QAction
*action
= actionCollection()->addAction(name
);
206 action
->setIcon(QIcon::fromTheme(iconName
));
207 action
->setText(text
);
208 action
->setData(url
);
209 action
->setActionGroup(actionGroup
);
212 void DolphinPart::slotGoTriggered(QAction
*action
)
214 const QString url
= action
->data().toString();
215 Q_EMIT m_extension
->openUrlRequest(QUrl(url
));
218 void DolphinPart::slotSelectionChanged(const KFileItemList
&selection
)
220 const bool hasSelection
= !selection
.isEmpty();
222 QAction
*renameAction
= actionCollection()->action(KStandardAction::name(KStandardAction::RenameFile
));
223 QAction
*moveToTrashAction
= actionCollection()->action(KStandardAction::name(KStandardAction::MoveToTrash
));
224 QAction
*deleteAction
= actionCollection()->action(KStandardAction::name(KStandardAction::DeleteFile
));
225 QAction
*editMimeTypeAction
= actionCollection()->action(QStringLiteral("editMimeType"));
226 QAction
*propertiesAction
= actionCollection()->action(QStringLiteral("properties"));
227 QAction
*deleteWithTrashShortcut
= actionCollection()->action(QStringLiteral("delete_shortcut")); // see DolphinViewActionHandler
230 stateChanged(QStringLiteral("has_no_selection"));
232 Q_EMIT m_extension
->enableAction("cut", false);
233 Q_EMIT m_extension
->enableAction("copy", false);
234 deleteWithTrashShortcut
->setEnabled(false);
235 editMimeTypeAction
->setEnabled(false);
237 stateChanged(QStringLiteral("has_selection"));
239 // TODO share this code with DolphinMainWindow::updateEditActions (and the desktop code)
241 KFileItemListProperties
capabilities(selection
);
242 const bool enableMoveToTrash
= capabilities
.isLocal() && capabilities
.supportsMoving();
244 renameAction
->setEnabled(capabilities
.supportsMoving());
245 moveToTrashAction
->setEnabled(enableMoveToTrash
);
246 deleteAction
->setEnabled(capabilities
.supportsDeleting());
247 deleteWithTrashShortcut
->setEnabled(capabilities
.supportsDeleting() && !enableMoveToTrash
);
248 editMimeTypeAction
->setEnabled(true);
249 propertiesAction
->setEnabled(true);
250 Q_EMIT m_extension
->enableAction("cut", capabilities
.supportsMoving());
251 Q_EMIT m_extension
->enableAction("copy", true);
255 void DolphinPart::updatePasteAction()
257 QPair
<bool, QString
> pasteInfo
= m_view
->pasteInfo();
258 Q_EMIT m_extension
->enableAction("paste", pasteInfo
.first
);
259 Q_EMIT m_extension
->setActionText("paste", pasteInfo
.second
);
262 QString
DolphinPart::urlToLocalFilePath(const QUrl
&url
)
264 KIO::StatJob
*statJob
= KIO::mostLocalUrl(url
);
265 KJobWidgets::setWindow(statJob
, widget());
267 QUrl localUrl
= statJob
->mostLocalUrl();
268 if (localUrl
.isLocalFile()) {
269 return localUrl
.toLocalFile();
274 bool DolphinPart::openUrl(const QUrl
&url
)
276 bool reload
= arguments().reload();
277 // A bit of a workaround so that changing the namefilter works: force reload.
278 // Otherwise DolphinView wouldn't relist the URL, so nothing would happen.
279 if (m_nameFilter
!= m_view
->nameFilter())
281 if (m_view
->url() == url
&& !reload
) { // DolphinView won't do anything in that case, so don't emit started
284 setUrl(url
); // remember url at the KParts level
285 setLocalFilePath(urlToLocalFilePath(url
)); // remember local path at the KParts level
286 QUrl
visibleUrl(url
);
287 if (!m_nameFilter
.isEmpty()) {
288 visibleUrl
.setPath(visibleUrl
.path() + '/' + m_nameFilter
);
290 QString prettyUrl
= visibleUrl
.toDisplayString(QUrl::PreferLocalFile
);
291 Q_EMIT
setWindowCaption(prettyUrl
);
292 Q_EMIT m_extension
->setLocationBarUrl(prettyUrl
);
293 Q_EMIT
started(nullptr); // get the wheel to spin
294 m_view
->setNameFilter(m_nameFilter
);
297 Q_EMIT
aboutToOpenURL();
300 // Disable "Find File" and "Open Terminal" actions for non-file URLs,
301 // e.g. ftp, smb, etc. #279283
302 const bool isLocalUrl
= !(localFilePath().isEmpty());
303 m_findFileAction
->setEnabled(isLocalUrl
);
304 if (m_openTerminalAction
) {
305 m_openTerminalAction
->setEnabled(isLocalUrl
);
310 void DolphinPart::slotMessage(const QString
&msg
)
312 Q_EMIT
setStatusBarText(msg
);
315 void DolphinPart::slotErrorMessage(const QString
&msg
)
317 qCDebug(DolphinDebug
) << msg
;
318 Q_EMIT
canceled(msg
);
319 //KMessageBox::error(m_view, msg);
322 void DolphinPart::slotRequestItemInfo(const KFileItem
&item
)
324 Q_EMIT m_extension
->mouseOverInfo(item
);
328 const QString escapedText
= Qt::convertFromPlainText(item
.getStatusBarInfo());
329 Q_EMIT
ReadOnlyPart::setStatusBarText(QStringLiteral("<qt>%1</qt>").arg(escapedText
));
333 void DolphinPart::slotItemActivated(const KFileItem
&item
)
335 KParts::OpenUrlArguments args
;
336 // Forget about the known mimetype if a target URL is used.
337 // Testcase: network:/ with a item (mimetype "inode/some-foo-service") pointing to a http URL (html)
338 if (item
.targetUrl() == item
.url()) {
339 args
.setMimeType(item
.mimetype());
342 Q_EMIT m_extension
->openUrlRequest(item
.targetUrl(), args
);
345 void DolphinPart::slotItemsActivated(const KFileItemList
&items
)
347 for (const KFileItem
&item
: items
) {
348 slotItemActivated(item
);
352 void DolphinPart::createNewWindow(const QUrl
&url
)
354 // TODO: Check issue N176832 for the missing QAIV signal; task 177399 - maybe this code
355 // should be moved into DolphinPart::slotItemActivated()
356 Q_EMIT m_extension
->createNewWindow(url
);
359 void DolphinPart::slotOpenContextMenu(const QPoint
&pos
, const KFileItem
&_item
, const KFileItemList
&selectedItems
, const QUrl
&)
361 KParts::NavigationExtension::PopupFlags popupFlags
=
362 KParts::NavigationExtension::DefaultPopupItems
| KParts::NavigationExtension::ShowProperties
| KParts::NavigationExtension::ShowUrlOperations
;
364 KFileItem
item(_item
);
366 if (item
.isNull()) { // viewport context menu
367 item
= m_view
->rootItem();
369 item
= KFileItem(url());
371 item
.setUrl(url()); // ensure we use the view url, not the canonical path (#213799)
375 if (selectedItems
.isEmpty()) {
378 items
= selectedItems
;
381 KFileItemListProperties
capabilities(items
);
383 KParts::NavigationExtension::ActionGroupMap actionGroups
;
384 QList
<QAction
*> editActions
;
385 editActions
+= m_view
->versionControlActions(m_view
->selectedItems());
387 if (!_item
.isNull()) { // only for context menu on one or more items
388 const bool supportsMoving
= capabilities
.supportsMoving();
390 if (capabilities
.supportsDeleting()) {
391 const bool showDeleteAction
= (KSharedConfig::openConfig()->group("KDE").readEntry("ShowDeleteCommand", false) || !item
.isLocalFile());
392 const bool showMoveToTrashAction
= capabilities
.isLocal() && supportsMoving
;
394 if (showDeleteAction
&& showMoveToTrashAction
) {
395 delete m_removeAction
;
396 m_removeAction
= nullptr;
397 editActions
.append(actionCollection()->action(KStandardAction::name(KStandardAction::MoveToTrash
)));
398 editActions
.append(actionCollection()->action(KStandardAction::name(KStandardAction::DeleteFile
)));
399 } else if (showDeleteAction
&& !showMoveToTrashAction
) {
400 editActions
.append(actionCollection()->action(KStandardAction::name(KStandardAction::DeleteFile
)));
403 m_removeAction
= new DolphinRemoveAction(this, actionCollection());
404 editActions
.append(m_removeAction
);
405 m_removeAction
->update();
408 popupFlags
|= KParts::NavigationExtension::NoDeletion
;
411 if (supportsMoving
) {
412 editActions
.append(actionCollection()->action(KStandardAction::name(KStandardAction::RenameFile
)));
415 // Normally KonqPopupMenu only shows the "Create new" submenu in the current view
416 // since otherwise the created file would not be visible.
417 // But in treeview mode we should allow it.
418 if (m_view
->itemsExpandable())
419 popupFlags
|= KParts::NavigationExtension::ShowCreateDirectory
;
422 actionGroups
.insert(QStringLiteral("editactions"), editActions
);
424 Q_EMIT m_extension
->popupMenu(pos
, items
, KParts::OpenUrlArguments(), popupFlags
, actionGroups
);
427 void DolphinPart::slotDirectoryRedirection(const QUrl
&oldUrl
, const QUrl
&newUrl
)
429 qCDebug(DolphinDebug
) << oldUrl
<< newUrl
<< "currentUrl=" << url();
430 if (oldUrl
.matches(url(), QUrl::StripTrailingSlash
/* #207572 */)) {
431 KParts::ReadOnlyPart::setUrl(newUrl
);
432 const QString prettyUrl
= newUrl
.toDisplayString(QUrl::PreferLocalFile
);
433 Q_EMIT m_extension
->setLocationBarUrl(prettyUrl
);
437 void DolphinPart::slotEditMimeType()
439 const KFileItemList items
= m_view
->selectedItems();
440 if (!items
.isEmpty()) {
441 KMimeTypeEditor::editMimeType(items
.first().mimetype(), m_view
);
445 void DolphinPart::slotSelectItemsMatchingPattern()
447 openSelectionDialog(i18nc("@title:window", "Select"), i18n("Select all items matching this pattern:"), true);
450 void DolphinPart::slotUnselectItemsMatchingPattern()
452 openSelectionDialog(i18nc("@title:window", "Unselect"), i18n("Unselect all items matching this pattern:"), false);
455 void DolphinPart::openSelectionDialog(const QString
&title
, const QString
&text
, bool selectItems
)
457 auto *dialog
= new QInputDialog(m_view
);
458 dialog
->setAttribute(Qt::WA_DeleteOnClose
, true);
459 dialog
->setInputMode(QInputDialog::TextInput
);
460 dialog
->setWindowTitle(title
);
461 dialog
->setLabelText(text
);
463 const KConfigGroup group
= KSharedConfig::openConfig("dolphinpartrc")->group("Select Dialog");
464 dialog
->setComboBoxEditable(true);
465 dialog
->setComboBoxItems(group
.readEntry("History", QStringList()));
467 dialog
->setTextValue(QStringLiteral("*"));
469 connect(dialog
, &QDialog::accepted
, this, [=]() {
470 const QString pattern
= dialog
->textValue();
471 if (!pattern
.isEmpty()) {
472 QStringList items
= dialog
->comboBoxItems();
473 items
.removeAll(pattern
);
474 items
.prepend(pattern
);
476 // Need to evaluate this again here, because the captured value is const
477 // (even if the const were removed from 'const KConfigGroup group =' above).
478 KConfigGroup group
= KSharedConfig::openConfig("dolphinpartrc")->group("Select Dialog");
479 // Limit the size of the saved history.
480 group
.writeEntry("History", items
.mid(0, 10));
483 const QRegularExpression
patternRegExp(QRegularExpression::wildcardToRegularExpression(pattern
));
484 m_view
->selectItems(patternRegExp
, selectItems
);
491 void DolphinPart::setCurrentViewMode(const QString
&viewModeName
)
493 QAction
*action
= actionCollection()->action(viewModeName
);
498 QString
DolphinPart::currentViewMode() const
500 return m_actionHandler
->currentViewModeActionName();
503 void DolphinPart::setNameFilter(const QString
&nameFilter
)
505 // This is the "/home/dfaure/*.diff" kind of name filter (KDirLister::setNameFilter)
506 // which is unrelated to DolphinView::setNameFilter which is substring filtering in a proxy.
507 m_nameFilter
= nameFilter
;
508 // TODO save/restore name filter in saveState/restoreState like KonqDirPart did in kde3?
511 QString
DolphinPart::localFilePathOrHome() const
513 const QString localPath
= localFilePath();
514 if (!localPath
.isEmpty()) {
517 return QDir::homePath();
520 void DolphinPart::slotOpenTerminal()
522 auto job
= new KTerminalLauncherJob(QString());
523 job
->setWorkingDirectory(localFilePathOrHome());
527 void DolphinPart::slotFindFile()
530 KMoreToolsMenuFactory("dolphin/search-tools").fillMenuFromGroupingNames(&searchTools
, {"files-find"}, QUrl::fromLocalFile(localFilePathOrHome()));
531 QList
<QAction
*> actions
= searchTools
.actions();
532 if (!(actions
.isEmpty())) {
533 actions
.first()->trigger();
535 KIO::CommandLauncherJob
*job
= new KIO::CommandLauncherJob(QStringLiteral("kfind"), {url().toString()}, this);
536 job
->setDesktopName(QStringLiteral("org.kde.kfind"));
537 job
->setUiDelegate(new KDialogJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled
, widget()));
542 void DolphinPart::updateNewMenu()
544 // As requested by KNewFileMenu :
545 m_newFileMenu
->checkUpToDate();
546 // And set the files that the menu apply on :
547 m_newFileMenu
->setWorkingDirectory(url());
550 void DolphinPart::updateStatusBar()
552 m_view
->requestStatusBarText();
555 void DolphinPart::updateProgress(int percent
)
557 Q_EMIT m_extension
->loadingProgress(percent
);
560 void DolphinPart::createDirectory()
562 m_newFileMenu
->setWorkingDirectory(url());
563 m_newFileMenu
->createDirectory();
566 void DolphinPart::setFilesToSelect(const QList
<QUrl
> &files
)
568 if (files
.isEmpty()) {
572 m_view
->markUrlsAsSelected(files
);
573 m_view
->markUrlAsCurrent(files
.at(0));
576 bool DolphinPart::eventFilter(QObject
*obj
, QEvent
*event
)
578 using ShiftState
= DolphinRemoveAction::ShiftState
;
579 const int type
= event
->type();
581 if ((type
== QEvent::KeyPress
|| type
== QEvent::KeyRelease
) && m_removeAction
) {
582 QMenu
*menu
= qobject_cast
<QMenu
*>(obj
);
583 if (menu
&& menu
->parent() == m_view
) {
584 QKeyEvent
*ev
= static_cast<QKeyEvent
*>(event
);
585 if (ev
->key() == Qt::Key_Shift
) {
586 m_removeAction
->update(type
== QEvent::KeyPress
? ShiftState::Pressed
: ShiftState::Released
);
591 return KParts::ReadOnlyPart::eventFilter(obj
, event
);
594 #include "dolphinpart.moc"
595 #include "moc_dolphinpart.cpp"