Changeset View
Changeset View
Standalone View
Standalone View
app/gvcore.cpp
Show First 20 Lines • Show All 126 Lines • ▼ Show 20 Line(s) | 115 | { | |||
---|---|---|---|---|---|
127 | mPalettes[GvCore::NormalViewPalette] = pal; | 127 | mPalettes[GvCore::NormalViewPalette] = pal; | ||
128 | 128 | | |||
129 | // Fullscreen | 129 | // Fullscreen | ||
130 | QString name = GwenviewConfig::fullScreenColorScheme(); | 130 | QString name = GwenviewConfig::fullScreenColorScheme(); | ||
131 | if (name.isEmpty()) { | 131 | if (name.isEmpty()) { | ||
132 | // Default color scheme | 132 | // Default color scheme | ||
133 | mFullScreenPaletteName = QStandardPaths::locate(QStandardPaths::AppDataLocation, "color-schemes/fullscreen.colors"); | 133 | mFullScreenPaletteName = QStandardPaths::locate(QStandardPaths::AppDataLocation, "color-schemes/fullscreen.colors"); | ||
134 | config = KSharedConfig::openConfig(mFullScreenPaletteName); | 134 | config = KSharedConfig::openConfig(mFullScreenPaletteName); | ||
135 | } else if (name.contains('/')) { | 135 | } else if (name.contains('/')) { | ||
136 | // Full path to a .colors file | 136 | // Full path to a .colors file | ||
137 | mFullScreenPaletteName = name; | 137 | mFullScreenPaletteName = name; | ||
138 | config = KSharedConfig::openConfig(mFullScreenPaletteName); | 138 | config = KSharedConfig::openConfig(mFullScreenPaletteName); | ||
rkflx: Did not test, but these lines probably refer to this [hidden config option](https://userbase. | |||||
You're right, we should only make changes if we're using the default fullscreen palette. huoni: You're right, we should only make changes if we're using the default fullscreen palette. | |||||
139 | } else { | 139 | } else { | ||
140 | // Standard KDE color scheme | 140 | // Standard KDE color scheme | ||
141 | mFullScreenPaletteName = QString("color-schemes/%1.colors").arg(name); | 141 | mFullScreenPaletteName = QString("color-schemes/%1.colors").arg(name); | ||
142 | config = KSharedConfig::openConfig(mFullScreenPaletteName, KConfig::FullConfig, QStandardPaths::AppDataLocation); | 142 | config = KSharedConfig::openConfig(mFullScreenPaletteName, KConfig::FullConfig, QStandardPaths::AppDataLocation); | ||
143 | } | 143 | } | ||
144 | mPalettes[GvCore::FullScreenPalette] = KColorScheme::createApplicationPalette(config); | 144 | mPalettes[GvCore::FullScreenPalette] = KColorScheme::createApplicationPalette(config); | ||
145 | 145 | | |||
146 | // If we are using the default palette, adjust it to match the system color scheme | ||||
147 | if (name.isEmpty()) { | ||||
148 | adjustDefaultFullScreenPalette(); | ||||
149 | } | ||||
150 | | ||||
151 | // FullScreenView has textured background | ||||
146 | pal = mPalettes[GvCore::FullScreenPalette]; | 152 | pal = mPalettes[GvCore::FullScreenPalette]; | ||
147 | QString path = QStandardPaths::locate(QStandardPaths::AppDataLocation, "images/background.png"); | 153 | QString path = QStandardPaths::locate(QStandardPaths::AppDataLocation, "images/background.png"); | ||
148 | QPixmap bgTexture(path); | 154 | QPixmap bgTexture(path); | ||
149 | pal.setBrush(QPalette::Base, bgTexture); | 155 | pal.setBrush(QPalette::Base, bgTexture); | ||
150 | mPalettes[GvCore::FullScreenViewPalette] = pal; | 156 | mPalettes[GvCore::FullScreenViewPalette] = pal; | ||
151 | } | 157 | } | ||
158 | | ||||
159 | void adjustDefaultFullScreenPalette() | ||||
rkflx: Great comments and formatting overall. Only a small typo: `Hightlight` | |||||
160 | { | ||||
161 | // The Fullscreen palette by default does not use the system color scheme, and therefore uses an 'accent' color | ||||
162 | // of blue. So for every color group/role combination that uses the accent color, we use a muted version of the | ||||
163 | // Normal palette. We also use the normal HighlightedText color so it properly contrasts with Highlight. | ||||
164 | const QPalette normalPal = mPalettes[GvCore::NormalPalette]; | ||||
165 | QPalette fullscreenPal = mPalettes[GvCore::FullScreenPalette]; | ||||
166 | | ||||
167 | // Colors from the normal palette (source of the system theme's accent color) | ||||
168 | const QColor normalToolTipBase = normalPal.color(QPalette::Normal, QPalette::ToolTipBase); | ||||
169 | const QColor normalToolTipText = normalPal.color(QPalette::Normal, QPalette::ToolTipText); | ||||
170 | const QColor normalHighlight = normalPal.color(QPalette::Normal, QPalette::Highlight); | ||||
171 | const QColor normalHighlightedText = normalPal.color(QPalette::Normal, QPalette::HighlightedText); | ||||
172 | const QColor normalLink = normalPal.color(QPalette::Normal, QPalette::Link); | ||||
173 | const QColor normalActiveToolTipBase = normalPal.color(QPalette::Active, QPalette::ToolTipBase); | ||||
174 | const QColor normalActiveToolTipText = normalPal.color(QPalette::Active, QPalette::ToolTipText); | ||||
175 | const QColor normalActiveHighlight = normalPal.color(QPalette::Active, QPalette::Highlight); | ||||
176 | const QColor normalActiveHighlightedText = normalPal.color(QPalette::Active, QPalette::HighlightedText); | ||||
rkflx: One more `Hightlight`. | |||||
177 | const QColor normalActiveLink = normalPal.color(QPalette::Active, QPalette::Link); | ||||
178 | const QColor normalDisabledToolTipBase = normalPal.color(QPalette::Disabled, QPalette::ToolTipBase); | ||||
179 | const QColor normalDisabledToolTipText = normalPal.color(QPalette::Disabled, QPalette::ToolTipText); | ||||
180 | // Note: Disabled Highlight missing as they do not use the accent color | ||||
181 | const QColor normalDisabledLink = normalPal.color(QPalette::Disabled, QPalette::Link); | ||||
182 | const QColor normalInactiveToolTipBase = normalPal.color(QPalette::Inactive, QPalette::ToolTipBase); | ||||
183 | const QColor normalInactiveToolTipText = normalPal.color(QPalette::Inactive, QPalette::ToolTipText); | ||||
184 | const QColor normalInactiveHighlight = normalPal.color(QPalette::Inactive, QPalette::Highlight); | ||||
185 | const QColor normalInactiveHighlightedText = normalPal.color(QPalette::Inactive, QPalette::HighlightedText); | ||||
186 | const QColor normalInactiveLink = normalPal.color(QPalette::Inactive, QPalette::Link); | ||||
187 | | ||||
188 | // Colors of the fullscreen palette which we will be modifying | ||||
189 | QColor fullScreenToolTipBase = fullscreenPal.color(QPalette::Normal, QPalette::ToolTipBase); | ||||
190 | QColor fullScreenToolTipText = fullscreenPal.color(QPalette::Normal, QPalette::ToolTipText); | ||||
191 | QColor fullScreenHighlight = fullscreenPal.color(QPalette::Normal, QPalette::Highlight); | ||||
192 | QColor fullScreenLink = fullscreenPal.color(QPalette::Normal, QPalette::Link); | ||||
193 | QColor fullScreenActiveToolTipBase = fullscreenPal.color(QPalette::Active, QPalette::ToolTipBase); | ||||
194 | QColor fullScreenActiveToolTipText = fullscreenPal.color(QPalette::Active, QPalette::ToolTipText); | ||||
195 | QColor fullScreenActiveHighlight = fullscreenPal.color(QPalette::Active, QPalette::Highlight); | ||||
196 | QColor fullScreenActiveLink = fullscreenPal.color(QPalette::Active, QPalette::Link); | ||||
197 | QColor fullScreenDisabledToolTipBase = fullscreenPal.color(QPalette::Disabled, QPalette::ToolTipBase); | ||||
198 | QColor fullScreenDisabledToolTipText = fullscreenPal.color(QPalette::Disabled, QPalette::ToolTipText); | ||||
199 | QColor fullScreenDisabledLink = fullscreenPal.color(QPalette::Disabled, QPalette::Link); | ||||
200 | QColor fullScreenInactiveToolTipBase = fullscreenPal.color(QPalette::Inactive, QPalette::ToolTipBase); | ||||
201 | QColor fullScreenInactiveToolTipText = fullscreenPal.color(QPalette::Inactive, QPalette::ToolTipText); | ||||
202 | QColor fullScreenInactiveHighlight = fullscreenPal.color(QPalette::Inactive, QPalette::Highlight); | ||||
203 | QColor fullScreenInactiveLink = fullscreenPal.color(QPalette::Inactive, QPalette::Link); | ||||
204 | | ||||
205 | // Adjust the value of the normal color so it's not too dark/bright, and apply to the respective fullscreen color | ||||
206 | fullScreenToolTipBase .setHsv(normalToolTipBase.hue(), normalToolTipBase.saturation(), (127 + 2 * normalToolTipBase.value()) / 3); | ||||
207 | fullScreenToolTipText .setHsv(normalToolTipText.hue(), normalToolTipText.saturation(), (127 + 2 * normalToolTipText.value()) / 3); | ||||
208 | fullScreenHighlight .setHsv(normalHighlight.hue(), normalHighlight.saturation(), (127 + 2 * normalHighlight.value()) / 3); | ||||
209 | fullScreenLink .setHsv(normalLink.hue(), normalLink.saturation(), (127 + 2 * normalLink.value()) / 3); | ||||
210 | fullScreenActiveToolTipBase .setHsv(normalActiveToolTipBase.hue(), normalActiveToolTipBase.saturation(), (127 + 2 * normalActiveToolTipBase.value()) / 3); | ||||
211 | fullScreenActiveToolTipText .setHsv(normalActiveToolTipText.hue(), normalActiveToolTipText.saturation(), (127 + 2 * normalActiveToolTipText.value()) / 3); | ||||
212 | fullScreenActiveHighlight .setHsv(normalActiveHighlight.hue(), normalActiveHighlight.saturation(), (127 + 2 * normalActiveHighlight.value()) / 3); | ||||
213 | fullScreenActiveLink .setHsv(normalActiveLink.hue(), normalActiveLink.saturation(), (127 + 2 * normalActiveLink.value()) / 3); | ||||
214 | fullScreenDisabledToolTipBase.setHsv(normalDisabledToolTipBase.hue(), normalDisabledToolTipBase.saturation(), (127 + 2 * normalDisabledToolTipBase.value()) / 3); | ||||
215 | fullScreenDisabledToolTipText.setHsv(normalDisabledToolTipText.hue(), normalDisabledToolTipText.saturation(), (127 + 2 * normalDisabledToolTipText.value()) / 3); | ||||
216 | fullScreenDisabledLink .setHsv(normalDisabledLink.hue(), normalDisabledLink.saturation(), (127 + 2 * normalDisabledLink.value()) / 3); | ||||
217 | fullScreenInactiveToolTipBase.setHsv(normalInactiveToolTipBase.hue(), normalInactiveToolTipBase.saturation(), (127 + 2 * normalInactiveToolTipBase.value()) / 3); | ||||
218 | fullScreenInactiveToolTipText.setHsv(normalInactiveToolTipText.hue(), normalInactiveToolTipText.saturation(), (127 + 2 * normalInactiveToolTipText.value()) / 3); | ||||
219 | fullScreenInactiveHighlight .setHsv(normalInactiveHighlight.hue(), normalInactiveHighlight.saturation(), (127 + 2 * normalInactiveHighlight.value()) / 3); | ||||
220 | fullScreenInactiveLink .setHsv(normalInactiveLink.hue(), normalInactiveLink.saturation(), (127 + 2 * normalInactiveLink.value()) / 3); | ||||
221 | | ||||
222 | // Apply the modified colors to the fullscreen palette | ||||
223 | fullscreenPal.setColor(QPalette::Normal, QPalette::ToolTipBase, fullScreenToolTipBase); | ||||
224 | fullscreenPal.setColor(QPalette::Normal, QPalette::ToolTipText, fullScreenToolTipText); | ||||
225 | fullscreenPal.setColor(QPalette::Normal, QPalette::Highlight, fullScreenHighlight); | ||||
226 | fullscreenPal.setColor(QPalette::Normal, QPalette::Link, fullScreenLink); | ||||
227 | fullscreenPal.setColor(QPalette::Active, QPalette::ToolTipBase, fullScreenActiveToolTipBase); | ||||
228 | fullscreenPal.setColor(QPalette::Active, QPalette::ToolTipText, fullScreenActiveToolTipText); | ||||
229 | fullscreenPal.setColor(QPalette::Active, QPalette::Highlight, fullScreenActiveHighlight); | ||||
230 | fullscreenPal.setColor(QPalette::Active, QPalette::Link, fullScreenActiveLink); | ||||
231 | fullscreenPal.setColor(QPalette::Disabled, QPalette::ToolTipBase, fullScreenDisabledToolTipBase); | ||||
232 | fullscreenPal.setColor(QPalette::Disabled, QPalette::ToolTipText, fullScreenDisabledToolTipText); | ||||
233 | fullscreenPal.setColor(QPalette::Disabled, QPalette::Link, fullScreenDisabledLink); | ||||
234 | fullscreenPal.setColor(QPalette::Inactive, QPalette::ToolTipBase, fullScreenInactiveToolTipBase); | ||||
235 | fullscreenPal.setColor(QPalette::Inactive, QPalette::ToolTipText, fullScreenInactiveToolTipText); | ||||
236 | fullscreenPal.setColor(QPalette::Inactive, QPalette::Highlight, fullScreenInactiveHighlight); | ||||
237 | fullscreenPal.setColor(QPalette::Inactive, QPalette::Link, fullScreenInactiveLink); | ||||
238 | | ||||
239 | // Since we use an adjusted version of the normal highlight color, we need to use the normal version of the | ||||
240 | // text color so it contrasts | ||||
241 | fullscreenPal.setColor(QPalette::Normal, QPalette::HighlightedText, normalHighlightedText); | ||||
242 | fullscreenPal.setColor(QPalette::Active, QPalette::HighlightedText, normalActiveHighlightedText); | ||||
243 | fullscreenPal.setColor(QPalette::Inactive, QPalette::HighlightedText, normalInactiveHighlightedText); | ||||
244 | | ||||
245 | mPalettes[GvCore::FullScreenPalette] = fullscreenPal; | ||||
246 | } | ||||
152 | }; | 247 | }; | ||
153 | 248 | | |||
154 | GvCore::GvCore(MainWindow* mainWindow, SortedDirModel* dirModel) | 249 | GvCore::GvCore(MainWindow* mainWindow, SortedDirModel* dirModel) | ||
155 | : QObject(mainWindow) | 250 | : QObject(mainWindow) | ||
156 | , d(new GvCorePrivate) | 251 | , d(new GvCorePrivate) | ||
157 | { | 252 | { | ||
158 | d->q = this; | 253 | d->q = this; | ||
159 | d->mMainWindow = mainWindow; | 254 | d->mMainWindow = mainWindow; | ||
▲ Show 20 Lines • Show All 228 Lines • Show Last 20 Lines |
Did not test, but these lines probably refer to this hidden config option. As far as I understand, you are now discarding all highlight related colours from these custom files?
Do you think we should only do what your patch title says if the hidden config option is not active? We could also remove this feature, but that might annoy some users and there's not really a need. Thoughts?