Changeset View
Changeset View
Standalone View
Standalone View
kded/configvalueprovider.cpp
Show All 27 Lines | |||||
28 | #include <KIconTheme> | 28 | #include <KIconTheme> | ||
29 | #include <KSharedConfig> | 29 | #include <KSharedConfig> | ||
30 | #include <KConfigGroup> | 30 | #include <KConfigGroup> | ||
31 | #include <KColorScheme> | 31 | #include <KColorScheme> | ||
32 | #include <KColorUtils> | 32 | #include <KColorUtils> | ||
33 | 33 | | |||
34 | #include <gtk/gtk.h> | 34 | #include <gtk/gtk.h> | ||
35 | 35 | | |||
36 | #include "dummydecorationbridge.h" | ||||
36 | #include "configvalueprovider.h" | 37 | #include "configvalueprovider.h" | ||
37 | 38 | | |||
38 | ConfigValueProvider::ConfigValueProvider() : | 39 | ConfigValueProvider::ConfigValueProvider() : | ||
39 | kdeglobalsConfig(KSharedConfig::openConfig(QStringLiteral("kdeglobals"))), | 40 | kdeglobalsConfig(KSharedConfig::openConfig(QStringLiteral("kdeglobals"))), | ||
40 | inputConfig(KSharedConfig::openConfig(QStringLiteral("kcminputrc"))), | 41 | inputConfig(KSharedConfig::openConfig(QStringLiteral("kcminputrc"))), | ||
41 | kwinConfig(KSharedConfig::openConfig(QStringLiteral("kwinrc"))) | 42 | kwinConfig(KSharedConfig::openConfig(QStringLiteral("kwinrc"))) | ||
42 | { | 43 | { | ||
43 | 44 | | |||
▲ Show 20 Lines • Show All 125 Lines • ▼ Show 20 Line(s) | 169 | { | |||
169 | KConfigGroup colorsConfigGroup = kdeglobalsConfig->group(QStringLiteral("Colors:Window")); | 170 | KConfigGroup colorsConfigGroup = kdeglobalsConfig->group(QStringLiteral("Colors:Window")); | ||
170 | QColor windowBackgroundColor = colorsConfigGroup.readEntry(QStringLiteral("BackgroundNormal"), QColor(239, 240, 241)); | 171 | QColor windowBackgroundColor = colorsConfigGroup.readEntry(QStringLiteral("BackgroundNormal"), QColor(239, 240, 241)); | ||
171 | const int windowBackgroundGray = qGray(windowBackgroundColor.rgb()); | 172 | const int windowBackgroundGray = qGray(windowBackgroundColor.rgb()); | ||
172 | 173 | | |||
173 | // We use heuristic to determine if current color scheme is dark or not | 174 | // We use heuristic to determine if current color scheme is dark or not | ||
174 | return windowBackgroundGray < 192; | 175 | return windowBackgroundGray < 192; | ||
175 | } | 176 | } | ||
176 | 177 | | |||
178 | QMap<QString, QPixmap> ConfigValueProvider::windowDecorationsButtonsImages() const | ||||
179 | { | ||||
180 | static const QVector<QString> buttonTypes { | ||||
181 | QStringLiteral("close"), | ||||
182 | QStringLiteral("maximize"), | ||||
183 | QStringLiteral("minimize"), | ||||
184 | }; | ||||
185 | | ||||
186 | static const QVector<QString> buttonStates { | ||||
187 | QStringLiteral("normal"), | ||||
188 | QStringLiteral("active"), // aka pressed | ||||
189 | QStringLiteral("hover"), | ||||
190 | }; | ||||
191 | | ||||
192 | KConfigGroup decorationGroup = kwinConfig->group(QStringLiteral("org.kde.kdecoration2")); | ||||
193 | const QString themeName = decorationGroup.readEntry(QStringLiteral("theme"), QStringLiteral("Breeze")); | ||||
194 | | ||||
195 | KDecoration2::DummyDecorationBridge kwinBridge {themeName}; | ||||
196 | QMap<QString, QPixmap> decorationsImages {}; | ||||
197 | | ||||
198 | for (const auto &buttonType : buttonTypes) { | ||||
199 | for (const auto &buttonState : buttonStates) { | ||||
200 | // TODO What size? | ||||
201 | QPixmap pixmap {20, 20}; | ||||
202 | pixmap.fill(Qt::transparent); | ||||
203 | | ||||
204 | QPainter painter {&pixmap}; | ||||
205 | kwinBridge.paintButton(painter, buttonType, buttonState); | ||||
206 | painter.save(); | ||||
207 | | ||||
208 | decorationsImages.insert(QStringLiteral("%1-%2").arg(buttonType, buttonState), pixmap); | ||||
209 | } | ||||
210 | } | ||||
211 | | ||||
212 | return decorationsImages; | ||||
213 | } | ||||
214 | | ||||
177 | QString ConfigValueProvider::windowDecorationsButtonsOrder() const | 215 | QString ConfigValueProvider::windowDecorationsButtonsOrder() const | ||
178 | { | 216 | { | ||
179 | KConfigGroup configGroup = kwinConfig->group(QStringLiteral("org.kde.kdecoration2")); | 217 | KConfigGroup configGroup = kwinConfig->group(QStringLiteral("org.kde.kdecoration2")); | ||
180 | QString buttonsOnLeftKdeConfigValue = configGroup.readEntry(QStringLiteral("ButtonsOnLeft"), "MS"); | 218 | QString buttonsOnLeftKdeConfigValue = configGroup.readEntry(QStringLiteral("ButtonsOnLeft"), "MS"); | ||
181 | QString buttonsOnRightKdeConfigValue = configGroup.readEntry(QStringLiteral("ButtonsOnRight"), "HIAX"); | 219 | QString buttonsOnRightKdeConfigValue = configGroup.readEntry(QStringLiteral("ButtonsOnRight"), "HIAX"); | ||
182 | 220 | | |||
183 | QString buttonsOnLeftInGtkNotation = windowDecorationButtonsOrderInGtkNotation(buttonsOnLeftKdeConfigValue); | 221 | QString buttonsOnLeftInGtkNotation = windowDecorationButtonsOrderInGtkNotation(buttonsOnLeftKdeConfigValue); | ||
184 | QString buttonsOnRightInGtkNotation = windowDecorationButtonsOrderInGtkNotation(buttonsOnRightKdeConfigValue); | 222 | QString buttonsOnRightInGtkNotation = windowDecorationButtonsOrderInGtkNotation(buttonsOnRightKdeConfigValue); | ||
▲ Show 20 Lines • Show All 226 Lines • Show Last 20 Lines |