Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qgtk3storage.cpp
Go to the documentation of this file.
1// Copyright (C) 2022 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5//
6// W A R N I N G
7// -------------
8//
9// This file is not part of the Qt API. It exists purely as an
10// implementation detail. This header file may change from version to
11// version without notice, or even be removed.
12//
13// We mean it.
14//
15
16#include "qgtk3json_p.h"
17#include "qgtk3storage_p.h"
18#include <qpa/qwindowsysteminterface.h>
19#if QT_CONFIG(dbus)
20# include <QtGui/private/qgnomeportalinterface_p.h>
21#endif
22
24
25QGtk3Storage::QGtk3Storage()
26{
27 m_interface.reset(new QGtk3Interface(this));
28#if QT_CONFIG(dbus)
29 m_portalInterface.reset(new QGnomePortalInterface);
30#endif
31 populateMap();
32}
33
35
36/*!
37 \internal
38 \enum QGtk3Storage::SourceType
39 \brief This enum represents the type of a color source.
40
41 \value Gtk Color is read from a GTK widget
42 \value Fixed A fixed brush is specified
43 \value Modified The color is a modification of another color (fixed or read from GTK)
44 \omitvalue Invalid
45 */
46
47/*!
48 \internal
49 \brief Find a brush from a source.
50
51 Returns a QBrush from a given \param source and a \param map of available brushes
52 to search from.
53
54 A null QBrush is returned, if no brush corresponding to the source has been found.
55 */
56QBrush QGtk3Storage::brush(const Source &source, const BrushMap &map) const
57{
58 switch (source.sourceType) {
59 case SourceType::Gtk:
60 return m_interface ? QBrush(m_interface->brush(source.gtk3.gtkWidgetType,
61 source.gtk3.source, source.gtk3.state))
62 : QBrush();
63
65 // don't loop through modified sources, break if modified source not found
66 Source recSource = brush(TargetBrush(source.rec.colorGroup, source.rec.colorRole,
67 source.rec.colorScheme), map);
68
69 if (!recSource.isValid() || (recSource.sourceType == SourceType::Modified))
70 return QBrush();
71
72 // Set brush and alter color
73 QBrush b = brush(recSource, map);
74 if (source.rec.width > 0 && source.rec.height > 0)
75 b.setTexture(QPixmap(source.rec.width, source.rec.height));
76 QColor c = b.color().lighter(source.rec.lighter);
77 c = QColor((c.red() + source.rec.deltaRed),
78 (c.green() + source.rec.deltaGreen),
79 (c.blue() + source.rec.deltaBlue));
80 b.setColor(c);
81 return b;
82 }
83
84 case SourceType::Mixed: {
85 // check the mixing source to be valid and be a Gtk source
86 constexpr auto check_source = [](const Source &source) -> bool
87 {
88 return source.isValid() && (source.sourceType == SourceType::Gtk);
89 };
90
91 const Source source1 = brush(TargetBrush(source.mix.sourceGroup,
92 source.mix.colorRole1), map);
93 if (!check_source(source1))
94 return QBrush();
95
96 const Source source2 = brush(TargetBrush(source.mix.sourceGroup,
97 source.mix.colorRole2), map);
98 if (!check_source(source2))
99 return QBrush();
100
101 const QBrush brush2 = brush(source2, map);
102 // the output brush is a copy of the brush from the first source
103 QBrush brush1 = brush(source1, map);
104 // only color is mixed
105 brush1.setColor(MixSources::mixColors(brush1.color(), brush2.color()));
106 return brush1;
107 }
108
110 return source.fix.fixedBrush;
111
113 return QBrush();
114 }
115
116 // needed because of the scope after recursive
117 Q_UNREACHABLE();
118}
119
120/*!
121 \internal
122 \brief Recurse to find a source brush for modification.
123
124 Returns the source specified by the target brush \param b in the \param map of brushes.
125 Takes dark/light/unknown into consideration.
126 Returns an empty brush if no suitable one can be found.
127 */
128QGtk3Storage::Source QGtk3Storage::brush(const TargetBrush &b, const BrushMap &map) const
129{
130#define FIND(brush) if (map.contains(brush))
131 return map.value(brush)
132
133 // Return exact match
134 FIND(b);
135
136 // unknown color scheme can find anything
137 if (b.colorScheme == Qt::ColorScheme::Unknown) {
138 FIND(TargetBrush(b, Qt::ColorScheme::Dark));
139 FIND(TargetBrush(b, Qt::ColorScheme::Light));
140 }
141
142 // Color group All can always be found
143 if (b.colorGroup != QPalette::All)
144 return brush(TargetBrush(QPalette::All, b.colorRole, b.colorScheme), map);
145
146 // Brush not found
147 return Source();
148#undef FIND
149}
150
151/*!
152 \internal
153 \brief Returns a simple, hard coded base palette.
154
155 Create a hard coded palette with default colors as a fallback for any color that can't be
156 obtained from GTK.
157
158 \note This palette will be used as a default baseline for the system palette, which then
159 will be used as a default baseline for any other palette type.
160 */
161QPalette QGtk3Storage::standardPalette()
162{
163 QColor backgroundColor(0xd4, 0xd0, 0xc8);
164 QColor lightColor(backgroundColor.lighter());
165 QColor darkColor(backgroundColor.darker());
166 const QBrush darkBrush(darkColor);
167 QColor midColor(Qt::gray);
168 QPalette palette(Qt::black, backgroundColor, lightColor, darkColor,
169 midColor, Qt::black, Qt::white);
170 palette.setBrush(QPalette::Disabled, QPalette::WindowText, darkBrush);
171 palette.setBrush(QPalette::Disabled, QPalette::Text, darkBrush);
172 palette.setBrush(QPalette::Disabled, QPalette::ButtonText, darkBrush);
173 palette.setBrush(QPalette::Disabled, QPalette::Base, QBrush(backgroundColor));
174 return palette;
175}
176
177/*!
178 \internal
179 \brief Return a GTK styled QPalette.
180
181 Returns the pointer to a (cached) QPalette for \param type, with its brushes
182 populated according to the current GTK theme.
183 */
184const QPalette *QGtk3Storage::palette(QPlatformTheme::Palette type) const
185{
186 if (type >= QPlatformTheme::NPalettes)
187 return nullptr;
188
189 if (m_paletteCache[type].has_value()) {
190 qCDebug(lcQGtk3Interface) << "Returning palette from cache:"
191 << QGtk3Json::fromPalette(type);
192
193 return &m_paletteCache[type].value();
194 }
195
196 // Read system palette as a baseline first
197 if (!m_paletteCache[QPlatformTheme::SystemPalette].has_value() && type != QPlatformTheme::SystemPalette)
198 palette();
199
200 // Fall back to system palette for unknown types
201 if (!m_palettes.contains(type) && type != QPlatformTheme::SystemPalette) {
202 qCDebug(lcQGtk3Interface) << "Returning system palette for unknown type"
203 << QGtk3Json::fromPalette(type);
204 return palette();
205 }
206
207 BrushMap brushes = m_palettes.value(type);
208
209 // Standard palette is base for system palette. System palette is base for all others.
210 QPalette p = QPalette( type == QPlatformTheme::SystemPalette ? standardPalette()
211 : m_paletteCache[QPlatformTheme::SystemPalette].value());
212
213 qCDebug(lcQGtk3Interface) << "Creating palette:" << QGtk3Json::fromPalette(type);
214 for (auto i = brushes.begin(); i != brushes.end(); ++i) {
215 Source source = i.value();
216
217 // Brush is set if
218 // - theme and source color scheme match
219 // - or either of them is unknown
220 const auto appSource = i.key().colorScheme;
221 const auto appTheme = colorScheme();
222 const bool setBrush = (appSource == appTheme) ||
223 (appSource == Qt::ColorScheme::Unknown) ||
224 (appTheme == Qt::ColorScheme::Unknown);
225
226 if (setBrush) {
227 p.setBrush(i.key().colorGroup, i.key().colorRole, brush(source, brushes));
228 }
229 }
230
231 m_paletteCache[type].emplace(p);
232 if (type == QPlatformTheme::SystemPalette)
233 qCDebug(lcQGtk3Interface) << "System Palette defined" << themeName() << colorScheme() << p;
234
235 return &m_paletteCache[type].value();
236}
237
238/*!
239 \internal
240 \brief Return a GTK styled font.
241
242 Returns a QFont of \param type, styled according to the current GTK theme.
243*/
244const QFont *QGtk3Storage::font(QPlatformTheme::Font type) const
245{
246 if (m_fontCache[type].has_value())
247 return &m_fontCache[type].value();
248
249 m_fontCache[type].emplace(m_interface->font(type));
250 return &m_fontCache[type].value();
251}
252
253/*!
254 \internal
255 \brief Return a GTK styled standard pixmap if available.
256
257 Returns a pixmap specified by \param standardPixmap and \param size.
258 Returns an empty pixmap if GTK doesn't support the requested one.
259 */
260QPixmap QGtk3Storage::standardPixmap(QPlatformTheme::StandardPixmap standardPixmap,
261 const QSizeF &size) const
262{
263 if (m_pixmapCache.contains(standardPixmap))
264 return QPixmap::fromImage(m_pixmapCache.object(standardPixmap)->scaled(size.toSize()));
265
266 if (!m_interface)
267 return QPixmap();
268
269 QImage image = m_interface->standardPixmap(standardPixmap);
270 if (image.isNull())
271 return QPixmap();
272
273 m_pixmapCache.insert(standardPixmap, new QImage(image));
274 return QPixmap::fromImage(image.scaled(size.toSize()));
275}
276
277/*!
278 \internal
279 \brief Returns a GTK styled file icon corresponding to \param fileInfo.
280 */
281QIcon QGtk3Storage::fileIcon(const QFileInfo &fileInfo) const
282{
283 return m_interface ? m_interface->fileIcon(fileInfo) : QIcon();
284}
285
286/*!
287 \internal
288 \brief Clears all caches.
289 */
290void QGtk3Storage::clear()
291{
292 m_colorScheme = Qt::ColorScheme::Unknown;
293 m_palettes.clear();
294 for (auto &cache : m_paletteCache)
295 cache.reset();
296
297 for (auto &cache : m_fontCache)
298 cache.reset();
299}
300
301/*!
302 \internal
303 \brief Handles a theme change at runtime.
304
305 Clear all caches, re-populate with current GTK theme and notify the window system interface.
306 This method is a callback for the theme change signal sent from GTK.
307 */
309{
311 QWindowSystemInterface::handleThemeChange();
312}
313
314/*!
315 \internal
316 \brief Populates a map with information about how to locate colors in GTK.
317
318 This method creates a data structure to locate color information for each brush of a QPalette
319 within GTK. The structure can hold mapping information for each QPlatformTheme::Palette
320 enum value. If no specific mapping is stored for an enum value, the system palette is returned
321 instead of a specific one. If no mapping is stored for the system palette, it will fall back to
322 QGtk3Storage::standardPalette.
323
324 The method will populate the data structure with a standard mapping, covering the following
325 palette types:
326 \list
327 \li QPlatformTheme::SystemPalette
328 \li QPlatformTheme::CheckBoxPalette
329 \li QPlatformTheme::RadioButtonPalette
330 \li QPlatformTheme::ComboBoxPalette
331 \li QPlatformTheme::GroupBoxPalette
332 \li QPlatformTheme::MenuPalette
333 \li QPlatformTheme::TextLineEditPalette
334 \endlist
335
336 The method will check the environment variable {{QT_GUI_GTK_JSON_SAVE}}. If it points to a
337 valid path with write access, it will write the standard mapping into a Json file.
338 That Json file can be modified and/or extended.
339 The Json syntax is
340 - "QGtk3Palettes" (top level value)
341 - QPlatformTheme::Palette
342 - QPalette::ColorRole
343 - Qt::ColorScheme
344 - Qt::ColorGroup
345 - Source data
346 - Source Type
347 - [source data]
348
349 If the environment variable {{QT_GUI_GTK_JSON_HARDCODED}} contains the keyword \c true,
350 all sources are converted to fixed sources. In that case, they contain the hard coded HexRGBA
351 values read from GTK.
352
353 The method will also check the environment variable {{QT_GUI_GTK_JSON}}. If it points to a valid
354 Json file with read access, it will be parsed instead of creating a standard mapping.
355 Parsing errors will be printed out with qCInfo if the logging category {{qt.qpa.gtk}} is activated.
356 In case of a parsing error, the method will fall back to creating a standard mapping.
357
358 \note
359 If a Json file contains only fixed brushes (e.g. exported with {{QT_GUI_GTK_JSON_HARDCODED=true}}),
360 no colors will be imported from GTK.
361 */
363{
364 static QString m_themeName;
365
366 // Distiguish initialization, theme change or call without theme change
367 Qt::ColorScheme newColorScheme = Qt::ColorScheme::Unknown;
368 const QString newThemeName = themeName();
369
370#if QT_CONFIG(dbus)
371 // Prefer color scheme we get from xdg-desktop-portal as this is what GNOME
372 // relies on these days
373 newColorScheme = m_portalInterface->colorScheme();
374#endif
375
376 if (newColorScheme == Qt::ColorScheme::Unknown) {
377 // Derive color scheme from theme name
378 newColorScheme = newThemeName.contains("dark"_L1, Qt::CaseInsensitive)
379 ? Qt::ColorScheme::Dark : m_interface->colorSchemeByColors();
380 }
381
382 if (m_themeName == newThemeName && m_colorScheme == newColorScheme)
383 return;
384
385 clear();
386
387 if (m_themeName.isEmpty()) {
388 qCDebug(lcQGtk3Interface) << "GTK theme initialized:" << newThemeName << newColorScheme;
389 } else {
390 qCDebug(lcQGtk3Interface) << "GTK theme changed to:" << newThemeName << newColorScheme;
391 }
392 m_colorScheme = newColorScheme;
393 m_themeName = newThemeName;
394
395 // create standard mapping or load from Json file?
396 const QString jsonInput = qEnvironmentVariable("QT_GUI_GTK_JSON");
397 if (!jsonInput.isEmpty()) {
398 if (load(jsonInput)) {
399 return;
400 } else {
401 qWarning() << "Falling back to standard GTK mapping.";
402 }
403 }
404
405 createMapping();
406
407 const QString jsonOutput = qEnvironmentVariable("QT_GUI_GTK_JSON_SAVE");
408 if (!jsonOutput.isEmpty() && !save(jsonOutput))
409 qWarning() << "File" << jsonOutput << "could not be saved.\n";
410}
411
412/*!
413 \internal
414 \brief Return a palette map for saving.
415
416 This method returns the existing palette map, if the environment variable
417 {{QT_GUI_GTK_JSON_HARDCODED}} is not set or does not contain the keyword \c true.
418 If it contains the keyword \c true, it returns a palette map with all brush
419 sources converted to fixed sources.
420 */
421const QGtk3Storage::PaletteMap QGtk3Storage::savePalettes() const
422{
423 const QString hard = qEnvironmentVariable("QT_GUI_GTK_JSON_HARDCODED");
424 if (!hard.contains("true"_L1, Qt::CaseInsensitive))
425 return m_palettes;
426
427 // Json output is supposed to be readable without GTK connection
428 // convert palette map into hard coded brushes
429 PaletteMap map = m_palettes;
430 for (auto paletteIterator = map.begin(); paletteIterator != map.end();
431 ++paletteIterator) {
432 QGtk3Storage::BrushMap &bm = paletteIterator.value();
433 for (auto brushIterator = bm.begin(); brushIterator != bm.end();
434 ++brushIterator) {
435 QGtk3Storage::Source &s = brushIterator.value();
436 switch (s.sourceType) {
437
438 // Read the brush and convert it into a fixed brush
439 case SourceType::Gtk: {
440 const QBrush fixedBrush = brush(s, bm);
441 s.fix.fixedBrush = fixedBrush;
443 }
444 break;
449 break;
450 }
451 }
452 }
453 return map;
454}
455
456/*!
457 \internal
458 \brief Saves current palette mapping to a \param filename with Json format \param f.
459
460 Saves the current palette mapping into a QJson file,
461 taking {{QT_GUI_GTK_JSON_HARDCODED}} into consideration.
462 Returns \c true if saving was successful and \c false otherwise.
463 */
464bool QGtk3Storage::save(const QString &filename, QJsonDocument::JsonFormat f) const
465{
466 return QGtk3Json::save(savePalettes(), filename, f);
467}
468
469/*!
470 \internal
471 \brief Returns a QJsonDocument with current palette mapping.
472
473 Saves the current palette mapping into a QJsonDocument,
474 taking {{QT_GUI_GTK_JSON_HARDCODED}} into consideration.
475 Returns \c true if saving was successful and \c false otherwise.
476 */
477QJsonDocument QGtk3Storage::save() const
478{
479 return QGtk3Json::save(savePalettes());
480}
481
482/*!
483 \internal
484 \brief Loads palette mapping from Json file \param filename.
485
486 Returns \c true if the file was successfully parsed and \c false otherwise.
487 */
488bool QGtk3Storage::load(const QString &filename)
489{
490 return QGtk3Json::load(m_palettes, filename);
491}
492
493/*!
494 \internal
495 \brief Creates a standard palette mapping.
496
497 The method creates a hard coded standard mapping, used if no external Json file
498 containing a valid mapping has been specified in the environment variable {{QT_GUI_GTK_JSON}}.
499 */
500void QGtk3Storage::createMapping()
501{
502 // Hard code standard mapping
503 BrushMap map;
504 Source source;
505
506 // Define a GTK source
507#define GTK(wtype, colorSource, state)
508 source = Source(QGtk3Interface::QGtkWidget::gtk_ ##wtype,
509 QGtk3Interface::QGtkColorSource::colorSource, GTK_STATE_FLAG_ ##state)
510
511 // Define a modified source
512#define LIGHTER(group, role, lighter)
513 source = Source(QPalette::group, QPalette::role,
514 Qt::ColorScheme::Unknown, lighter)
515#define MODIFY(group, role, red, green, blue)
516 source = Source(QPalette::group, QPalette::role,
517 Qt::ColorScheme::Unknown, red, green, blue)
518
519 // Define fixed source
520#define FIX(color) source = FixedSource(color);
521
522 // Add the source to a target brush
523 // Use default Qt::ColorScheme::Unknown, if no color scheme was specified
524#define ADD_2(group, role) map.insert(TargetBrush(QPalette::group, QPalette::role), source);
525#define ADD_3(group, role, app) map.insert(TargetBrush(QPalette::group, QPalette::role,
526 Qt::ColorScheme::app), source);
527#define ADD_X(x, group, role, app, FUNC, ...) FUNC
528#define ADD(...) ADD_X(,##__VA_ARGS__, ADD_3(__VA_ARGS__), ADD_2(__VA_ARGS__))
529 // Save target brushes to a palette type
530#define SAVE(palette) m_palettes.insert(QPlatformTheme::palette, map)
531 // Clear brushes to start next palette
532#define CLEAR map.clear()
533
534 /*
535 Macro usage:
536
537 1. Define a source
538 GTK(QGtkWidget, QGtkColorSource, GTK_STATE_FLAG)
539 Fetch the color from a GtkWidget, related to a source and a state.
540
541 LIGHTER(ColorGroup, ColorROle, lighter)
542 Use a color of the same QPalette related to ColorGroup and ColorRole.
543 Make the color lighter (if lighter >100) or darker (if lighter < 100)
544
545 MODIFY(ColorGroup, ColorRole, red, green, blue)
546 Use a color of the same QPalette related to ColorGroup and ColorRole.
547 Modify it by adding red, green, blue.
548
549 FIX(const QBrush &)
550 Use a fixed brush without querying GTK
551
552 2. Define the target
553 Use ADD(ColorGroup, ColorRole) to use the defined source for the
554 color group / role in the current palette.
555
556 Use ADD(ColorGroup, ColorRole, ColorScheme) to use the defined source
557 only for a specific color scheme
558
559 3. Save mapping
560 Save the defined mappings for a specific palette.
561 If a mapping entry does not cover all color groups and roles of a palette,
562 the system palette will be used for the remaining values.
563 If the system palette does not have all combination of color groups and roles,
564 the remaining ones will be populated by a hard coded fusion-style like palette.
565
566 4. Clear mapping
567 Use CLEAR to clear the mapping and begin a new one.
568 */
569
570
571 // System palette
572 {
573 // background color and calculate derivates
574 GTK(Default, Background, INSENSITIVE);
575 ADD(All, Window);
576 ADD(All, Button);
577 ADD(All, Base);
578 LIGHTER(Normal, Window, 125);
579 ADD(Normal, Light);
580 ADD(Inactive, Light);
581 LIGHTER(Normal, Window, 70);
582 ADD(Normal, Shadow);
583 LIGHTER(Normal, Window, 80);
584 ADD(Normal, Dark);
585 ADD(Inactive, Dark)
586
587 GTK(button, Foreground, ACTIVE);
588 ADD(Inactive, WindowText);
589
590 auto ADD_MIX = [&map](QPalette::ColorGroup targetGroup,
591 QPalette::ColorRole targetRole,
592 QPalette::ColorGroup sourceGroup,
593 QPalette::ColorRole role1,
594 QPalette::ColorRole role2)
595 {
596 const Source source{sourceGroup, role1, role2};
597 map.insert(TargetBrush(targetGroup, targetRole), source);
598 };
599 ADD_MIX(QPalette::Disabled, QPalette::Text,
600 QPalette::Normal, QPalette::Base, QPalette::Text);
601 ADD_MIX(QPalette::Disabled, QPalette::WindowText,
602 QPalette::Normal, QPalette::Window, QPalette::WindowText);
603 ADD_MIX(QPalette::Disabled, QPalette::ButtonText,
604 QPalette::Normal, QPalette::Button, QPalette::ButtonText);
605
606 GTK(button, Text, NORMAL);
607 ADD(Inactive, ButtonText);
608
609 // special background colors
610 GTK(Default, Background, SELECTED);
611 ADD(Disabled, Highlight);
612 ADD(Normal, Highlight);
613 ADD(Inactive, Highlight);
614
615 GTK(entry, Foreground, SELECTED);
616 ADD(Normal, HighlightedText);
617 ADD(Inactive, HighlightedText);
618
619 // text color and friends
620 GTK(entry, Text, NORMAL);
621 ADD(Normal, ButtonText);
622 ADD(Normal, WindowText);
623 ADD(Disabled, HighlightedText);
624
625 GTK(Default, Text, NORMAL);
626 ADD(Normal, Text);
627 ADD(Inactive, Text);
628 ADD(Normal, HighlightedText);
629 LIGHTER(Normal, Base, 93);
630 ADD(All, AlternateBase);
631
632 GTK(Default, Foreground, NORMAL);
633 MODIFY(Normal, Text, 100, 100, 100);
634 ADD(All, PlaceholderText, Light);
635 MODIFY(Normal, Text, -100, -100, -100);
636 ADD(All, PlaceholderText, Dark);
637
638 // Light, midlight, dark, mid, shadow colors
639 LIGHTER(Normal, Button, 125);
640 ADD(All, Light)
641 LIGHTER(Normal, Button, 113);
642 ADD(All, Midlight)
643 LIGHTER(Normal, Button, 113);
644 ADD(All, Mid)
645 LIGHTER(Normal, Button, 87);
646 ADD(All, Dark)
647 LIGHTER(Normal, Button, 5);
648 ADD(All, Shadow)
649
650 SAVE(SystemPalette);
651 CLEAR;
652 }
653
654 // Label and TabBar Palette
655 {
656 GTK(entry, Text, NORMAL);
657 ADD(Normal, WindowText);
658 ADD(Inactive, WindowText);
659
660 SAVE(LabelPalette);
661 SAVE(TabBarPalette);
662 CLEAR;
663 }
664
665 // Checkbox and RadioButton Palette
666 {
667 GTK(button, Text, ACTIVE);
668 ADD(Normal, Base, Dark);
669 ADD(Inactive, WindowText, Dark);
670
671 GTK(Default, Foreground, NORMAL);
672 ADD(All, Text);
673
674 GTK(Default, Background, NORMAL);
675 ADD(All, Base);
676
677 GTK(button, Text, NORMAL);
678 ADD(Normal, Base, Light);
679 ADD(Inactive, WindowText, Light);
680
681 SAVE(CheckBoxPalette);
682 SAVE(RadioButtonPalette);
683 CLEAR;
684 }
685
686 // ComboBox, GroupBox & Frame Palette
687 {
688 GTK(combo_box, Text, NORMAL);
689 ADD(Normal, ButtonText, Dark);
690 ADD(Normal, Text, Dark);
691 ADD(Inactive, WindowText, Dark);
692
693 GTK(combo_box, Text, ACTIVE);
694 ADD(Normal, ButtonText, Light);
695 ADD(Normal, Text, Light);
696 ADD(Inactive, WindowText, Light);
697
698 SAVE(ComboBoxPalette);
699 SAVE(GroupBoxPalette);
700 CLEAR;
701 }
702
703 // MenuBar Palette
704 {
705 GTK(Default, Text, ACTIVE);
706 ADD(Normal, ButtonText);
707 SAVE(MenuPalette);
708 CLEAR;
709 }
710
711 // LineEdit Palette
712 {
713 GTK(Default, Background, NORMAL);
714 ADD(All, Base);
715 SAVE(TextLineEditPalette);
716 CLEAR;
717 }
718
719#undef GTK
720#undef REC
721#undef FIX
722#undef ADD
723#undef ADD_2
724#undef ADD_3
725#undef ADD_X
726#undef SAVE
727#undef LOAD
728}
729
730QT_END_NAMESPACE
void handleThemeChange()
Handles a theme change at runtime.
const QPalette * palette(QPlatformTheme::Palette=QPlatformTheme::SystemPalette) const
Return a GTK styled QPalette.
QFlatMap< QPlatformTheme::Palette, BrushMap > PaletteMap
QFlatMap< TargetBrush, Source > BrushMap
QIcon fileIcon(const QFileInfo &fileInfo) const
Returns a GTK styled file icon corresponding to.
void populateMap()
Populates a map with information about how to locate colors in GTK.
SourceType
This enum represents the type of a color source.
const QFont * font(QPlatformTheme::Font type) const
Return a GTK styled font.
QPixmap standardPixmap(QPlatformTheme::StandardPixmap standardPixmap, const QSizeF &size) const
Return a GTK styled standard pixmap if available.
#define SAVE(src, state, prop, def)
#define FIND(brush)
#define GTK(wtype, colorSource, state)
#define CLEAR
#define ADD(...)
#define LIGHTER(group, role, lighter)
#define MODIFY(group, role, red, green, blue)