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
#include <KLocalizedString>
#include <KMessageBox>
#include <KLocalizedString>
#include <KMessageBox>
+#include <KProtocolManager>
#include <QButtonGroup>
#include <QCheckBox>
#include <QButtonGroup>
#include <QCheckBox>
GeneralSettings* settings = GeneralSettings::self();
const QUrl url(QUrl::fromUserInput(m_homeUrl->text(), QString(), QUrl::AssumeLocalFile));
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();
+ }
+ });
- 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
}
// Remove saved state if "remember open tabs" has been turned off
m_showFullPathInTitlebar->setChecked(GeneralSettings::showFullPathInTitlebar());
m_openExternallyCalledFolderInNewTab->setChecked(GeneralSettings::openExternallyCalledFolderInNewTab());
}
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."));
+}
private:
void loadSettings();
private:
void loadSettings();
+ void showSetDefaultDirectoryError();