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 | return font.family() + QStringLiteral(", ") + font.styleName() + ' ' + QString::number(font.pointSize()); | 48 | return font.family() + QStringLiteral(", ") + font.styleName() + ' ' + QString::number(font.pointSize()); | ||
50 | } | 49 | } | ||
51 | 50 | | |||
52 | QString ConfigValueProvider::iconThemeName() const | 51 | QString ConfigValueProvider::iconThemeName() const | ||
53 | { | 52 | { | ||
54 | KIconTheme *newIconTheme = KIconLoader::global()->theme(); | 53 | KConfigGroup configGroup = kdeglobalsConfig->group(QStringLiteral("Icons")); | ||
55 | if (newIconTheme) { | 54 | return configGroup.readEntry(QStringLiteral("Theme"), QStringLiteral("breeze")); | ||
56 | return newIconTheme->internalName(); | | |||
57 | } else { | | |||
58 | return QStringLiteral("breeze"); | | |||
59 | } | | |||
60 | } | 55 | } | ||
61 | 56 | | |||
62 | QString ConfigValueProvider::cursorThemeName() const | 57 | QString ConfigValueProvider::cursorThemeName() const | ||
63 | { | 58 | { | ||
64 | inputConfig->reparseConfiguration(); | | |||
65 | KConfigGroup configGroup = inputConfig->group(QStringLiteral("Mouse")); | 59 | KConfigGroup configGroup = inputConfig->group(QStringLiteral("Mouse")); | ||
66 | return configGroup.readEntry(QStringLiteral("cursorTheme"), QStringLiteral("breeze_cursors")); | 60 | return configGroup.readEntry(QStringLiteral("cursorTheme"), QStringLiteral("breeze_cursors")); | ||
67 | } | 61 | } | ||
68 | 62 | | |||
69 | QString ConfigValueProvider::iconsOnButtons() const | 63 | QString ConfigValueProvider::iconsOnButtons() const | ||
70 | { | 64 | { | ||
71 | kdeglobalsConfig->reparseConfiguration(); | | |||
72 | KConfigGroup configGroup = kdeglobalsConfig->group(QStringLiteral("KDE")); | 65 | KConfigGroup configGroup = kdeglobalsConfig->group(QStringLiteral("KDE")); | ||
73 | bool kdeConfigValue = configGroup.readEntry(QStringLiteral("ShowIconsOnPushButtons"), true); | 66 | bool kdeConfigValue = configGroup.readEntry(QStringLiteral("ShowIconsOnPushButtons"), true); | ||
74 | 67 | | |||
75 | if (kdeConfigValue) { | 68 | if (kdeConfigValue) { | ||
76 | return QStringLiteral("1"); | 69 | return QStringLiteral("1"); | ||
77 | } else { | 70 | } else { | ||
78 | return QStringLiteral("0"); | 71 | return QStringLiteral("0"); | ||
79 | } | 72 | } | ||
80 | } | 73 | } | ||
81 | 74 | | |||
82 | QString ConfigValueProvider::iconsInMenus() const | 75 | QString ConfigValueProvider::iconsInMenus() const | ||
83 | { | 76 | { | ||
84 | kdeglobalsConfig->reparseConfiguration(); | | |||
85 | KConfigGroup configGroup = kdeglobalsConfig->group(QStringLiteral("KDE")); | 77 | KConfigGroup configGroup = kdeglobalsConfig->group(QStringLiteral("KDE")); | ||
86 | bool kdeConfigValue = configGroup.readEntry(QStringLiteral("ShowIconsInMenuItems"), true); | 78 | bool kdeConfigValue = configGroup.readEntry(QStringLiteral("ShowIconsInMenuItems"), true); | ||
87 | 79 | | |||
88 | if (kdeConfigValue) { | 80 | if (kdeConfigValue) { | ||
89 | return QStringLiteral("1"); | 81 | return QStringLiteral("1"); | ||
90 | } else { | 82 | } else { | ||
91 | return QStringLiteral("0"); | 83 | return QStringLiteral("0"); | ||
92 | } | 84 | } | ||
93 | } | 85 | } | ||
94 | 86 | | |||
95 | QString ConfigValueProvider::toolbarStyle(ConfigValueProvider::ToolbarStyleNotation notation) const | 87 | QString ConfigValueProvider::toolbarStyle(ConfigValueProvider::ToolbarStyleNotation notation) const | ||
96 | { | 88 | { | ||
97 | kdeglobalsConfig->reparseConfiguration(); | | |||
98 | KConfigGroup configGroup = kdeglobalsConfig->group(QStringLiteral("Toolbar style")); | 89 | KConfigGroup configGroup = kdeglobalsConfig->group(QStringLiteral("Toolbar style")); | ||
99 | QString kdeConfigValue = configGroup.readEntry(QStringLiteral("ToolButtonStyle"), "TextBesideIcon"); | 90 | QString kdeConfigValue = configGroup.readEntry(QStringLiteral("ToolButtonStyle"), "TextBesideIcon"); | ||
100 | return toolbarStyleInDesiredNotation(kdeConfigValue, notation); | 91 | return toolbarStyleInDesiredNotation(kdeConfigValue, notation); | ||
101 | } | 92 | } | ||
102 | 93 | | |||
103 | QString ConfigValueProvider::scrollbarBehavior() const | 94 | QString ConfigValueProvider::scrollbarBehavior() const | ||
104 | { | 95 | { | ||
105 | kdeglobalsConfig->reparseConfiguration(); | | |||
106 | KConfigGroup configGroup = kdeglobalsConfig->group(QStringLiteral("KDE")); | 96 | KConfigGroup configGroup = kdeglobalsConfig->group(QStringLiteral("KDE")); | ||
107 | bool kdeConfigValue = configGroup.readEntry(QStringLiteral("ScrollbarLeftClickNavigatesByPage"), true); | 97 | bool kdeConfigValue = configGroup.readEntry(QStringLiteral("ScrollbarLeftClickNavigatesByPage"), true); | ||
108 | if (kdeConfigValue) { // GTK setting is inverted | 98 | if (kdeConfigValue) { // GTK setting is inverted | ||
109 | return QStringLiteral("0"); | 99 | return QStringLiteral("0"); | ||
110 | } else { | 100 | } else { | ||
111 | return QStringLiteral("1"); | 101 | return QStringLiteral("1"); | ||
112 | } | 102 | } | ||
113 | } | 103 | } | ||
114 | 104 | | |||
115 | QString ConfigValueProvider::preferDarkTheme() const | 105 | QString ConfigValueProvider::preferDarkTheme() const | ||
116 | { | 106 | { | ||
117 | kdeglobalsConfig->reparseConfiguration(); | | |||
118 | KConfigGroup colorsConfigGroup = kdeglobalsConfig->group(QStringLiteral("Colors:Window")); | 107 | KConfigGroup colorsConfigGroup = kdeglobalsConfig->group(QStringLiteral("Colors:Window")); | ||
119 | QColor windowBackgroundColor = colorsConfigGroup.readEntry(QStringLiteral("BackgroundNormal"), QColor(239, 240, 241)); | 108 | QColor windowBackgroundColor = colorsConfigGroup.readEntry(QStringLiteral("BackgroundNormal"), QColor(239, 240, 241)); | ||
120 | const int windowBackgroundGray = qGray(windowBackgroundColor.rgb()); | 109 | const int windowBackgroundGray = qGray(windowBackgroundColor.rgb()); | ||
121 | 110 | | |||
122 | // We use heuristic to determine if current color scheme is dark or not | 111 | // We use heuristic to determine if current color scheme is dark or not | ||
123 | if (windowBackgroundGray >= 192) { | 112 | if (windowBackgroundGray >= 192) { | ||
124 | return QStringLiteral("0"); | 113 | return QStringLiteral("0"); | ||
125 | } else { | 114 | } else { | ||
126 | return QStringLiteral("1"); | 115 | return QStringLiteral("1"); | ||
127 | } | 116 | } | ||
128 | } | 117 | } | ||
129 | 118 | | |||
130 | QString ConfigValueProvider::windowDecorationsButtonsOrder() const | 119 | QString ConfigValueProvider::windowDecorationsButtonsOrder() const | ||
131 | { | 120 | { | ||
132 | kwinConfig->reparseConfiguration(); | | |||
133 | KConfigGroup configGroup = kwinConfig->group(QStringLiteral("org.kde.kdecoration2")); | 121 | KConfigGroup configGroup = kwinConfig->group(QStringLiteral("org.kde.kdecoration2")); | ||
134 | QString buttonsOnLeftKdeConfigValue = configGroup.readEntry(QStringLiteral("ButtonsOnLeft"), "MS"); | 122 | QString buttonsOnLeftKdeConfigValue = configGroup.readEntry(QStringLiteral("ButtonsOnLeft"), "MS"); | ||
135 | QString buttonsOnRightKdeConfigValue = configGroup.readEntry(QStringLiteral("ButtonsOnRight"), "HIAX"); | 123 | QString buttonsOnRightKdeConfigValue = configGroup.readEntry(QStringLiteral("ButtonsOnRight"), "HIAX"); | ||
136 | 124 | | |||
137 | QString buttonsOnLeftInGtkNotation = windowDecorationButtonsOrderInGtkNotation(buttonsOnLeftKdeConfigValue); | 125 | QString buttonsOnLeftInGtkNotation = windowDecorationButtonsOrderInGtkNotation(buttonsOnLeftKdeConfigValue); | ||
138 | QString buttonsOnRightInGtkNotation = windowDecorationButtonsOrderInGtkNotation(buttonsOnRightKdeConfigValue); | 126 | QString buttonsOnRightInGtkNotation = windowDecorationButtonsOrderInGtkNotation(buttonsOnRightKdeConfigValue); | ||
139 | 127 | | |||
140 | return buttonsOnLeftInGtkNotation + QStringLiteral(":") + buttonsOnRightInGtkNotation; | 128 | return buttonsOnLeftInGtkNotation + QStringLiteral(":") + buttonsOnRightInGtkNotation; | ||
▲ Show 20 Lines • Show All 72 Lines • Show Last 20 Lines |