Changeset View
Changeset View
Standalone View
Standalone View
kded/gtkconfig.cpp
Show All 13 Lines | |||||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | * GNU General Public License for more details. | 16 | * GNU General Public License for more details. | ||
17 | * | 17 | * | ||
18 | * You should have received a copy of the GNU General Public License | 18 | * You should have received a copy of the GNU General Public License | ||
19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
20 | */ | 20 | */ | ||
21 | 21 | | |||
22 | #include <QDebug> | | |||
23 | #include <QFont> | 22 | #include <QFont> | ||
24 | #include <QDBusConnection> | 23 | #include <QDBusConnection> | ||
24 | #include <QDBusMessage> | ||||
25 | #include <QGuiApplication> | 25 | #include <QGuiApplication> | ||
26 | 26 | | |||
27 | #include <KIconLoader> | 27 | #include <KIconLoader> | ||
28 | #include <KPluginFactory> | 28 | #include <KPluginFactory> | ||
29 | #include <KConfigWatcher> | 29 | #include <KConfigWatcher> | ||
30 | 30 | | |||
31 | #include "gtkconfig.h" | 31 | #include "gtkconfig.h" | ||
32 | #include "configvalueprovider.h" | 32 | #include "configvalueprovider.h" | ||
33 | #include "themepreviewer.h" | ||||
33 | 34 | | |||
34 | K_PLUGIN_CLASS_WITH_JSON(GtkConfig, "gtkconfig.json") | 35 | K_PLUGIN_CLASS_WITH_JSON(GtkConfig, "gtkconfig.json") | ||
35 | 36 | | |||
36 | GtkConfig::GtkConfig(QObject *parent, const QVariantList&) : | 37 | GtkConfig::GtkConfig(QObject *parent, const QVariantList&) : | ||
37 | KDEDModule(parent), | 38 | KDEDModule(parent), | ||
38 | configValueProvider(new ConfigValueProvider()), | 39 | configValueProvider(new ConfigValueProvider()), | ||
40 | themePreviewer(new ThemePreviewer(this)), | ||||
39 | kwinConfigWatcher(KConfigWatcher::create(KSharedConfig::openConfig(QStringLiteral("kwinrc")))) | 41 | kwinConfigWatcher(KConfigWatcher::create(KSharedConfig::openConfig(QStringLiteral("kwinrc")))) | ||
40 | { | 42 | { | ||
43 | QDBusConnection dbus = QDBusConnection::sessionBus(); | ||||
44 | dbus.registerService(QStringLiteral("org.kde.GtkConfig")); | ||||
45 | dbus.registerObject(QStringLiteral("/GtkConfig"), this, QDBusConnection::ExportScriptableSlots); | ||||
46 | | ||||
41 | connect(qGuiApp, &QGuiApplication::fontChanged, this, &GtkConfig::setFont); | 47 | connect(qGuiApp, &QGuiApplication::fontChanged, this, &GtkConfig::setFont); | ||
42 | connect(KIconLoader::global(), &KIconLoader::iconChanged, this, &GtkConfig::setIconTheme); | 48 | connect(KIconLoader::global(), &KIconLoader::iconChanged, this, &GtkConfig::setIconTheme); | ||
43 | connect(kwinConfigWatcher.data(), &KConfigWatcher::configChanged, this, &GtkConfig::onKWinSettingsChange); | 49 | connect(kwinConfigWatcher.data(), &KConfigWatcher::configChanged, this, &GtkConfig::onKWinSettingsChange); | ||
44 | QDBusConnection::sessionBus().connect(QString(), | 50 | dbus.connect( | ||
51 | QString(), | ||||
45 | QStringLiteral("/KGlobalSettings"), | 52 | QStringLiteral("/KGlobalSettings"), | ||
46 | QStringLiteral("org.kde.KGlobalSettings"), | 53 | QStringLiteral("org.kde.KGlobalSettings"), | ||
47 | QStringLiteral("notifyChange"), | 54 | QStringLiteral("notifyChange"), | ||
48 | this, | 55 | this, | ||
49 | SLOT(onGlobalSettingsChange(int,int))); | 56 | SLOT(onGlobalSettingsChange(int,int)) | ||
57 | ); | ||||
58 | | ||||
59 | ConfigEditor::removeLegacyGtk2Strings(); | ||||
50 | applyAllSettings(); | 60 | applyAllSettings(); | ||
51 | } | 61 | } | ||
52 | 62 | | |||
63 | GtkConfig::~GtkConfig() | ||||
64 | { | ||||
65 | QDBusConnection dbus = QDBusConnection::sessionBus(); | ||||
66 | dbus.unregisterService(QStringLiteral("org.kde.GtkConfig")); | ||||
67 | dbus.unregisterObject(QStringLiteral("/GtkConfig")); | ||||
68 | } | ||||
69 | | ||||
70 | void GtkConfig::setGtk2Theme(const QString &themeName) const | ||||
71 | { | ||||
72 | ConfigEditor::setGtk2ConfigValue(QStringLiteral("gtk-theme-name"), themeName); | ||||
73 | } | ||||
74 | | ||||
75 | void GtkConfig::setGtk3Theme(const QString &themeName) const | ||||
76 | { | ||||
77 | ConfigEditor::setGtk3ConfigValueDconf(QStringLiteral("gtk-theme"), themeName); | ||||
78 | ConfigEditor::setGtk3ConfigValueSettingsIni(QStringLiteral("gtk-theme-name"), themeName); | ||||
79 | ConfigEditor::setGtk3ConfigValueXSettingsd(QStringLiteral("Net/ThemeName"), themeName); | ||||
80 | } | ||||
81 | | ||||
82 | QString GtkConfig::gtk2Theme() const | ||||
83 | { | ||||
84 | return ConfigEditor::gtk2ConfigValue(QStringLiteral("gtk-theme-name")); | ||||
85 | } | ||||
86 | | ||||
87 | QString GtkConfig::gtk3Theme() const | ||||
88 | { | ||||
89 | return ConfigEditor::gtk3ConfigValueSettingsIni(QStringLiteral("gtk-theme-name")); | ||||
90 | } | ||||
91 | | ||||
92 | void GtkConfig::showGtk2ThemePreview(const QString& themeName) const | ||||
93 | { | ||||
94 | themePreviewer->showGtk2App(themeName); | ||||
95 | } | ||||
96 | | ||||
97 | void GtkConfig::showGtk3ThemePreview(const QString& themeName) const | ||||
98 | { | ||||
99 | themePreviewer->showGtk3App(themeName); | ||||
100 | } | ||||
101 | | ||||
53 | void GtkConfig::setFont() const | 102 | void GtkConfig::setFont() const | ||
54 | { | 103 | { | ||
55 | const QString configFontName = configValueProvider->fontName(); | 104 | const QString configFontName = configValueProvider->fontName(); | ||
56 | ConfigEditor::setGtk2ConfigValue(QStringLiteral("gtk-font-name"), configFontName); | 105 | ConfigEditor::setGtk2ConfigValue(QStringLiteral("gtk-font-name"), configFontName); | ||
57 | ConfigEditor::setGtk3ConfigValueDconf(QStringLiteral("font-name"), configFontName); | 106 | ConfigEditor::setGtk3ConfigValueDconf(QStringLiteral("font-name"), configFontName); | ||
58 | ConfigEditor::setGtk3ConfigValueSettingsIni(QStringLiteral("gtk-font-name"), configFontName); | 107 | ConfigEditor::setGtk3ConfigValueSettingsIni(QStringLiteral("gtk-font-name"), configFontName); | ||
59 | ConfigEditor::setGtk3ConfigValueXSettingsd(QStringLiteral("Gtk/FontName"), configFontName); | 108 | ConfigEditor::setGtk3ConfigValueXSettingsd(QStringLiteral("Gtk/FontName"), configFontName); | ||
60 | } | 109 | } | ||
▲ Show 20 Lines • Show All 113 Lines • Show Last 20 Lines |