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