Coverage Report

Created: 2026-09-26 06:35

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/qt/qtbase/src/gui/kernel/qplatformtheme.h
Line
Count
Source
1
// Copyright (C) 2016 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
#ifndef QPLATFORMTHEME_H
6
#define QPLATFORMTHEME_H
7
8
//
9
//  W A R N I N G
10
//  -------------
11
//
12
// This file is part of the QPA API and is not meant to be used
13
// in applications. Usage of this API may make your code
14
// source and binary incompatible with future versions of Qt.
15
//
16
17
#include <QtGui/qtguiglobal.h>
18
#include <QtCore/QObject>
19
#include <QtCore/QScopedPointer>
20
#if QT_CONFIG(shortcut)
21
#  include <QtGui/QKeySequence>
22
#endif
23
24
QT_BEGIN_NAMESPACE
25
26
class QIcon;
27
class QIconEngine;
28
class QMenu;
29
class QMenuBar;
30
class QPlatformMenuItem;
31
class QPlatformMenu;
32
class QPlatformMenuBar;
33
class QPlatformDialogHelper;
34
class QPlatformSystemTrayIcon;
35
class QPlatformThemePrivate;
36
class QVariant;
37
class QPalette;
38
class QFont;
39
class QPixmap;
40
class QSizeF;
41
class QFileInfo;
42
43
class Q_GUI_EXPORT QPlatformTheme
44
{
45
    Q_GADGET
46
0
    Q_DECLARE_PRIVATE(QPlatformTheme)
47
0
48
0
public:
49
0
    Q_DISABLE_COPY_MOVE(QPlatformTheme)
50
0
51
0
    enum ThemeHint {
52
0
        CursorFlashTime,
53
0
        KeyboardInputInterval,
54
0
        MouseDoubleClickInterval,
55
0
        StartDragDistance,
56
0
        StartDragTime,
57
0
        KeyboardAutoRepeatRate,
58
0
        PasswordMaskDelay,
59
0
        StartDragVelocity,
60
0
        TextCursorWidth,
61
0
        DropShadow,
62
0
        MaximumScrollBarDragDistance,
63
0
        ToolButtonStyle,
64
0
        ToolBarIconSize,
65
0
        ItemViewActivateItemOnSingleClick,
66
0
        SystemIconThemeName,
67
0
        SystemIconFallbackThemeName,
68
0
        IconThemeSearchPaths,
69
0
        StyleNames,
70
0
        WindowAutoPlacement,
71
0
        DialogButtonBoxLayout,
72
0
        DialogButtonBoxButtonsHaveIcons,
73
0
        UseFullScreenForPopupMenu,
74
0
        KeyboardScheme,
75
0
        UiEffects,
76
0
        SpellCheckUnderlineStyle,
77
0
        TabFocusBehavior,
78
0
        IconPixmapSizes,
79
0
        PasswordMaskCharacter,
80
0
        DialogSnapToDefaultButton,
81
0
        ContextMenuOnMouseRelease,
82
0
        MousePressAndHoldInterval,
83
0
        MouseDoubleClickDistance,
84
0
        WheelScrollLines,
85
0
        TouchDoubleTapDistance,
86
0
        ShowShortcutsInContextMenus,
87
0
        IconFallbackSearchPaths,
88
0
        MouseQuickSelectionThreshold,
89
0
        InteractiveResizeAcrossScreens,
90
0
        ShowDirectoriesFirst,
91
0
        PreselectFirstFileInDirectory,
92
0
        ButtonPressKeys,
93
0
        SetFocusOnTouchRelease,
94
0
        FlickStartDistance,
95
0
        FlickMaximumVelocity,
96
0
        FlickDeceleration,
97
0
        MenuBarFocusOnAltPressRelease,
98
0
        MouseCursorTheme,
99
0
        MouseCursorSize,
100
0
        UnderlineShortcut,
101
0
        ShowIconsInMenus,
102
0
        PreferFileIconFromTheme,
103
0
        MenuSelectionWraps,
104
0
        ScrollSingleStepDistance,
105
0
        MnemonicsEnabled
106
0
    };
107
0
    Q_ENUM(ThemeHint)
Unexecuted instantiation: qt_getEnumMetaObject(QPlatformTheme::ThemeHint)
Unexecuted instantiation: qt_getEnumName(QPlatformTheme::ThemeHint)
108
0
109
0
    enum DialogType {
110
0
        FileDialog,
111
0
        ColorDialog,
112
0
        FontDialog,
113
0
        MessageDialog
114
0
    };
115
0
    Q_ENUM(DialogType)
Unexecuted instantiation: qt_getEnumMetaObject(QPlatformTheme::DialogType)
Unexecuted instantiation: qt_getEnumName(QPlatformTheme::DialogType)
116
0
117
0
    enum Palette {
118
0
        SystemPalette,
119
0
        ToolTipPalette,
120
0
        ToolButtonPalette,
121
0
        ButtonPalette,
122
0
        CheckBoxPalette,
123
0
        RadioButtonPalette,
124
0
        HeaderPalette,
125
0
        ComboBoxPalette,
126
0
        ItemViewPalette,
127
0
        MessageBoxLabelPelette,
128
0
        MessageBoxLabelPalette = MessageBoxLabelPelette,
129
0
        TabBarPalette,
130
0
        LabelPalette,
131
0
        GroupBoxPalette,
132
0
        MenuPalette,
133
0
        MenuBarPalette,
134
0
        TextEditPalette,
135
0
        TextLineEditPalette,
136
0
        NPalettes
137
0
    };
138
0
    Q_ENUM(Palette)
Unexecuted instantiation: qt_getEnumMetaObject(QPlatformTheme::Palette)
Unexecuted instantiation: qt_getEnumName(QPlatformTheme::Palette)
139
0
140
0
    enum Font {
141
0
        SystemFont,
142
0
        MenuFont,
143
0
        MenuBarFont,
144
0
        MenuItemFont,
145
0
        MessageBoxFont,
146
0
        LabelFont,
147
0
        TipLabelFont,
148
0
        StatusBarFont,
149
0
        TitleBarFont,
150
0
        MdiSubWindowTitleFont,
151
0
        DockWidgetTitleFont,
152
0
        PushButtonFont,
153
0
        CheckBoxFont,
154
0
        RadioButtonFont,
155
0
        ToolButtonFont,
156
0
        ItemViewFont,
157
0
        ListViewFont,
158
0
        HeaderViewFont,
159
0
        ListBoxFont,
160
0
        ComboMenuItemFont,
161
0
        ComboLineEditFont,
162
0
        SmallFont,
163
0
        MiniFont,
164
0
        FixedFont,
165
0
        GroupBoxTitleFont,
166
0
        TabButtonFont,
167
0
        EditorFont,
168
0
        NFonts
169
0
    };
170
0
    Q_ENUM(Font)
Unexecuted instantiation: qt_getEnumMetaObject(QPlatformTheme::Font)
Unexecuted instantiation: qt_getEnumName(QPlatformTheme::Font)
171
0
172
0
    enum StandardPixmap {  // Keep in sync with QStyle::StandardPixmap
173
0
        TitleBarMenuButton,
174
0
        TitleBarMinButton,
175
0
        TitleBarMaxButton,
176
0
        TitleBarCloseButton,
177
0
        TitleBarNormalButton,
178
0
        TitleBarShadeButton,
179
0
        TitleBarUnshadeButton,
180
0
        TitleBarContextHelpButton,
181
0
        DockWidgetCloseButton,
182
0
        MessageBoxInformation,
183
0
        MessageBoxWarning,
184
0
        MessageBoxCritical,
185
0
        MessageBoxQuestion,
186
0
        DesktopIcon,
187
0
        TrashIcon,
188
0
        ComputerIcon,
189
0
        DriveFDIcon,
190
0
        DriveHDIcon,
191
0
        DriveCDIcon,
192
0
        DriveDVDIcon,
193
0
        DriveNetIcon,
194
0
        DirOpenIcon,
195
0
        DirClosedIcon,
196
0
        DirLinkIcon,
197
0
        DirLinkOpenIcon,
198
0
        FileIcon,
199
0
        FileLinkIcon,
200
0
        ToolBarHorizontalExtensionButton,
201
0
        ToolBarVerticalExtensionButton,
202
0
        FileDialogStart,
203
0
        FileDialogEnd,
204
0
        FileDialogToParent,
205
0
        FileDialogNewFolder,
206
0
        FileDialogDetailedView,
207
0
        FileDialogInfoView,
208
0
        FileDialogContentsView,
209
0
        FileDialogListView,
210
0
        FileDialogBack,
211
0
        DirIcon,
212
0
        DialogOkButton,
213
0
        DialogCancelButton,
214
0
        DialogHelpButton,
215
0
        DialogOpenButton,
216
0
        DialogSaveButton,
217
0
        DialogCloseButton,
218
0
        DialogApplyButton,
219
0
        DialogResetButton,
220
0
        DialogDiscardButton,
221
0
        DialogYesButton,
222
0
        DialogNoButton,
223
0
        ArrowUp,
224
0
        ArrowDown,
225
0
        ArrowLeft,
226
0
        ArrowRight,
227
0
        ArrowBack,
228
0
        ArrowForward,
229
0
        DirHomeIcon,
230
0
        CommandLink,
231
0
        VistaShield,
232
0
        BrowserReload,
233
0
        BrowserStop,
234
0
        MediaPlay,
235
0
        MediaStop,
236
0
        MediaPause,
237
0
        MediaSkipForward,
238
0
        MediaSkipBackward,
239
0
        MediaSeekForward,
240
0
        MediaSeekBackward,
241
0
        MediaVolume,
242
0
        MediaVolumeMuted,
243
0
        LineEditClearButton,
244
0
        DialogYesToAllButton,
245
0
        DialogNoToAllButton,
246
0
        DialogSaveAllButton,
247
0
        DialogAbortButton,
248
0
        DialogRetryButton,
249
0
        DialogIgnoreButton,
250
0
        RestoreDefaultsButton,
251
0
        TabCloseButton,
252
0
        TabScrollLeftButton,
253
0
        TabScrollRightButton,
254
0
        TabScrollUpButton,
255
0
        TabScrollDownButton,
256
0
        NStandardPixmap, // assertion value for sync with QStyle::StandardPixmap
257
0
258
0
        // do not add any values below/greater than this
259
0
        CustomBase = 0xf0000000
260
0
    };
261
0
    Q_ENUM(StandardPixmap)
Unexecuted instantiation: qt_getEnumMetaObject(QPlatformTheme::StandardPixmap)
Unexecuted instantiation: qt_getEnumName(QPlatformTheme::StandardPixmap)
262
0
263
0
    enum KeyboardSchemes
264
0
    {
265
0
        WindowsKeyboardScheme,
266
0
        MacKeyboardScheme,
267
0
        X11KeyboardScheme,
268
0
        KdeKeyboardScheme,
269
0
        GnomeKeyboardScheme,
270
0
        CdeKeyboardScheme
271
0
    };
272
0
    Q_ENUM(KeyboardSchemes)
Unexecuted instantiation: qt_getEnumMetaObject(QPlatformTheme::KeyboardSchemes)
Unexecuted instantiation: qt_getEnumName(QPlatformTheme::KeyboardSchemes)
273
0
274
0
    enum UiEffect
275
0
    {
276
0
        GeneralUiEffect = 0x1,
277
0
        AnimateMenuUiEffect = 0x2,
278
0
        FadeMenuUiEffect = 0x4,
279
0
        AnimateComboUiEffect = 0x8,
280
0
        AnimateTooltipUiEffect = 0x10,
281
0
        FadeTooltipUiEffect = 0x20,
282
0
        AnimateToolBoxUiEffect = 0x40,
283
0
        HoverEffect = 0x80
284
0
    };
285
0
    Q_ENUM(UiEffect)
Unexecuted instantiation: qt_getEnumMetaObject(QPlatformTheme::UiEffect)
Unexecuted instantiation: qt_getEnumName(QPlatformTheme::UiEffect)
286
0
287
0
    enum IconOption {
288
0
        DontUseCustomDirectoryIcons = 0x01
289
0
    };
290
0
    Q_DECLARE_FLAGS(IconOptions, IconOption)
291
0
292
0
    explicit QPlatformTheme();
293
0
    virtual ~QPlatformTheme();
294
0
295
0
    virtual QPlatformMenuItem* createPlatformMenuItem() const;
296
0
    virtual QPlatformMenu* createPlatformMenu() const;
297
0
    virtual QPlatformMenuBar* createPlatformMenuBar() const;
298
0
    virtual void showPlatformMenuBar() {}
299
300
    virtual bool usePlatformNativeDialog(DialogType type) const;
301
    virtual QPlatformDialogHelper *createPlatformDialogHelper(DialogType type) const;
302
303
#ifndef QT_NO_SYSTEMTRAYICON
304
    virtual QPlatformSystemTrayIcon *createPlatformSystemTrayIcon() const;
305
#endif
306
307
    virtual Qt::ColorScheme colorScheme() const;
308
309
    virtual const QPalette *palette(Palette type = SystemPalette) const;
310
311
    virtual const QFont *font(Font type = SystemFont) const;
312
313
    virtual QVariant themeHint(ThemeHint hint) const;
314
315
    virtual QPixmap standardPixmap(StandardPixmap sp, const QSizeF &size) const;
316
    virtual QIcon fileIcon(const QFileInfo &fileInfo,
317
                           QPlatformTheme::IconOptions iconOptions = { }) const;
318
    virtual QIconEngine *createIconEngine(const QString &iconName) const;
319
320
#if QT_CONFIG(shortcut)
321
    virtual QList<QKeySequence> keyBindings(QKeySequence::StandardKey key) const;
322
#endif
323
324
    virtual QString standardButtonText(int button) const;
325
#if QT_CONFIG(shortcut)
326
    virtual QKeySequence standardButtonShortcut(int button) const;
327
#endif
328
    virtual void requestColorScheme(Qt::ColorScheme scheme);
329
    virtual Qt::ContrastPreference contrastPreference() const;
330
    virtual Qt::MotionPreference motionPreference() const;
331
332
    static QVariant defaultThemeHint(ThemeHint hint);
333
    static QString defaultStandardButtonText(int button);
334
    static QString removeMnemonics(const QString &original);
335
    QString name() const;
336
337
protected:
338
    explicit QPlatformTheme(QPlatformThemePrivate *priv);
339
    QScopedPointer<QPlatformThemePrivate> d_ptr;
340
341
private:
342
    friend class QPlatformThemeFactory;
343
};
344
345
QT_END_NAMESPACE
346
347
#endif // QPLATFORMTHEME_H