![]() |
Qt 6.x
The Qt SDK
|
The QPlatformTheme class allows customizing the UI based on themes. More...
#include <qplatformtheme.h>
Static Public Member Functions | |
static QVariant | defaultThemeHint (ThemeHint hint) |
static QString | defaultStandardButtonText (int button) |
static QString | removeMnemonics (const QString &original) |
Protected Member Functions | |
QPlatformTheme (QPlatformThemePrivate *priv) | |
Protected Attributes | |
QScopedPointer< QPlatformThemePrivate > | d_ptr |
Friends | |
class | QPlatformThemeFactory |
The QPlatformTheme class allows customizing the UI based on themes.
\preliminary
See the init_platform function in qguiapplication.cpp for the complete platform initialization process.
Definition at line 42 of file qplatformtheme.h.
Enumerator | |
---|---|
FileDialog | |
ColorDialog | |
FontDialog | |
MessageDialog |
Definition at line 103 of file qplatformtheme.h.
enum QPlatformTheme::Font |
Definition at line 134 of file qplatformtheme.h.
Enumerator | |
---|---|
DontUseCustomDirectoryIcons |
Definition at line 277 of file qplatformtheme.h.
Enumerator | |
---|---|
WindowsKeyboardScheme | |
MacKeyboardScheme | |
X11KeyboardScheme | |
KdeKeyboardScheme | |
GnomeKeyboardScheme | |
CdeKeyboardScheme |
Definition at line 253 of file qplatformtheme.h.
Definition at line 111 of file qplatformtheme.h.
Definition at line 166 of file qplatformtheme.h.
This enum describes the available theme hints.
\value CursorFlashTime (int) Cursor flash time in ms, overriding QPlatformIntegration::styleHint.
\value KeyboardInputInterval (int) Keyboard input interval in ms, overriding QPlatformIntegration::styleHint.
\value MouseDoubleClickInterval (int) Mouse double click interval in ms, overriding QPlatformIntegration::styleHint.
\value MouseDoubleClickDistance (int) The maximum distance in logical pixels which the mouse can travel between clicks in order for the click sequence to be handled as a double click. The default value is 5 logical pixels.
\value MousePressAndHoldInterval (int) Mouse press and hold interval in ms, overriding QPlatformIntegration::styleHint.
\value StartDragDistance (int) Start drag distance, overriding QPlatformIntegration::styleHint.
\value StartDragTime (int) Start drag time in ms, overriding QPlatformIntegration::styleHint.
\value WheelScrollLines (int) The number of lines to scroll a widget, when the mouse wheel is rotated. The default value is 3.
\value KeyboardAutoRepeatRate (int) Keyboard auto repeat rate, overriding QPlatformIntegration::styleHint.
\value PasswordMaskDelay (int) Pass word mask delay in ms, overriding QPlatformIntegration::styleHint.
\value StartDragVelocity (int) Velocity of a drag, overriding QPlatformIntegration::styleHint.
\value TextCursorWidth (int) Determines the width of the text cursor.
\value DropShadow (bool) Determines whether the drop shadow effect for tooltips or whatsthis is enabled.
\value MaximumScrollBarDragDistance (int) Determines the value returned by QStyle::pixelMetric(PM_MaximumDragDistance)
\value ToolButtonStyle (int) A value representing a Qt::ToolButtonStyle.
\value ToolBarIconSize Icon size for tool bars.
\value SystemIconThemeName (QString) Name of the icon theme.
\value SystemIconFallbackThemeName (QString) Name of the fallback icon theme.
\value IconThemeSearchPaths (QStringList) Search paths for icons.
\value ItemViewActivateItemOnSingleClick (bool) Activate items by single click.
\value StyleNames (QStringList) A list of preferred style names.
\value WindowAutoPlacement (bool) A boolean value indicating whether Windows (particularly dialogs) are placed by the system (see _NET_WM_FULL_PLACEMENT in X11).
\value DialogButtonBoxLayout (int) An integer representing a QDialogButtonBox::ButtonLayout value.
\value DialogButtonBoxButtonsHaveIcons (bool) A boolean value indicating whether the buttons of a QDialogButtonBox should have icons.
\value UseFullScreenForPopupMenu (bool) Pop menus can cover the full screen including task bar.
\value KeyboardScheme (int) An integer value (enum KeyboardSchemes) specifying the keyboard scheme.
\value UiEffects (int) A flag value consisting of UiEffect values specifying the enabled UI animations.
\value SpellCheckUnderlineStyle (int) A QTextCharFormat::UnderlineStyle specifying the underline style used misspelled words when spell checking.
\value TabFocusBehavior (int) A Qt::TabFocusBehavior specifying the behavior of focus change when tab key was pressed. This enum value was added in Qt 5.5.
\value DialogSnapToDefaultButton (bool) Whether the mouse should snap to the default button when a dialog becomes visible.
\value ContextMenuOnMouseRelease (bool) Whether the context menu should be shown on mouse release.
\value TouchDoubleTapDistance (int) The maximum distance in logical pixels which a touchpoint can travel between taps in order for the tap sequence to be handled as a double tap. The default value is double the MouseDoubleClickDistance, or 10 logical pixels if that is not specified.
\value ShowShortcutsInContextMenus (bool) Whether to display shortcut key sequences in context menus.
\value InteractiveResizeAcrossScreens (bool) Whether using the whole virtual geometry of all the screens as basis for the resize. This enum value has been added in Qt 6.2.
\value ShowDirectoriesFirst (bool) Whether directories should be shown first (before files) in file dialogs. This enum value was added in Qt 6.3.
\value PreselectFirstFileInDirectory (bool) Whether the first file in a directory should be automatically selected when a file dialog opens. This enum value was added in Qt 6.3.
\value ButtonPressKeys (QList<Qt::Key>) A list of keys that can be used to press buttons via keyboard input.
\value SetFocusOnTouchRelease (bool) Whether focus objects (line edits etc) should receive input focus after a touch/mouse release. This enum value has been added in Qt 6.5.
\value MouseCursorTheme (QString) Name of the mouse cursor theme. This enum value has been added in Qt 6.5.
\value MouseCursorSize (QSize) Size of the mouse cursor. This enum value has been added in Qt 6.5.
Definition at line 50 of file qplatformtheme.h.
Enumerator | |
---|---|
GeneralUiEffect | |
AnimateMenuUiEffect | |
FadeMenuUiEffect | |
AnimateComboUiEffect | |
AnimateTooltipUiEffect | |
FadeTooltipUiEffect | |
AnimateToolBoxUiEffect | |
HoverEffect |
Definition at line 264 of file qplatformtheme.h.
|
explicit |
Definition at line 417 of file qplatformtheme.cpp.
Referenced by QXdgDesktopPortalTheme::QXdgDesktopPortalTheme().
|
virtual |
Definition at line 427 of file qplatformtheme.cpp.
|
explicitprotected |
Definition at line 423 of file qplatformtheme.cpp.
|
virtual |
Reimplemented in QGnomeTheme, QAndroidPlatformTheme, QCocoaTheme, QIOSTheme, QWindowsTheme, QGtk3Theme, and QXdgDesktopPortalTheme.
Definition at line 444 of file qplatformtheme.cpp.
References Qt::Unknown.
Referenced by QGuiApplicationPrivate::colorScheme(), and isDarkMode().
|
virtual |
Factory function for the QIconEngine used by QIcon::fromTheme().
By default this function returns a QIconLoaderEngine, but subclasses can reimplement it to provide their own.
It is especially useful to benefit from some platform specific facilities or optimizations like an inter-process cache in systems mostly built with Qt.
Reimplemented in QXdgDesktopPortalTheme.
Definition at line 690 of file qplatformtheme.cpp.
|
virtual |
Reimplemented in QCocoaTheme, QAndroidPlatformTheme, QIOSTheme, QWindowsTheme, QGtk3Theme, and QXdgDesktopPortalTheme.
Definition at line 438 of file qplatformtheme.cpp.
References Q_UNUSED.
Referenced by QQuickLabsPlatformDialog::create(), and QDialogPrivate::platformHelper().
|
virtual |
Reimplemented in QAndroidPlatformTheme, QCocoaTheme, QIOSTheme, QWindowsTheme, QGtk3Theme, and QXdgDesktopPortalTheme.
Definition at line 659 of file qplatformtheme.cpp.
Referenced by QQuickLabsPlatformMenu::create(), QPlatformMenuBar::createMenu(), QPlatformSystemTrayIcon::createMenu(), and QPlatformMenu::createSubMenu().
|
virtual |
Reimplemented in QGenericUnixTheme, QGnomeTheme, QAndroidPlatformTheme, QCocoaTheme, QWindowsTheme, and QXdgDesktopPortalTheme.
Definition at line 664 of file qplatformtheme.cpp.
Referenced by QQuickLabsPlatformMenuBar::QQuickLabsPlatformMenuBar(), QMenuBarPrivate::init(), and QMenuBar::setNativeMenuBar().
|
virtual |
Reimplemented in QAndroidPlatformTheme, QCocoaTheme, QIOSTheme, QWindowsTheme, QGtk3Theme, and QXdgDesktopPortalTheme.
Definition at line 654 of file qplatformtheme.cpp.
Referenced by QQuickLabsPlatformMenuItem::create(), and QPlatformMenu::createMenuItem().
|
virtual |
Factory function for QSystemTrayIcon.
This function will return 0 if the platform integration does not support creating any system tray icon.
Reimplemented in QGenericUnixTheme, QGnomeTheme, QCocoaTheme, and QXdgDesktopPortalTheme.
Definition at line 674 of file qplatformtheme.cpp.
Referenced by QQuickLabsPlatformSystemTrayIcon::QQuickLabsPlatformSystemTrayIcon().
|
static |
Definition at line 771 of file qplatformtheme.cpp.
References QPlatformDialogHelper::Abort, QPlatformDialogHelper::Apply, button, QPlatformDialogHelper::Cancel, QPlatformDialogHelper::Close, QPlatformDialogHelper::Discard, QPlatformDialogHelper::Help, QPlatformDialogHelper::Ignore, QPlatformDialogHelper::No, QPlatformDialogHelper::NoToAll, QPlatformDialogHelper::Ok, QPlatformDialogHelper::Open, QPlatformDialogHelper::Reset, QPlatformDialogHelper::RestoreDefaults, QPlatformDialogHelper::Retry, QPlatformDialogHelper::Save, QPlatformDialogHelper::SaveAll, QCoreApplication::translate(), QPlatformDialogHelper::Yes, and QPlatformDialogHelper::YesToAll.
Referenced by QGtk3FileDialogHelper::QGtk3FileDialogHelper(), and standardButtonText().
Definition at line 540 of file qplatformtheme.cpp.
References ButtonPressKeys, ContextMenuOnMouseRelease, CursorFlashTime, defaultThemeHint(), DialogButtonBoxButtonsHaveIcons, DialogButtonBoxLayout, DialogSnapToDefaultButton, dist(), DropShadow, FlickDeceleration, FlickMaximumVelocity, FlickStartDistance, QVariant::fromValue(), hint(), IconFallbackSearchPaths, IconPixmapSizes, IconThemeSearchPaths, InteractiveResizeAcrossScreens, ItemViewActivateItemOnSingleClick, Qt::Key_Select, Qt::Key_Space, KeyboardAutoRepeatRate, KeyboardInputInterval, KeyboardScheme, MaximumScrollBarDragDistance, MenuBarFocusOnAltPressRelease, MouseCursorSize, MouseCursorTheme, MouseDoubleClickDistance, MouseDoubleClickInterval, MousePressAndHoldInterval, MouseQuickSelectionThreshold, ok, PasswordMaskCharacter, PasswordMaskDelay, PreselectFirstFileInDirectory, qEnvironmentVariableIntValue(), SetFocusOnTouchRelease, ShowDirectoriesFirst, ShowShortcutsInContextMenus, SpellCheckUnderlineStyle, StartDragDistance, StartDragTime, StartDragVelocity, StyleNames, SystemIconFallbackThemeName, SystemIconThemeName, Qt::TabFocusAllControls, TabFocusBehavior, TextCursorWidth, QVariant::toInt(), ToolBarIconSize, Qt::ToolButtonIconOnly, ToolButtonStyle, TouchDoubleTapDistance, UiEffects, UnderlineShortcut, UseFullScreenForPopupMenu, QTextCharFormat::WaveUnderline, WheelScrollLines, WindowAutoPlacement, and WindowsKeyboardScheme.
Referenced by defaultThemeHint(), QPlatformIntegration::styleHint(), QCommonStyle::styleHint(), QQC2::QCommonStyle::styleHint(), themeableHint(), and themeHint().
|
virtual |
Return an icon for fileInfo, observing iconOptions.
This function is queried by QFileIconProvider and similar classes to obtain an icon for a file. If it does not return a non-null icon, fileIconPixmap() is queried for a specific size.
Reimplemented in QGtk3Theme, QXdgDesktopPortalTheme, QWindowsTheme, QCocoaTheme, and QGnomeTheme.
Definition at line 484 of file qplatformtheme.cpp.
References Q_UNUSED.
|
virtual |
Reimplemented in QGenericUnixTheme, QGnomeTheme, QWasmTheme, QAndroidPlatformTheme, QCocoaTheme, QIOSTheme, OffscreenTheme, QWindowsTheme, QGtk3Theme, and QXdgDesktopPortalTheme.
Definition at line 460 of file qplatformtheme.cpp.
References Q_UNUSED.
Referenced by QApplicationPrivate::initializeWidgetFontHash().
QString QPlatformTheme::name | ( | ) | const |
Definition at line 868 of file qplatformtheme.cpp.
Referenced by Q_GLOBAL_STATIC_WITH_ARGS().
|
virtual |
Reimplemented in QAndroidPlatformTheme, QCocoaTheme, QIOSTheme, QWindowsTheme, QGtk3Theme, and QXdgDesktopPortalTheme.
Definition at line 449 of file qplatformtheme.cpp.
References d, d_ptr, QPlatformThemePrivate::initializeSystemPalette(), and SystemPalette.
Referenced by QGuiApplicationPrivate::basePalette(), and QApplicationPrivate::initializeWidgetPalettesFromTheme().
QPlatformTheme::Q_ENUM | ( | DialogType | ) |
Definition at line 816 of file qplatformtheme.cpp.
References QString::at(), QString::endsWith(), QString::first(), QString::front(), QString::isEmpty(), QChar::isSpace(), Q_ASSERT, QString::size(), QString::sliced(), QString::startsWith(), text, and QString::truncate().
Referenced by QQuickDialogButtonBoxPrivate::buttonText(), qt_mac_removeAmpersandEscapes(), QIOSMenuItem::setText(), QCocoaMessageDialog::show(), strippedText(), QCocoaMenuItem::sync(), and QTornOffMenu::updateWindowTitle().
|
inlinevirtual |
Reimplemented in QAndroidPlatformTheme, QWindowsTheme, and QXdgDesktopPortalTheme.
Definition at line 288 of file qplatformtheme.h.
Referenced by QGuiApplicationPrivate::processKeyEvent().
|
virtual |
Returns the text of a standard button.
Reimplemented in QGnomeTheme, QAndroidPlatformTheme, QCocoaTheme, and QXdgDesktopPortalTheme.
Definition at line 751 of file qplatformtheme.cpp.
References button, and defaultStandardButtonText().
Referenced by QDialogButtonBoxPrivate::retranslateStrings(), QGnomeTheme::standardButtonText(), QAndroidPlatformTheme::standardButtonText(), and QCocoaTheme::standardButtonText().
|
virtual |
Reimplemented in QCocoaTheme, QWindowsTheme, QGtk3Theme, and QXdgDesktopPortalTheme.
Definition at line 466 of file qplatformtheme.cpp.
Referenced by QCocoaTheme::standardPixmap(), and QWindowsTheme::standardPixmap().
Reimplemented in OffscreenTheme, QGenericUnixTheme, QGnomeTheme, QAndroidPlatformTheme, QCocoaTheme, QIOSTheme, QWasmTheme, QGtk3Theme, QXdgDesktopPortalTheme, and QWindowsTheme.
Definition at line 492 of file qplatformtheme.cpp.
References QPlatformIntegration::CursorFlashTime, CursorFlashTime, defaultThemeHint(), QPlatformIntegration::FlickDeceleration, FlickDeceleration, QPlatformIntegration::FlickMaximumVelocity, FlickMaximumVelocity, QPlatformIntegration::FlickStartDistance, FlickStartDistance, hint(), QPlatformIntegration::ItemViewActivateItemOnSingleClick, ItemViewActivateItemOnSingleClick, QPlatformIntegration::KeyboardAutoRepeatRate, KeyboardAutoRepeatRate, QPlatformIntegration::KeyboardInputInterval, KeyboardInputInterval, QPlatformIntegration::MouseDoubleClickInterval, MouseDoubleClickInterval, QPlatformIntegration::MousePressAndHoldInterval, MousePressAndHoldInterval, QPlatformIntegration::PasswordMaskCharacter, PasswordMaskCharacter, QPlatformIntegration::PasswordMaskDelay, PasswordMaskDelay, QGuiApplicationPrivate::platformIntegration(), QPlatformIntegration::SetFocusOnTouchRelease, SetFocusOnTouchRelease, QPlatformIntegration::ShowShortcutsInContextMenus, ShowShortcutsInContextMenus, QPlatformIntegration::StartDragDistance, StartDragDistance, QPlatformIntegration::StartDragTime, StartDragTime, QPlatformIntegration::StartDragVelocity, StartDragVelocity, QPlatformIntegration::styleHint(), QPlatformIntegration::UiEffects, UiEffects, QPlatformIntegration::UnderlineShortcut, and UnderlineShortcut.
Referenced by QQuickAbstractButtonPrivate::acceptKeyClick(), QPlatformThemePrivate::currentKeyPlatforms(), QQuickDeliveryAgentPrivate::deliverTouchAsMouse(), drawTextItemDecoration(), QWindow::event(), QGroupBox::event(), QQuickMenuBar::eventFilter(), QQuickPlatformTheme::getThemeHint(), QWidgetWindow::handleMouseEvent(), initThemeHints(), QAbstractButton::keyPressEvent(), QComboBox::keyPressEvent(), QQuickComboBox::keyPressEvent(), QAbstractButton::keyReleaseEvent(), QQuickComboBox::keyReleaseEvent(), QQC2::QCommonStyle::pixelMetric(), QCommonStyle::pixelMetric(), platformButtonLayout(), QDialogPrivate::setVisible(), QCommonStyle::styleHint(), QQC2::QCommonStyle::styleHint(), OffscreenTheme::themeHint(), QGenericUnixTheme::themeHint(), QGnomeTheme::themeHint(), QAndroidPlatformTheme::themeHint(), QCocoaTheme::themeHint(), QIOSTheme::themeHint(), QWasmTheme::themeHint(), QWindowsTheme::themeHint(), and QQuickFileDialogImplPrivate::updateSelectedFile().
|
virtual |
Reimplemented in QCocoaTheme, QAndroidPlatformTheme, QIOSTheme, QWindowsTheme, QGtk3Theme, and QXdgDesktopPortalTheme.
Definition at line 432 of file qplatformtheme.cpp.
References Q_UNUSED.
Referenced by QDialogPrivate::canBeNativeDialog(), and QQuickLabsPlatformDialog::useNativeDialog().
|
friend |
Definition at line 329 of file qplatformtheme.h.
|
protected |
Definition at line 326 of file qplatformtheme.h.
Referenced by palette().