Changeset View
Changeset View
Standalone View
Standalone View
kded/configvalueprovider.cpp
Show All 35 Lines | |||||
36 | { | 36 | { | ||
37 | 37 | | |||
38 | } | 38 | } | ||
39 | 39 | | |||
40 | QString ConfigValueProvider::fontName() const | 40 | QString ConfigValueProvider::fontName() const | ||
41 | { | 41 | { | ||
42 | static const QFont defaultFont(QStringLiteral("Noto Sans"), 10); | 42 | static const QFont defaultFont(QStringLiteral("Noto Sans"), 10); | ||
43 | 43 | | |||
44 | kdeglobalsConfig->reparseConfiguration(); | | |||
45 | KConfigGroup configGroup = kdeglobalsConfig->group(QStringLiteral("General")); | 44 | KConfigGroup configGroup = kdeglobalsConfig->group(QStringLiteral("General")); | ||
46 | QString fontAsString = configGroup.readEntry(QStringLiteral("font"), defaultFont.toString()); | 45 | QString fontAsString = configGroup.readEntry(QStringLiteral("font"), defaultFont.toString()); | ||
47 | static QFont font; | 46 | static QFont font; | ||
48 | font.fromString(fontAsString); | 47 | font.fromString(fontAsString); | ||
49 | const QString fontStyle = fontStyleHelper(font); | 48 | const QString fontStyle = fontStyleHelper(font); | ||
50 | return font.family() + QStringLiteral(", ") + fontStyle + ' ' + QString::number(font.pointSize()); | 49 | return font.family() + QStringLiteral(", ") + fontStyle + ' ' + QString::number(font.pointSize()); | ||
51 | } | 50 | } | ||
52 | 51 | | |||
▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Line(s) | 53 | { | |||
109 | } | 108 | } | ||
110 | 109 | | |||
111 | return result.simplified(); | 110 | return result.simplified(); | ||
112 | } | 111 | } | ||
113 | 112 | | |||
114 | 113 | | |||
115 | QString ConfigValueProvider::iconThemeName() const | 114 | QString ConfigValueProvider::iconThemeName() const | ||
116 | { | 115 | { | ||
117 | KIconTheme *newIconTheme = KIconLoader::global()->theme(); | 116 | KConfigGroup configGroup = kdeglobalsConfig->group(QStringLiteral("Icons")); | ||
118 | if (newIconTheme) { | 117 | return configGroup.readEntry(QStringLiteral("Theme"), QStringLiteral("breeze")); | ||
119 | return newIconTheme->internalName(); | | |||
120 | } else { | | |||
121 | return QStringLiteral("breeze"); | | |||
122 | } | | |||
123 | } | 118 | } | ||
124 | 119 | | |||
125 | QString ConfigValueProvider::cursorThemeName() const | 120 | QString ConfigValueProvider::cursorThemeName() const | ||
126 | { | 121 | { | ||
127 | inputConfig->reparseConfiguration(); | | |||
128 | KConfigGroup configGroup = inputConfig->group(QStringLiteral("Mouse")); | 122 | KConfigGroup configGroup = inputConfig->group(QStringLiteral("Mouse")); | ||
129 | return configGroup.readEntry(QStringLiteral("cursorTheme"), QStringLiteral("breeze_cursors")); | 123 | return configGroup.readEntry(QStringLiteral("cursorTheme"), QStringLiteral("breeze_cursors")); | ||
130 | } | 124 | } | ||
131 | 125 | | |||
132 | QString ConfigValueProvider::iconsOnButtons() const | 126 | QString ConfigValueProvider::iconsOnButtons() const | ||
133 | { | 127 | { | ||
134 | kdeglobalsConfig->reparseConfiguration(); | | |||
135 | KConfigGroup configGroup = kdeglobalsConfig->group(QStringLiteral("KDE")); | 128 | KConfigGroup configGroup = kdeglobalsConfig->group(QStringLiteral("KDE")); | ||
136 | bool kdeConfigValue = configGroup.readEntry(QStringLiteral("ShowIconsOnPushButtons"), true); | 129 | bool kdeConfigValue = configGroup.readEntry(QStringLiteral("ShowIconsOnPushButtons"), true); | ||
137 | 130 | | |||
138 | if (kdeConfigValue) { | 131 | if (kdeConfigValue) { | ||
139 | return QStringLiteral("1"); | 132 | return QStringLiteral("1"); | ||
140 | } else { | 133 | } else { | ||
141 | return QStringLiteral("0"); | 134 | return QStringLiteral("0"); | ||
142 | } | 135 | } | ||
143 | } | 136 | } | ||
144 | 137 | | |||
145 | QString ConfigValueProvider::iconsInMenus() const | 138 | QString ConfigValueProvider::iconsInMenus() const | ||
146 | { | 139 | { | ||
147 | kdeglobalsConfig->reparseConfiguration(); | | |||
148 | KConfigGroup configGroup = kdeglobalsConfig->group(QStringLiteral("KDE")); | 140 | KConfigGroup configGroup = kdeglobalsConfig->group(QStringLiteral("KDE")); | ||
149 | bool kdeConfigValue = configGroup.readEntry(QStringLiteral("ShowIconsInMenuItems"), true); | 141 | bool kdeConfigValue = configGroup.readEntry(QStringLiteral("ShowIconsInMenuItems"), true); | ||
150 | 142 | | |||
151 | if (kdeConfigValue) { | 143 | if (kdeConfigValue) { | ||
152 | return QStringLiteral("1"); | 144 | return QStringLiteral("1"); | ||
153 | } else { | 145 | } else { | ||
154 | return QStringLiteral("0"); | 146 | return QStringLiteral("0"); | ||
155 | } | 147 | } | ||
156 | } | 148 | } | ||
157 | 149 | | |||
158 | QString ConfigValueProvider::toolbarStyle(ConfigValueProvider::ToolbarStyleNotation notation) const | 150 | QString ConfigValueProvider::toolbarStyle(ConfigValueProvider::ToolbarStyleNotation notation) const | ||
159 | { | 151 | { | ||
160 | kdeglobalsConfig->reparseConfiguration(); | | |||
161 | KConfigGroup configGroup = kdeglobalsConfig->group(QStringLiteral("Toolbar style")); | 152 | KConfigGroup configGroup = kdeglobalsConfig->group(QStringLiteral("Toolbar style")); | ||
162 | QString kdeConfigValue = configGroup.readEntry(QStringLiteral("ToolButtonStyle"), "TextBesideIcon"); | 153 | QString kdeConfigValue = configGroup.readEntry(QStringLiteral("ToolButtonStyle"), "TextBesideIcon"); | ||
163 | return toolbarStyleInDesiredNotation(kdeConfigValue, notation); | 154 | return toolbarStyleInDesiredNotation(kdeConfigValue, notation); | ||
164 | } | 155 | } | ||
165 | 156 | | |||
166 | QString ConfigValueProvider::scrollbarBehavior() const | 157 | QString ConfigValueProvider::scrollbarBehavior() const | ||
167 | { | 158 | { | ||
168 | kdeglobalsConfig->reparseConfiguration(); | | |||
169 | KConfigGroup configGroup = kdeglobalsConfig->group(QStringLiteral("KDE")); | 159 | KConfigGroup configGroup = kdeglobalsConfig->group(QStringLiteral("KDE")); | ||
170 | bool kdeConfigValue = configGroup.readEntry(QStringLiteral("ScrollbarLeftClickNavigatesByPage"), true); | 160 | bool kdeConfigValue = configGroup.readEntry(QStringLiteral("ScrollbarLeftClickNavigatesByPage"), true); | ||
171 | if (kdeConfigValue) { // GTK setting is inverted | 161 | if (kdeConfigValue) { // GTK setting is inverted | ||
172 | return QStringLiteral("0"); | 162 | return QStringLiteral("0"); | ||
173 | } else { | 163 | } else { | ||
174 | return QStringLiteral("1"); | 164 | return QStringLiteral("1"); | ||
175 | } | 165 | } | ||
176 | } | 166 | } | ||
177 | 167 | | |||
178 | QString ConfigValueProvider::preferDarkTheme() const | 168 | QString ConfigValueProvider::preferDarkTheme() const | ||
179 | { | 169 | { | ||
180 | kdeglobalsConfig->reparseConfiguration(); | | |||
181 | KConfigGroup colorsConfigGroup = kdeglobalsConfig->group(QStringLiteral("Colors:Window")); | 170 | KConfigGroup colorsConfigGroup = kdeglobalsConfig->group(QStringLiteral("Colors:Window")); | ||
182 | QColor windowBackgroundColor = colorsConfigGroup.readEntry(QStringLiteral("BackgroundNormal"), QColor(239, 240, 241)); | 171 | QColor windowBackgroundColor = colorsConfigGroup.readEntry(QStringLiteral("BackgroundNormal"), QColor(239, 240, 241)); | ||
183 | const int windowBackgroundGray = qGray(windowBackgroundColor.rgb()); | 172 | const int windowBackgroundGray = qGray(windowBackgroundColor.rgb()); | ||
184 | 173 | | |||
185 | // 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 | ||
186 | if (windowBackgroundGray >= 192) { | 175 | if (windowBackgroundGray >= 192) { | ||
187 | return QStringLiteral("0"); | 176 | return QStringLiteral("0"); | ||
188 | } else { | 177 | } else { | ||
189 | return QStringLiteral("1"); | 178 | return QStringLiteral("1"); | ||
190 | } | 179 | } | ||
191 | } | 180 | } | ||
192 | 181 | | |||
193 | QString ConfigValueProvider::windowDecorationsButtonsOrder() const | 182 | QString ConfigValueProvider::windowDecorationsButtonsOrder() const | ||
194 | { | 183 | { | ||
195 | kwinConfig->reparseConfiguration(); | | |||
196 | KConfigGroup configGroup = kwinConfig->group(QStringLiteral("org.kde.kdecoration2")); | 184 | KConfigGroup configGroup = kwinConfig->group(QStringLiteral("org.kde.kdecoration2")); | ||
197 | QString buttonsOnLeftKdeConfigValue = configGroup.readEntry(QStringLiteral("ButtonsOnLeft"), "MS"); | 185 | QString buttonsOnLeftKdeConfigValue = configGroup.readEntry(QStringLiteral("ButtonsOnLeft"), "MS"); | ||
198 | QString buttonsOnRightKdeConfigValue = configGroup.readEntry(QStringLiteral("ButtonsOnRight"), "HIAX"); | 186 | QString buttonsOnRightKdeConfigValue = configGroup.readEntry(QStringLiteral("ButtonsOnRight"), "HIAX"); | ||
199 | 187 | | |||
200 | QString buttonsOnLeftInGtkNotation = windowDecorationButtonsOrderInGtkNotation(buttonsOnLeftKdeConfigValue); | 188 | QString buttonsOnLeftInGtkNotation = windowDecorationButtonsOrderInGtkNotation(buttonsOnLeftKdeConfigValue); | ||
201 | QString buttonsOnRightInGtkNotation = windowDecorationButtonsOrderInGtkNotation(buttonsOnRightKdeConfigValue); | 189 | QString buttonsOnRightInGtkNotation = windowDecorationButtonsOrderInGtkNotation(buttonsOnRightKdeConfigValue); | ||
202 | 190 | | |||
203 | return buttonsOnLeftInGtkNotation + QStringLiteral(":") + buttonsOnRightInGtkNotation; | 191 | return buttonsOnLeftInGtkNotation + QStringLiteral(":") + buttonsOnRightInGtkNotation; | ||
▲ Show 20 Lines • Show All 72 Lines • Show Last 20 Lines |