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 // Ideally, konqueror should be changed to not require trustedSource for directory views,
343 // since the idea was not to need BrowserArguments for non-browser stuff...
344 KParts::BrowserArguments browserArgs
;
345 browserArgs
.trustedSource
= true;
346 Q_EMIT m_extension
->openUrlRequest(item
.targetUrl(), args
, browserArgs
);
349 void DolphinPart::slotItemsActivated(const KFileItemList
&items
)
351 for (const KFileItem
&item
: items
) {
352 slotItemActivated(item
);
356 void DolphinPart::createNewWindow(const QUrl
&url
)
358 // TODO: Check issue N176832 for the missing QAIV signal; task 177399 - maybe this code
359 // should be moved into DolphinPart::slotItemActivated()
360 Q_EMIT m_extension
->createNewWindow(url
);
363 void DolphinPart::slotOpenContextMenu(const QPoint
&pos
, const KFileItem
&_item
, const KFileItemList
&selectedItems
, const QUrl
&)
365 KParts::NavigationExtension::PopupFlags popupFlags
=
366 KParts::NavigationExtension::DefaultPopupItems
| KParts::NavigationExtension::ShowProperties
| KParts::NavigationExtension::ShowUrlOperations
;
368 KFileItem
item(_item
);
370 if (item
.isNull()) { // viewport context menu
371 item
= m_view
->rootItem();
373 item
= KFileItem(url());
375 item
.setUrl(url()); // ensure we use the view url, not the canonical path (#213799)
379 if (selectedItems
.isEmpty()) {
382 items
= selectedItems
;
385 KFileItemListProperties
capabilities(items
);
387 KParts::NavigationExtension::ActionGroupMap actionGroups
;
388 QList
<QAction
*> editActions
;
389 editActions
+= m_view
->versionControlActions(m_view
->selectedItems());
391 if (!_item
.isNull()) { // only for context menu on one or more items
392 const bool supportsMoving
= capabilities
.supportsMoving();
394 if (capabilities
.supportsDeleting()) {
395 const bool showDeleteAction
= (KSharedConfig::openConfig()->group("KDE").readEntry("ShowDeleteCommand", false) || !item
.isLocalFile());
396 const bool showMoveToTrashAction
= capabilities
.isLocal() && supportsMoving
;
398 if (showDeleteAction
&& showMoveToTrashAction
) {
399 delete m_removeAction
;
400 m_removeAction
= nullptr;
401 editActions
.append(actionCollection()->action(KStandardAction::name(KStandardAction::MoveToTrash
)));
402 editActions
.append(actionCollection()->action(KStandardAction::name(KStandardAction::DeleteFile
)));
403 } else if (showDeleteAction
&& !showMoveToTrashAction
) {
404 editActions
.append(actionCollection()->action(KStandardAction::name(KStandardAction::DeleteFile
)));
407 m_removeAction
= new DolphinRemoveAction(this, actionCollection());
408 editActions
.append(m_removeAction
);
409 m_removeAction
->update();
412 popupFlags
|= KParts::NavigationExtension::NoDeletion
;
415 if (supportsMoving
) {
416 editActions
.append(actionCollection()->action(KStandardAction::name(KStandardAction::RenameFile
)));
419 // Normally KonqPopupMenu only shows the "Create new" submenu in the current view
420 // since otherwise the created file would not be visible.
421 // But in treeview mode we should allow it.
422 if (m_view
->itemsExpandable())
423 popupFlags
|= KParts::NavigationExtension::ShowCreateDirectory
;
426 actionGroups
.insert(QStringLiteral("editactions"), editActions
);
428 Q_EMIT m_extension
->popupMenu(pos
, items
, KParts::OpenUrlArguments(), KParts::BrowserArguments(), popupFlags
, actionGroups
);
431 void DolphinPart::slotDirectoryRedirection(const QUrl
&oldUrl
, const QUrl
&newUrl
)
433 qCDebug(DolphinDebug
) << oldUrl
<< newUrl
<< "currentUrl=" << url();
434 if (oldUrl
.matches(url(), QUrl::StripTrailingSlash
/* #207572 */)) {
435 KParts::ReadOnlyPart::setUrl(newUrl
);
436 const QString prettyUrl
= newUrl
.toDisplayString(QUrl::PreferLocalFile
);
437 Q_EMIT m_extension
->setLocationBarUrl(prettyUrl
);
441 void DolphinPart::slotEditMimeType()
443 const KFileItemList items
= m_view
->selectedItems();
444 if (!items
.isEmpty()) {
445 KMimeTypeEditor::editMimeType(items
.first().mimetype(), m_view
);
449 void DolphinPart::slotSelectItemsMatchingPattern()
451 openSelectionDialog(i18nc("@title:window", "Select"), i18n("Select all items matching this pattern:"), true);
454 void DolphinPart::slotUnselectItemsMatchingPattern()
456 openSelectionDialog(i18nc("@title:window", "Unselect"), i18n("Unselect all items matching this pattern:"), false);
459 void DolphinPart::openSelectionDialog(const QString
&title
, const QString
&text
, bool selectItems
)
461 auto *dialog
= new QInputDialog(m_view
);
462 dialog
->setAttribute(Qt::WA_DeleteOnClose
, true);
463 dialog
->setInputMode(QInputDialog::TextInput
);
464 dialog
->setWindowTitle(title
);
465 dialog
->setLabelText(text
);
467 const KConfigGroup group
= KSharedConfig::openConfig("dolphinpartrc")->group("Select Dialog");
468 dialog
->setComboBoxEditable(true);
469 dialog
->setComboBoxItems(group
.readEntry("History", QStringList()));
471 dialog
->setTextValue(QStringLiteral("*"));
473 connect(dialog
, &QDialog::accepted
, this, [=]() {
474 const QString pattern
= dialog
->textValue();
475 if (!pattern
.isEmpty()) {
476 QStringList items
= dialog
->comboBoxItems();
477 items
.removeAll(pattern
);
478 items
.prepend(pattern
);
480 // Need to evaluate this again here, because the captured value is const
481 // (even if the const were removed from 'const KConfigGroup group =' above).
482 KConfigGroup group
= KSharedConfig::openConfig("dolphinpartrc")->group("Select Dialog");
483 // Limit the size of the saved history.
484 group
.writeEntry("History", items
.mid(0, 10));
487 const QRegularExpression
patternRegExp(QRegularExpression::wildcardToRegularExpression(pattern
));
488 m_view
->selectItems(patternRegExp
, selectItems
);
495 void DolphinPart::setCurrentViewMode(const QString
&viewModeName
)
497 QAction
*action
= actionCollection()->action(viewModeName
);
502 QString
DolphinPart::currentViewMode() const
504 return m_actionHandler
->currentViewModeActionName();
507 void DolphinPart::setNameFilter(const QString
&nameFilter
)
509 // This is the "/home/dfaure/*.diff" kind of name filter (KDirLister::setNameFilter)
510 // which is unrelated to DolphinView::setNameFilter which is substring filtering in a proxy.
511 m_nameFilter
= nameFilter
;
512 // TODO save/restore name filter in saveState/restoreState like KonqDirPart did in kde3?
515 QString
DolphinPart::localFilePathOrHome() const
517 const QString localPath
= localFilePath();
518 if (!localPath
.isEmpty()) {
521 return QDir::homePath();
524 void DolphinPart::slotOpenTerminal()
526 auto job
= new KTerminalLauncherJob(QString());
527 job
->setWorkingDirectory(localFilePathOrHome());
531 void DolphinPart::slotFindFile()
534 KMoreToolsMenuFactory("dolphin/search-tools").fillMenuFromGroupingNames(&searchTools
, {"files-find"}, QUrl::fromLocalFile(localFilePathOrHome()));
535 QList
<QAction
*> actions
= searchTools
.actions();
536 if (!(actions
.isEmpty())) {
537 actions
.first()->trigger();
539 KIO::CommandLauncherJob
*job
= new KIO::CommandLauncherJob(QStringLiteral("kfind"), {url().toString()}, this);
540 job
->setDesktopName(QStringLiteral("org.kde.kfind"));
541 job
->setUiDelegate(new KDialogJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled
, widget()));
546 void DolphinPart::updateNewMenu()
548 // As requested by KNewFileMenu :
549 m_newFileMenu
->checkUpToDate();
550 // And set the files that the menu apply on :
551 m_newFileMenu
->setWorkingDirectory(url());
554 void DolphinPart::updateStatusBar()
556 m_view
->requestStatusBarText();
559 void DolphinPart::updateProgress(int percent
)
561 Q_EMIT m_extension
->loadingProgress(percent
);
564 void DolphinPart::createDirectory()
566 m_newFileMenu
->setWorkingDirectory(url());
567 m_newFileMenu
->createDirectory();
570 void DolphinPart::setFilesToSelect(const QList
<QUrl
> &files
)
572 if (files
.isEmpty()) {
576 m_view
->markUrlsAsSelected(files
);
577 m_view
->markUrlAsCurrent(files
.at(0));
580 bool DolphinPart::eventFilter(QObject
*obj
, QEvent
*event
)
582 using ShiftState
= DolphinRemoveAction::ShiftState
;
583 const int type
= event
->type();
585 if ((type
== QEvent::KeyPress
|| type
== QEvent::KeyRelease
) && m_removeAction
) {
586 QMenu
*menu
= qobject_cast
<QMenu
*>(obj
);
587 if (menu
&& menu
->parent() == m_view
) {
588 QKeyEvent
*ev
= static_cast<QKeyEvent
*>(event
);
589 if (ev
->key() == Qt::Key_Shift
) {
590 m_removeAction
->update(type
== QEvent::KeyPress
? ShiftState::Pressed
: ShiftState::Released
);
595 return KParts::ReadOnlyPart::eventFilter(obj
, event
);
598 #include "dolphinpart.moc"
599 #include "moc_dolphinpart.cpp"