Commit c879e4fa authored by Fabian Vogt's avatar Fabian Vogt

Also read sddm.conf.d config directories

Summary:
SDDM reads files in alphabetical order from /usr/lib/sddm/sddm.conf.d/,
then /etc/sddm.conf.d/ and /etc/sddm.conf. The latest occurence takes
precedence.
The paths in CMakeLists are copied from sddm.

Test Plan: kcmshell5 kcm_sddm now shows the right preselected values.

Reviewers: #plasma, davidedmundson

Reviewed By: #plasma, davidedmundson

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D12359
parent 4af19263
set(SDDM_CONFIG_FILE "/etc/sddm.conf" CACHE PATH "Path of the sddm config file")
set(SDDM_CONFIG_FILE "${CMAKE_INSTALL_FULL_SYSCONFDIR}/sddm.conf" CACHE PATH "Path of the sddm config file")
set(SDDM_CONFIG_DIR "${CMAKE_INSTALL_FULL_SYSCONFDIR}/sddm.conf.d" CACHE PATH "Path of the sddm config directory")
set(SDDM_SYSTEM_CONFIG_DIR "${CMAKE_INSTALL_PREFIX}/lib/sddm/sddm.conf.d" CACHE PATH "Path of the system sddm config directory")
configure_file(config.h.in config.h IMMEDIATE @ONLY)
# add_subdirectory(configwidgets)
......
......@@ -33,11 +33,10 @@
const int MIN_UID = 1000;
const int MAX_UID = 65000;
AdvanceConfig::AdvanceConfig(QWidget *parent) :
QWidget(parent)
AdvanceConfig::AdvanceConfig(const KSharedConfigPtr &config, QWidget *parent) :
QWidget(parent),
mConfig(config)
{
mConfig = KSharedConfig::openConfig(SDDM_CONFIG_FILE, KConfig::SimpleConfig);
configUi = new Ui::AdvanceConfig();
configUi->setupUi(this);
......
......@@ -34,7 +34,7 @@ class AdvanceConfig : public QWidget
{
Q_OBJECT
public:
explicit AdvanceConfig(QWidget *parent = 0);
explicit AdvanceConfig(const KSharedConfigPtr &config, QWidget *parent = 0);
~AdvanceConfig();
QVariantMap save();
......
#ifndef CONFIG_H
#define CONFIG_H
#define SDDM_CONFIG_FILE "@SDDM_CONFIG_FILE@"
#define SDDM_CONFIG_FILE "@SDDM_CONFIG_FILE@"
#define SDDM_CONFIG_DIR "@SDDM_CONFIG_DIR@"
#define SDDM_SYSTEM_CONFIG_DIR "@SDDM_SYSTEM_CONFIG_DIR@"
#endif //CONFIG_H
\ No newline at end of file
#endif //CONFIG_H
......@@ -16,6 +16,9 @@
*/
#include "sddmkcm.h"
#include <algorithm>
#include <QDir>
#include <QHBoxLayout>
#include <QTabWidget>
......@@ -54,7 +57,19 @@ SddmKcm::SddmKcm(QWidget *parent, const QVariantList &args) :
setAboutData(aboutData);
setNeedsAuthorization(true);
mSddmConfig = KSharedConfig::openConfig(SDDM_CONFIG_FILE, KConfig::CascadeConfig);
// This does not listen for new config files in the directory.
QStringList configFiles = QDir(SDDM_CONFIG_DIR).entryList(QDir::Files | QDir::NoDotAndDotDot, QDir::LocaleAware),
systemConfigFiles = QDir(SDDM_SYSTEM_CONFIG_DIR).entryList(QDir::Files | QDir::NoDotAndDotDot, QDir::LocaleAware);
std::transform(systemConfigFiles.begin(), systemConfigFiles.end(), systemConfigFiles.begin(),
[](const QString &filename) { return QStringLiteral(SDDM_SYSTEM_CONFIG_DIR "/") + filename; });
std::transform(configFiles.begin(), configFiles.end(), configFiles.begin(),
[](const QString &filename) { return QStringLiteral(SDDM_CONFIG_DIR "/") + filename; });
mSddmConfig->addConfigSources(systemConfigFiles + configFiles);
prepareUi();
}
......@@ -101,12 +116,12 @@ void SddmKcm::prepareUi()
QTabWidget* tabHolder = new QTabWidget(this);
layout->addWidget(tabHolder);
mThemeConfig = new ThemeConfig(this);
mThemeConfig = new ThemeConfig(mSddmConfig, this);
connect(mThemeConfig, SIGNAL(changed(bool)), SIGNAL(changed(bool)));
tabHolder->addTab(mThemeConfig, i18n("Theme"));
mAdvanceConfig = new AdvanceConfig(this);
mAdvanceConfig = new AdvanceConfig(mSddmConfig, this);
connect(mAdvanceConfig, SIGNAL(changed(bool)), SIGNAL(changed(bool)));
tabHolder->addTab(mAdvanceConfig, i18n("Advanced"));
......
......@@ -18,6 +18,7 @@
#define SDDMKCM_H
#include <KCModule>
#include <KSharedConfig>
class ThemeConfig;
class AdvanceConfig;
......@@ -36,6 +37,7 @@ private:
void prepareUi();
private:
KSharedConfigPtr mSddmConfig;
ThemeConfig *mThemeConfig;
AdvanceConfig *mAdvanceConfig;
};
......
......@@ -37,11 +37,10 @@
#include "config.h"
ThemeConfig::ThemeConfig(QWidget *parent) :
QWidget(parent)
ThemeConfig::ThemeConfig(const KSharedConfigPtr &config, QWidget *parent) :
QWidget(parent),
mConfig(config)
{
mConfig = KSharedConfig::openConfig(SDDM_CONFIG_FILE, KConfig::SimpleConfig);
configUi = new Ui::ThemeConfig();
configUi->setupUi(this);
configUi->messageWidget->setVisible(false);
......
......@@ -31,7 +31,7 @@ class ThemeConfig : public QWidget
{
Q_OBJECT
public:
explicit ThemeConfig(QWidget *parent = 0);
explicit ThemeConfig(const KSharedConfigPtr &config, QWidget *parent = 0);
~ThemeConfig();
QVariantMap save();
......
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