Commit 9b83378c authored by Ahmad Samir's avatar Ahmad Samir Committed by Elvis Angelaccio
Browse files

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.
parent d0c71a14
......@@ -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
......
......@@ -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()
......
......@@ -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();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment