summaryrefslogtreecommitdiffstats
path: root/src/settings.h
blob: a218e3be31d0f77c62b4d406d8ece636627e3acb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#ifndef SETTINGS_H
#define SETTINGS_H

#include <QSettings>
#include <QDir>
#include <QTextCodec>

#define CONFIG_FILE "/etc/lightdm/qt-lightdm-greeter.conf"
#define CONFIG_FOLDER "/etc/lightdm/qt-lightdm-greeter.conf.d"
#define CONFIG_QSS_FILE "/etc/lightdm/qt-lightdm-greeter.qss"

class Settings;
extern Settings *s_settings;

class Settings : public QSettings
{
public:

	Settings() : QSettings(QString(CONFIG_FILE), IniFormat)
	{
		setIniCodec(QTextCodec::codecForLocale());
		QDir configDir(CONFIG_FOLDER);
		QFileInfoList fileInfoList = configDir.entryInfoList(QStringList() << "*.conf", QDir::Files, QDir::Name);

		for (QFileInfo fileInfo : fileInfoList) {
			QString filePath = fileInfo.absoluteFilePath();
			QSettings setting(filePath, IniFormat);
			for(QString key : setting.allKeys()) {
				this->setValue(key, setting.value(key));
			}
		}
	}
    static QString iconThemeName() { return s_settings->value("greeter-icon-theme").toString(); }
    static QString backgrundImageFile() { return s_settings->value("greeter-background-image").toString(); }
    static QString offsetX() { return s_settings->value("loginform-offset-x").toString(); }
    static QString offsetY() { return s_settings->value("loginform-offset-y").toString(); }
    static QString miniIconFile() { return s_settings->value("loginform-mini-icon").toString(); }
    static QString bannerImageFile() { return s_settings->value("greeter-banner-image").toString(); }
    static QString bottomLeftLogoFile() { return s_settings->value("greeter-bottom-left-logo-file").toString(); }
    static QString bottomLeftLogoDir() { return s_settings->value("greeter-bottom-left-logo-path").toString(); }
    static QStringList gradientColors() { return s_settings->value("greeter-background-gradient").toString().split(QRegExp("\\s"), QString::SkipEmptyParts); }
    static QString logMessageFile() { return s_settings->value("greeter-message-file").toString(); }
    static QString newsHtmlFile() { return s_settings->value("news-html-file").toString(); }
    static QString autoLoginCheckCmd() { return s_settings->value("auto-login-check-cmd").toString(); }
    static QString clockStyle() { return s_settings->value("clock-text-style").toString(); }
    static QString clockBackgroundStyle() { return s_settings->value("clock-background-style").toString(); }
    static QStringList clockShadow() { return s_settings->value("clock-shadow").toString().split(QRegExp("\\s"), QString::SkipEmptyParts); }
    static QString usernamePlaceholder() { return s_settings->value("username-placeholder").toString(); }
    static QString passwordPlaceholder() { return s_settings->value("password-placeholder").toString(); }
    static bool userSessionEnabled() { return s_settings->value("user-session-enabled", "1").toBool(); }
    static bool guestSessionEnabled() { return s_settings->value("guest-session-enabled").toBool(); }
    static bool shibSessionEnabled() { return s_settings->value("shib-session-enabled").toBool(); }
    static bool qrSessionEnabled() { return s_settings->value("qr-session-enabled").toBool(); }
    static QString shibUrl() { return s_settings->value("shib-url").toString(); }
    static QString urlWhitelistFile() { return s_settings->value("shib-url-whitelist").toString(); }
    static QString urlBlacklistFile() { return s_settings->value("shib-url-blacklist").toString(); }
    static QString shibSessionButtonText() { return s_settings->value("shib-session-button-text").toString(); }
    static QString qrSessionButtonText() { return s_settings->value("qr-session-button-text").toString(); }
    static QString userSessionButtonText() { return s_settings->value("user-session-button-text").toString(); }
    static QString guestSessionButtonText() { return s_settings->value("guest-session-button-text").toString(); }
    static QString guestSessionStartText() { return s_settings->value("guest-session-start-text").toString(); }
    static QString guestSessionStartButtonText() { return s_settings->value("guest-session-start-button-text").toString(); }
    static QString allowedShibbolethDomains() { return s_settings->value("allowed-shibboleth-domains").toString(); }
    static int resetForm() { return s_settings->value("reset-timeout", "30").toInt(); }
    static int rpcPort() { return s_settings->value("rpc-port", "0").toInt(); }
};

#endif // SETTINGS_H