mirror of
https://invent.kde.org/system/dolphin
synced 2024-09-17 15:31:20 +00:00
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
This commit is contained in:
parent
ecd5c7d678
commit
87bb0ca10b
|
@ -13,6 +13,7 @@
|
||||||
|
|
||||||
#include <KLocalizedString>
|
#include <KLocalizedString>
|
||||||
#include <KMessageBox>
|
#include <KMessageBox>
|
||||||
|
#include <KProtocolManager>
|
||||||
|
|
||||||
#include <QButtonGroup>
|
#include <QButtonGroup>
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
|
@ -138,11 +139,17 @@ void StartupSettingsPage::applySettings()
|
||||||
GeneralSettings* settings = GeneralSettings::self();
|
GeneralSettings* settings = GeneralSettings::self();
|
||||||
|
|
||||||
const QUrl url(QUrl::fromUserInput(m_homeUrl->text(), QString(), QUrl::AssumeLocalFile));
|
const QUrl url(QUrl::fromUserInput(m_homeUrl->text(), QString(), QUrl::AssumeLocalFile));
|
||||||
KFileItem fileItem(url);
|
if (url.isValid() && KProtocolManager::supportsListing(url)) {
|
||||||
if ((url.isValid() && fileItem.isDir()) || (url.scheme() == QLatin1String("timeline"))) {
|
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));
|
settings->setHomeUrl(url.toDisplayString(QUrl::PreferLocalFile));
|
||||||
} else {
|
} else {
|
||||||
KMessageBox::error(this, i18nc("@info", "The location for the home folder is invalid or does not exist, it will not be applied."));
|
showSetDefaultDirectoryError();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
showSetDefaultDirectoryError();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove saved state if "remember open tabs" has been turned off
|
// Remove saved state if "remember open tabs" has been turned off
|
||||||
|
@ -222,3 +229,8 @@ void StartupSettingsPage::loadSettings()
|
||||||
m_showFullPathInTitlebar->setChecked(GeneralSettings::showFullPathInTitlebar());
|
m_showFullPathInTitlebar->setChecked(GeneralSettings::showFullPathInTitlebar());
|
||||||
m_openExternallyCalledFolderInNewTab->setChecked(GeneralSettings::openExternallyCalledFolderInNewTab());
|
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:
|
private:
|
||||||
void loadSettings();
|
void loadSettings();
|
||||||
|
void showSetDefaultDirectoryError();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QUrl m_url;
|
QUrl m_url;
|
||||||
|
|
Loading…
Reference in a new issue