Changeset View
Changeset View
Standalone View
Standalone View
src/dolphinpart.cpp
Context not available. | |||||
297 | return new KAboutData(QStringLiteral("dolphinpart"), i18nc("@title", "Dolphin Part"), QStringLiteral("0.1")); | 297 | return new KAboutData(QStringLiteral("dolphinpart"), i18nc("@title", "Dolphin Part"), QStringLiteral("0.1")); | ||
---|---|---|---|---|---|
298 | } | 298 | } | ||
299 | 299 | | |||
300 | QString DolphinPart::urlToLocalFilePath(const QUrl &url) | ||||
301 | { | ||||
302 | KIO::StatJob* statJob = KIO::mostLocalUrl(url); | ||||
303 | KJobWidgets::setWindow(statJob, widget()); | ||||
304 | statJob->exec(); | ||||
305 | QUrl localUrl = statJob->mostLocalUrl(); | ||||
306 | if (localUrl.isLocalFile()) { | ||||
307 | return localUrl.toLocalFile(); | ||||
308 | } | ||||
309 | return QString(); | ||||
310 | } | ||||
311 | | ||||
300 | bool DolphinPart::openUrl(const QUrl &url) | 312 | bool DolphinPart::openUrl(const QUrl &url) | ||
301 | { | 313 | { | ||
302 | bool reload = arguments().reload(); | 314 | bool reload = arguments().reload(); | ||
Context not available. | |||||
307 | if (m_view->url() == url && !reload) { // DolphinView won't do anything in that case, so don't emit started | 319 | if (m_view->url() == url && !reload) { // DolphinView won't do anything in that case, so don't emit started | ||
308 | return true; | 320 | return true; | ||
309 | } | 321 | } | ||
310 | setUrl(url); // remember it at the KParts level | 322 | setUrl(url); // remember url at the KParts level | ||
elvisangelaccio: Have you tried to use `KParts::ReadOnlyPart::openUrl()` instead? (as described here: https… | |||||
@pdabrowski Ping? elvisangelaccio: @pdabrowski Ping? | |||||
Yes, KParts::ReadOnlyPart::openUrl() seems to work fine here. pdabrowski: Yes, `KParts::ReadOnlyPart::openUrl()` seems to work fine here.
I'm not sure if there were any… | |||||
No, it doesn't work for remote addresses (tested: fish://localhost/). } else { d->openRemoteFile(); return true; } pdabrowski: No, it doesn't work for remote addresses (tested: `fish://localhost/`).
It shows remote… | |||||
Thanks for the test. I merged the invent patch, can you abandon this one? elvisangelaccio: Thanks for the test. I merged the invent patch, can you abandon this one? | |||||
323 | setLocalFilePath(urlToLocalFilePath(url)); // remember local path at the KParts level | ||||
311 | QUrl visibleUrl(url); | 324 | QUrl visibleUrl(url); | ||
312 | if (!m_nameFilter.isEmpty()) { | 325 | if (!m_nameFilter.isEmpty()) { | ||
313 | visibleUrl.setPath(visibleUrl.path() + '/' + m_nameFilter); | 326 | visibleUrl.setPath(visibleUrl.path() + '/' + m_nameFilter); | ||
Context not available. | |||||
324 | m_view->reload(); | 337 | m_view->reload(); | ||
325 | // Disable "Find File" and "Open Terminal" actions for non-file URLs, | 338 | // Disable "Find File" and "Open Terminal" actions for non-file URLs, | ||
326 | // e.g. ftp, smb, etc. #279283 | 339 | // e.g. ftp, smb, etc. #279283 | ||
327 | const bool isLocalUrl = url.isLocalFile(); | 340 | const bool isLocalUrl = !(localFilePath().isEmpty()); | ||
328 | m_findFileAction->setEnabled(isLocalUrl); | 341 | m_findFileAction->setEnabled(isLocalUrl); | ||
329 | if (m_openTerminalAction) { | 342 | if (m_openTerminalAction) { | ||
330 | m_openTerminalAction->setEnabled(isLocalUrl); | 343 | m_openTerminalAction->setEnabled(isLocalUrl); | ||
Context not available. | |||||
531 | // TODO save/restore name filter in saveState/restoreState like KonqDirPart did in kde3? | 544 | // TODO save/restore name filter in saveState/restoreState like KonqDirPart did in kde3? | ||
532 | } | 545 | } | ||
533 | 546 | | |||
547 | QString DolphinPart::localFilePathOrHome() const | ||||
548 | { | ||||
549 | const QString localPath = localFilePath(); | ||||
550 | if (!localPath.isEmpty()) { | ||||
551 | return localPath; | ||||
552 | } | ||||
553 | return QDir::homePath(); | ||||
554 | } | ||||
555 | | ||||
534 | void DolphinPart::slotOpenTerminal() | 556 | void DolphinPart::slotOpenTerminal() | ||
535 | { | 557 | { | ||
536 | KToolInvocation::invokeTerminal(QString(), KParts::ReadOnlyPart::localFilePath()); | 558 | KToolInvocation::invokeTerminal(QString(), localFilePathOrHome()); | ||
537 | } | 559 | } | ||
538 | 560 | | |||
539 | void DolphinPart::slotFindFile() | 561 | void DolphinPart::slotFindFile() | ||
540 | { | 562 | { | ||
541 | QMenu searchTools; | 563 | QMenu searchTools; | ||
542 | KMoreToolsMenuFactory("dolphin/search-tools").fillMenuFromGroupingNames( | 564 | KMoreToolsMenuFactory("dolphin/search-tools").fillMenuFromGroupingNames( | ||
543 | &searchTools, { "files-find" }, QUrl::fromLocalFile(KParts::ReadOnlyPart::localFilePath()) | 565 | &searchTools, { "files-find" }, QUrl::fromLocalFile(localFilePathOrHome()) | ||
544 | ); | 566 | ); | ||
545 | QList<QAction*> actions = searchTools.actions(); | 567 | QList<QAction*> actions = searchTools.actions(); | ||
546 | if (!(actions.isEmpty())) { | 568 | if (!(actions.isEmpty())) { | ||
Context not available. |
Have you tried to use KParts::ReadOnlyPart::openUrl() instead? (as described here: https://bugs.kde.org/show_bug.cgi?id=416989#c0)