Commit ac84e7b2 authored by Nicolas Fella's avatar Nicolas Fella
Browse files

[kcms/desktoppaths] Drop autostart path setting

The path for autostart files is an implementation detail that the user doesn't care about.

It also does not match the XDG autostart spec that defines the autostart dir relative to XDG_DATA_DIRS.

Plasma also does not use this directly. It is only used when migrating KDE4 config (https://invent.kde.org/plasma/plasma-workspace/-/blob/master/startkde/plasma-session/startup.cpp#L385)
parent 5889d41f
......@@ -102,7 +102,7 @@ Comment[uk]=Місце для особистих файлів
Comment[x-test]=xxLocation for Personal Filesxx
Comment[zh_CN]=个人文件位置
Comment[zh_TW]=個人檔案的路徑
X-KDE-Keywords=konqueror,dolphin,files,filemanager,path, paths,desktop,directories,autostart,downloads,music,documents,movies,pictures
X-KDE-Keywords=konqueror,dolphin,files,filemanager,path, paths,desktop,directories,downloads,music,documents,movies,pictures
X-KDE-Keywords[ar]=كنكر,دولفين,ملف,ملفات,مدير ملفات,مسار,مسارات,سطح المكتب,أدلة,البدء الآلي,تنزيلات,موسيقى,مستندات,فيديوهات,صور
X-KDE-Keywords[az]=konqueror,dolphin,files,filemanager,path, paths,desktop,directories,autostart,downloads,music,documents,movies,pictures konqueror, dolphin, fayllar, fayl meneceri, yol, yollar, iş masası, qovluqlar,autobaşlama, yükləmələr, musiqi, sənədlər, filmlər, şəkillər
X-KDE-Keywords[bs]=konqueror, delfin, datoteke, menadžer datoteka, put, putevi, desktop, upute, autostart, preuuzimanja, muzika, dokumenti, filmovi, slike
......
......@@ -29,67 +29,6 @@ namespace {
}
}
class PathsSettingsStore : public QObject
{
Q_OBJECT
Q_PROPERTY(QUrl autostartLocation READ autostartLocation WRITE setAutostartLocation)
public:
PathsSettingsStore(DesktopPathsSettings *parent = nullptr)
: QObject(parent)
, m_config(KSharedConfig::openConfig())
, m_settings(parent)
{
}
QUrl autostartLocation() const
{
return readUrl(QStringLiteral("Autostart"), m_settings->defaultAutostartLocation());
}
void setAutostartLocation(const QUrl &url)
{
if (url.matches(m_settings->defaultAutostartLocation(), QUrl::StripTrailingSlash)) {
resetUrl(QStringLiteral("Autostart"));
} else {
writeUrl(QStringLiteral("Autostart"), url);
}
}
void save()
{
if (m_config->isDirty()) {
m_config->sync();
}
}
private:
QUrl readUrl(const QString &key, const QUrl &defaultValue) const
{
KConfigGroup group(m_config, QStringLiteral("Paths"));
const auto path = group.readPathEntry(key, QString());
if (path.isEmpty()) {
return defaultValue;
} else {
return QUrl::fromLocalFile(path);
}
}
void writeUrl(const QString &key, const QUrl &url)
{
KConfigGroup group(m_config, QStringLiteral("Paths"));
group.writePathEntry(key, url.toLocalFile(), KConfig::Normal | KConfig::Global);
}
void resetUrl(const QString &key)
{
KConfigGroup group(m_config, QStringLiteral("Paths"));
group.revertToDefault(key, KConfig::Normal | KConfig::Global);
}
KSharedConfig::Ptr m_config;
DesktopPathsSettings *m_settings;
};
class XdgPathsSettingsStore : public QObject
{
Q_OBJECT
......@@ -192,7 +131,6 @@ private:
DesktopPathsSettings::DesktopPathsSettings(QObject *parent)
: KCoreConfigSkeleton(userDirsConfig(), parent)
, m_pathsStore(new PathsSettingsStore(this))
, m_xdgPathsStore(new XdgPathsSettingsStore(this))
{
addItemInternal("desktopLocation", defaultDesktopLocation());
......@@ -201,10 +139,6 @@ DesktopPathsSettings::DesktopPathsSettings(QObject *parent)
addItemInternal("musicLocation", defaultMusicLocation());
addItemInternal("picturesLocation", defaultPicturesLocation());
addItemInternal("videosLocation", defaultVideosLocation());
auto *item = new KPropertySkeletonItem(m_pathsStore, "autostartLocation", defaultAutostartLocation());
item->setNotifyFunction([this] { emit this->widgetChanged(); });
addItem(item, "autostartLocation");
}
void DesktopPathsSettings::addItemInternal(const QByteArray &propertyName, const QVariant &defaultValue)
......@@ -214,21 +148,6 @@ void DesktopPathsSettings::addItemInternal(const QByteArray &propertyName, const
addItem(item, propertyName);
}
QUrl DesktopPathsSettings::autostartLocation() const
{
return findItem("autostartLocation")->property().toUrl();
}
void DesktopPathsSettings::setAutostartLocation(const QUrl &url)
{
findItem("autostartLocation")->setProperty(url);
}
QUrl DesktopPathsSettings::defaultAutostartLocation() const
{
return QUrl::fromLocalFile(QDir::homePath() + QStringLiteral("/.config/autostart"));
}
QUrl DesktopPathsSettings::desktopLocation() const
{
return findItem("desktopLocation")->property().toUrl();
......@@ -319,10 +238,4 @@ QUrl DesktopPathsSettings::defaultVideosLocation() const
return QUrl::fromLocalFile(QDir::homePath() + QStringLiteral("/Videos"));
}
bool DesktopPathsSettings::usrSave()
{
m_pathsStore->save();
return KCoreConfigSkeleton::usrSave();
}
#include "desktoppathssettings.moc"
......@@ -21,7 +21,6 @@
#include <KCoreConfigSkeleton>
class PathsSettingsStore;
class XdgPathsSettingsStore;
class DesktopPathsSettings : public KCoreConfigSkeleton
......@@ -30,10 +29,6 @@ class DesktopPathsSettings : public KCoreConfigSkeleton
public:
DesktopPathsSettings(QObject *parent = nullptr);
QUrl autostartLocation() const;
void setAutostartLocation(const QUrl &url);
QUrl defaultAutostartLocation() const;
QUrl desktopLocation() const;
void setDesktopLocation(const QUrl &url);
QUrl defaultDesktopLocation() const;
......@@ -63,11 +58,9 @@ Q_SIGNALS:
void widgetChanged();
private:
bool usrSave() override;
void addItemInternal(const QByteArray &propertyName, const QVariant &defaultValue);
private:
PathsSettingsStore *m_pathsStore;
XdgPathsSettingsStore *m_xdgPathsStore;
};
......
......@@ -72,7 +72,6 @@ DesktopPathConfig::~DesktopPathConfig()
void DesktopPathConfig::updateDefaultIndicator()
{
setDefaultIndicatorVisible(m_ui->kcfg_desktopLocation, m_data->settings()->defaultDesktopLocation());
setDefaultIndicatorVisible(m_ui->kcfg_autostartLocation, m_data->settings()->defaultAutostartLocation());
setDefaultIndicatorVisible(m_ui->kcfg_documentsLocation, m_data->settings()->defaultDocumentsLocation());
setDefaultIndicatorVisible(m_ui->kcfg_downloadsLocation, m_data->settings()->defaultDownloadsLocation());
setDefaultIndicatorVisible(m_ui->kcfg_musicLocation, m_data->settings()->defaultMusicLocation());
......
......@@ -40,7 +40,7 @@ class DesktopPathsData;
//-----------------------------------------------------------------------------
// The "Path" Tab contains :
// The paths for Desktop, Autostart and Documents
// The paths for Desktop and Documents
class DesktopPathConfig : public KCModule
{
......
......@@ -28,23 +28,6 @@
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Autostart path:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="KUrlRequester" name="kcfg_autostartLocation">
<property name="whatsThis">
<string>This folder contains applications or links to applications (shortcuts) that you want to have started automatically whenever the session starts. You can change the location of this folder if you want to, and the contents will move automatically to the new location as well.</string>
</property>
<property name="mode">
<enum>KFile::Directory</enum>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment