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