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(), this);
145 m_newFileMenu
->setParentWidget(widget());
146 m_newFileMenu
->setNewFolderShortcutAction(actionCollection()->action("create_dir"));
147 connect(m_newFileMenu
->menu(), &QMenu::aboutToShow
, this, &DolphinPart::updateNewMenu
);
149 QAction
*editMimeTypeAction
= actionCollection()->addAction(QStringLiteral("editMimeType"));
150 editMimeTypeAction
->setText(i18nc("@action:inmenu Edit", "&Edit File Type..."));
151 connect(editMimeTypeAction
, &QAction::triggered
, this, &DolphinPart::slotEditMimeType
);
153 QAction
*selectItemsMatching
= actionCollection()->addAction(QStringLiteral("select_items_matching"));
154 selectItemsMatching
->setText(i18nc("@action:inmenu Edit", "Select Items Matching..."));
155 actionCollection()->setDefaultShortcut(selectItemsMatching
, Qt::CTRL
| Qt::Key_S
);
156 connect(selectItemsMatching
, &QAction::triggered
, this, &DolphinPart::slotSelectItemsMatchingPattern
);
158 QAction
*unselectItemsMatching
= actionCollection()->addAction(QStringLiteral("unselect_items_matching"));
159 unselectItemsMatching
->setText(i18nc("@action:inmenu Edit", "Unselect Items Matching..."));
160 connect(unselectItemsMatching
, &QAction::triggered
, this, &DolphinPart::slotUnselectItemsMatchingPattern
);
162 KStandardAction::selectAll(m_view
, &DolphinView::selectAll
, actionCollection());
164 QAction
*unselectAll
= actionCollection()->addAction(QStringLiteral("unselect_all"));
165 unselectAll
->setText(i18nc("@action:inmenu Edit", "Unselect All"));
166 connect(unselectAll
, &QAction::triggered
, m_view
, &DolphinView::clearSelection
);
168 QAction
*invertSelection
= actionCollection()->addAction(QStringLiteral("invert_selection"));
169 invertSelection
->setText(i18nc("@action:inmenu Edit", "Invert Selection"));
170 actionCollection()->setDefaultShortcut(invertSelection
, Qt::CTRL
| Qt::SHIFT
| Qt::Key_A
);
171 connect(invertSelection
, &QAction::triggered
, m_view
, &DolphinView::invertSelection
);
173 // View menu: all done by DolphinViewActionHandler
177 QActionGroup
*goActionGroup
= new QActionGroup(this);
178 connect(goActionGroup
, &QActionGroup::triggered
, this, &DolphinPart::slotGoTriggered
);
180 createGoAction("go_applications", "start-here-kde", i18nc("@action:inmenu Go", "App&lications"), QStringLiteral("programs:/"), goActionGroup
);
181 createGoAction("go_network_folders", "folder-remote", i18nc("@action:inmenu Go", "&Network Folders"), QStringLiteral("remote:/"), goActionGroup
);
182 createGoAction("go_trash", "user-trash", i18nc("@action:inmenu Go", "Trash"), QStringLiteral("trash:/"), goActionGroup
);
183 createGoAction("go_autostart",
185 i18nc("@action:inmenu Go", "Autostart"),
186 QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation
) + "/autostart",
190 m_findFileAction
= KStandardAction::find(this, &DolphinPart::slotFindFile
, actionCollection());
191 m_findFileAction
->setText(i18nc("@action:inmenu Tools", "Find File..."));
194 if (KAuthorized::authorize(QStringLiteral("shell_access"))) {
195 m_openTerminalAction
= actionCollection()->addAction(QStringLiteral("open_terminal"));
196 m_openTerminalAction
->setIcon(QIcon::fromTheme(QStringLiteral("dialog-scripts")));
197 m_openTerminalAction
->setText(i18nc("@action:inmenu Tools", "Open &Terminal"));
198 connect(m_openTerminalAction
, &QAction::triggered
, this, &DolphinPart::slotOpenTerminal
);
199 actionCollection()->setDefaultShortcut(m_openTerminalAction
, Qt::Key_F4
);
204 void DolphinPart::createGoAction(const char *name
, const char *iconName
, const QString
&text
, const QString
&url
, QActionGroup
*actionGroup
)
206 QAction
*action
= actionCollection()->addAction(name
);
207 action
->setIcon(QIcon::fromTheme(iconName
));
208 action
->setText(text
);
209 action
->setData(url
);
210 action
->setActionGroup(actionGroup
);
213 void DolphinPart::slotGoTriggered(QAction
*action
)
215 const QString url
= action
->data().toString();
216 Q_EMIT m_extension
->openUrlRequest(QUrl(url
));
219 void DolphinPart::slotSelectionChanged(const KFileItemList
&selection
)
221 const bool hasSelection
= !selection
.isEmpty();
223 QAction
*renameAction
= actionCollection()->action(KStandardAction::name(KStandardAction::RenameFile
));
224 QAction
*moveToTrashAction
= actionCollection()->action(KStandardAction::name(KStandardAction::MoveToTrash
));
225 QAction
*deleteAction
= actionCollection()->action(KStandardAction::name(KStandardAction::DeleteFile
));
226 QAction
*editMimeTypeAction
= actionCollection()->action(QStringLiteral("editMimeType"));
227 QAction
*propertiesAction
= actionCollection()->action(QStringLiteral("properties"));
228 QAction
*deleteWithTrashShortcut
= actionCollection()->action(QStringLiteral("delete_shortcut")); // see DolphinViewActionHandler
231 stateChanged(QStringLiteral("has_no_selection"));
233 Q_EMIT m_extension
->enableAction("cut", false);
234 Q_EMIT m_extension
->enableAction("copy", false);
235 deleteWithTrashShortcut
->setEnabled(false);
236 editMimeTypeAction
->setEnabled(false);
238 stateChanged(QStringLiteral("has_selection"));
240 // TODO share this code with DolphinMainWindow::updateEditActions (and the desktop code)
242 KFileItemListProperties
capabilities(selection
);
243 const bool enableMoveToTrash
= capabilities
.isLocal() && capabilities
.supportsMoving();
245 renameAction
->setEnabled(capabilities
.supportsMoving());
246 moveToTrashAction
->setEnabled(enableMoveToTrash
);
247 deleteAction
->setEnabled(capabilities
.supportsDeleting());
248 deleteWithTrashShortcut
->setEnabled(capabilities
.supportsDeleting() && !enableMoveToTrash
);
249 editMimeTypeAction
->setEnabled(true);
250 propertiesAction
->setEnabled(true);
251 Q_EMIT m_extension
->enableAction("cut", capabilities
.supportsMoving());
252 Q_EMIT m_extension
->enableAction("copy", true);
256 void DolphinPart::updatePasteAction()
258 QPair
<bool, QString
> pasteInfo
= m_view
->pasteInfo();
259 Q_EMIT m_extension
->enableAction("paste", pasteInfo
.first
);
260 Q_EMIT m_extension
->setActionText("paste", pasteInfo
.second
);
263 QString
DolphinPart::urlToLocalFilePath(const QUrl
&url
)
265 KIO::StatJob
*statJob
= KIO::mostLocalUrl(url
);
266 KJobWidgets::setWindow(statJob
, widget());
268 QUrl localUrl
= statJob
->mostLocalUrl();
269 if (localUrl
.isLocalFile()) {
270 return localUrl
.toLocalFile();
275 bool DolphinPart::openUrl(const QUrl
&url
)
277 bool reload
= arguments().reload();
278 // A bit of a workaround so that changing the namefilter works: force reload.
279 // Otherwise DolphinView wouldn't relist the URL, so nothing would happen.
280 if (m_nameFilter
!= m_view
->nameFilter())
282 if (m_view
->url() == url
&& !reload
) { // DolphinView won't do anything in that case, so don't emit started
285 setUrl(url
); // remember url at the KParts level
286 setLocalFilePath(urlToLocalFilePath(url
)); // remember local path at the KParts level
287 QUrl
visibleUrl(url
);
288 if (!m_nameFilter
.isEmpty()) {
289 visibleUrl
.setPath(visibleUrl
.path() + '/' + m_nameFilter
);
291 QString prettyUrl
= visibleUrl
.toDisplayString(QUrl::PreferLocalFile
);
292 Q_EMIT
setWindowCaption(prettyUrl
);
293 Q_EMIT m_extension
->setLocationBarUrl(prettyUrl
);
294 Q_EMIT
started(nullptr); // get the wheel to spin
295 m_view
->setNameFilter(m_nameFilter
);
298 Q_EMIT
aboutToOpenURL();
301 // Disable "Find File" and "Open Terminal" actions for non-file URLs,
302 // e.g. ftp, smb, etc. #279283
303 const bool isLocalUrl
= !(localFilePath().isEmpty());
304 m_findFileAction
->setEnabled(isLocalUrl
);
305 if (m_openTerminalAction
) {
306 m_openTerminalAction
->setEnabled(isLocalUrl
);
311 void DolphinPart::slotMessage(const QString
&msg
)
313 Q_EMIT
setStatusBarText(msg
);
316 void DolphinPart::slotErrorMessage(const QString
&msg
)
318 qCDebug(DolphinDebug
) << msg
;
319 Q_EMIT
canceled(msg
);
320 //KMessageBox::error(m_view, msg);
323 void DolphinPart::slotRequestItemInfo(const KFileItem
&item
)
325 Q_EMIT m_extension
->mouseOverInfo(item
);
329 const QString escapedText
= Qt::convertFromPlainText(item
.getStatusBarInfo());
330 Q_EMIT
ReadOnlyPart::setStatusBarText(QStringLiteral("<qt>%1</qt>").arg(escapedText
));
334 void DolphinPart::slotItemActivated(const KFileItem
&item
)
336 KParts::OpenUrlArguments args
;
337 // Forget about the known mimetype if a target URL is used.
338 // Testcase: network:/ with a item (mimetype "inode/some-foo-service") pointing to a http URL (html)
339 if (item
.targetUrl() == item
.url()) {
340 args
.setMimeType(item
.mimetype());
343 // Ideally, konqueror should be changed to not require trustedSource for directory views,
344 // since the idea was not to need BrowserArguments for non-browser stuff...
345 KParts::BrowserArguments browserArgs
;
346 browserArgs
.trustedSource
= true;
347 Q_EMIT m_extension
->openUrlRequest(item
.targetUrl(), args
, browserArgs
);
350 void DolphinPart::slotItemsActivated(const KFileItemList
&items
)
352 for (const KFileItem
&item
: items
) {
353 slotItemActivated(item
);
357 void DolphinPart::createNewWindow(const QUrl
&url
)
359 // TODO: Check issue N176832 for the missing QAIV signal; task 177399 - maybe this code
360 // should be moved into DolphinPart::slotItemActivated()
361 Q_EMIT m_extension
->createNewWindow(url
);
364 void DolphinPart::slotOpenContextMenu(const QPoint
&pos
, const KFileItem
&_item
, const KFileItemList
&selectedItems
, const QUrl
&)
366 KParts::NavigationExtension::PopupFlags popupFlags
=
367 KParts::NavigationExtension::DefaultPopupItems
| KParts::NavigationExtension::ShowProperties
| KParts::NavigationExtension::ShowUrlOperations
;
369 KFileItem
item(_item
);
371 if (item
.isNull()) { // viewport context menu
372 item
= m_view
->rootItem();
374 item
= KFileItem(url());
376 item
.setUrl(url()); // ensure we use the view url, not the canonical path (#213799)
380 if (selectedItems
.isEmpty()) {
383 items
= selectedItems
;
386 KFileItemListProperties
capabilities(items
);
388 KParts::NavigationExtension::ActionGroupMap actionGroups
;
389 QList
<QAction
*> editActions
;
390 editActions
+= m_view
->versionControlActions(m_view
->selectedItems());
392 if (!_item
.isNull()) { // only for context menu on one or more items
393 const bool supportsMoving
= capabilities
.supportsMoving();
395 if (capabilities
.supportsDeleting()) {
396 const bool showDeleteAction
= (KSharedConfig::openConfig()->group("KDE").readEntry("ShowDeleteCommand", false) || !item
.isLocalFile());
397 const bool showMoveToTrashAction
= capabilities
.isLocal() && supportsMoving
;
399 if (showDeleteAction
&& showMoveToTrashAction
) {
400 delete m_removeAction
;
401 m_removeAction
= nullptr;
402 editActions
.append(actionCollection()->action(KStandardAction::name(KStandardAction::MoveToTrash
)));
403 editActions
.append(actionCollection()->action(KStandardAction::name(KStandardAction::DeleteFile
)));
404 } else if (showDeleteAction
&& !showMoveToTrashAction
) {
405 editActions
.append(actionCollection()->action(KStandardAction::name(KStandardAction::DeleteFile
)));
408 m_removeAction
= new DolphinRemoveAction(this, actionCollection());
409 editActions
.append(m_removeAction
);
410 m_removeAction
->update();
413 popupFlags
|= KParts::NavigationExtension::NoDeletion
;
416 if (supportsMoving
) {
417 editActions
.append(actionCollection()->action(KStandardAction::name(KStandardAction::RenameFile
)));
420 // Normally KonqPopupMenu only shows the "Create new" submenu in the current view
421 // since otherwise the created file would not be visible.
422 // But in treeview mode we should allow it.
423 if (m_view
->itemsExpandable())
424 popupFlags
|= KParts::NavigationExtension::ShowCreateDirectory
;
427 actionGroups
.insert(QStringLiteral("editactions"), editActions
);
429 Q_EMIT m_extension
->popupMenu(pos
, items
, KParts::OpenUrlArguments(), KParts::BrowserArguments(), popupFlags
, actionGroups
);
432 void DolphinPart::slotDirectoryRedirection(const QUrl
&oldUrl
, const QUrl
&newUrl
)
434 qCDebug(DolphinDebug
) << oldUrl
<< newUrl
<< "currentUrl=" << url();
435 if (oldUrl
.matches(url(), QUrl::StripTrailingSlash
/* #207572 */)) {
436 KParts::ReadOnlyPart::setUrl(newUrl
);
437 const QString prettyUrl
= newUrl
.toDisplayString(QUrl::PreferLocalFile
);
438 Q_EMIT m_extension
->setLocationBarUrl(prettyUrl
);
442 void DolphinPart::slotEditMimeType()
444 const KFileItemList items
= m_view
->selectedItems();
445 if (!items
.isEmpty()) {
446 KMimeTypeEditor::editMimeType(items
.first().mimetype(), m_view
);
450 void DolphinPart::slotSelectItemsMatchingPattern()
452 openSelectionDialog(i18nc("@title:window", "Select"), i18n("Select all items matching this pattern:"), true);
455 void DolphinPart::slotUnselectItemsMatchingPattern()
457 openSelectionDialog(i18nc("@title:window", "Unselect"), i18n("Unselect all items matching this pattern:"), false);
460 void DolphinPart::openSelectionDialog(const QString
&title
, const QString
&text
, bool selectItems
)
462 auto *dialog
= new QInputDialog(m_view
);
463 dialog
->setAttribute(Qt::WA_DeleteOnClose
, true);
464 dialog
->setInputMode(QInputDialog::TextInput
);
465 dialog
->setWindowTitle(title
);
466 dialog
->setLabelText(text
);
468 const KConfigGroup group
= KSharedConfig::openConfig("dolphinpartrc")->group("Select Dialog");
469 dialog
->setComboBoxEditable(true);
470 dialog
->setComboBoxItems(group
.readEntry("History", QStringList()));
472 dialog
->setTextValue(QStringLiteral("*"));
474 connect(dialog
, &QDialog::accepted
, this, [=]() {
475 const QString pattern
= dialog
->textValue();
476 if (!pattern
.isEmpty()) {
477 QStringList items
= dialog
->comboBoxItems();
478 items
.removeAll(pattern
);
479 items
.prepend(pattern
);
481 // Need to evaluate this again here, because the captured value is const
482 // (even if the const were removed from 'const KConfigGroup group =' above).
483 KConfigGroup group
= KSharedConfig::openConfig("dolphinpartrc")->group("Select Dialog");
484 // Limit the size of the saved history.
485 group
.writeEntry("History", items
.mid(0, 10));
488 const QRegularExpression
patternRegExp(QRegularExpression::wildcardToRegularExpression(pattern
));
489 m_view
->selectItems(patternRegExp
, selectItems
);
496 void DolphinPart::setCurrentViewMode(const QString
&viewModeName
)
498 QAction
*action
= actionCollection()->action(viewModeName
);
503 QString
DolphinPart::currentViewMode() const
505 return m_actionHandler
->currentViewModeActionName();
508 void DolphinPart::setNameFilter(const QString
&nameFilter
)
510 // This is the "/home/dfaure/*.diff" kind of name filter (KDirLister::setNameFilter)
511 // which is unrelated to DolphinView::setNameFilter which is substring filtering in a proxy.
512 m_nameFilter
= nameFilter
;
513 // TODO save/restore name filter in saveState/restoreState like KonqDirPart did in kde3?
516 QString
DolphinPart::localFilePathOrHome() const
518 const QString localPath
= localFilePath();
519 if (!localPath
.isEmpty()) {
522 return QDir::homePath();
525 void DolphinPart::slotOpenTerminal()
527 auto job
= new KTerminalLauncherJob(QString());
528 job
->setWorkingDirectory(localFilePathOrHome());
532 void DolphinPart::slotFindFile()
535 KMoreToolsMenuFactory("dolphin/search-tools").fillMenuFromGroupingNames(&searchTools
, {"files-find"}, QUrl::fromLocalFile(localFilePathOrHome()));
536 QList
<QAction
*> actions
= searchTools
.actions();
537 if (!(actions
.isEmpty())) {
538 actions
.first()->trigger();
540 KIO::CommandLauncherJob
*job
= new KIO::CommandLauncherJob(QStringLiteral("kfind"), {url().toString()}, this);
541 job
->setDesktopName(QStringLiteral("org.kde.kfind"));
542 job
->setUiDelegate(new KDialogJobUiDelegate(KJobUiDelegate::AutoHandlingEnabled
, widget()));
547 void DolphinPart::updateNewMenu()
549 // As requested by KNewFileMenu :
550 m_newFileMenu
->checkUpToDate();
551 // And set the files that the menu apply on :
552 m_newFileMenu
->setWorkingDirectory(url());
555 void DolphinPart::updateStatusBar()
557 m_view
->requestStatusBarText();
560 void DolphinPart::updateProgress(int percent
)
562 Q_EMIT m_extension
->loadingProgress(percent
);
565 void DolphinPart::createDirectory()
567 m_newFileMenu
->setWorkingDirectory(url());
568 m_newFileMenu
->createDirectory();
571 void DolphinPart::setFilesToSelect(const QList
<QUrl
> &files
)
573 if (files
.isEmpty()) {
577 m_view
->markUrlsAsSelected(files
);
578 m_view
->markUrlAsCurrent(files
.at(0));
581 bool DolphinPart::eventFilter(QObject
*obj
, QEvent
*event
)
583 using ShiftState
= DolphinRemoveAction::ShiftState
;
584 const int type
= event
->type();
586 if ((type
== QEvent::KeyPress
|| type
== QEvent::KeyRelease
) && m_removeAction
) {
587 QMenu
*menu
= qobject_cast
<QMenu
*>(obj
);
588 if (menu
&& menu
->parent() == m_view
) {
589 QKeyEvent
*ev
= static_cast<QKeyEvent
*>(event
);
590 if (ev
->key() == Qt::Key_Shift
) {
591 m_removeAction
->update(type
== QEvent::KeyPress
? ShiftState::Pressed
: ShiftState::Released
);
596 return KParts::ReadOnlyPart::eventFilter(obj
, event
);
599 #include "dolphinpart.moc"