Changeset View
Changeset View
Standalone View
Standalone View
kded/gtkconfig.cpp
Show All 20 Lines | |||||
21 | 21 | | |||
22 | #include <QDebug> | 22 | #include <QDebug> | ||
23 | #include <QFont> | 23 | #include <QFont> | ||
24 | #include <QDBusConnection> | 24 | #include <QDBusConnection> | ||
25 | #include <QGuiApplication> | 25 | #include <QGuiApplication> | ||
26 | 26 | | |||
27 | #include <KIconLoader> | 27 | #include <KIconLoader> | ||
28 | #include <KPluginFactory> | 28 | #include <KPluginFactory> | ||
29 | #include <KConfigWatcher> | ||||
29 | 30 | | |||
30 | #include "gtkconfig.h" | 31 | #include "gtkconfig.h" | ||
31 | #include "configvalueprovider.h" | 32 | #include "configvalueprovider.h" | ||
32 | 33 | | |||
33 | K_PLUGIN_CLASS_WITH_JSON(GtkConfig, "gtkconfig.json") | 34 | K_PLUGIN_CLASS_WITH_JSON(GtkConfig, "gtkconfig.json") | ||
34 | 35 | | |||
35 | GtkConfig::GtkConfig(QObject *parent, const QVariantList&) : | 36 | GtkConfig::GtkConfig(QObject *parent, const QVariantList&) : | ||
36 | KDEDModule(parent), | 37 | KDEDModule(parent), | ||
37 | configValueProvider(new ConfigValueProvider()) | 38 | configValueProvider(new ConfigValueProvider()), | ||
39 | kwinConfigWatcher(KConfigWatcher::create(KSharedConfig::openConfig(QStringLiteral("kwinrc")))) | ||||
38 | { | 40 | { | ||
39 | connect(qGuiApp, &QGuiApplication::fontChanged, this, &GtkConfig::setFont); | 41 | connect(qGuiApp, &QGuiApplication::fontChanged, this, &GtkConfig::setFont); | ||
40 | connect(KIconLoader::global(), &KIconLoader::iconChanged, this, &GtkConfig::setIconTheme); | 42 | connect(KIconLoader::global(), &KIconLoader::iconChanged, this, &GtkConfig::setIconTheme); | ||
43 | connect(kwinConfigWatcher.data(), &KConfigWatcher::configChanged, this, &GtkConfig::onKWinSettingsChange); | ||||
41 | QDBusConnection::sessionBus().connect(QString(), | 44 | QDBusConnection::sessionBus().connect(QString(), | ||
42 | QStringLiteral("/KGlobalSettings"), | 45 | QStringLiteral("/KGlobalSettings"), | ||
43 | QStringLiteral("org.kde.KGlobalSettings"), | 46 | QStringLiteral("org.kde.KGlobalSettings"), | ||
44 | QStringLiteral("notifyChange"), | 47 | QStringLiteral("notifyChange"), | ||
45 | this, | 48 | this, | ||
46 | SLOT(onGlobalSettingsChange(int,int))); | 49 | SLOT(onGlobalSettingsChange(int,int))); | ||
47 | | ||||
48 | applyAllSettings(); | 50 | applyAllSettings(); | ||
49 | } | 51 | } | ||
50 | 52 | | |||
51 | void GtkConfig::setFont() const | 53 | void GtkConfig::setFont() const | ||
52 | { | 54 | { | ||
53 | const QString configFontName = configValueProvider->fontName(); | 55 | const QString configFontName = configValueProvider->fontName(); | ||
54 | ConfigEditor::setGtk2ConfigValue(QStringLiteral("gtk-font-name"), configFontName); | 56 | ConfigEditor::setGtk2ConfigValue(QStringLiteral("gtk-font-name"), configFontName); | ||
55 | ConfigEditor::setGtk3ConfigValueDconf(QStringLiteral("font-name"), configFontName); | 57 | ConfigEditor::setGtk3ConfigValueDconf(QStringLiteral("font-name"), configFontName); | ||
▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Line(s) | 99 | { | |||
102 | QString toolbarStyleXSettingsd = configValueProvider->toolbarStyle(ToolbarStyleNotation::Xsettingsd); | 104 | QString toolbarStyleXSettingsd = configValueProvider->toolbarStyle(ToolbarStyleNotation::Xsettingsd); | ||
103 | 105 | | |||
104 | ConfigEditor::setGtk2ConfigValue(QStringLiteral("gtk-toolbar-style"), toolbarStyleSettingsIni); | 106 | ConfigEditor::setGtk2ConfigValue(QStringLiteral("gtk-toolbar-style"), toolbarStyleSettingsIni); | ||
105 | ConfigEditor::setGtk3ConfigValueDconf(QStringLiteral("toolbar-style"), toolbarStyleDConf); | 107 | ConfigEditor::setGtk3ConfigValueDconf(QStringLiteral("toolbar-style"), toolbarStyleDConf); | ||
106 | ConfigEditor::setGtk3ConfigValueSettingsIni(QStringLiteral("gtk-toolbar-style"), toolbarStyleSettingsIni); | 108 | ConfigEditor::setGtk3ConfigValueSettingsIni(QStringLiteral("gtk-toolbar-style"), toolbarStyleSettingsIni); | ||
107 | ConfigEditor::setGtk3ConfigValueXSettingsd(QStringLiteral("Gtk/ToolbarStyle"), toolbarStyleXSettingsd); | 109 | ConfigEditor::setGtk3ConfigValueXSettingsd(QStringLiteral("Gtk/ToolbarStyle"), toolbarStyleXSettingsd); | ||
108 | } | 110 | } | ||
109 | 111 | | |||
112 | void GtkConfig::setWindowDecorationsButtonsOrder() const | ||||
113 | { | ||||
114 | const QString windowDecorationsButtonOrder = configValueProvider->windowDecorationsButtonsOrder(); | ||||
115 | ConfigEditor::setGtk3ConfigValueDconf(QStringLiteral("button-layout"), windowDecorationsButtonOrder, QStringLiteral("org.gnome.desktop.wm.preferences")); | ||||
116 | ConfigEditor::setGtk3ConfigValueSettingsIni(QStringLiteral("gtk-decoration-layout"), windowDecorationsButtonOrder); | ||||
117 | ConfigEditor::setGtk3ConfigValueXSettingsd(QStringLiteral("Gtk/DecorationLayout"), windowDecorationsButtonOrder); | ||||
118 | } | ||||
119 | | ||||
110 | void GtkConfig::applyAllSettings() const | 120 | void GtkConfig::applyAllSettings() const | ||
111 | { | 121 | { | ||
112 | setFont(); | 122 | setFont(); | ||
113 | setIconTheme(KIconLoader::Group::Desktop); | 123 | setIconTheme(KIconLoader::Group::Desktop); | ||
114 | setCursorTheme(); | 124 | setCursorTheme(); | ||
115 | setIconsOnButtons(); | 125 | setIconsOnButtons(); | ||
116 | setIconsInMenus(); | 126 | setIconsInMenus(); | ||
117 | setToolbarStyle(); | 127 | setToolbarStyle(); | ||
128 | setWindowDecorationsButtonsOrder(); | ||||
118 | } | 129 | } | ||
119 | 130 | | |||
120 | void GtkConfig::onGlobalSettingsChange(int settingsChangeType, int arg) const | 131 | void GtkConfig::onGlobalSettingsChange(int settingsChangeType, int arg) const | ||
121 | { | 132 | { | ||
122 | SettingsChangeType changeType = static_cast<SettingsChangeType>(settingsChangeType); | 133 | SettingsChangeType changeType = static_cast<SettingsChangeType>(settingsChangeType); | ||
123 | SettingsCategory settingsCategory = static_cast<SettingsCategory>(arg); | 134 | SettingsCategory settingsCategory = static_cast<SettingsCategory>(arg); | ||
124 | 135 | | |||
125 | if (changeType == SettingsChangeType::Cursor) { | 136 | if (changeType == SettingsChangeType::Cursor) { | ||
126 | setCursorTheme(); | 137 | setCursorTheme(); | ||
127 | } else if (changeType == SettingsChangeType::Settings && settingsCategory == SettingsCategory::Style) { | 138 | } else if (changeType == SettingsChangeType::Settings && settingsCategory == SettingsCategory::Style) { | ||
128 | setIconsOnButtons(); | 139 | setIconsOnButtons(); | ||
129 | setIconsInMenus(); | 140 | setIconsInMenus(); | ||
130 | setToolbarStyle(); | 141 | setToolbarStyle(); | ||
131 | } | 142 | } | ||
132 | } | 143 | } | ||
133 | 144 | | |||
145 | void GtkConfig::onKWinSettingsChange(const KConfigGroup &group, const QByteArrayList &names) const | ||||
146 | { | ||||
147 | if (group.name() == QStringLiteral("org.kde.kdecoration2") | ||||
148 | && (names.contains("ButtonsOnRight") || names.contains("ButtonsOnLeft"))) { | ||||
149 | setWindowDecorationsButtonsOrder(); | ||||
150 | } | ||||
151 | } | ||||
152 | | ||||
134 | #include "gtkconfig.moc" | 153 | #include "gtkconfig.moc" |