mirror of
https://invent.kde.org/system/dolphin
synced 2024-10-28 03:21:56 +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 <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;
|
||||
|
|
Loading…
Reference in a new issue