![]() |
Qt 6.x
The Qt SDK
|
#include <qgtk3storage_p.h>
Classes | |
struct | FixedSource |
struct | Gtk3Source |
struct | RecursiveSource |
struct | Source |
struct | TargetBrush |
Public Types | |
enum class | SourceType { Gtk , Fixed , Modified , Invalid } |
This enum represents the type of a color source. More... | |
typedef QFlatMap< TargetBrush, Source > | BrushMap |
typedef QFlatMap< QPlatformTheme::Palette, BrushMap > | PaletteMap |
Public Member Functions | |
QGtk3Storage () | |
const QPalette * | palette (QPlatformTheme::Palette=QPlatformTheme::SystemPalette) const |
Return a GTK styled QPalette. | |
QPixmap | standardPixmap (QPlatformTheme::StandardPixmap standardPixmap, const QSizeF &size) const |
Return a GTK styled standard pixmap if available. | |
Qt::ColorScheme | colorScheme () const |
const QString | themeName () const |
const QFont * | font (QPlatformTheme::Font type) const |
Return a GTK styled font. | |
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. | |
void | handleThemeChange () |
Handles a theme change at runtime. | |
Static Public Member Functions | |
static QPalette | standardPalette () |
Returns a simple, hard coded base palette. | |
Definition at line 30 of file qgtk3storage_p.h.
typedef QFlatMap<TargetBrush, Source> QGtk3Storage::BrushMap |
Definition at line 185 of file qgtk3storage_p.h.
Definition at line 188 of file qgtk3storage_p.h.
|
strong |
This enum represents the type of a color source.
\value Gtk Color is read from a GTK widget \value Fixed A fixed brush is specified \value Modified The color is a modification of another color (fixed or read from GTK) \omitvalue Invalid
Enumerator | |
---|---|
Gtk | |
Fixed | |
Modified | |
Invalid |
Definition at line 37 of file qgtk3storage_p.h.
QT_BEGIN_NAMESPACE QGtk3Storage::QGtk3Storage | ( | ) |
Definition at line 21 of file qgtk3storage.cpp.
References populateMap().
|
inline |
Definition at line 193 of file qgtk3storage_p.h.
Referenced by palette().
Returns a GTK styled file icon corresponding to.
fileInfo. |
Definition at line 247 of file qgtk3storage.cpp.
const QFont * QGtk3Storage::font | ( | QPlatformTheme::Font | type | ) | const |
Return a GTK styled font.
Returns a QFont of
type,styled | according to the current GTK theme. |
Definition at line 210 of file qgtk3storage.cpp.
void QGtk3Storage::handleThemeChange | ( | ) |
Handles a theme change at runtime.
Clear all caches, re-populate with current GTK theme and notify the window system interface. This method is a callback for the theme change signal sent from GTK.
Definition at line 274 of file qgtk3storage.cpp.
References QWindowSystemInterface::handleThemeChange(), and populateMap().
Referenced by QGtk3Interface::QGtk3Interface().
const QPalette * QGtk3Storage::palette | ( | QPlatformTheme::Palette | type = QPlatformTheme::SystemPalette | ) | const |
Return a GTK styled QPalette.
Returns the pointer to a (cached) QPalette for
type,with | its brushes populated according to the current GTK theme. |
Definition at line 150 of file qgtk3storage.cpp.
References QFlatMap< Key, T, Compare, KeyContainer, MappedContainer >::begin(), colorScheme(), QFlatMap< Key, T, Compare, KeyContainer, MappedContainer >::contains(), QFlatMap< Key, T, Compare, KeyContainer, MappedContainer >::end(), QGtk3Json::fromPalette(), i, QPlatformTheme::NPalettes, palette, qCDebug, standardPalette(), QPlatformTheme::SystemPalette, themeName(), Qt::Unknown, and QFlatMap< Key, T, Compare, KeyContainer, MappedContainer >::value().
void QGtk3Storage::populateMap | ( | ) |
Populates a map with information about how to locate colors in GTK.
This method creates a data structure to locate color information for each brush of a QPalette within GTK. The structure can hold mapping information for each QPlatformTheme::Palette enum value. If no specific mapping is stored for an enum value, the system palette is returned instead of a specific one. If no mapping is stored for the system palette, it will fall back to QGtk3Storage::standardPalette.
The method will populate the data structure with a standard mapping, covering the following palette types: \list
The method will check the environment variable {{QT_GUI_GTK_JSON_SAVE}}. If it points to a valid path with write access, it will write the standard mapping into a Json file. That Json file can be modified and/or extended. The Json syntax is
If the environment variable {{QT_GUI_GTK_JSON_HARDCODED}} contains the keyword true
, all sources are converted to fixed sources. In that case, they contain the hard coded HexRGBA values read from GTK.
The method will also check the environment variable {{QT_GUI_GTK_JSON}}. If it points to a valid Json file with read access, it will be parsed instead of creating a standard mapping. Parsing errors will be printed out with qCInfo if the logging category {{qt.qpa.gtk}} is activated. In case of a parsing error, the method will fall back to creating a standard mapping.
Definition at line 329 of file qgtk3storage.cpp.
References Qt::CaseInsensitive, QString::contains(), Qt::Dark, QString::isEmpty(), qCDebug, qEnvironmentVariable(), qWarning, and themeName().
Referenced by QGtk3Storage(), and handleThemeChange().
|
static |
Returns a simple, hard coded base palette.
Create a hard coded palette with default colors as a fallback for any color that can't be obtained from GTK.
Definition at line 127 of file qgtk3storage.cpp.
References QPalette::Base, Qt::black, QPalette::ButtonText, QColor::darker(), QPalette::Disabled, Qt::gray, QColor::lighter(), palette, QPalette::Text, Qt::white, and QPalette::WindowText.
Referenced by palette().
QPixmap QGtk3Storage::standardPixmap | ( | QPlatformTheme::StandardPixmap | standardPixmap, |
const QSizeF & | size | ||
) | const |
Return a GTK styled standard pixmap if available.
Returns a pixmap specified by
standardPixmap | and |
size. | Returns an empty pixmap if GTK doesn't support the requested one. |
Definition at line 226 of file qgtk3storage.cpp.
References QCache< Key, T >::contains(), QPixmap::fromImage(), QCache< Key, T >::insert(), QCache< Key, T >::object(), QImage::scaled(), and standardPixmap().
Referenced by standardPixmap().
|
inline |
Definition at line 195 of file qgtk3storage_p.h.
Referenced by palette(), and populateMap().