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 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, &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::statusBarTextChanged
, this, [this](const QString
&text
) {
89 const QString escapedText
= Qt::convertFromPlainText(text
);
90 Q_EMIT
ReadOnlyPart::setStatusBarText(QStringLiteral("<qt>%1</qt>").arg(escapedText
));
92 connect(m_view
, &DolphinView::tabRequested
,
93 this, &DolphinPart::createNewWindow
);
94 connect(m_view
, &DolphinView::requestContextMenu
,
95 this, &DolphinPart::slotOpenContextMenu
);
96 connect(m_view
, &DolphinView::selectionChanged
,
97 m_extension
, &KParts::BrowserExtension::selectionInfo
);
98 connect(m_view
, &DolphinView::selectionChanged
,
99 this, &DolphinPart::slotSelectionChanged
);
100 connect(m_view
, &DolphinView::requestItemInfo
,
101 this, &DolphinPart::slotRequestItemInfo
);
102 connect(m_view
, &DolphinView::modeChanged
,
103 this, &DolphinPart::viewModeChanged
); // relay signal
104 connect(m_view
, &DolphinView::redirection
,
105 this, &DolphinPart::slotDirectoryRedirection
);
107 // Watch for changes that should result in updates to the
109 connect(m_view
, &DolphinView::itemCountChanged
, this, &DolphinPart::updateStatusBar
);
110 connect(m_view
, &DolphinView::selectionChanged
, this, &DolphinPart::updateStatusBar
);
112 m_actionHandler
= new DolphinViewActionHandler(actionCollection(), this);
113 m_actionHandler
->setCurrentView(m_view
);
114 connect(m_actionHandler
, &DolphinViewActionHandler::createDirectoryTriggered
, this, &DolphinPart::createDirectory
);
116 m_remoteEncoding
= new DolphinRemoteEncoding(this, m_actionHandler
);
117 connect(this, &DolphinPart::aboutToOpenURL
,
118 m_remoteEncoding
, &DolphinRemoteEncoding::slotAboutToOpenUrl
);
120 QClipboard
* clipboard
= QApplication::clipboard();
121 connect(clipboard
, &QClipboard::dataChanged
,
122 this, &DolphinPart::updatePasteAction
);
124 // Create file info and listing filter extensions.
125 // NOTE: Listing filter needs to be instantiated after the creation of the view.
126 new DolphinPartFileInfoExtension(this);
128 new DolphinPartListingFilterExtension(this);
130 KDirLister
* lister
= m_view
->m_model
->m_dirLister
;
132 DolphinPartListingNotificationExtension
* notifyExt
= new DolphinPartListingNotificationExtension(this);
133 connect(lister
, &KDirLister::newItems
, notifyExt
, &DolphinPartListingNotificationExtension::slotNewItems
);
134 connect(lister
, &KDirLister::itemsDeleted
, notifyExt
, &DolphinPartListingNotificationExtension::slotItemsDeleted
);
136 qCWarning(DolphinDebug
) << "NULL KDirLister object! KParts::ListingNotificationExtension will NOT be supported";
140 m_actionHandler
->updateViewActions();
141 slotSelectionChanged(KFileItemList()); // initially disable selection-dependent actions
143 // Listen to events from the app so we can update the remove key by
144 // checking for a Shift key press.
145 qApp
->installEventFilter(this);
147 // TODO there was a "always open a new window" (when clicking on a directory) setting in konqueror
148 // (sort of spacial navigation)
151 DolphinPart::~DolphinPart()
155 void DolphinPart::createActions()
159 m_newFileMenu
= new DolphinNewFileMenu(actionCollection(), this);
160 m_newFileMenu
->setParentWidget(widget());
161 connect(m_newFileMenu
->menu(), &QMenu::aboutToShow
,
162 this, &DolphinPart::updateNewMenu
);
164 QAction
*editMimeTypeAction
= actionCollection()->addAction( QStringLiteral("editMimeType") );
165 editMimeTypeAction
->setText( i18nc("@action:inmenu Edit", "&Edit File Type..." ) );
166 connect(editMimeTypeAction
, &QAction::triggered
, this, &DolphinPart::slotEditMimeType
);
168 QAction
* selectItemsMatching
= actionCollection()->addAction(QStringLiteral("select_items_matching"));
169 selectItemsMatching
->setText(i18nc("@action:inmenu Edit", "Select Items Matching..."));
170 actionCollection()->setDefaultShortcut(selectItemsMatching
, Qt::CTRL
| Qt::Key_S
);
171 connect(selectItemsMatching
, &QAction::triggered
, this, &DolphinPart::slotSelectItemsMatchingPattern
);
173 QAction
* unselectItemsMatching
= actionCollection()->addAction(QStringLiteral("unselect_items_matching"));
174 unselectItemsMatching
->setText(i18nc("@action:inmenu Edit", "Unselect Items Matching..."));
175 connect(unselectItemsMatching
, &QAction::triggered
, this, &DolphinPart::slotUnselectItemsMatchingPattern
);
177 KStandardAction::selectAll(m_view
, &DolphinView::selectAll
, actionCollection());
179 QAction
* unselectAll
= actionCollection()->addAction(QStringLiteral("unselect_all"));
180 unselectAll
->setText(i18nc("@action:inmenu Edit", "Unselect All"));
181 connect(unselectAll
, &QAction::triggered
, m_view
, &DolphinView::clearSelection
);
183 QAction
* invertSelection
= actionCollection()->addAction(QStringLiteral("invert_selection"));
184 invertSelection
->setText(i18nc("@action:inmenu Edit", "Invert Selection"));
185 actionCollection()->setDefaultShortcut(invertSelection
, Qt::CTRL
| Qt::SHIFT
| Qt::Key_A
);
186 connect(invertSelection
, &QAction::triggered
, m_view
, &DolphinView::invertSelection
);
188 // View menu: all done by DolphinViewActionHandler
192 QActionGroup
* goActionGroup
= new QActionGroup(this);
193 connect(goActionGroup
, &QActionGroup::triggered
,
194 this, &DolphinPart::slotGoTriggered
);
196 createGoAction("go_applications", "start-here-kde",
197 i18nc("@action:inmenu Go", "App&lications"), QStringLiteral("programs:/"),
199 createGoAction("go_network_folders", "folder-remote",
200 i18nc("@action:inmenu Go", "&Network Folders"), QStringLiteral("remote:/"),
202 createGoAction("go_trash", "user-trash",
203 i18nc("@action:inmenu Go", "Trash"), QStringLiteral("trash:/"),
205 createGoAction("go_autostart", "",
206 i18nc("@action:inmenu Go", "Autostart"), QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation
) + "/autostart",
210 m_findFileAction
= KStandardAction::find(this, &DolphinPart::slotFindFile
, actionCollection());
211 m_findFileAction
->setText(i18nc("@action:inmenu Tools", "Find File..."));
214 if (KAuthorized::authorize(QStringLiteral("shell_access"))) {
215 m_openTerminalAction
= actionCollection()->addAction(QStringLiteral("open_terminal"));
216 m_openTerminalAction
->setIcon(QIcon::fromTheme(QStringLiteral("dialog-scripts")));
217 m_openTerminalAction
->setText(i18nc("@action:inmenu Tools", "Open &Terminal"));
218 connect(m_openTerminalAction
, &QAction::triggered
, this, &DolphinPart::slotOpenTerminal
);
219 actionCollection()->setDefaultShortcut(m_openTerminalAction
, Qt::Key_F4
);
224 void DolphinPart::createGoAction(const char* name
, const char* iconName
,
225 const QString
& text
, const QString
& url
,
226 QActionGroup
* actionGroup
)
228 QAction
* action
= actionCollection()->addAction(name
);
229 action
->setIcon(QIcon::fromTheme(iconName
));
230 action
->setText(text
);
231 action
->setData(url
);
232 action
->setActionGroup(actionGroup
);
235 void DolphinPart::slotGoTriggered(QAction
* action
)
237 const QString url
= action
->data().toString();
238 Q_EMIT m_extension
->openUrlRequest(QUrl(url
));
241 void DolphinPart::slotSelectionChanged(const KFileItemList
& selection
)
243 const bool hasSelection
= !selection
.isEmpty();
245 QAction
* renameAction
= actionCollection()->action(KStandardAction::name(KStandardAction::RenameFile
));
246 QAction
* moveToTrashAction
= actionCollection()->action(KStandardAction::name(KStandardAction::MoveToTrash
));
247 QAction
* deleteAction
= actionCollection()->action(KStandardAction::name(KStandardAction::DeleteFile
));
248 QAction
* editMimeTypeAction
= actionCollection()->action(QStringLiteral("editMimeType"));
249 QAction
* propertiesAction
= actionCollection()->action(QStringLiteral("properties"));
250 QAction
* deleteWithTrashShortcut
= actionCollection()->action(QStringLiteral("delete_shortcut")); // see DolphinViewActionHandler
253 stateChanged(QStringLiteral("has_no_selection"));
255 Q_EMIT m_extension
->enableAction("cut", false);
256 Q_EMIT m_extension
->enableAction("copy", false);
257 deleteWithTrashShortcut
->setEnabled(false);
258 editMimeTypeAction
->setEnabled(false);
260 stateChanged(QStringLiteral("has_selection"));
262 // TODO share this code with DolphinMainWindow::updateEditActions (and the desktop code)
264 KFileItemListProperties
capabilities(selection
);
265 const bool enableMoveToTrash
= capabilities
.isLocal() && capabilities
.supportsMoving();
267 renameAction
->setEnabled(capabilities
.supportsMoving());
268 moveToTrashAction
->setEnabled(enableMoveToTrash
);
269 deleteAction
->setEnabled(capabilities
.supportsDeleting());
270 deleteWithTrashShortcut
->setEnabled(capabilities
.supportsDeleting() && !enableMoveToTrash
);
271 editMimeTypeAction
->setEnabled(true);
272 propertiesAction
->setEnabled(true);
273 Q_EMIT m_extension
->enableAction("cut", capabilities
.supportsMoving());
274 Q_EMIT m_extension
->enableAction("copy", true);
278 void DolphinPart::updatePasteAction()
280 QPair
<bool, QString
> pasteInfo
= m_view
->pasteInfo();
281 Q_EMIT m_extension
->enableAction( "paste", pasteInfo
.first
);
282 Q_EMIT m_extension
->setActionText( "paste", pasteInfo
.second
);
285 QString
DolphinPart::urlToLocalFilePath(const QUrl
&url
)
287 KIO::StatJob
* statJob
= KIO::mostLocalUrl(url
);
288 KJobWidgets::setWindow(statJob
, widget());
290 QUrl localUrl
= statJob
->mostLocalUrl();
291 if (localUrl
.isLocalFile()) {
292 return localUrl
.toLocalFile();
297 bool DolphinPart::openUrl(const QUrl
&url
)
299 bool reload
= arguments().reload();
300 // A bit of a workaround so that changing the namefilter works: force reload.
301 // Otherwise DolphinView wouldn't relist the URL, so nothing would happen.
302 if (m_nameFilter
!= m_view
->nameFilter())
304 if (m_view
->url() == url
&& !reload
) { // DolphinView won't do anything in that case, so don't emit started
307 setUrl(url
); // remember url at the KParts level
308 setLocalFilePath(urlToLocalFilePath(url
)); // remember local path at the KParts level
309 QUrl
visibleUrl(url
);
310 if (!m_nameFilter
.isEmpty()) {
311 visibleUrl
.setPath(visibleUrl
.path() + '/' + m_nameFilter
);
313 QString prettyUrl
= visibleUrl
.toDisplayString(QUrl::PreferLocalFile
);
314 Q_EMIT
setWindowCaption(prettyUrl
);
315 Q_EMIT m_extension
->setLocationBarUrl(prettyUrl
);
316 Q_EMIT
started(nullptr); // get the wheel to spin
317 m_view
->setNameFilter(m_nameFilter
);
320 Q_EMIT
aboutToOpenURL();
323 // Disable "Find File" and "Open Terminal" actions for non-file URLs,
324 // e.g. ftp, smb, etc. #279283
325 const bool isLocalUrl
= !(localFilePath().isEmpty());
326 m_findFileAction
->setEnabled(isLocalUrl
);
327 if (m_openTerminalAction
) {
328 m_openTerminalAction
->setEnabled(isLocalUrl
);
333 void DolphinPart::slotMessage(const QString
& msg
)
335 Q_EMIT
setStatusBarText(msg
);
338 void DolphinPart::slotErrorMessage(const QString
& msg
)
340 qCDebug(DolphinDebug
) << msg
;
341 Q_EMIT
canceled(msg
);
342 //KMessageBox::error(m_view, msg);
345 void DolphinPart::slotRequestItemInfo(const KFileItem
& item
)
347 Q_EMIT m_extension
->mouseOverInfo(item
);
351 const QString escapedText
= Qt::convertFromPlainText(item
.getStatusBarInfo());
352 Q_EMIT
ReadOnlyPart::setStatusBarText(QStringLiteral("<qt>%1</qt>").arg(escapedText
));
356 void DolphinPart::slotItemActivated(const KFileItem
& item
)
358 KParts::OpenUrlArguments args
;
359 // Forget about the known mimetype if a target URL is used.
360 // Testcase: network:/ with a item (mimetype "inode/some-foo-service") pointing to a http URL (html)
361 if (item
.targetUrl() == item
.url()) {
362 args
.setMimeType(item
.mimetype());
365 // Ideally, konqueror should be changed to not require trustedSource for directory views,
366 // since the idea was not to need BrowserArguments for non-browser stuff...
367 KParts::BrowserArguments browserArgs
;
368 browserArgs
.trustedSource
= true;
369 Q_EMIT m_extension
->openUrlRequest(item
.targetUrl(), args
, browserArgs
);
372 void DolphinPart::slotItemsActivated(const KFileItemList
& items
)
374 for (const KFileItem
& item
: items
) {
375 slotItemActivated(item
);
379 void DolphinPart::createNewWindow(const QUrl
& url
)
381 // TODO: Check issue N176832 for the missing QAIV signal; task 177399 - maybe this code
382 // should be moved into DolphinPart::slotItemActivated()
383 Q_EMIT m_extension
->createNewWindow(url
);
386 void DolphinPart::slotOpenContextMenu(const QPoint
& pos
,
387 const KFileItem
& _item
,
388 const KFileItemList
&selectedItems
,
391 KParts::BrowserExtension::PopupFlags popupFlags
= KParts::BrowserExtension::DefaultPopupItems
392 | KParts::BrowserExtension::ShowProperties
393 | KParts::BrowserExtension::ShowUrlOperations
;
395 KFileItem
item(_item
);
397 if (item
.isNull()) { // viewport context menu
398 item
= m_view
->rootItem();
400 item
= KFileItem(url());
402 item
.setUrl(url()); // ensure we use the view url, not the canonical path (#213799)
406 if (selectedItems
.isEmpty()) {
409 items
= selectedItems
;
412 KFileItemListProperties
capabilities(items
);
414 KParts::BrowserExtension::ActionGroupMap actionGroups
;
415 QList
<QAction
*> editActions
;
416 editActions
+= m_view
->versionControlActions(m_view
->selectedItems());
418 if (!_item
.isNull()) { // only for context menu on one or more items
419 const bool supportsMoving
= capabilities
.supportsMoving();
421 if (capabilities
.supportsDeleting()) {
422 const bool showDeleteAction
= (KSharedConfig::openConfig()->group("KDE").readEntry("ShowDeleteCommand", false) ||
423 !item
.isLocalFile());
424 const bool showMoveToTrashAction
= capabilities
.isLocal() && supportsMoving
;
426 if (showDeleteAction
&& showMoveToTrashAction
) {
427 delete m_removeAction
;
428 m_removeAction
= nullptr;
429 editActions
.append(actionCollection()->action(KStandardAction::name(KStandardAction::MoveToTrash
)));
430 editActions
.append(actionCollection()->action(KStandardAction::name(KStandardAction::DeleteFile
)));
431 } else if (showDeleteAction
&& !showMoveToTrashAction
) {
432 editActions
.append(actionCollection()->action(KStandardAction::name(KStandardAction::DeleteFile
)));
435 m_removeAction
= new DolphinRemoveAction(this, actionCollection());
436 editActions
.append(m_removeAction
);
437 m_removeAction
->update();
440 popupFlags
|= KParts::BrowserExtension::NoDeletion
;
443 if (supportsMoving
) {
444 editActions
.append(actionCollection()->action(KStandardAction::name(KStandardAction::RenameFile
)));
447 // Normally KonqPopupMenu only shows the "Create new" submenu in the current view
448 // since otherwise the created file would not be visible.
449 // But in treeview mode we should allow it.
450 if (m_view
->itemsExpandable())
451 popupFlags
|= KParts::BrowserExtension::ShowCreateDirectory
;
455 actionGroups
.insert(QStringLiteral("editactions"), editActions
);
457 Q_EMIT m_extension
->popupMenu(pos
,
459 KParts::OpenUrlArguments(),
460 KParts::BrowserArguments(),
465 void DolphinPart::slotDirectoryRedirection(const QUrl
&oldUrl
, const QUrl
&newUrl
)
467 qCDebug(DolphinDebug
) << oldUrl
<< newUrl
<< "currentUrl=" << url();
468 if (oldUrl
.matches(url(), QUrl::StripTrailingSlash
/* #207572 */)) {
469 KParts::ReadOnlyPart::setUrl(newUrl
);
470 const QString prettyUrl
= newUrl
.toDisplayString(QUrl::PreferLocalFile
);
471 Q_EMIT m_extension
->setLocationBarUrl(prettyUrl
);
476 void DolphinPart::slotEditMimeType()
478 const KFileItemList items
= m_view
->selectedItems();
479 if (!items
.isEmpty()) {
480 KMimeTypeEditor::editMimeType(items
.first().mimetype(), m_view
);
484 void DolphinPart::slotSelectItemsMatchingPattern()
486 openSelectionDialog(i18nc("@title:window", "Select"),
487 i18n("Select all items matching this pattern:"),
491 void DolphinPart::slotUnselectItemsMatchingPattern()
493 openSelectionDialog(i18nc("@title:window", "Unselect"),
494 i18n("Unselect all items matching this pattern:"),
498 void DolphinPart::openSelectionDialog(const QString
& title
, const QString
& text
, bool selectItems
)
500 auto *dialog
= new QInputDialog(m_view
);
501 dialog
->setAttribute(Qt::WA_DeleteOnClose
, true);
502 dialog
->setInputMode(QInputDialog::TextInput
);
503 dialog
->setWindowTitle(title
);
504 dialog
->setLabelText(text
);
506 const KConfigGroup group
= KSharedConfig::openConfig("dolphinpartrc")->group("Select Dialog");
507 dialog
->setComboBoxEditable(true);
508 dialog
->setComboBoxItems(group
.readEntry("History", QStringList()));
510 dialog
->setTextValue(QStringLiteral("*"));
512 connect(dialog
, &QDialog::accepted
, this, [=]() {
513 const QString pattern
= dialog
->textValue();
514 if (!pattern
.isEmpty()) {
515 QStringList items
= dialog
->comboBoxItems();
516 items
.removeAll(pattern
);
517 items
.prepend(pattern
);
519 // Need to evaluate this again here, because the captured value is const
520 // (even if the const were removed from 'const KConfigGroup group =' above).
521 KConfigGroup group
= KSharedConfig::openConfig("dolphinpartrc")->group("Select Dialog");
522 // Limit the size of the saved history.
523 group
.writeEntry("History", items
.mid(0, 10));
526 const QRegularExpression
patternRegExp(QRegularExpression::wildcardToRegularExpression(pattern
));
527 m_view
->selectItems(patternRegExp
, selectItems
);
534 void DolphinPart::setCurrentViewMode(const QString
& viewModeName
)
536 QAction
* action
= actionCollection()->action(viewModeName
);
541 QString
DolphinPart::currentViewMode() const
543 return m_actionHandler
->currentViewModeActionName();
546 void DolphinPart::setNameFilter(const QString
& nameFilter
)
548 // This is the "/home/dfaure/*.diff" kind of name filter (KDirLister::setNameFilter)
549 // which is unrelated to DolphinView::setNameFilter which is substring filtering in a proxy.
550 m_nameFilter
= nameFilter
;
551 // TODO save/restore name filter in saveState/restoreState like KonqDirPart did in kde3?
554 QString
DolphinPart::localFilePathOrHome() const
556 const QString localPath
= localFilePath();
557 if (!localPath
.isEmpty()) {
560 return QDir::homePath();
563 void DolphinPart::slotOpenTerminal()
565 auto job
= new KTerminalLauncherJob(QString());
566 job
->setWorkingDirectory(localFilePathOrHome());
570 void DolphinPart::slotFindFile()
573 KMoreToolsMenuFactory("dolphin/search-tools").fillMenuFromGroupingNames(
574 &searchTools
, { "files-find" }, QUrl::fromLocalFile(localFilePathOrHome())
576 QList
<QAction
*> actions
= searchTools
.actions();
577 if (!(actions
.isEmpty())) {
578 actions
.first()->trigger();
580 KIO::CommandLauncherJob
*job
= new KIO::CommandLauncherJob(QStringLiteral("kfind"), {url().toString()}, this);
581 job
->setDesktopName(QStringLiteral("org.kde.kfind"));
582 job
->setUiDelegate(new KDialogJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled
, widget()));
587 void DolphinPart::updateNewMenu()
589 // As requested by KNewFileMenu :
590 m_newFileMenu
->checkUpToDate();
591 // And set the files that the menu apply on :
592 m_newFileMenu
->setPopupFiles(QList
<QUrl
>() << url());
595 void DolphinPart::updateStatusBar()
597 m_view
->requestStatusBarText();
600 void DolphinPart::updateProgress(int percent
)
602 Q_EMIT m_extension
->loadingProgress(percent
);
605 void DolphinPart::createDirectory()
607 m_newFileMenu
->setPopupFiles(QList
<QUrl
>() << url());
608 m_newFileMenu
->createDirectory();
611 void DolphinPart::setFilesToSelect(const QList
<QUrl
>& files
)
613 if (files
.isEmpty()) {
617 m_view
->markUrlsAsSelected(files
);
618 m_view
->markUrlAsCurrent(files
.at(0));
621 bool DolphinPart::eventFilter(QObject
* obj
, QEvent
* event
)
623 using ShiftState
= DolphinRemoveAction::ShiftState
;
624 const int type
= event
->type();
626 if ((type
== QEvent::KeyPress
|| type
== QEvent::KeyRelease
) && m_removeAction
) {
627 QMenu
* menu
= qobject_cast
<QMenu
*>(obj
);
628 if (menu
&& menu
->parent() == m_view
) {
629 QKeyEvent
* ev
= static_cast<QKeyEvent
*>(event
);
630 if (ev
->key() == Qt::Key_Shift
) {
631 m_removeAction
->update(type
== QEvent::KeyPress
? ShiftState::Pressed
: ShiftState::Released
);
636 return KParts::ReadOnlyPart::eventFilter(obj
, event
);
639 #include "dolphinpart.moc"