Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QGtk3Storage Class Reference

#include <qgtk3storage_p.h>

+ Collaboration diagram for QGtk3Storage:

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, SourceBrushMap
 
typedef QFlatMap< QPlatformTheme::Palette, BrushMapPaletteMap
 

Public Member Functions

 QGtk3Storage ()
 
const QPalettepalette (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 QFontfont (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.
 

Detailed Description

Definition at line 33 of file qgtk3storage_p.h.

Member Typedef Documentation

◆ BrushMap

Definition at line 188 of file qgtk3storage_p.h.

◆ PaletteMap

Member Enumeration Documentation

◆ SourceType

enum class QGtk3Storage::SourceType
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 40 of file qgtk3storage_p.h.

Constructor & Destructor Documentation

◆ QGtk3Storage()

QT_BEGIN_NAMESPACE QGtk3Storage::QGtk3Storage ( )

Definition at line 21 of file qgtk3storage.cpp.

References populateMap().

+ Here is the call graph for this function:

Member Function Documentation

◆ colorScheme()

Qt::ColorScheme QGtk3Storage::colorScheme ( ) const
inline

Definition at line 196 of file qgtk3storage_p.h.

Referenced by palette().

+ Here is the caller graph for this function:

◆ fileIcon()

QIcon QGtk3Storage::fileIcon ( const QFileInfo & fileInfo) const

Returns a GTK styled file icon corresponding to.

Parameters
fileInfo.

Definition at line 250 of file qgtk3storage.cpp.

◆ font()

const QFont * QGtk3Storage::font ( QPlatformTheme::Font type) const

Return a GTK styled font.

Returns a QFont of

Parameters
type,styledaccording to the current GTK theme.

Definition at line 213 of file qgtk3storage.cpp.

◆ handleThemeChange()

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 277 of file qgtk3storage.cpp.

References QWindowSystemInterface::handleThemeChange(), and populateMap().

+ Here is the call graph for this function:

◆ palette()

const QPalette * QGtk3Storage::palette ( QPlatformTheme::Palette type = QPlatformTheme::SystemPalette) const

Return a GTK styled QPalette.

Returns the pointer to a (cached) QPalette for

Parameters
type,withits brushes populated according to the current GTK theme.

Definition at line 153 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().

+ Here is the call graph for this function:

◆ populateMap()

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.

Note
If a Json file contains only fixed brushes (e.g. exported with {{QT_GUI_GTK_JSON_HARDCODED=true}}), no colors will be imported from GTK.

Definition at line 331 of file qgtk3storage.cpp.

References Qt::CaseInsensitive, Qt::Dark, qCDebug, qEnvironmentVariable(), qWarning, themeName(), and Qt::Unknown.

Referenced by QGtk3Storage(), and handleThemeChange().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ standardPalette()

QPalette QGtk3Storage::standardPalette ( )
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.

Note
This palette will be used as a default baseline for the system palette, which then will be used as a default baseline for any other palette type.

Definition at line 130 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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ standardPixmap()

QPixmap QGtk3Storage::standardPixmap ( QPlatformTheme::StandardPixmap standardPixmap,
const QSizeF & size ) const

Return a GTK styled standard pixmap if available.

Returns a pixmap specified by

Parameters
standardPixmapand
size.Returns an empty pixmap if GTK doesn't support the requested one.

Definition at line 229 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().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ themeName()

const QString QGtk3Storage::themeName ( ) const
inline

Definition at line 198 of file qgtk3storage_p.h.

Referenced by palette(), and populateMap().

+ Here is the caller graph for this function:

The documentation for this class was generated from the following files: