9#include <QtCore/QVariant>
10#include <QtCore/QStringList>
11#include <QtCore/qfileinfo.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>
25
26
27
28
29
30
31
32
33
34
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
170#if QT_CONFIG(shortcut)
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),
185const QKeyBinding QPlatformThemePrivate::keyBindings[] = {
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},
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},
207 {QKeySequence::Cut, 0, Qt::Key_F20, KB_X11},
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},
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},
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},
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},
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 },
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},
308 {QKeySequence::MoveToEndOfBlock, 0, Qt::META | Qt::Key_E, KB_Mac},
309 {QKeySequence::MoveToEndOfBlock, 1, Qt::ALT | Qt::Key_Down, KB_Mac},
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},
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},
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},
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}
374const uint QPlatformThemePrivate::numberOfKeyBindings =
sizeof(QPlatformThemePrivate::keyBindings)/(
sizeof(QKeyBinding));
377QPlatformThemePrivate::QPlatformThemePrivate()
378 : systemPalette(
nullptr)
381QPlatformThemePrivate::~QPlatformThemePrivate()
384 delete systemPalette;
389 auto theme = QGuiApplicationPrivate::platformTheme();
390 const bool darkAppearance = theme
391 ? theme->colorScheme() == Qt::ColorScheme::Dark
393 const QColor windowText = darkAppearance ? QColor(240, 240, 240) : Qt::black;
394 const QColor backGround = darkAppearance ? QColor(50, 50, 50) : QColor(239, 239, 239);
395 const QColor light = backGround.lighter(150);
396 const QColor mid = (backGround.darker(130));
397 const QColor midLight = mid.lighter(110);
398 const QColor base = darkAppearance ? backGround.darker(140) : Qt::white;
399 const QColor disabledBase(backGround);
400 const QColor dark = backGround.darker(150);
401 const QColor darkDisabled = QColor(209, 209, 209).darker(110);
402 const QColor text = darkAppearance ? windowText : Qt::black;
403 const QColor highlight = QColor(48, 140, 198);
404 const QColor hightlightedText = darkAppearance ? windowText : Qt::white;
405 const QColor disabledText = darkAppearance ? QColor(130, 130, 130) : QColor(190, 190, 190);
406 const QColor button = backGround;
407 const QColor shadow = dark.darker(135);
408 const QColor disabledShadow = shadow.lighter(150);
409 const QColor disabledHighlight(145, 145, 145);
410 QColor placeholder = text;
411 placeholder.setAlpha(128);
413 QPalette fusionPalette(windowText, backGround, light, dark, mid, text, base);
414 fusionPalette.setBrush(QPalette::Midlight, midLight);
415 fusionPalette.setBrush(QPalette::Button, button);
416 fusionPalette.setBrush(QPalette::Shadow, shadow);
417 fusionPalette.setBrush(QPalette::HighlightedText, hightlightedText);
419 fusionPalette.setBrush(QPalette::Disabled, QPalette::Text, disabledText);
420 fusionPalette.setBrush(QPalette::Disabled, QPalette::WindowText, disabledText);
421 fusionPalette.setBrush(QPalette::Disabled, QPalette::ButtonText, disabledText);
422 fusionPalette.setBrush(QPalette::Disabled, QPalette::Base, disabledBase);
423 fusionPalette.setBrush(QPalette::Disabled, QPalette::Dark, darkDisabled);
424 fusionPalette.setBrush(QPalette::Disabled, QPalette::Shadow, disabledShadow);
426 fusionPalette.setBrush(QPalette::Active, QPalette::Highlight, highlight);
427 fusionPalette.setBrush(QPalette::Inactive, QPalette::Highlight, highlight);
428 fusionPalette.setBrush(QPalette::Disabled, QPalette::Highlight, disabledHighlight);
430 fusionPalette.setBrush(QPalette::Active, QPalette::Accent, highlight);
431 fusionPalette.setBrush(QPalette::Inactive, QPalette::Accent, highlight);
432 fusionPalette.setBrush(QPalette::Disabled, QPalette::Accent, disabledHighlight);
434 fusionPalette.setBrush(QPalette::PlaceholderText, placeholder);
438 fusionPalette.setBrush(QPalette::Link, highlight);
440 return fusionPalette;
443void QPlatformThemePrivate::initializeSystemPalette()
445 Q_ASSERT(!systemPalette);
446 systemPalette =
new QPalette(qt_fusionPalette());
449QPlatformTheme::QPlatformTheme()
450 : d_ptr(
new QPlatformThemePrivate)
455QPlatformTheme::QPlatformTheme(QPlatformThemePrivate *priv)
459QPlatformTheme::~QPlatformTheme()
464bool QPlatformTheme::usePlatformNativeDialog(DialogType type)
const
470QPlatformDialogHelper *QPlatformTheme::createPlatformDialogHelper(DialogType type)
const
476Qt::ColorScheme QPlatformTheme::colorScheme()
const
478 return Qt::ColorScheme::Unknown;
481void QPlatformTheme::requestColorScheme(Qt::ColorScheme scheme)
485 if (d->systemPalette) {
486 delete d->systemPalette;
487 d->systemPalette =
nullptr;
491Qt::ContrastPreference QPlatformTheme::contrastPreference()
const
493 return Qt::ContrastPreference::NoPreference;
496Qt::MotionPreference QPlatformTheme::motionPreference()
const
498 return Qt::MotionPreference::NoPreference;
502
503
504
505
506
507
508
509
510const QPalette *QPlatformTheme::palette(Palette type)
const
512 Q_D(
const QPlatformTheme);
513 if (type == QPlatformTheme::SystemPalette) {
514 if (!d->systemPalette)
515 const_cast<QPlatformTheme *>(
this)->d_ptr->initializeSystemPalette();
516 return d->systemPalette;
521const QFont *QPlatformTheme::font(Font type)
const
528
529
530
531
532
533
534QPixmap QPlatformTheme::standardPixmap(StandardPixmap standardPixmap,
const QSizeF &size)
const
536 Q_UNUSED(standardPixmap);
543
544
545
546
547
548
549
550
552QIcon QPlatformTheme::fileIcon(
const QFileInfo &fileInfo, QPlatformTheme::IconOptions iconOptions)
const
555 Q_UNUSED(iconOptions);
560QVariant QPlatformTheme::themeHint(ThemeHint hint)
const
567 case QPlatformTheme::CursorFlashTime:
568 return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::CursorFlashTime);
569 case QPlatformTheme::KeyboardInputInterval:
570 return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::KeyboardInputInterval);
571 case QPlatformTheme::KeyboardAutoRepeatRate:
572 return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::KeyboardAutoRepeatRate);
573 case QPlatformTheme::MouseDoubleClickInterval:
574 return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::MouseDoubleClickInterval);
575 case QPlatformTheme::StartDragDistance:
576 return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::StartDragDistance);
577 case QPlatformTheme::StartDragTime:
578 return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::StartDragTime);
579 case QPlatformTheme::StartDragVelocity:
580 return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::StartDragVelocity);
581 case QPlatformTheme::PasswordMaskDelay:
582 return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::PasswordMaskDelay);
583 case QPlatformTheme::PasswordMaskCharacter:
584 return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::PasswordMaskCharacter);
585 case QPlatformTheme::MousePressAndHoldInterval:
586 return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::MousePressAndHoldInterval);
587 case QPlatformTheme::ItemViewActivateItemOnSingleClick:
588 return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::ItemViewActivateItemOnSingleClick);
589 case QPlatformTheme::UiEffects:
590 return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::UiEffects);
591 case QPlatformTheme::ShowShortcutsInContextMenus:
592 return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::ShowShortcutsInContextMenus);
593 case QPlatformTheme::SetFocusOnTouchRelease:
594 return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::SetFocusOnTouchRelease);
595 case QPlatformTheme::FlickStartDistance:
596 return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::FlickStartDistance);
597 case QPlatformTheme::FlickMaximumVelocity:
598 return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::FlickMaximumVelocity);
599 case QPlatformTheme::FlickDeceleration:
600 return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::FlickDeceleration);
601 case QPlatformTheme::UnderlineShortcut:
602 return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::UnderlineShortcut);
604 return QPlatformTheme::defaultThemeHint(hint);
608QVariant QPlatformTheme::defaultThemeHint(ThemeHint hint)
611 case QPlatformTheme::CursorFlashTime:
612 return QVariant(1000);
613 case QPlatformTheme::KeyboardInputInterval:
614 return QVariant(400);
615 case QPlatformTheme::KeyboardAutoRepeatRate:
617 case QPlatformTheme::MouseDoubleClickInterval:
618 return QVariant(400);
619 case QPlatformTheme::StartDragDistance:
621 case QPlatformTheme::StartDragTime:
622 return QVariant(500);
623 case QPlatformTheme::PasswordMaskDelay:
624 return QVariant(
int(0));
625 case QPlatformTheme::PasswordMaskCharacter:
626 return QVariant(QChar(u'\x25CF'));
627 case QPlatformTheme::StartDragVelocity:
628 return QVariant(
int(0));
629 case QPlatformTheme::UseFullScreenForPopupMenu:
630 return QVariant(
false);
631 case QPlatformTheme::WindowAutoPlacement:
632 return QVariant(
false);
633 case QPlatformTheme::DialogButtonBoxLayout:
634 return QVariant(
int(0));
635 case QPlatformTheme::DialogButtonBoxButtonsHaveIcons:
636 return QVariant(
false);
637 case QPlatformTheme::ItemViewActivateItemOnSingleClick:
638 return QVariant(
false);
639 case QPlatformTheme::ToolButtonStyle:
640 return QVariant(
int(Qt::ToolButtonIconOnly));
641 case QPlatformTheme::ToolBarIconSize:
642 return QVariant(
int(0));
643 case QPlatformTheme::SystemIconThemeName:
644 case QPlatformTheme::SystemIconFallbackThemeName:
645 return QVariant(QString());
646 case QPlatformTheme::IconThemeSearchPaths:
647 return QVariant(QStringList());
648 case QPlatformTheme::IconFallbackSearchPaths:
649 return QVariant(QStringList());
650 case QPlatformTheme::StyleNames:
651 return QVariant(QStringList());
652 case QPlatformTheme::ShowShortcutsInContextMenus:
653 return QVariant(
true);
654 case TextCursorWidth:
657 return QVariant(
false);
658 case MaximumScrollBarDragDistance:
661 return QVariant(
int(WindowsKeyboardScheme));
663 return QVariant(
int(0));
664 case SpellCheckUnderlineStyle:
665 return QVariant(
int(QTextCharFormat::WaveUnderline));
666 case TabFocusBehavior:
667 return QVariant(
int(Qt::TabFocusAllControls));
668 case IconPixmapSizes:
669 return QVariant::fromValue(QList<
int>());
670 case DialogSnapToDefaultButton:
671 case ContextMenuOnMouseRelease:
672 return QVariant(
false);
673 case MousePressAndHoldInterval:
674 return QVariant(800);
675 case MouseDoubleClickDistance:
678 const int dist = qEnvironmentVariableIntValue(
"QT_DBL_CLICK_DIST", &ok);
679 return QVariant(ok ? dist : 5);
681 case WheelScrollLines:
683 case TouchDoubleTapDistance:
686 int dist = qEnvironmentVariableIntValue(
"QT_DBL_TAP_DIST", &ok);
688 dist = defaultThemeHint(MouseDoubleClickDistance).toInt(&ok) * 2;
689 return QVariant(ok ? dist : 10);
691 case MouseQuickSelectionThreshold:
693 case InteractiveResizeAcrossScreens:
695 case ShowDirectoriesFirst:
697 case PreselectFirstFileInDirectory:
699 case ButtonPressKeys:
700 return QVariant::fromValue(QList<Qt::Key>({ Qt::Key_Space, Qt::Key_Select }));
701 case SetFocusOnTouchRelease:
703 case FlickStartDistance:
705 case FlickMaximumVelocity:
706 return QVariant(2500);
707 case FlickDeceleration:
708 return QVariant(1500);
709 case MenuBarFocusOnAltPressRelease:
711 case MouseCursorTheme:
712 return QVariant(QString());
713 case MouseCursorSize:
714 return QVariant(QSize(16, 16));
715 case UnderlineShortcut:
717 case ShowIconsInMenus:
719 case PreferFileIconFromTheme:
721 case MenuSelectionWraps:
723 case ScrollSingleStepDistance:
730QPlatformMenuItem *QPlatformTheme::createPlatformMenuItem()
const
735QPlatformMenu *QPlatformTheme::createPlatformMenu()
const
740QPlatformMenuBar *QPlatformTheme::createPlatformMenuBar()
const
745#ifndef QT_NO_SYSTEMTRAYICON
747
748
749
750QPlatformSystemTrayIcon *QPlatformTheme::createPlatformSystemTrayIcon()
const
757
758
759
760
761
762
763
764
765
766QIconEngine *QPlatformTheme::createIconEngine(
const QString &iconName)
const
768 return new QIconLoaderEngine(iconName);
771#if QT_CONFIG(shortcut)
773struct ByStandardKey {
774 typedef bool result_type;
776 bool operator()(QKeySequence::StandardKey lhs, QKeySequence::StandardKey rhs)
const
777 {
return lhs < rhs; }
779 bool operator()(
const QKeyBinding& lhs,
const QKeyBinding& rhs)
const
780 {
return operator()(lhs.standardKey, rhs.standardKey); }
782 bool operator()(QKeySequence::StandardKey lhs,
const QKeyBinding& rhs)
const
783 {
return operator()(lhs, rhs.standardKey); }
785 bool operator()(
const QKeyBinding& lhs, QKeySequence::StandardKey rhs)
const
786 {
return operator()(lhs.standardKey, rhs); }
790
791
792
793
794QList<QKeySequence> QPlatformTheme::keyBindings(QKeySequence::StandardKey key)
const
796 const uint platform = QPlatformThemePrivate::currentKeyPlatforms();
797 QList <QKeySequence> list;
799 std::pair<
const QKeyBinding *,
const QKeyBinding *> range =
800 std::equal_range(QPlatformThemePrivate::keyBindings,
801 QPlatformThemePrivate::keyBindings + QPlatformThemePrivate::numberOfKeyBindings,
802 key, ByStandardKey());
804 for (
const QKeyBinding *it = range.first; it < range.second; ++it) {
805 if (!(it->platform & platform))
808 uint shortcut = it->shortcut.toCombined();
810 if (it->priority > 0)
811 list.prepend(QKeySequence(shortcut));
813 list.append(QKeySequence(shortcut));
821
822
823
824
825
827QString QPlatformTheme::standardButtonText(
int button)
const
829 return QPlatformTheme::defaultStandardButtonText(button);
832#if QT_CONFIG(shortcut)
834
835
836
837
838
840QKeySequence QPlatformTheme::standardButtonShortcut(
int button)
const
843 return QKeySequence();
847QString QPlatformTheme::defaultStandardButtonText(
int button)
850 case QPlatformDialogHelper::Ok:
851 return QCoreApplication::translate(
"QPlatformTheme",
"OK");
852 case QPlatformDialogHelper::Save:
853 return QCoreApplication::translate(
"QPlatformTheme",
"Save");
854 case QPlatformDialogHelper::SaveAll:
855 return QCoreApplication::translate(
"QPlatformTheme",
"Save All");
856 case QPlatformDialogHelper::Open:
857 return QCoreApplication::translate(
"QPlatformTheme",
"Open");
858 case QPlatformDialogHelper::Yes:
859 return QCoreApplication::translate(
"QPlatformTheme",
"&Yes");
860 case QPlatformDialogHelper::YesToAll:
861 return QCoreApplication::translate(
"QPlatformTheme",
"Yes to &All");
862 case QPlatformDialogHelper::No:
863 return QCoreApplication::translate(
"QPlatformTheme",
"&No");
864 case QPlatformDialogHelper::NoToAll:
865 return QCoreApplication::translate(
"QPlatformTheme",
"N&o to All");
866 case QPlatformDialogHelper::Abort:
867 return QCoreApplication::translate(
"QPlatformTheme",
"Abort");
868 case QPlatformDialogHelper::Retry:
869 return QCoreApplication::translate(
"QPlatformTheme",
"Retry");
870 case QPlatformDialogHelper::Ignore:
871 return QCoreApplication::translate(
"QPlatformTheme",
"Ignore");
872 case QPlatformDialogHelper::Close:
873 return QCoreApplication::translate(
"QPlatformTheme",
"Close");
874 case QPlatformDialogHelper::Cancel:
875 return QCoreApplication::translate(
"QPlatformTheme",
"Cancel");
876 case QPlatformDialogHelper::Discard:
877 return QCoreApplication::translate(
"QPlatformTheme",
"Discard");
878 case QPlatformDialogHelper::Help:
879 return QCoreApplication::translate(
"QPlatformTheme",
"Help");
880 case QPlatformDialogHelper::Apply:
881 return QCoreApplication::translate(
"QPlatformTheme",
"Apply");
882 case QPlatformDialogHelper::Reset:
883 return QCoreApplication::translate(
"QPlatformTheme",
"Reset");
884 case QPlatformDialogHelper::RestoreDefaults:
885 return QCoreApplication::translate(
"QPlatformTheme",
"Restore Defaults");
892QString QPlatformTheme::removeMnemonics(
const QString &original)
894 const auto mnemonicInParentheses = [](QStringView text) {
896
897
898
899 Q_ASSERT(text.size() == 4);
900 constexpr QChar wideOpen = u'\uff08', wideClose = u'\uff09';
901 if (!text.startsWith(u'(') && !text.startsWith(wideOpen))
903 if (text[1] != u'&' || text[2] == u'&')
905 return text.endsWith(u')') || text.endsWith(wideClose);
907 QString returnText(original.size(), u'\0');
909 QStringView text(original);
910 while (!text.isEmpty()) {
911 if (text.startsWith(u'&')) {
912 text = text.sliced(1);
915 }
else if (text.size() >= 4 && mnemonicInParentheses(text.first(4))) {
917 text = text.sliced(4);
919 while (finalDest > 0 && returnText.at(finalDest - 1).isSpace())
923 returnText[finalDest] = text.front();
924 text = text.sliced(1);
927 returnText.truncate(finalDest);
931unsigned QPlatformThemePrivate::currentKeyPlatforms()
933 const uint keyboardScheme = QGuiApplicationPrivate::platformTheme()->themeHint(QPlatformTheme::KeyboardScheme).toInt();
934 unsigned result = 1u << keyboardScheme;
935#if QT_CONFIG(shortcut)
936 if (keyboardScheme == QPlatformTheme::KdeKeyboardScheme
937 || keyboardScheme == QPlatformTheme::GnomeKeyboardScheme
938 || keyboardScheme == QPlatformTheme::CdeKeyboardScheme)
944QString QPlatformTheme::name()
const
946 return d_func()->name;
951#include "moc_qplatformtheme.cpp"
The QPalette class contains color groups for each widget state.