Coverage Report

Created: 2026-08-25 06:40

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/qtbase/src/gui/kernel/qplatformtheme.cpp
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
#include "qplatformtheme.h"
6
7
#include "qplatformtheme_p.h"
8
9
#include <QtCore/QVariant>
10
#include <QtCore/QStringList>
11
#include <QtCore/qfileinfo.h>
12
#include <qicon.h>
13
#include <qpalette.h>
14
#include <qtextformat.h>
15
#include <private/qiconloader_p.h>
16
#include <private/qguiapplication_p.h>
17
#include <qpa/qplatformintegration.h>
18
#include <qpa/qplatformdialoghelper.h>
19
20
#include <algorithm>
21
22
QT_BEGIN_NAMESPACE
23
24
/*!
25
    \class QPlatformTheme
26
    \since 5.0
27
    \internal
28
    \preliminary
29
    \ingroup qpa
30
    \brief The QPlatformTheme class allows customizing the UI based on themes.
31
32
    See the init_platform function in qguiapplication.cpp for the complete
33
    platform initialization process.
34
*/
35
36
/*!
37
    \enum QPlatformTheme::ThemeHint
38
39
    This enum describes the available theme hints.
40
41
    \value CursorFlashTime (int) Cursor flash time in ms, overriding
42
                                 QPlatformIntegration::styleHint.
43
44
    \value KeyboardInputInterval (int) Keyboard input interval in ms, overriding
45
                                 QPlatformIntegration::styleHint.
46
47
    \value MouseDoubleClickInterval (int) Mouse double click interval in ms,
48
                                    overriding QPlatformIntegration::styleHint.
49
50
    \value MouseDoubleClickDistance (int) The maximum distance in logical pixels which the mouse can travel
51
                        between clicks in order for the click sequence to be handled as a double click.
52
                        The default value is 5 logical pixels.
53
54
    \value MousePressAndHoldInterval (int) Mouse press and hold interval in ms,
55
                                    overriding QPlatformIntegration::styleHint.
56
57
    \value StartDragDistance (int) Start drag distance,
58
                             overriding QPlatformIntegration::styleHint.
59
60
    \value StartDragTime (int) Start drag time in ms,
61
                               overriding QPlatformIntegration::styleHint.
62
63
    \value WheelScrollLines (int) The number of lines to scroll a widget, when the mouse wheel is rotated.
64
                        The default value is 3.  \sa QApplication::wheelScrollLines()
65
66
    \value KeyboardAutoRepeatRate (int) Keyboard auto repeat rate,
67
                                  overriding QPlatformIntegration::styleHint.
68
69
    \value PasswordMaskDelay (int) Pass word mask delay in ms,
70
                                   overriding QPlatformIntegration::styleHint.
71
72
    \value StartDragVelocity (int) Velocity of a drag,
73
                                   overriding QPlatformIntegration::styleHint.
74
75
    \value TextCursorWidth  (int) Determines the width of the text cursor.
76
77
    \value DropShadow       (bool) Determines whether the drop shadow effect for
78
                            tooltips or whatsthis is enabled.
79
80
    \value MaximumScrollBarDragDistance (int) Determines the value returned by
81
                            QStyle::pixelMetric(PM_MaximumDragDistance)
82
83
    \value ToolButtonStyle (int) A value representing a Qt::ToolButtonStyle.
84
85
    \value ToolBarIconSize Icon size for tool bars.
86
87
    \value SystemIconThemeName (QString) Name of the icon theme.
88
89
    \value SystemIconFallbackThemeName (QString) Name of the fallback icon theme.
90
91
    \value IconThemeSearchPaths (QStringList) Search paths for icons.
92
93
    \value ItemViewActivateItemOnSingleClick (bool) Activate items by single click.
94
95
    \value StyleNames (QStringList) A list of preferred style names.
96
97
    \value WindowAutoPlacement (bool) A boolean value indicating whether Windows
98
                               (particularly dialogs) are placed by the system
99
                               (see _NET_WM_FULL_PLACEMENT in X11).
100
101
    \value DialogButtonBoxLayout (int) An integer representing a
102
                                 QDialogButtonBox::ButtonLayout value.
103
104
    \value DialogButtonBoxButtonsHaveIcons (bool) A boolean value indicating whether
105
                                            the buttons of a QDialogButtonBox should have icons.
106
107
    \value UseFullScreenForPopupMenu (bool) Pop menus can cover the full screen including task bar.
108
109
    \value KeyboardScheme (int) An integer value (enum KeyboardSchemes) specifying the
110
                           keyboard scheme.
111
112
    \value UiEffects (int) A flag value consisting of UiEffect values specifying the enabled UI animations.
113
114
    \value SpellCheckUnderlineStyle (int) A QTextCharFormat::UnderlineStyle specifying
115
                                    the underline style used misspelled words when spell checking.
116
117
    \value TabFocusBehavior (int) A Qt::TabFocusBehavior specifying
118
                         the behavior of focus change when tab key was pressed.
119
                         This enum value was added in Qt 5.5.
120
121
    \value DialogSnapToDefaultButton (bool) Whether the mouse should snap to the default button when a dialog
122
                                     becomes visible.
123
124
    \value ContextMenuOnMouseRelease (bool) Whether the context menu should be shown on mouse release.
125
126
    \value MenuSelectionWraps (bool) Determines whether menu selection wraps. That is, whether key navigation moves
127
                                     the selection to the first menu item again after the last menu item has been
128
                                     reached, and vice versa.
129
                                     This enum value was added in Qt 6.10.
130
131
    \value TouchDoubleTapDistance (int) The maximum distance in logical pixels which a touchpoint can travel
132
                        between taps in order for the tap sequence to be handled as a double tap.
133
                        The default value is double the MouseDoubleClickDistance, or 10 logical pixels
134
                        if that is not specified.
135
136
    \value ShowShortcutsInContextMenus (bool) Whether to display shortcut key sequences in context menus.
137
138
    \value InteractiveResizeAcrossScreens (bool) Whether using the whole virtual geometry of all the screens
139
                        as basis for the resize.
140
                        This enum value has been added in Qt 6.2.
141
142
    \value ShowDirectoriesFirst (bool) Whether directories should be shown
143
           first (before files) in file dialogs.
144
           This enum value was added in Qt 6.3.
145
146
    \value PreselectFirstFileInDirectory (bool) Whether the first file in a directory
147
           should be automatically selected when a file dialog opens.
148
           This enum value was added in Qt 6.3.
149
150
    \value ButtonPressKeys (QList<Qt::Key>) A list of keys that can be used to press buttons via keyboard input.
151
152
    \value SetFocusOnTouchRelease (bool) Whether focus objects (line edits etc) should receive
153
           input focus after a touch/mouse release.
154
           This enum value has been added in Qt 6.5.
155
156
    \value MouseCursorTheme (QString) Name of the mouse cursor theme.
157
           This enum value has been added in Qt 6.5.
158
159
    \value MouseCursorSize (QSize) Size of the mouse cursor.
160
           This enum value has been added in Qt 6.5.
161
162
    \value ScrollSingleStepDistance (int) The distance in logical pixels that scrollable
163
           controls should scroll in response to a single step (e.g. scroll-bar arrow click,
164
           mouse wheel line).
165
166
    \value MnemonicsEnabled (bool) Whether \l {QShortcut#mnemonic}{mnemonics} are enabled.
167
168
    \sa themeHint(), QStyle::pixelMetric()
169
*/
170
171
172
#if QT_CONFIG(shortcut)
173
// Table of key bindings. It must be sorted on key sequence:
174
// The integer value of VK_KEY | Modifier Keys (e.g., VK_META, and etc.)
175
// A priority of 1 indicates that this is the primary key binding when multiple are defined.
176
177
enum KeyPlatform {
178
    KB_Win = (1 << QPlatformTheme::WindowsKeyboardScheme),
179
    KB_Mac = (1 << QPlatformTheme::MacKeyboardScheme),
180
    KB_X11 = (1 << QPlatformTheme::X11KeyboardScheme),
181
    KB_KDE = (1 << QPlatformTheme::KdeKeyboardScheme),
182
    KB_Gnome = (1 << QPlatformTheme::GnomeKeyboardScheme),
183
    KB_CDE = (1 << QPlatformTheme::CdeKeyboardScheme),
184
    KB_All = 0xffff
185
};
186
187
const QKeyBinding QPlatformThemePrivate::keyBindings[] = {
188
    //   StandardKey                            Priority    Key Sequence                            Platforms
189
    {QKeySequence::HelpContents,            1,          Qt::CTRL | Qt::Key_Question,            KB_Mac},
190
    {QKeySequence::HelpContents,            0,          Qt::Key_F1,                             KB_Win | KB_X11},
191
    {QKeySequence::HelpContents,            0,          Qt::Key_Help,                           KB_All},
192
    {QKeySequence::WhatsThis,               1,          Qt::SHIFT | Qt::Key_F1,                 KB_All},
193
    {QKeySequence::Open,                    1,          Qt::CTRL | Qt::Key_O,                   KB_All},
194
    {QKeySequence::Open,                    0,          Qt::Key_Open,                           KB_All},
195
    {QKeySequence::Close,                   0,          Qt::CTRL | Qt::Key_F4,                  KB_Mac},
196
    {QKeySequence::Close,                   1,          Qt::CTRL | Qt::Key_F4,                  KB_Win},
197
    {QKeySequence::Close,                   1,          Qt::CTRL | Qt::Key_W,                   KB_Mac},
198
    {QKeySequence::Close,                   0,          Qt::CTRL | Qt::Key_W,                   KB_Win | KB_X11},
199
    {QKeySequence::Close,                   0,          Qt::Key_Close,                          KB_All},
200
    {QKeySequence::Save,                    1,          Qt::CTRL | Qt::Key_S,                   KB_All},
201
    {QKeySequence::Save,                    0,          Qt::Key_Save,                           KB_All},
202
    {QKeySequence::New,                     1,          Qt::CTRL | Qt::Key_N,                   KB_All},
203
    {QKeySequence::New,                     0,          Qt::Key_New,                            KB_All},
204
    {QKeySequence::Delete,                  0,          Qt::CTRL | Qt::Key_D,                   KB_X11}, //emacs (line edit only)
205
    {QKeySequence::Delete,                  1,          Qt::Key_Delete,                         KB_All},
206
    {QKeySequence::Delete,                  0,          Qt::META | Qt::Key_D,                   KB_Mac},
207
    {QKeySequence::Cut,                     1,          Qt::CTRL | Qt::Key_X,                   KB_All},
208
    {QKeySequence::Cut,                     0,          Qt::SHIFT | Qt::Key_Delete,             KB_Win | KB_X11}, //## Check if this should work on mac
209
    {QKeySequence::Cut,                     0,          Qt::Key_F20,                            KB_X11}, //Cut on sun keyboards
210
    {QKeySequence::Cut,                     0,          Qt::META | Qt::Key_K,                   KB_Mac},
211
    {QKeySequence::Cut,                     0,          Qt::Key_Cut,                            KB_All},
212
    {QKeySequence::Copy,                    0,          Qt::CTRL | Qt::Key_Insert,              KB_X11 | KB_Win},
213
    {QKeySequence::Copy,                    1,          Qt::CTRL | Qt::Key_C,                   KB_All},
214
    {QKeySequence::Copy,                    0,          Qt::Key_F16,                            KB_X11}, //Copy on sun keyboards
215
    {QKeySequence::Copy,                    0,          Qt::Key_Copy,                           KB_All},
216
    {QKeySequence::Paste,                   0,          Qt::CTRL | Qt::SHIFT | Qt::Key_Insert,  KB_X11},
217
    {QKeySequence::Paste,                   1,          Qt::CTRL | Qt::Key_V,                   KB_All},
218
    {QKeySequence::Paste,                   0,          Qt::SHIFT | Qt::Key_Insert,             KB_Win | KB_X11},
219
    {QKeySequence::Paste,                   0,          Qt::Key_F18,                            KB_X11}, //Paste on sun keyboards
220
    {QKeySequence::Paste,                   0,          Qt::META | Qt::Key_Y,                   KB_Mac},
221
    {QKeySequence::Paste,                   0,          Qt::Key_Paste,                          KB_All},
222
    {QKeySequence::Undo,                    0,          Qt::ALT  | Qt::Key_Backspace,           KB_Win},
223
    {QKeySequence::Undo,                    1,          Qt::CTRL | Qt::Key_Z,                   KB_All},
224
    {QKeySequence::Undo,                    0,          Qt::Key_F14,                            KB_X11}, //Undo on sun keyboards
225
    {QKeySequence::Undo,                    0,          Qt::Key_Undo,                           KB_All},
226
    {QKeySequence::Redo,                    0,          Qt::ALT  | Qt::SHIFT | Qt::Key_Backspace,KB_Win},
227
    {QKeySequence::Redo,                    0,          Qt::CTRL | Qt::SHIFT | Qt::Key_Z,       KB_Mac},
228
    {QKeySequence::Redo,                    0,          Qt::CTRL | Qt::SHIFT | Qt::Key_Z,       KB_Win | KB_X11},
229
    {QKeySequence::Redo,                    1,          Qt::CTRL | Qt::Key_Y,                   KB_Win},
230
    {QKeySequence::Redo,                    0,          Qt::Key_Redo,                           KB_All},
231
    {QKeySequence::Back,                    1,          Qt::ALT  | Qt::Key_Left,                KB_Win | KB_X11},
232
    {QKeySequence::Back,                    0,          Qt::CTRL | Qt::Key_Left,                KB_Mac},
233
    {QKeySequence::Back,                    1,          Qt::CTRL | Qt::Key_BracketLeft,         KB_Mac},
234
    {QKeySequence::Back,                    0,          Qt::Key_Backspace,                      KB_Win},
235
    {QKeySequence::Back,                    0,          Qt::Key_Back,                           KB_All},
236
    {QKeySequence::Forward,                 1,          Qt::ALT  | Qt::Key_Right,               KB_Win | KB_X11},
237
    {QKeySequence::Forward,                 0,          Qt::CTRL | Qt::Key_Right,               KB_Mac},
238
    {QKeySequence::Forward,                 1,          Qt::CTRL | Qt::Key_BracketRight,        KB_Mac},
239
    {QKeySequence::Forward,                 0,          Qt::SHIFT | Qt::Key_Backspace,          KB_Win},
240
    {QKeySequence::Forward,                 0,          Qt::Key_Forward,                        KB_All},
241
    {QKeySequence::Refresh,                 1,          Qt::CTRL | Qt::Key_R,                   KB_Gnome | KB_Mac},
242
    {QKeySequence::Refresh,                 0,          Qt::Key_F5,                             KB_Win | KB_X11},
243
    {QKeySequence::Refresh,                 0,          Qt::Key_Refresh,                        KB_All},
244
    {QKeySequence::ZoomIn,                  1,          Qt::CTRL | Qt::Key_Plus,                KB_All},
245
    {QKeySequence::ZoomIn,                  0,          Qt::Key_ZoomIn,                         KB_All},
246
    {QKeySequence::ZoomOut,                 1,          Qt::CTRL | Qt::Key_Minus,               KB_All},
247
    {QKeySequence::ZoomOut,                 0,          Qt::Key_ZoomOut,                        KB_All},
248
    {QKeySequence::Print,                   1,          Qt::CTRL | Qt::Key_P,                   KB_All},
249
    {QKeySequence::AddTab,                  1,          Qt::CTRL | Qt::SHIFT | Qt::Key_N,       KB_KDE},
250
    {QKeySequence::AddTab,                  0,          Qt::CTRL | Qt::Key_T,                   KB_All},
251
    {QKeySequence::NextChild,               0,          Qt::CTRL | Qt::Key_F6,                  KB_Win},
252
    {QKeySequence::NextChild,               0,          Qt::CTRL | Qt::Key_Tab,                 KB_Mac}, //different priority from above
253
    {QKeySequence::NextChild,               1,          Qt::CTRL | Qt::Key_Tab,                 KB_Win | KB_X11},
254
    {QKeySequence::NextChild,               1,          Qt::CTRL | Qt::Key_BraceRight,          KB_Mac},
255
    {QKeySequence::NextChild,               0,          Qt::CTRL | Qt::Key_Comma,               KB_KDE},
256
    {QKeySequence::NextChild,               0,          Qt::Key_Forward,                        KB_All},
257
    {QKeySequence::PreviousChild,           0,          Qt::CTRL | Qt::SHIFT | Qt::Key_F6,      KB_Win},
258
    {QKeySequence::PreviousChild,           0,          Qt::CTRL | Qt::SHIFT | Qt::Key_Backtab, KB_Mac },//different priority from above
259
    {QKeySequence::PreviousChild,           1,          Qt::CTRL | Qt::SHIFT | Qt::Key_Backtab, KB_Win | KB_X11},
260
    {QKeySequence::PreviousChild,           1,          Qt::CTRL | Qt::Key_BraceLeft,           KB_Mac},
261
    {QKeySequence::PreviousChild,           0,          Qt::CTRL | Qt::Key_Period,              KB_KDE},
262
    {QKeySequence::PreviousChild,           0,          Qt::Key_Back,                           KB_All},
263
    {QKeySequence::Find,                    0,          Qt::CTRL | Qt::Key_F,                   KB_All},
264
    {QKeySequence::Find,                    0,          Qt::Key_Find,                           KB_All},
265
    {QKeySequence::FindNext,                0,          Qt::CTRL | Qt::Key_G,                   KB_Win},
266
    {QKeySequence::FindNext,                1,          Qt::CTRL | Qt::Key_G,                   KB_Gnome | KB_Mac},
267
    {QKeySequence::FindNext,                1,          Qt::Key_F3,                             KB_Win},
268
    {QKeySequence::FindNext,                0,          Qt::Key_F3,                             KB_X11},
269
    {QKeySequence::FindPrevious,            0,          Qt::CTRL | Qt::SHIFT | Qt::Key_G,       KB_Win},
270
    {QKeySequence::FindPrevious,            1,          Qt::CTRL | Qt::SHIFT | Qt::Key_G,       KB_Gnome | KB_Mac},
271
    {QKeySequence::FindPrevious,            1,          Qt::SHIFT | Qt::Key_F3,                 KB_Win},
272
    {QKeySequence::FindPrevious,            0,          Qt::SHIFT | Qt::Key_F3,                 KB_X11},
273
    {QKeySequence::Replace,                 0,          Qt::CTRL | Qt::Key_R,                   KB_KDE},
274
    {QKeySequence::Replace,                 0,          Qt::CTRL | Qt::Key_H,                   KB_Gnome},
275
    {QKeySequence::Replace,                 0,          Qt::CTRL | Qt::Key_H,                   KB_Win},
276
    {QKeySequence::SelectAll,               1,          Qt::CTRL | Qt::Key_A,                   KB_All},
277
    {QKeySequence::Bold,                    1,          Qt::CTRL | Qt::Key_B,                   KB_All},
278
    {QKeySequence::Italic,                  0,          Qt::CTRL | Qt::Key_I,                   KB_All},
279
    {QKeySequence::Underline,               1,          Qt::CTRL | Qt::Key_U,                   KB_All},
280
    {QKeySequence::MoveToNextChar,          1,          Qt::Key_Right,                          KB_All},
281
    {QKeySequence::MoveToNextChar,          0,          Qt::META | Qt::Key_F,                   KB_Mac},
282
    {QKeySequence::MoveToPreviousChar,      1,          Qt::Key_Left,                           KB_All},
283
    {QKeySequence::MoveToPreviousChar,      0,          Qt::META | Qt::Key_B,                   KB_Mac},
284
    {QKeySequence::MoveToNextWord,          0,          Qt::ALT  | Qt::Key_Right,               KB_Mac},
285
    {QKeySequence::MoveToNextWord,          0,          Qt::CTRL | Qt::Key_Right,               KB_Win | KB_X11},
286
    {QKeySequence::MoveToPreviousWord,      0,          Qt::ALT  | Qt::Key_Left,                KB_Mac},
287
    {QKeySequence::MoveToPreviousWord,      0,          Qt::CTRL | Qt::Key_Left,                KB_Win | KB_X11},
288
    {QKeySequence::MoveToNextLine,          1,          Qt::Key_Down,                           KB_All},
289
    {QKeySequence::MoveToNextLine,          0,          Qt::META | Qt::Key_N,                   KB_Mac},
290
    {QKeySequence::MoveToPreviousLine,      1,          Qt::Key_Up,                             KB_All},
291
    {QKeySequence::MoveToPreviousLine,      0,          Qt::META | Qt::Key_P,                   KB_Mac},
292
    {QKeySequence::MoveToNextPage,          0,          Qt::META | Qt::Key_PageDown,            KB_Mac},
293
    {QKeySequence::MoveToNextPage,          0,          Qt::META | Qt::Key_Down,                KB_Mac},
294
    {QKeySequence::MoveToNextPage,          0,          Qt::META | Qt::Key_V,                   KB_Mac},
295
    {QKeySequence::MoveToNextPage,          0,          Qt::ALT  | Qt::Key_PageDown,            KB_Mac },
296
    {QKeySequence::MoveToNextPage,          1,          Qt::Key_PageDown,                       KB_All},
297
    {QKeySequence::MoveToPreviousPage,      0,          Qt::META | Qt::Key_PageUp,              KB_Mac},
298
    {QKeySequence::MoveToPreviousPage,      0,          Qt::META | Qt::Key_Up,                  KB_Mac},
299
    {QKeySequence::MoveToPreviousPage,      0,          Qt::ALT  | Qt::Key_PageUp,              KB_Mac },
300
    {QKeySequence::MoveToPreviousPage,      1,          Qt::Key_PageUp,                         KB_All},
301
    {QKeySequence::MoveToStartOfLine,       0,          Qt::META | Qt::Key_Left,                KB_Mac},
302
    {QKeySequence::MoveToStartOfLine,       0,          Qt::CTRL | Qt::Key_Left,                KB_Mac },
303
    {QKeySequence::MoveToStartOfLine,       0,          Qt::Key_Home,                           KB_Win | KB_X11},
304
    {QKeySequence::MoveToEndOfLine,         0,          Qt::META | Qt::Key_Right,               KB_Mac},
305
    {QKeySequence::MoveToEndOfLine,         0,          Qt::CTRL | Qt::Key_Right,               KB_Mac },
306
    {QKeySequence::MoveToEndOfLine,         0,          Qt::Key_End,                            KB_Win | KB_X11},
307
    {QKeySequence::MoveToEndOfLine,         0,          Qt::CTRL | Qt::Key_E,                   KB_X11},
308
    {QKeySequence::MoveToStartOfBlock,      0,          Qt::META | Qt::Key_A,                   KB_Mac},
309
    {QKeySequence::MoveToStartOfBlock,      1,          Qt::ALT  | Qt::Key_Up,                  KB_Mac}, //mac only
310
    {QKeySequence::MoveToEndOfBlock,        0,          Qt::META | Qt::Key_E,                   KB_Mac},
311
    {QKeySequence::MoveToEndOfBlock,        1,          Qt::ALT  | Qt::Key_Down,                KB_Mac}, //mac only
312
    {QKeySequence::MoveToStartOfDocument,   1,          Qt::CTRL | Qt::Key_Up,                  KB_Mac},
313
    {QKeySequence::MoveToStartOfDocument,   0,          Qt::CTRL | Qt::Key_Home,                KB_Win | KB_X11},
314
    {QKeySequence::MoveToStartOfDocument,   0,          Qt::Key_Home,                           KB_Mac},
315
    {QKeySequence::MoveToEndOfDocument,     1,          Qt::CTRL | Qt::Key_Down,                KB_Mac},
316
    {QKeySequence::MoveToEndOfDocument,     0,          Qt::CTRL | Qt::Key_End,                 KB_Win | KB_X11},
317
    {QKeySequence::MoveToEndOfDocument,     0,          Qt::Key_End,                            KB_Mac},
318
    {QKeySequence::SelectNextChar,          0,          Qt::SHIFT | Qt::Key_Right,              KB_All},
319
    {QKeySequence::SelectPreviousChar,      0,          Qt::SHIFT | Qt::Key_Left,               KB_All},
320
    {QKeySequence::SelectNextWord,          0,          Qt::ALT  | Qt::SHIFT | Qt::Key_Right,   KB_Mac},
321
    {QKeySequence::SelectNextWord,          0,          Qt::CTRL | Qt::SHIFT | Qt::Key_Right,   KB_Win | KB_X11},
322
    {QKeySequence::SelectPreviousWord,      0,          Qt::ALT  | Qt::SHIFT | Qt::Key_Left,    KB_Mac},
323
    {QKeySequence::SelectPreviousWord,      0,          Qt::CTRL | Qt::SHIFT | Qt::Key_Left,    KB_Win | KB_X11},
324
    {QKeySequence::SelectNextLine,          0,          Qt::SHIFT | Qt::Key_Down,               KB_All},
325
    {QKeySequence::SelectPreviousLine,      0,          Qt::SHIFT | Qt::Key_Up,                 KB_All},
326
    {QKeySequence::SelectNextPage,          0,          Qt::SHIFT | Qt::Key_PageDown,           KB_All},
327
    {QKeySequence::SelectPreviousPage,      0,          Qt::SHIFT | Qt::Key_PageUp,             KB_All},
328
    {QKeySequence::SelectStartOfLine,       0,          Qt::META | Qt::SHIFT | Qt::Key_Left,    KB_Mac},
329
    {QKeySequence::SelectStartOfLine,       1,          Qt::CTRL | Qt::SHIFT | Qt::Key_Left,    KB_Mac },
330
    {QKeySequence::SelectStartOfLine,       0,          Qt::SHIFT | Qt::Key_Home,               KB_Win | KB_X11},
331
    {QKeySequence::SelectEndOfLine,         0,          Qt::META | Qt::SHIFT | Qt::Key_Right,   KB_Mac},
332
    {QKeySequence::SelectEndOfLine,         1,          Qt::CTRL | Qt::SHIFT | Qt::Key_Right,   KB_Mac },
333
    {QKeySequence::SelectEndOfLine,         0,          Qt::SHIFT | Qt::Key_End,                KB_Win | KB_X11},
334
    {QKeySequence::SelectStartOfBlock,      1,          Qt::ALT  | Qt::SHIFT | Qt::Key_Up,      KB_Mac}, //mac only
335
    {QKeySequence::SelectStartOfBlock,      0,          Qt::META | Qt::SHIFT | Qt::Key_A,       KB_Mac},
336
    {QKeySequence::SelectEndOfBlock,        1,          Qt::ALT  | Qt::SHIFT | Qt::Key_Down,    KB_Mac}, //mac only
337
    {QKeySequence::SelectEndOfBlock,        0,          Qt::META | Qt::SHIFT | Qt::Key_E,       KB_Mac},
338
    {QKeySequence::SelectStartOfDocument,   1,          Qt::CTRL | Qt::SHIFT | Qt::Key_Up,      KB_Mac},
339
    {QKeySequence::SelectStartOfDocument,   0,          Qt::CTRL | Qt::SHIFT | Qt::Key_Home,    KB_Win | KB_X11},
340
    {QKeySequence::SelectStartOfDocument,   0,          Qt::SHIFT | Qt::Key_Home,               KB_Mac},
341
    {QKeySequence::SelectEndOfDocument,     1,          Qt::CTRL | Qt::SHIFT | Qt::Key_Down,    KB_Mac},
342
    {QKeySequence::SelectEndOfDocument,     0,          Qt::CTRL | Qt::SHIFT | Qt::Key_End,     KB_Win | KB_X11},
343
    {QKeySequence::SelectEndOfDocument,     0,          Qt::SHIFT | Qt::Key_End,                KB_Mac},
344
    {QKeySequence::DeleteStartOfWord,       0,          Qt::ALT  | Qt::Key_Backspace,           KB_Mac},
345
    {QKeySequence::DeleteStartOfWord,       0,          Qt::CTRL | Qt::Key_Backspace,           KB_X11 | KB_Win},
346
    {QKeySequence::DeleteEndOfWord,         0,          Qt::ALT  | Qt::Key_Delete,              KB_Mac},
347
    {QKeySequence::DeleteEndOfWord,         0,          Qt::CTRL | Qt::Key_Delete,              KB_X11 | KB_Win},
348
    {QKeySequence::DeleteEndOfLine,         0,          Qt::CTRL | Qt::Key_K,                   KB_X11}, //emacs (line edit only)
349
    {QKeySequence::InsertParagraphSeparator,0,          Qt::Key_Enter,                          KB_All},
350
    {QKeySequence::InsertParagraphSeparator,0,          Qt::Key_Return,                         KB_All},
351
    {QKeySequence::InsertLineSeparator,     0,          Qt::META | Qt::Key_Enter,               KB_Mac},
352
    {QKeySequence::InsertLineSeparator,     0,          Qt::META | Qt::Key_Return,              KB_Mac},
353
    {QKeySequence::InsertLineSeparator,     0,          Qt::SHIFT | Qt::Key_Enter,              KB_All},
354
    {QKeySequence::InsertLineSeparator,     0,          Qt::SHIFT | Qt::Key_Return,             KB_All},
355
    {QKeySequence::InsertLineSeparator,     0,          Qt::META | Qt::Key_O,                   KB_Mac},
356
    {QKeySequence::SaveAs,                  0,          Qt::CTRL | Qt::SHIFT | Qt::Key_S,       KB_All},
357
    {QKeySequence::SaveAs,                  0,          Qt::SHIFT | Qt::Key_Save,               KB_All},
358
    {QKeySequence::Preferences,             0,          Qt::CTRL | Qt::Key_Comma,               KB_Mac},
359
    {QKeySequence::Preferences,             0,          Qt::CTRL | Qt::SHIFT | Qt::Key_Comma,   KB_KDE},
360
    {QKeySequence::Preferences,             0,          Qt::Key_Settings,                       KB_Mac | KB_KDE},
361
    {QKeySequence::Quit,                    0,          Qt::CTRL | Qt::Key_Q,                   KB_X11 | KB_Gnome | KB_KDE | KB_Mac},
362
    {QKeySequence::Quit,                    0,          Qt::Key_Exit,                           KB_X11 | KB_Gnome | KB_KDE | KB_Mac},
363
    {QKeySequence::FullScreen,              1,          Qt::META | Qt::CTRL | Qt::Key_F,        KB_Mac},
364
    {QKeySequence::FullScreen,              0,          Qt::ALT  | Qt::Key_Enter,               KB_Win},
365
    {QKeySequence::FullScreen,              0,          Qt::CTRL | Qt::SHIFT | Qt::Key_F,       KB_KDE},
366
    {QKeySequence::FullScreen,              1,          Qt::Key_F11,                            KB_Win | KB_Gnome | KB_KDE},
367
    {QKeySequence::Deselect,                0,          Qt::CTRL | Qt::SHIFT | Qt::Key_A,       KB_X11},
368
    {QKeySequence::DeleteCompleteLine,      0,          Qt::CTRL | Qt::Key_U,                   KB_X11},
369
    {QKeySequence::Backspace,               1,          Qt::Key_Backspace,                      KB_Mac},
370
    {QKeySequence::Backspace,               0,          Qt::META | Qt::Key_H,                   KB_Mac},
371
    {QKeySequence::Cancel,                  0,          Qt::Key_Escape,                         KB_All},
372
    {QKeySequence::Cancel,                  0,          Qt::CTRL | Qt::Key_Period,              KB_Mac},
373
    {QKeySequence::Cancel,                  0,          Qt::Key_Cancel,                         KB_All}
374
};
375
376
const uint QPlatformThemePrivate::numberOfKeyBindings = sizeof(QPlatformThemePrivate::keyBindings)/(sizeof(QKeyBinding));
377
#endif
378
379
QPlatformThemePrivate::QPlatformThemePrivate()
380
94.1k
        : systemPalette(nullptr)
381
94.1k
{ }
382
383
QPlatformThemePrivate::~QPlatformThemePrivate()
384
94.1k
{
385
94.1k
    if (systemPalette)
386
94.1k
        delete systemPalette;
387
94.1k
}
388
389
Q_GUI_EXPORT QPalette qt_fusionPalette()
390
94.1k
{
391
94.1k
    auto theme = QGuiApplicationPrivate::platformTheme();
392
94.1k
    const bool darkAppearance = theme
393
94.1k
                              ? theme->colorScheme() == Qt::ColorScheme::Dark
394
94.1k
                              : false;
395
94.1k
    const QColor windowText = darkAppearance ? QColor(240, 240, 240) : Qt::black;
396
94.1k
    const QColor backGround = darkAppearance ? QColor(50, 50, 50) : QColor(239, 239, 239);
397
94.1k
    const QColor light = backGround.lighter(150);
398
94.1k
    const QColor mid = (backGround.darker(130));
399
94.1k
    const QColor midLight = mid.lighter(110);
400
94.1k
    const QColor base = darkAppearance ? backGround.darker(140) : Qt::white;
401
94.1k
    const QColor disabledBase(backGround);
402
94.1k
    const QColor dark = backGround.darker(150);
403
94.1k
    const QColor darkDisabled = QColor(209, 209, 209).darker(110);
404
94.1k
    const QColor text = darkAppearance ? windowText : Qt::black;
405
94.1k
    const QColor highlight = QColor(48, 140, 198);
406
94.1k
    const QColor hightlightedText = darkAppearance ? windowText : Qt::white;
407
94.1k
    const QColor disabledText = darkAppearance ? QColor(130, 130, 130) : QColor(190, 190, 190);
408
94.1k
    const QColor button = backGround;
409
94.1k
    const QColor shadow = dark.darker(135);
410
94.1k
    const QColor disabledShadow = shadow.lighter(150);
411
94.1k
    const QColor disabledHighlight(145, 145, 145);
412
94.1k
    QColor placeholder = text;
413
94.1k
    placeholder.setAlpha(128);
414
415
94.1k
    QPalette fusionPalette(windowText, backGround, light, dark, mid, text, base);
416
94.1k
    fusionPalette.setBrush(QPalette::Midlight, midLight);
417
94.1k
    fusionPalette.setBrush(QPalette::Button, button);
418
94.1k
    fusionPalette.setBrush(QPalette::Shadow, shadow);
419
94.1k
    fusionPalette.setBrush(QPalette::HighlightedText, hightlightedText);
420
421
94.1k
    fusionPalette.setBrush(QPalette::Disabled, QPalette::Text, disabledText);
422
94.1k
    fusionPalette.setBrush(QPalette::Disabled, QPalette::WindowText, disabledText);
423
94.1k
    fusionPalette.setBrush(QPalette::Disabled, QPalette::ButtonText, disabledText);
424
94.1k
    fusionPalette.setBrush(QPalette::Disabled, QPalette::Base, disabledBase);
425
94.1k
    fusionPalette.setBrush(QPalette::Disabled, QPalette::Dark, darkDisabled);
426
94.1k
    fusionPalette.setBrush(QPalette::Disabled, QPalette::Shadow, disabledShadow);
427
428
94.1k
    fusionPalette.setBrush(QPalette::Active, QPalette::Highlight, highlight);
429
94.1k
    fusionPalette.setBrush(QPalette::Inactive, QPalette::Highlight, highlight);
430
94.1k
    fusionPalette.setBrush(QPalette::Disabled, QPalette::Highlight, disabledHighlight);
431
432
94.1k
    fusionPalette.setBrush(QPalette::Active, QPalette::Accent, highlight);
433
94.1k
    fusionPalette.setBrush(QPalette::Inactive, QPalette::Accent, highlight);
434
94.1k
    fusionPalette.setBrush(QPalette::Disabled, QPalette::Accent, disabledHighlight);
435
436
94.1k
    fusionPalette.setBrush(QPalette::PlaceholderText, placeholder);
437
438
    // Use a more legible light blue on dark backgrounds than the default Qt::blue.
439
94.1k
    if (darkAppearance)
440
0
        fusionPalette.setBrush(QPalette::Link, highlight);
441
442
94.1k
    return fusionPalette;
443
94.1k
}
444
445
void QPlatformThemePrivate::initializeSystemPalette()
446
94.1k
{
447
94.1k
    Q_ASSERT(!systemPalette);
448
94.1k
    systemPalette = new QPalette(qt_fusionPalette());
449
94.1k
}
450
451
QPlatformTheme::QPlatformTheme()
452
94.1k
    : d_ptr(new QPlatformThemePrivate)
453
94.1k
{
454
455
94.1k
}
456
457
QPlatformTheme::QPlatformTheme(QPlatformThemePrivate *priv)
458
0
    : d_ptr(priv)
459
0
{ }
460
461
QPlatformTheme::~QPlatformTheme()
462
94.1k
{
463
464
94.1k
}
465
466
bool QPlatformTheme::usePlatformNativeDialog(DialogType type) const
467
0
{
468
0
    Q_UNUSED(type);
469
0
    return false;
470
0
}
471
472
QPlatformDialogHelper *QPlatformTheme::createPlatformDialogHelper(DialogType type) const
473
0
{
474
0
    Q_UNUSED(type);
475
0
    return nullptr;
476
0
}
477
478
Qt::ColorScheme QPlatformTheme::colorScheme() const
479
188k
{
480
188k
    return Qt::ColorScheme::Unknown;
481
188k
}
482
483
void QPlatformTheme::requestColorScheme(Qt::ColorScheme scheme)
484
0
{
485
0
    Q_UNUSED(scheme);
486
0
    Q_D(QPlatformTheme);
487
0
    if (d->systemPalette) {
488
0
        delete d->systemPalette;
489
0
        d->systemPalette = nullptr;
490
0
    }
491
0
}
492
493
Qt::ContrastPreference QPlatformTheme::contrastPreference() const
494
94.1k
{
495
94.1k
    return Qt::ContrastPreference::NoPreference;
496
94.1k
}
497
498
Qt::MotionPreference QPlatformTheme::motionPreference() const
499
94.1k
{
500
94.1k
    return Qt::MotionPreference::NoPreference;
501
94.1k
}
502
503
/*!
504
    \internal
505
    \brief Return a color palette for type \a type.
506
507
    When relying on system color palette keep in mind that it is
508
    lazily initialized and cached. If it needs to be updated
509
    (i.e. due to ColorScheme changes), it's up to the caller
510
    to take care of it. See \c requestColorScheme.
511
*/
512
const QPalette *QPlatformTheme::palette(Palette type) const
513
188k
{
514
188k
    Q_D(const QPlatformTheme);
515
188k
    if (type == QPlatformTheme::SystemPalette) {
516
188k
        if (!d->systemPalette)
517
94.1k
            const_cast<QPlatformTheme *>(this)->d_ptr->initializeSystemPalette();
518
188k
        return d->systemPalette;
519
188k
    }
520
0
    return nullptr;
521
188k
}
522
523
const QFont *QPlatformTheme::font(Font type) const
524
21.3k
{
525
21.3k
    Q_UNUSED(type);
526
21.3k
    return nullptr;
527
21.3k
}
528
529
/*!
530
    \brief Return a pixmap for \a standardPixmap, at the given \a size.
531
532
    The implementation should not take system DPR into account, and
533
    always return a pixmap with a DPR of 1. It's up to the consumer
534
    to account for DPR and request a pixmap of the right size.
535
*/
536
QPixmap QPlatformTheme::standardPixmap(StandardPixmap standardPixmap, const QSizeF &size) const
537
0
{
538
0
    Q_UNUSED(standardPixmap);
539
0
    Q_UNUSED(size);
540
    // TODO Should return QCommonStyle pixmaps?
541
0
    return QPixmap();
542
0
}
543
544
/*!
545
    \brief Return an icon for \a fileInfo, observing \a iconOptions.
546
547
    This function is queried by QFileIconProvider and similar classes to obtain
548
    an icon for a file. If it does not return a non-null icon, fileIconPixmap()
549
    is queried for a specific size.
550
551
    \since 5.8
552
*/
553
554
QIcon QPlatformTheme::fileIcon(const QFileInfo &fileInfo, QPlatformTheme::IconOptions iconOptions) const
555
0
{
556
0
    Q_UNUSED(fileInfo);
557
0
    Q_UNUSED(iconOptions);
558
    // TODO Should return QCommonStyle pixmaps?
559
0
    return QIcon();
560
0
}
561
562
QVariant QPlatformTheme::themeHint(ThemeHint hint) const
563
376k
{
564
    // For theme hints which mirror platform integration style hints, query
565
    // the platform integration. The base QPlatformIntegration::styleHint()
566
    // function will in turn query QPlatformTheme::defaultThemeHint() if there
567
    // is no custom value.
568
376k
    switch (hint) {
569
0
    case QPlatformTheme::CursorFlashTime:
570
0
        return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::CursorFlashTime);
571
0
    case QPlatformTheme::KeyboardInputInterval:
572
0
        return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::KeyboardInputInterval);
573
0
    case QPlatformTheme::KeyboardAutoRepeatRate:
574
0
        return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::KeyboardAutoRepeatRate);
575
0
    case QPlatformTheme::MouseDoubleClickInterval:
576
0
        return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::MouseDoubleClickInterval);
577
0
    case QPlatformTheme::StartDragDistance:
578
0
        return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::StartDragDistance);
579
0
    case QPlatformTheme::StartDragTime:
580
0
        return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::StartDragTime);
581
0
    case QPlatformTheme::StartDragVelocity:
582
0
        return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::StartDragVelocity);
583
0
    case QPlatformTheme::PasswordMaskDelay:
584
0
        return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::PasswordMaskDelay);
585
0
    case QPlatformTheme::PasswordMaskCharacter:
586
0
        return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::PasswordMaskCharacter);
587
0
    case QPlatformTheme::MousePressAndHoldInterval:
588
0
        return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::MousePressAndHoldInterval);
589
0
    case QPlatformTheme::ItemViewActivateItemOnSingleClick:
590
0
        return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::ItemViewActivateItemOnSingleClick);
591
0
    case QPlatformTheme::UiEffects:
592
0
        return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::UiEffects);
593
94.1k
    case QPlatformTheme::ShowShortcutsInContextMenus:
594
94.1k
        return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::ShowShortcutsInContextMenus);
595
0
    case QPlatformTheme::SetFocusOnTouchRelease:
596
0
        return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::SetFocusOnTouchRelease);
597
0
    case QPlatformTheme::FlickStartDistance:
598
0
        return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::FlickStartDistance);
599
0
    case QPlatformTheme::FlickMaximumVelocity:
600
0
        return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::FlickMaximumVelocity);
601
0
    case QPlatformTheme::FlickDeceleration:
602
0
        return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::FlickDeceleration);
603
0
    case QPlatformTheme::UnderlineShortcut:
604
0
        return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::UnderlineShortcut);
605
282k
    default:
606
282k
        return QPlatformTheme::defaultThemeHint(hint);
607
376k
    }
608
376k
}
609
610
QVariant QPlatformTheme::defaultThemeHint(ThemeHint hint)
611
470k
{
612
470k
    switch (hint) {
613
0
    case QPlatformTheme::CursorFlashTime:
614
0
        return QVariant(1000);
615
0
    case QPlatformTheme::KeyboardInputInterval:
616
0
        return QVariant(400);
617
0
    case QPlatformTheme::KeyboardAutoRepeatRate:
618
0
        return QVariant(30);
619
0
    case QPlatformTheme::MouseDoubleClickInterval:
620
0
        return QVariant(400);
621
0
    case QPlatformTheme::StartDragDistance:
622
0
        return QVariant(10);
623
0
    case QPlatformTheme::StartDragTime:
624
0
        return QVariant(500);
625
0
    case QPlatformTheme::PasswordMaskDelay:
626
0
        return QVariant(int(0));
627
0
    case QPlatformTheme::PasswordMaskCharacter:
628
0
        return QVariant(QChar(u'\x25CF'));
629
0
    case QPlatformTheme::StartDragVelocity:
630
0
        return QVariant(int(0)); // no limit
631
0
    case QPlatformTheme::UseFullScreenForPopupMenu:
632
0
        return QVariant(false);
633
0
    case QPlatformTheme::WindowAutoPlacement:
634
0
        return QVariant(false);
635
0
    case QPlatformTheme::DialogButtonBoxLayout:
636
0
        return QVariant(int(0));
637
0
    case QPlatformTheme::DialogButtonBoxButtonsHaveIcons:
638
0
        return QVariant(false);
639
0
    case QPlatformTheme::ItemViewActivateItemOnSingleClick:
640
0
        return QVariant(false);
641
0
    case QPlatformTheme::ToolButtonStyle:
642
0
        return QVariant(int(Qt::ToolButtonIconOnly));
643
0
    case QPlatformTheme::ToolBarIconSize:
644
0
        return QVariant(int(0));
645
0
    case QPlatformTheme::SystemIconThemeName:
646
0
    case QPlatformTheme::SystemIconFallbackThemeName:
647
0
        return QVariant(QString());
648
0
    case QPlatformTheme::IconThemeSearchPaths:
649
0
        return QVariant(QStringList());
650
0
    case QPlatformTheme::IconFallbackSearchPaths:
651
0
        return QVariant(QStringList());
652
0
    case QPlatformTheme::StyleNames:
653
0
        return QVariant(QStringList());
654
94.1k
    case QPlatformTheme::ShowShortcutsInContextMenus:
655
94.1k
        return QVariant(true);
656
0
    case TextCursorWidth:
657
0
        return QVariant(1);
658
0
    case DropShadow:
659
0
        return QVariant(false);
660
0
    case MaximumScrollBarDragDistance:
661
0
        return QVariant(-1);
662
0
    case KeyboardScheme:
663
0
        return QVariant(int(WindowsKeyboardScheme));
664
0
    case UiEffects:
665
0
        return QVariant(int(0));
666
0
    case SpellCheckUnderlineStyle:
667
0
        return QVariant(int(QTextCharFormat::WaveUnderline));
668
0
    case TabFocusBehavior:
669
0
        return QVariant(int(Qt::TabFocusAllControls));
670
0
    case IconPixmapSizes:
671
0
        return QVariant::fromValue(QList<int>());
672
0
    case DialogSnapToDefaultButton:
673
0
    case ContextMenuOnMouseRelease:
674
0
        return QVariant(false);
675
0
    case MousePressAndHoldInterval:
676
0
        return QVariant(800);
677
188k
    case MouseDoubleClickDistance:
678
188k
        {
679
188k
            bool ok = false;
680
188k
            const int dist = qEnvironmentVariableIntValue("QT_DBL_CLICK_DIST", &ok);
681
188k
            return QVariant(ok ? dist : 5);
682
0
        }
683
0
    case WheelScrollLines:
684
0
        return QVariant(3);
685
94.1k
    case TouchDoubleTapDistance:
686
94.1k
        {
687
94.1k
            bool ok = false;
688
94.1k
            int dist = qEnvironmentVariableIntValue("QT_DBL_TAP_DIST", &ok);
689
94.1k
            if (!ok)
690
94.1k
                dist = defaultThemeHint(MouseDoubleClickDistance).toInt(&ok) * 2;
691
94.1k
            return QVariant(ok ? dist : 10);
692
0
        }
693
0
    case MouseQuickSelectionThreshold:
694
0
        return QVariant(10);
695
0
    case InteractiveResizeAcrossScreens:
696
0
        return true;
697
0
    case ShowDirectoriesFirst:
698
0
        return true;
699
0
    case PreselectFirstFileInDirectory:
700
0
        return false;
701
0
    case ButtonPressKeys:
702
0
        return QVariant::fromValue(QList<Qt::Key>({ Qt::Key_Space, Qt::Key_Select }));
703
0
    case SetFocusOnTouchRelease:
704
0
        return false;
705
0
    case FlickStartDistance:
706
0
        return QVariant(15);
707
0
    case FlickMaximumVelocity:
708
0
        return QVariant(2500);
709
0
    case FlickDeceleration:
710
0
        return QVariant(1500);
711
0
    case MenuBarFocusOnAltPressRelease:
712
0
        return false;
713
0
    case MouseCursorTheme:
714
0
        return QVariant(QString());
715
0
    case MouseCursorSize:
716
0
        return QVariant(QSize(16, 16));
717
0
    case UnderlineShortcut:
718
0
        return true;
719
94.1k
    case ShowIconsInMenus:
720
94.1k
        return true;
721
0
    case PreferFileIconFromTheme:
722
0
        return false;
723
0
    case MenuSelectionWraps:
724
0
        return true;
725
0
    case ScrollSingleStepDistance:
726
0
        return 20;
727
0
    case MnemonicsEnabled:
728
0
        return true;
729
470k
    }
730
731
0
    return QVariant();
732
470k
}
733
734
QPlatformMenuItem *QPlatformTheme::createPlatformMenuItem() const
735
0
{
736
0
    return nullptr;
737
0
}
738
739
QPlatformMenu *QPlatformTheme::createPlatformMenu() const
740
0
{
741
0
    return nullptr;
742
0
}
743
744
QPlatformMenuBar *QPlatformTheme::createPlatformMenuBar() const
745
0
{
746
0
    return nullptr;
747
0
}
748
749
#ifndef QT_NO_SYSTEMTRAYICON
750
/*!
751
   Factory function for QSystemTrayIcon. This function will return 0 if the platform
752
   integration does not support creating any system tray icon.
753
*/
754
QPlatformSystemTrayIcon *QPlatformTheme::createPlatformSystemTrayIcon() const
755
0
{
756
0
    return nullptr;
757
0
}
758
#endif
759
760
/*!
761
   Factory function for the QIconEngine used by QIcon::fromTheme(). By default this
762
   function returns a QIconLoaderEngine, but subclasses can reimplement it to
763
   provide their own.
764
765
   It is especially useful to benefit from some platform specific facilities or
766
   optimizations like an inter-process cache in systems mostly built with Qt.
767
768
   \since 5.1
769
*/
770
QIconEngine *QPlatformTheme::createIconEngine(const QString &iconName) const
771
0
{
772
0
    return new QIconLoaderEngine(iconName);
773
0
}
774
775
#if QT_CONFIG(shortcut)
776
// mixed-mode predicate: all of these overloads are actually needed (but not all for every compiler)
777
struct ByStandardKey {
778
    typedef bool result_type;
779
780
    bool operator()(QKeySequence::StandardKey lhs, QKeySequence::StandardKey rhs) const
781
0
    { return lhs < rhs; }
782
783
    bool operator()(const QKeyBinding& lhs, const QKeyBinding& rhs) const
784
0
    { return operator()(lhs.standardKey, rhs.standardKey); }
785
786
    bool operator()(QKeySequence::StandardKey lhs, const QKeyBinding& rhs) const
787
0
    { return operator()(lhs, rhs.standardKey); }
788
789
    bool operator()(const QKeyBinding& lhs, QKeySequence::StandardKey rhs) const
790
0
    { return operator()(lhs.standardKey, rhs); }
791
};
792
793
/*!
794
   Returns the key sequence that should be used for a standard action.
795
796
  \since 5.2
797
 */
798
QList<QKeySequence> QPlatformTheme::keyBindings(QKeySequence::StandardKey key) const
799
0
{
800
0
    const uint platform = QPlatformThemePrivate::currentKeyPlatforms();
801
0
    QList <QKeySequence> list;
802
803
0
    std::pair<const QKeyBinding *, const QKeyBinding *> range =
804
0
        std::equal_range(QPlatformThemePrivate::keyBindings,
805
0
                         QPlatformThemePrivate::keyBindings + QPlatformThemePrivate::numberOfKeyBindings,
806
0
                         key, ByStandardKey());
807
808
0
    for (const QKeyBinding *it = range.first; it < range.second; ++it) {
809
0
        if (!(it->platform & platform))
810
0
            continue;
811
812
0
        uint shortcut = it->shortcut.toCombined();
813
814
0
        if (it->priority > 0)
815
0
            list.prepend(QKeySequence(shortcut));
816
0
        else
817
0
            list.append(QKeySequence(shortcut));
818
0
    }
819
820
0
    return list;
821
0
}
822
#endif
823
824
/*!
825
   Returns the text of a standard \a button.
826
827
  \since 5.3
828
  \sa QPlatformDialogHelper::StandardButton
829
 */
830
831
QString QPlatformTheme::standardButtonText(int button) const
832
0
{
833
0
    return QPlatformTheme::defaultStandardButtonText(button);
834
0
}
835
836
#if QT_CONFIG(shortcut)
837
/*!
838
   Returns the mnemonic that should be used for a standard \a button.
839
840
  \since 5.9
841
  \sa QPlatformDialogHelper::StandardButton
842
 */
843
844
QKeySequence QPlatformTheme::standardButtonShortcut(int button) const
845
0
{
846
0
    Q_UNUSED(button);
847
0
    return QKeySequence();
848
0
}
849
#endif // QT_CONFIG(shortcut)
850
851
QString QPlatformTheme::defaultStandardButtonText(int button)
852
0
{
853
0
    switch (button) {
854
0
    case QPlatformDialogHelper::Ok:
855
0
        return QCoreApplication::translate("QPlatformTheme", "OK");
856
0
    case QPlatformDialogHelper::Save:
857
0
        return QCoreApplication::translate("QPlatformTheme", "Save");
858
0
    case QPlatformDialogHelper::SaveAll:
859
0
        return QCoreApplication::translate("QPlatformTheme", "Save All");
860
0
    case QPlatformDialogHelper::Open:
861
0
        return QCoreApplication::translate("QPlatformTheme", "Open");
862
0
    case QPlatformDialogHelper::Yes:
863
0
        return QCoreApplication::translate("QPlatformTheme", "&Yes");
864
0
    case QPlatformDialogHelper::YesToAll:
865
0
        return QCoreApplication::translate("QPlatformTheme", "Yes to &All");
866
0
    case QPlatformDialogHelper::No:
867
0
        return QCoreApplication::translate("QPlatformTheme", "&No");
868
0
    case QPlatformDialogHelper::NoToAll:
869
0
        return QCoreApplication::translate("QPlatformTheme", "N&o to All");
870
0
    case QPlatformDialogHelper::Abort:
871
0
        return QCoreApplication::translate("QPlatformTheme", "Abort");
872
0
    case QPlatformDialogHelper::Retry:
873
0
        return QCoreApplication::translate("QPlatformTheme", "Retry");
874
0
    case QPlatformDialogHelper::Ignore:
875
0
        return QCoreApplication::translate("QPlatformTheme", "Ignore");
876
0
    case QPlatformDialogHelper::Close:
877
0
        return QCoreApplication::translate("QPlatformTheme", "Close");
878
0
    case QPlatformDialogHelper::Cancel:
879
0
        return QCoreApplication::translate("QPlatformTheme", "Cancel");
880
0
    case QPlatformDialogHelper::Discard:
881
0
        return QCoreApplication::translate("QPlatformTheme", "Discard");
882
0
    case QPlatformDialogHelper::Help:
883
0
        return QCoreApplication::translate("QPlatformTheme", "Help");
884
0
    case QPlatformDialogHelper::Apply:
885
0
        return QCoreApplication::translate("QPlatformTheme", "Apply");
886
0
    case QPlatformDialogHelper::Reset:
887
0
        return QCoreApplication::translate("QPlatformTheme", "Reset");
888
0
    case QPlatformDialogHelper::RestoreDefaults:
889
0
        return QCoreApplication::translate("QPlatformTheme", "Restore Defaults");
890
0
    default:
891
0
        break;
892
0
    }
893
0
    return QString();
894
0
}
895
896
QString QPlatformTheme::removeMnemonics(const QString &original)
897
0
{
898
0
    const auto mnemonicInParentheses = [](QStringView text) {
899
        /* Format of mnemonics to remove is /\(&[^&]\)/ but accept full-width
900
           forms of ( and ) as equivalent, for cross-platform compatibility with
901
           MS (and consequent behavior of translators, see QTBUG-110829).
902
        */
903
0
        Q_ASSERT(text.size() == 4); // Caller's responsibility.
904
0
        constexpr QChar wideOpen = u'\uff08', wideClose = u'\uff09';
905
0
        if (!text.startsWith(u'(') && !text.startsWith(wideOpen))
906
0
            return false;
907
0
        if (text[1] != u'&' || text[2] == u'&')
908
0
            return false;
909
0
        return text.endsWith(u')') || text.endsWith(wideClose);
910
0
    };
911
0
    QString returnText(original.size(), u'\0');
912
0
    int finalDest = 0;
913
0
    QStringView text(original);
914
0
    while (!text.isEmpty()) {
915
0
        if (text.startsWith(u'&')) {
916
0
            text = text.sliced(1);
917
0
            if (text.isEmpty())
918
0
                break;
919
0
        } else if (text.size() >= 4 && mnemonicInParentheses(text.first(4))) {
920
            // Advance over the matched mnemonic:
921
0
            text = text.sliced(4);
922
            // Also strip any leading space before it:
923
0
            while (finalDest > 0 && returnText.at(finalDest - 1).isSpace())
924
0
                --finalDest;
925
0
            continue;
926
0
        }
927
0
        returnText[finalDest] = text.front();
928
0
        text = text.sliced(1);
929
0
        ++finalDest;
930
0
    }
931
0
    returnText.truncate(finalDest);
932
0
    return returnText;
933
0
}
934
935
unsigned QPlatformThemePrivate::currentKeyPlatforms()
936
0
{
937
0
    const uint keyboardScheme = QGuiApplicationPrivate::platformTheme()->themeHint(QPlatformTheme::KeyboardScheme).toInt();
938
0
    unsigned result = 1u << keyboardScheme;
939
0
#if QT_CONFIG(shortcut)
940
0
    if (keyboardScheme == QPlatformTheme::KdeKeyboardScheme
941
0
        || keyboardScheme == QPlatformTheme::GnomeKeyboardScheme
942
0
        || keyboardScheme == QPlatformTheme::CdeKeyboardScheme)
943
0
        result |= KB_X11;
944
0
#endif
945
0
    return result;
946
0
}
947
948
QString QPlatformTheme::name() const
949
0
{
950
0
    return d_func()->name;
951
0
}
952
953
QT_END_NAMESPACE
954
955
#include "moc_qplatformtheme.cpp"