Changeset View
Changeset View
Standalone View
Standalone View
kded/configvalueprovider.cpp
Show All 14 Lines | |||||
15 | * GNU General Public License for more details. | 15 | * GNU General Public License for more details. | ||
16 | * | 16 | * | ||
17 | * You should have received a copy of the GNU General Public License | 17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
19 | */ | 19 | */ | ||
20 | 20 | | |||
21 | #include <QFont> | 21 | #include <QFont> | ||
22 | #include <QString> | 22 | #include <QString> | ||
23 | #include <QColor> | ||||
23 | 24 | | |||
24 | #include <KConfig> | 25 | #include <KConfig> | ||
25 | #include <KIconTheme> | 26 | #include <KIconTheme> | ||
26 | #include <KSharedConfig> | 27 | #include <KSharedConfig> | ||
27 | #include <KConfigGroup> | 28 | #include <KConfigGroup> | ||
28 | 29 | | |||
29 | #include "configvalueprovider.h" | 30 | #include "configvalueprovider.h" | ||
30 | 31 | | |||
▲ Show 20 Lines • Show All 74 Lines • ▼ Show 20 Line(s) | 103 | { | |||
105 | bool kdeConfigValue = configGroup.readEntry(QStringLiteral("ScrollbarLeftClickNavigatesByPage"), true); | 106 | bool kdeConfigValue = configGroup.readEntry(QStringLiteral("ScrollbarLeftClickNavigatesByPage"), true); | ||
106 | if (kdeConfigValue) { // GTK setting is inverted | 107 | if (kdeConfigValue) { // GTK setting is inverted | ||
107 | return QStringLiteral("0"); | 108 | return QStringLiteral("0"); | ||
108 | } else { | 109 | } else { | ||
109 | return QStringLiteral("1"); | 110 | return QStringLiteral("1"); | ||
110 | } | 111 | } | ||
111 | } | 112 | } | ||
112 | 113 | | |||
114 | QString ConfigValueProvider::preferDarkTheme() const | ||||
115 | { | ||||
116 | kdeglobalsConfig->reparseConfiguration(); | ||||
117 | KConfigGroup colorsConfigGroup = kdeglobalsConfig->group(QStringLiteral("Colors:Window")); | ||||
118 | QColor windowBackgroundColor = colorsConfigGroup.readEntry(QStringLiteral("BackgroundNormal"), QColor(239, 240, 241)); | ||||
119 | const int windowBackgroundGray = qGray(windowBackgroundColor.rgb()); | ||||
120 | | ||||
121 | // We use heuristic to determine if current color scheme is dark or not | ||||
122 | if (windowBackgroundGray >= 192) { | ||||
123 | return QStringLiteral("0"); | ||||
124 | } else { | ||||
125 | return QStringLiteral("1"); | ||||
126 | } | ||||
127 | } | ||||
128 | | ||||
113 | QString ConfigValueProvider::toolbarStyleInDesiredNotation(const QString &kdeConfigValue, ConfigValueProvider::ToolbarStyleNotation notation) const | 129 | QString ConfigValueProvider::toolbarStyleInDesiredNotation(const QString &kdeConfigValue, ConfigValueProvider::ToolbarStyleNotation notation) const | ||
114 | { | 130 | { | ||
115 | QStringList toolbarStyles {}; | 131 | QStringList toolbarStyles {}; | ||
116 | if (notation == ToolbarStyleNotation::SettingsIni) { | 132 | if (notation == ToolbarStyleNotation::SettingsIni) { | ||
117 | toolbarStyles.append({ | 133 | toolbarStyles.append({ | ||
118 | QStringLiteral("GTK_TOOLBAR_ICONS"), | 134 | QStringLiteral("GTK_TOOLBAR_ICONS"), | ||
119 | QStringLiteral("GTK_TOOLBAR_TEXT"), | 135 | QStringLiteral("GTK_TOOLBAR_TEXT"), | ||
120 | QStringLiteral("GTK_TOOLBAR_BOTH_HORIZ"), | 136 | QStringLiteral("GTK_TOOLBAR_BOTH_HORIZ"), | ||
Show All 28 Lines |