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