]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphinpart.cpp
GIT_SILENT Update Appstream for new release
[dolphin.git] / src / dolphinpart.cpp
index 00c99efd0c0805e4567fdf8d506a57b239cb6682..cc252635381ff332e14117e684699bfd9f0b3f89 100644 (file)
@@ -85,6 +85,10 @@ DolphinPart::DolphinPart(QWidget* parentWidget, QObject* parent,
             this, &DolphinPart::slotItemActivated);
     connect(m_view, &DolphinView::itemsActivated,
             this, &DolphinPart::slotItemsActivated);
+    connect(m_view, &DolphinView::statusBarTextChanged, this, [this](const QString &text) {
+        const QString escapedText = Qt::convertFromPlainText(text);
+        Q_EMIT ReadOnlyPart::setStatusBarText(QStringLiteral("<qt>%1</qt>").arg(escapedText));
+    });
     connect(m_view, &DolphinView::tabRequested,
             this, &DolphinPart::createNewWindow);
     connect(m_view, &DolphinView::requestContextMenu,
@@ -283,6 +287,18 @@ void DolphinPart::updatePasteAction()
     Q_EMIT m_extension->setActionText( "paste", pasteInfo.second );
 }
 
+QString DolphinPart::urlToLocalFilePath(const QUrl &url)
+{
+    KIO::StatJob* statJob = KIO::mostLocalUrl(url);
+    KJobWidgets::setWindow(statJob, widget());
+    statJob->exec();
+    QUrl localUrl = statJob->mostLocalUrl();
+    if (localUrl.isLocalFile()) {
+        return localUrl.toLocalFile();
+    }
+    return QString();
+}
+
 bool DolphinPart::openUrl(const QUrl &url)
 {
     bool reload = arguments().reload();
@@ -293,7 +309,8 @@ bool DolphinPart::openUrl(const QUrl &url)
     if (m_view->url() == url && !reload) { // DolphinView won't do anything in that case, so don't emit started
         return true;
     }
-    setUrl(url); // remember it at the KParts level
+    setUrl(url); // remember url at the KParts level
+    setLocalFilePath(urlToLocalFilePath(url)); // remember local path at the KParts level
     QUrl visibleUrl(url);
     if (!m_nameFilter.isEmpty()) {
         visibleUrl.setPath(visibleUrl.path() + '/' + m_nameFilter);
@@ -310,7 +327,7 @@ bool DolphinPart::openUrl(const QUrl &url)
         m_view->reload();
     // Disable "Find File" and "Open Terminal" actions for non-file URLs,
     // e.g. ftp, smb, etc. #279283
-    const bool isLocalUrl = url.isLocalFile();
+    const bool isLocalUrl = !(localFilePath().isEmpty());
     m_findFileAction->setEnabled(isLocalUrl);
     if (m_openTerminalAction) {
         m_openTerminalAction->setEnabled(isLocalUrl);
@@ -542,16 +559,25 @@ void DolphinPart::setNameFilter(const QString& nameFilter)
     // TODO save/restore name filter in saveState/restoreState like KonqDirPart did in kde3?
 }
 
+QString DolphinPart::localFilePathOrHome() const
+{
+    const QString localPath = localFilePath();
+    if (!localPath.isEmpty()) {
+        return localPath;
+    }
+    return QDir::homePath();
+}
+
 void DolphinPart::slotOpenTerminal()
 {
-    KToolInvocation::invokeTerminal(QString(), KParts::ReadOnlyPart::localFilePath());
+    KToolInvocation::invokeTerminal(QString(), {}, localFilePathOrHome());
 }
 
 void DolphinPart::slotFindFile()
 {
     QMenu searchTools;
     KMoreToolsMenuFactory("dolphin/search-tools").fillMenuFromGroupingNames(
-        &searchTools, { "files-find" }, QUrl::fromLocalFile(KParts::ReadOnlyPart::localFilePath())
+        &searchTools, { "files-find" }, QUrl::fromLocalFile(localFilePathOrHome())
     );
     QList<QAction*> actions = searchTools.actions();
     if (!(actions.isEmpty())) {
@@ -575,8 +601,7 @@ void DolphinPart::updateNewMenu()
 
 void DolphinPart::updateStatusBar()
 {
-    const QString escapedText = Qt::convertFromPlainText(m_view->statusBarText());
-    Q_EMIT ReadOnlyPart::setStatusBarText(QStringLiteral("<qt>%1</qt>").arg(escapedText));
+    m_view->requestStatusBarText();
 }
 
 void DolphinPart::updateProgress(int percent)