Changeset View
Changeset View
Standalone View
Standalone View
kded/gtkconfig.cpp
Show All 32 Lines | |||||
33 | #include "themepreviewer.h" | 33 | #include "themepreviewer.h" | ||
34 | 34 | | |||
35 | K_PLUGIN_CLASS_WITH_JSON(GtkConfig, "gtkconfig.json") | 35 | K_PLUGIN_CLASS_WITH_JSON(GtkConfig, "gtkconfig.json") | ||
36 | 36 | | |||
37 | GtkConfig::GtkConfig(QObject *parent, const QVariantList&) : | 37 | GtkConfig::GtkConfig(QObject *parent, const QVariantList&) : | ||
38 | KDEDModule(parent), | 38 | KDEDModule(parent), | ||
39 | configValueProvider(new ConfigValueProvider()), | 39 | configValueProvider(new ConfigValueProvider()), | ||
40 | themePreviewer(new ThemePreviewer(this)), | 40 | themePreviewer(new ThemePreviewer(this)), | ||
41 | kdeglobalsConfigWatcher(KConfigWatcher::create(KSharedConfig::openConfig(QStringLiteral("kdeglobals")))), | ||||
41 | kwinConfigWatcher(KConfigWatcher::create(KSharedConfig::openConfig(QStringLiteral("kwinrc")))) | 42 | kwinConfigWatcher(KConfigWatcher::create(KSharedConfig::openConfig(QStringLiteral("kwinrc")))) | ||
42 | { | 43 | { | ||
43 | QDBusConnection dbus = QDBusConnection::sessionBus(); | 44 | QDBusConnection dbus = QDBusConnection::sessionBus(); | ||
44 | dbus.registerService(QStringLiteral("org.kde.GtkConfig")); | 45 | dbus.registerService(QStringLiteral("org.kde.GtkConfig")); | ||
45 | dbus.registerObject(QStringLiteral("/GtkConfig"), this, QDBusConnection::ExportScriptableSlots); | 46 | dbus.registerObject(QStringLiteral("/GtkConfig"), this, QDBusConnection::ExportScriptableSlots); | ||
46 | 47 | | |||
47 | connect(qGuiApp, &QGuiApplication::fontChanged, this, &GtkConfig::setFont); | 48 | connect(qGuiApp, &QGuiApplication::fontChanged, this, &GtkConfig::setFont); | ||
48 | connect(KIconLoader::global(), &KIconLoader::iconChanged, this, &GtkConfig::setIconTheme); | 49 | connect(KIconLoader::global(), &KIconLoader::iconChanged, this, &GtkConfig::setIconTheme); | ||
50 | connect(kdeglobalsConfigWatcher.data(), &KConfigWatcher::configChanged, this, &GtkConfig::onKdeglobalsSettingsChange); | ||||
49 | connect(kwinConfigWatcher.data(), &KConfigWatcher::configChanged, this, &GtkConfig::onKWinSettingsChange); | 51 | connect(kwinConfigWatcher.data(), &KConfigWatcher::configChanged, this, &GtkConfig::onKWinSettingsChange); | ||
50 | dbus.connect( | 52 | dbus.connect( | ||
51 | QString(), | 53 | QString(), | ||
52 | QStringLiteral("/KGlobalSettings"), | 54 | QStringLiteral("/KGlobalSettings"), | ||
53 | QStringLiteral("org.kde.KGlobalSettings"), | 55 | QStringLiteral("org.kde.KGlobalSettings"), | ||
54 | QStringLiteral("notifyChange"), | 56 | QStringLiteral("notifyChange"), | ||
55 | this, | 57 | this, | ||
56 | SLOT(onGlobalSettingsChange(int,int)) | 58 | SLOT(onGlobalSettingsChange(int,int)) | ||
▲ Show 20 Lines • Show All 118 Lines • ▼ Show 20 Line(s) | |||||
175 | void GtkConfig::setWindowDecorationsButtonsOrder() const | 177 | void GtkConfig::setWindowDecorationsButtonsOrder() const | ||
176 | { | 178 | { | ||
177 | const QString windowDecorationsButtonOrder = configValueProvider->windowDecorationsButtonsOrder(); | 179 | const QString windowDecorationsButtonOrder = configValueProvider->windowDecorationsButtonsOrder(); | ||
178 | ConfigEditor::setGtk3ConfigValueDconf(QStringLiteral("button-layout"), windowDecorationsButtonOrder, QStringLiteral("org.gnome.desktop.wm.preferences")); | 180 | ConfigEditor::setGtk3ConfigValueDconf(QStringLiteral("button-layout"), windowDecorationsButtonOrder, QStringLiteral("org.gnome.desktop.wm.preferences")); | ||
179 | ConfigEditor::setGtk3ConfigValueSettingsIni(QStringLiteral("gtk-decoration-layout"), windowDecorationsButtonOrder); | 181 | ConfigEditor::setGtk3ConfigValueSettingsIni(QStringLiteral("gtk-decoration-layout"), windowDecorationsButtonOrder); | ||
180 | ConfigEditor::setGtk3ConfigValueXSettingsd(QStringLiteral("Gtk/DecorationLayout"), windowDecorationsButtonOrder); | 182 | ConfigEditor::setGtk3ConfigValueXSettingsd(QStringLiteral("Gtk/DecorationLayout"), windowDecorationsButtonOrder); | ||
181 | } | 183 | } | ||
182 | 184 | | |||
185 | void GtkConfig::setEnableAnimations() const | ||||
186 | { | ||||
187 | const QString enableAnimations = configValueProvider->enableAnimations(); | ||||
188 | ConfigEditor::setGtk2ConfigValue(QStringLiteral("gtk-enable-animations"), enableAnimations); | ||||
gikari: Wrong settings key | |||||
189 | // FIXME work with booleans in configValueProvider... | ||||
org.gnome.desktop.interface param is not necessary - it is the default. Most of the settings are in this category in dconf. gikari: `org.gnome.desktop.interface` param is not necessary - it is the default. Most of the settings… | |||||
190 | ConfigEditor::setGtk3ConfigValueDconf(QStringLiteral("enable-animations"), enableAnimations == QLatin1String("1")); | ||||
191 | ConfigEditor::setGtk3ConfigValueSettingsIni(QStringLiteral("gtk-enable-animations"), enableAnimations); | ||||
192 | ConfigEditor::setGtk3ConfigValueXSettingsd(QStringLiteral("Gtk/EnableAnimations"), enableAnimations); | ||||
193 | } | ||||
194 | | ||||
183 | void GtkConfig::applyAllSettings() const | 195 | void GtkConfig::applyAllSettings() const | ||
184 | { | 196 | { | ||
185 | setFont(); | 197 | setFont(); | ||
186 | setIconTheme(KIconLoader::Group::Desktop); | 198 | setIconTheme(KIconLoader::Group::Desktop); | ||
187 | setCursorTheme(); | 199 | setCursorTheme(); | ||
188 | setIconsOnButtons(); | 200 | setIconsOnButtons(); | ||
189 | setIconsInMenus(); | 201 | setIconsInMenus(); | ||
190 | setToolbarStyle(); | 202 | setToolbarStyle(); | ||
191 | setScrollbarBehavior(); | 203 | setScrollbarBehavior(); | ||
192 | setDarkThemePreference(); | 204 | setDarkThemePreference(); | ||
193 | setWindowDecorationsButtonsOrder(); | 205 | setWindowDecorationsButtonsOrder(); | ||
206 | setEnableAnimations(); | ||||
194 | } | 207 | } | ||
195 | 208 | | |||
196 | void GtkConfig::onGlobalSettingsChange(int settingsChangeType, int arg) const | 209 | void GtkConfig::onGlobalSettingsChange(int settingsChangeType, int arg) const | ||
197 | { | 210 | { | ||
198 | SettingsChangeType changeType = static_cast<SettingsChangeType>(settingsChangeType); | 211 | SettingsChangeType changeType = static_cast<SettingsChangeType>(settingsChangeType); | ||
199 | SettingsCategory settingsCategory = static_cast<SettingsCategory>(arg); | 212 | SettingsCategory settingsCategory = static_cast<SettingsCategory>(arg); | ||
200 | 213 | | |||
201 | if (changeType == SettingsChangeType::Cursor) { | 214 | if (changeType == SettingsChangeType::Cursor) { | ||
202 | setCursorTheme(); | 215 | setCursorTheme(); | ||
203 | } else if (changeType == SettingsChangeType::Settings && settingsCategory == SettingsCategory::Style) { | 216 | } else if (changeType == SettingsChangeType::Settings && settingsCategory == SettingsCategory::Style) { | ||
204 | setIconsOnButtons(); | 217 | setIconsOnButtons(); | ||
205 | setIconsInMenus(); | 218 | setIconsInMenus(); | ||
206 | setToolbarStyle(); | 219 | setToolbarStyle(); | ||
207 | } else if (changeType == SettingsChangeType::Settings && settingsCategory == SettingsCategory::Mouse) { | 220 | } else if (changeType == SettingsChangeType::Settings && settingsCategory == SettingsCategory::Mouse) { | ||
208 | setScrollbarBehavior(); | 221 | setScrollbarBehavior(); | ||
209 | } else if (changeType == SettingsChangeType::Palette) { | 222 | } else if (changeType == SettingsChangeType::Palette) { | ||
210 | setDarkThemePreference(); | 223 | setDarkThemePreference(); | ||
211 | } | 224 | } | ||
212 | } | 225 | } | ||
213 | 226 | | |||
227 | void GtkConfig::onKdeglobalsSettingsChange(const KConfigGroup &group, const QByteArrayList &names) const | ||||
228 | { | ||||
229 | if (group.name() == QLatin1String("KDE") | ||||
230 | && names.contains(QByteArrayLiteral("AnimationDurationFactor"))) { | ||||
231 | setEnableAnimations(); | ||||
232 | } | ||||
233 | } | ||||
234 | | ||||
214 | void GtkConfig::onKWinSettingsChange(const KConfigGroup &group, const QByteArrayList &names) const | 235 | void GtkConfig::onKWinSettingsChange(const KConfigGroup &group, const QByteArrayList &names) const | ||
215 | { | 236 | { | ||
216 | if (group.name() == QStringLiteral("org.kde.kdecoration2") | 237 | if (group.name() == QStringLiteral("org.kde.kdecoration2") | ||
217 | && (names.contains("ButtonsOnRight") || names.contains("ButtonsOnLeft"))) { | 238 | && (names.contains("ButtonsOnRight") || names.contains("ButtonsOnLeft"))) { | ||
218 | setWindowDecorationsButtonsOrder(); | 239 | setWindowDecorationsButtonsOrder(); | ||
219 | } | 240 | } | ||
220 | } | 241 | } | ||
221 | 242 | | |||
222 | #include "gtkconfig.moc" | 243 | #include "gtkconfig.moc" |
Wrong settings key