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
QGtk3Interface Class Reference

The QGtk3Interface class centralizes communication with the GTK3 library. More...

#include <qgtk3interface_p.h>

+ Collaboration diagram for QGtk3Interface:

Public Types

enum class  QGtkWidget {
  gtk_menu_bar , gtk_menu , gtk_button , gtk_button_box ,
  gtk_check_button , gtk_radio_button , gtk_frame , gtk_statusbar ,
  gtk_entry , gtk_popup , gtk_notebook , gtk_toolbar ,
  gtk_tree_view , gtk_combo_box , gtk_combo_box_text , gtk_progress_bar ,
  gtk_fixed , gtk_separator_menu_item , gtk_Default , gtk_offscreen_window
}
 
enum class  QGtkColorSource {
  Foreground , Background , Text , Base ,
  Border
}
 
enum class  QGtkColorDefault { Foreground , Background , Border }
 

Public Member Functions

 QGtk3Interface (QGtk3Storage *)
 
 ~QGtk3Interface ()
 
QBrush brush (QGtkWidget wtype, QGtkColorSource source, GtkStateFlags state) const
 Create a QBrush from a GTK widget.
 
QImage standardPixmap (QPlatformTheme::StandardPixmap standardPixmap) const
 Returns a QImage corresponding to.
 
QFont font (QPlatformTheme::Font type) const
 Return a GTK styled font.
 
QIcon fileIcon (const QFileInfo &fileInfo) const
 Returns a GTK styled file icon for.
 
QString themeName () const
 Returns the name of the current GTK theme.
 
Qt::ColorScheme colorSchemeByColors () const
 Determine color scheme by colors.
 

Static Public Member Functions

static int toGtkState (const QString &state)
 Converts a string into the GtkStateFlags enum.
 
static const QLatin1String fromGtkState (GtkStateFlags state)
 Returns.
 

Detailed Description

The QGtk3Interface class centralizes communication with the GTK3 library.

By encapsulating all GTK version specific syntax and conversions, it makes Qt's GTK theme independent from GTK versions.

Note
Including GTK3 headers requires #undef signals, which disables Qt signal/slot handling.

Definition at line 53 of file qgtk3interface_p.h.

Member Enumeration Documentation

◆ QGtkColorDefault

Enumerator
Foreground 
Background 
Border 

Definition at line 121 of file qgtk3interface_p.h.

◆ QGtkColorSource

Enumerator
Foreground 
Background 
Text 
Base 
Border 

Definition at line 100 of file qgtk3interface_p.h.

◆ QGtkWidget

enum class QGtk3Interface::QGtkWidget
strong
Enumerator
gtk_menu_bar 
gtk_menu 
gtk_button 
gtk_button_box 
gtk_check_button 
gtk_radio_button 
gtk_frame 
gtk_statusbar 
gtk_entry 
gtk_popup 
gtk_notebook 
gtk_toolbar 
gtk_tree_view 
gtk_combo_box 
gtk_combo_box_text 
gtk_progress_bar 
gtk_fixed 
gtk_separator_menu_item 
gtk_Default 
gtk_offscreen_window 

Definition at line 67 of file qgtk3interface_p.h.

Constructor & Destructor Documentation

◆ QGtk3Interface()

QGtk3Interface::QGtk3Interface ( QGtk3Storage * s)

Definition at line 29 of file qgtk3interface.cpp.

References m_storage, qCDebug, and settings.

◆ ~QGtk3Interface()

QGtk3Interface::~QGtk3Interface ( )

Definition at line 56 of file qgtk3interface.cpp.

References m_storage.

Member Function Documentation

◆ brush()

QBrush QGtk3Interface::brush ( QGtkWidget wtype,
QGtkColorSource source,
GtkStateFlags state ) const

Create a QBrush from a GTK widget.

Returns a QBrush corresponding to GTK widget type

Parameters
wtype

param source and

Parameters
state.

Brush height and width is ignored in GTK3, because brush assets (e.g. 9-patches) can't be accessed by the GTK3 API. It's therefore unknown, if the brush relates only to colors, or to a pixmap based style.

Definition at line 469 of file qgtk3interface.cpp.

References state, and widget.

◆ colorSchemeByColors()

Qt::ColorScheme QGtk3Interface::colorSchemeByColors ( ) const

Determine color scheme by colors.

Returns the color scheme of the current GTK theme, heuristically determined by the lightness difference between default background and foreground colors.

Note
Returns Unknown in the unlikely case that both colors have the same lightness.

Definition at line 503 of file qgtk3interface.cpp.

References Background, Qt::Dark, Foreground, gtk_Default, Qt::Light, QColor::lightness(), Qt::Unknown, and widget.

+ Here is the call graph for this function:

◆ fileIcon()

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

Returns a GTK styled file icon for.

Parameters
fileInfo.

Definition at line 665 of file qgtk3interface.cpp.

References QFileInfo::absoluteFilePath(), QByteArray::constData(), file, QPixmap::fromImage(), icon, info, and QString::toLatin1().

+ Here is the call graph for this function:

◆ font()

QFont QGtk3Interface::font ( QPlatformTheme::Font type) const

Return a GTK styled font.

Returns the QFont corresponding to

Parameters
typeby reading the corresponding GTK widget type's font.
Note
GTK allows to specify a non fixed font as the system's fixed font. If a fixed font is requested, the method fixes the pitch and falls back to monospace, unless a suitable fixed pitch font is found.

Definition at line 606 of file qgtk3interface.cpp.

References con, context, QFont::family(), QPlatformTheme::FixedFont, font, QString::fromLatin1(), QString::isEmpty(), qCDebug, QFont::setFamily(), QFont::setFixedPitch(), QFont::setPointSizeF(), QFont::setStyle(), and widget.

+ Here is the call graph for this function:

◆ fromGtkState()

const QLatin1String QGtk3Interface::fromGtkState ( GtkStateFlags state)
static

Returns.

Parameters
stateconverted into a string.

Definition at line 105 of file qgtk3interface.cpp.

References CONVERT, and state.

Referenced by QGtk3Json::fromGtkState().

+ Here is the caller graph for this function:

◆ standardPixmap()

QImage QGtk3Interface::standardPixmap ( QPlatformTheme::StandardPixmap standardPixmap) const

Returns a QImage corresponding to.

Parameters
standardPixmap.

A QImage (not a QPixmap) is returned so it can be cached and re-scaled in case the pixmap is requested multiple times with different resolutions.

Note
Rather than defaulting to a QImage(), all QPlatformTheme::StandardPixmap enum values have been mentioned explicitly. That way they can be covered more easily in case additional icons are provided by GTK.

Definition at line 159 of file qgtk3interface.cpp.

References QPlatformTheme::ArrowBack, QPlatformTheme::ArrowDown, QPlatformTheme::ArrowForward, QPlatformTheme::ArrowLeft, QPlatformTheme::ArrowRight, QPlatformTheme::ArrowUp, QPlatformTheme::BrowserReload, QPlatformTheme::BrowserStop, QPlatformTheme::CommandLink, QPlatformTheme::ComputerIcon, QPlatformTheme::CustomBase, QPlatformTheme::DesktopIcon, QPlatformTheme::DialogAbortButton, QPlatformTheme::DialogApplyButton, QPlatformTheme::DialogCancelButton, QPlatformTheme::DialogCloseButton, QPlatformTheme::DialogDiscardButton, QPlatformTheme::DialogHelpButton, QPlatformTheme::DialogIgnoreButton, QPlatformTheme::DialogNoButton, QPlatformTheme::DialogNoToAllButton, QPlatformTheme::DialogOkButton, QPlatformTheme::DialogOpenButton, QPlatformTheme::DialogResetButton, QPlatformTheme::DialogRetryButton, QPlatformTheme::DialogSaveAllButton, QPlatformTheme::DialogSaveButton, QPlatformTheme::DialogYesButton, QPlatformTheme::DialogYesToAllButton, QPlatformTheme::DirClosedIcon, QPlatformTheme::DirHomeIcon, QPlatformTheme::DirIcon, QPlatformTheme::DirLinkIcon, QPlatformTheme::DirLinkOpenIcon, QPlatformTheme::DirOpenIcon, QPlatformTheme::DockWidgetCloseButton, QPlatformTheme::DriveCDIcon, QPlatformTheme::DriveDVDIcon, QPlatformTheme::DriveFDIcon, QPlatformTheme::DriveHDIcon, QPlatformTheme::DriveNetIcon, QPlatformTheme::FileDialogBack, QPlatformTheme::FileDialogContentsView, QPlatformTheme::FileDialogDetailedView, QPlatformTheme::FileDialogEnd, QPlatformTheme::FileDialogInfoView, QPlatformTheme::FileDialogListView, QPlatformTheme::FileDialogNewFolder, QPlatformTheme::FileDialogStart, QPlatformTheme::FileDialogToParent, QPlatformTheme::FileIcon, QPlatformTheme::FileLinkIcon, QPlatformTheme::LineEditClearButton, QPlatformTheme::MediaPause, QPlatformTheme::MediaPlay, QPlatformTheme::MediaSeekBackward, QPlatformTheme::MediaSeekForward, QPlatformTheme::MediaSkipBackward, QPlatformTheme::MediaSkipForward, QPlatformTheme::MediaStop, QPlatformTheme::MediaVolume, QPlatformTheme::MediaVolumeMuted, QPlatformTheme::MessageBoxCritical, QPlatformTheme::MessageBoxInformation, QPlatformTheme::MessageBoxQuestion, QPlatformTheme::MessageBoxWarning, QPlatformTheme::NStandardPixmap, QPlatformTheme::RestoreDefaultsButton, standardPixmap(), QPlatformTheme::TabCloseButton, QPlatformTheme::TitleBarCloseButton, QPlatformTheme::TitleBarContextHelpButton, QPlatformTheme::TitleBarMaxButton, QPlatformTheme::TitleBarMenuButton, QPlatformTheme::TitleBarMinButton, QPlatformTheme::TitleBarNormalButton, QPlatformTheme::TitleBarShadeButton, QPlatformTheme::TitleBarUnshadeButton, QPlatformTheme::ToolBarHorizontalExtensionButton, QPlatformTheme::ToolBarVerticalExtensionButton, QPlatformTheme::TrashIcon, and QPlatformTheme::VistaShield.

Referenced by standardPixmap().

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

◆ themeName()

QString QGtk3Interface::themeName ( ) const

Returns the name of the current GTK theme.

Definition at line 480 of file qgtk3interface.cpp.

References settings.

◆ toGtkState()

int QGtk3Interface::toGtkState ( const QString & state)
static

Converts a string into the GtkStateFlags enum.

Converts a string formatted GTK color

Parameters
stateinto an enum value. Returns an integer corresponding to GtkStateFlags. Returns -1 if
statedoes not correspond to a valid enum key.

Definition at line 74 of file qgtk3interface.cpp.

References CONVERT.

Referenced by QGtk3Json::toGtkState().

+ Here is the caller graph for this function:

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