┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAhmad Samir <[email protected]>2020-09-14 16:01:47 +0200
committerElvis Angelaccio <[email protected]>2020-09-20 21:29:23 +0000
commit9b83378c087a87cef537ba751b7713aff8bed84c (patch)
treefaeb65576e074f130611bc435f7ef04206d2831f
parentd0c71a1435bc9d67475c5525c3641bd4a13c61f0 (diff)
Check protocol Class before creating a StatJob
StatJob::mostLocalUrl only works with ":local" protocols, adjust the code accordingly. Make the code async. Remove activeContainerLocalPath() method as it isn't needed anymore. Drive-by change: minimum required version of Qt should be 5.12 because that's what KF >= 5.73 already requires.
-rw-r--r--CMakeLists.txt2
-rw-r--r--src/dolphinmainwindow.cpp38
-rw-r--r--src/dolphinmainwindow.h6
3 files changed, 26 insertions, 20 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5aaa9a7e7..5c1a08843 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -7,7 +7,7 @@ set (RELEASE_SERVICE_VERSION_MICRO "70")
set (RELEASE_SERVICE_VERSION "${RELEASE_SERVICE_VERSION_MAJOR}.${RELEASE_SERVICE_VERSION_MINOR}.${RELEASE_SERVICE_VERSION_MICRO}")
project(Dolphin VERSION ${RELEASE_SERVICE_VERSION})
-set(QT_MIN_VERSION "5.11.0")
+set(QT_MIN_VERSION "5.12.0")
set(KF5_MIN_VERSION "5.73.0")
# ECM setup
diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp
index 7c9a687aa..92d673a95 100644
--- a/src/dolphinmainwindow.cpp
+++ b/src/dolphinmainwindow.cpp
@@ -943,18 +943,6 @@ void DolphinMainWindow::toggleShowMenuBar()
}
}
-QString DolphinMainWindow::activeContainerLocalPath()
-{
- KIO::StatJob* statJob = KIO::mostLocalUrl(m_activeViewContainer->url());
- KJobWidgets::setWindow(statJob, this);
- statJob->exec();
- QUrl url = statJob->mostLocalUrl();
- if (url.isLocalFile()) {
- return url.toLocalFile();
- }
- return QDir::homePath();
-}
-
QPointer<QAction> DolphinMainWindow::preferredSearchTool()
{
m_searchTools.clear();
@@ -1001,7 +989,31 @@ void DolphinMainWindow::openPreferredSearchTool()
void DolphinMainWindow::openTerminal()
{
- KToolInvocation::invokeTerminal(QString(), activeContainerLocalPath());
+ const QUrl url = m_activeViewContainer->url();
+
+ if (url.isLocalFile()) {
+ KToolInvocation::invokeTerminal(QString(), url.toLocalFile());
+ return;
+ }
+
+ // Not a local file, with protocol Class ":local", try stat'ing
+ if (KProtocolInfo::protocolClass(url.scheme()) == QLatin1String(":local")) {
+ KIO::StatJob *job = KIO::mostLocalUrl(url);
+ KJobWidgets::setWindow(job, this);
+ connect(job, &KJob::result, this, [job]() {
+ QUrl statUrl;
+ if (!job->error()) {
+ statUrl = job->mostLocalUrl();
+ }
+
+ KToolInvocation::invokeTerminal(QString(), statUrl.isLocalFile() ? statUrl.toLocalFile() : QDir::homePath());
+ });
+
+ return;
+ }
+
+ // Nothing worked, just use $HOME
+ KToolInvocation::invokeTerminal(QString(), QDir::homePath());
}
void DolphinMainWindow::editSettings()
diff --git a/src/dolphinmainwindow.h b/src/dolphinmainwindow.h
index 79084ae7d..c03eb1be0 100644
--- a/src/dolphinmainwindow.h
+++ b/src/dolphinmainwindow.h
@@ -592,12 +592,6 @@ private:
/** Adds "What's This?" texts to many widgets and StandardActions. */
void setupWhatsThis();
- /**
- * Returns the KIO::StatJob::mostLocalUrl() for the active container URL
- * if it's a local file. Otherwise returns the user's home path.
- */
- QString activeContainerLocalPath();
-
/** Returns preferred search tool as configured in "More Search Tools" menu. */
QPointer<QAction> preferredSearchTool();