X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/a058c64eba30f11bfa87ac097371c04437d0471e..87bb0ca10b9a486d982ceadf9be3d0dad68cf437:/src/settings/startup/startupsettingspage.cpp diff --git a/src/settings/startup/startupsettingspage.cpp b/src/settings/startup/startupsettingspage.cpp index eb1495746..a7fcec4fa 100644 --- a/src/settings/startup/startupsettingspage.cpp +++ b/src/settings/startup/startupsettingspage.cpp @@ -1,21 +1,8 @@ -/*************************************************************************** - * Copyright (C) 2008 by Peter Penz * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * - ***************************************************************************/ +/* + * SPDX-FileCopyrightText: 2008 Peter Penz + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ #include "startupsettingspage.h" @@ -26,6 +13,7 @@ #include #include +#include #include #include @@ -151,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(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 @@ -193,7 +187,7 @@ void StartupSettingsPage::slotSettingsChanged() // Enable and disable home URL controls appropriately updateInitialViewOptions(); - emit changed(); + Q_EMIT changed(); } void StartupSettingsPage::updateInitialViewOptions() @@ -235,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.")); +}