mirror of
https://invent.kde.org/system/dolphin
synced 2024-07-04 17:30:55 +00:00
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.
This commit is contained in:
parent
d0c71a1435
commit
9b83378c08
|
@ -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();
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user