]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Port to KTerminalLauncherJob
authorNate Graham <nate@kde.org>
Tue, 31 Aug 2021 15:09:14 +0000 (09:09 -0600)
committerNate Graham <nate@kde.org>
Tue, 31 Aug 2021 15:12:16 +0000 (09:12 -0600)
Dolphin still uses KToolInvocation::invokeTerminal() which is
deprecated and requires KInit. However Dolphin was ported away from
requiring it in other ways, so it is now possible to have Dolphin
running but not KInit, which breaks the "Open in Terminal"
functionality.

Using KTerminalLauncherJob fixes this. It was introduced in Frameworks
5.83, so the CMake dependency version is accordingly increased.

BUG: 441072
FIXED-IN: 21.12

CMakeLists.txt
src/dolphinmainwindow.cpp
src/dolphinpart.cpp

index 7d50205bc583063433e5df55ec1da87e0740e2b9..ec87cdecc4e48dfbf513785cbce5cdd7f758bafa 100644 (file)
@@ -8,7 +8,7 @@ set (RELEASE_SERVICE_VERSION "${RELEASE_SERVICE_VERSION_MAJOR}.${RELEASE_SERVICE
 project(Dolphin VERSION ${RELEASE_SERVICE_VERSION})
 
 set(QT_MIN_VERSION "5.15.0")
-set(KF5_MIN_VERSION "5.82.0")
+set(KF5_MIN_VERSION "5.83.0")
 
 set(CMAKE_CXX_STANDARD 17)
 set(CMAKE_CXX_STANDARD_REQUIRED ON)
index 62e347032be8604f65b8d29c0af7491230507834..f3a5e3b4e89539fbc3d720b3f1874d7926701e65 100644 (file)
 #include <KStandardAction>
 #include <KStartupInfo>
 #include <KSycoca>
+#include <KTerminalLauncherJob>
 #include <KToggleAction>
 #include <KToolBar>
 #include <KToolBarPopupAction>
-#include <KToolInvocation>
 #include <KUrlComboBox>
 #include <KUrlNavigator>
 #include <KWindowSystem>
@@ -1033,7 +1033,9 @@ void DolphinMainWindow::openTerminal()
     const QUrl url = m_activeViewContainer->url();
 
     if (url.isLocalFile()) {
-        KToolInvocation::invokeTerminal(QString(), {}, url.toLocalFile());
+        auto job = new KTerminalLauncherJob(QString());
+        job->setWorkingDirectory(url.toLocalFile());
+        job->start();
         return;
     }
 
@@ -1047,14 +1049,18 @@ void DolphinMainWindow::openTerminal()
                 statUrl = job->mostLocalUrl();
             }
 
-            KToolInvocation::invokeTerminal(QString(), {}, statUrl.isLocalFile() ? statUrl.toLocalFile() : QDir::homePath());
+            auto job = new KTerminalLauncherJob(QString());
+            job->setWorkingDirectory(statUrl.isLocalFile() ? statUrl.toLocalFile() : QDir::homePath());
+            job->start();
         });
 
         return;
     }
 
     // Nothing worked, just use $HOME
-    KToolInvocation::invokeTerminal(QString(), {}, QDir::homePath());
+    auto job = new KTerminalLauncherJob(QString());
+    job->setWorkingDirectory(QDir::homePath());
+    job->start();
 }
 
 void DolphinMainWindow::editSettings()
index 9c551d67abf797cbc6883cb31fb860773c9b9a07..8d528f418a9b817826011bcfdafaa85dbb2b5343 100644 (file)
@@ -32,7 +32,7 @@
 #include <KPluginFactory>
 #include <KIO/CommandLauncherJob>
 #include <KSharedConfig>
-#include <KToolInvocation>
+#include <KTerminalLauncherJob>
 
 #include <QActionGroup>
 #include <QApplication>
@@ -567,7 +567,9 @@ QString DolphinPart::localFilePathOrHome() const
 
 void DolphinPart::slotOpenTerminal()
 {
-    KToolInvocation::invokeTerminal(QString(), {}, localFilePathOrHome());
+    auto job = new KTerminalLauncherJob(QString());
+    job->setWorkingDirectory(localFilePathOrHome());
+    job->start();
 }
 
 void DolphinPart::slotFindFile()