Commit 87bb0ca1 authored by Derek Christ's avatar Derek Christ Committed by Elvis Angelaccio
Browse files

Allow non-local startup location

Only local directories were supported to be set as the starting location
of Dolphin. This commit fixes this by using an KIO::StatJob to determine
if the path is actually pointing to a directory or a file regardless if
it is a local or a remote path.

Additionaly a hard-coded exception for urls with the scheme "timeline"
was removed because with the new fix it is now obsolete.

BUG: 428885
parent ecd5c7d6
Pipeline #44930 passed with stage
in 6 minutes and 55 seconds
......@@ -13,6 +13,7 @@
#include <KLocalizedString>
#include <KMessageBox>
#include <KProtocolManager>
#include <QButtonGroup>
#include <QCheckBox>
......@@ -138,11 +139,17 @@ void StartupSettingsPage::applySettings()
GeneralSettings* settings = GeneralSettings::self();
const QUrl url(QUrl::fromUserInput(m_homeUrl->text(), QString(), QUrl::AssumeLocalFile));
KFileItem fileItem(url);
if ((url.isValid() && fileItem.isDir()) || (url.scheme() == QLatin1String("timeline"))) {
settings->setHomeUrl(url.toDisplayString(QUrl::PreferLocalFile));
if (url.isValid() && KProtocolManager::supportsListing(url)) {
KIO::StatJob* job = KIO::statDetails(url, KIO::StatJob::SourceSide, KIO::StatDetail::StatBasic, KIO::JobFlag::HideProgressInfo);
connect(job, &KJob::result, this, [this, settings, url](KJob* job) {
if (job->error() == 0 && qobject_cast<KIO::StatJob*>(job)->statResult().isDir()) {
settings->setHomeUrl(url.toDisplayString(QUrl::PreferLocalFile));
} else {
showSetDefaultDirectoryError();
}
});
} else {
KMessageBox::error(this, i18nc("@info", "The location for the home folder is invalid or does not exist, it will not be applied."));
showSetDefaultDirectoryError();
}
// Remove saved state if "remember open tabs" has been turned off
......@@ -222,3 +229,8 @@ void StartupSettingsPage::loadSettings()
m_showFullPathInTitlebar->setChecked(GeneralSettings::showFullPathInTitlebar());
m_openExternallyCalledFolderInNewTab->setChecked(GeneralSettings::openExternallyCalledFolderInNewTab());
}
void StartupSettingsPage::showSetDefaultDirectoryError()
{
KMessageBox::error(this, i18nc("@info", "The location for the home folder is invalid or does not exist, it will not be applied."));
}
......@@ -43,6 +43,7 @@ private slots:
private:
void loadSettings();
void showSetDefaultDirectoryError();
private:
QUrl m_url;
......
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