-/***************************************************************************
- * Copyright (C) 2008 by Peter Penz <peter.penz19@gmail.com> *
- * *
- * 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 <peter.penz19@gmail.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
#include "startupsettingspage.h"
#include <KLocalizedString>
#include <KMessageBox>
+#include <KProtocolManager>
#include <QButtonGroup>
#include <QCheckBox>
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
// Enable and disable home URL controls appropriately
updateInitialViewOptions();
- emit changed();
+ Q_EMIT changed();
}
void StartupSettingsPage::updateInitialViewOptions()
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."));
+}