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