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
168
169
172#if QT_CONFIG(shortcut)
178 KB_Win = (1 << QPlatformTheme::WindowsKeyboardScheme),
179 KB_Mac = (1 << QPlatformTheme::MacKeyboardScheme),
180 KB_X11 = (1 << QPlatformTheme::X11KeyboardScheme),
181 KB_KDE = (1 << QPlatformTheme::KdeKeyboardScheme),
182 KB_Gnome = (1 << QPlatformTheme::GnomeKeyboardScheme),
183 KB_CDE = (1 << QPlatformTheme::CdeKeyboardScheme),
187const QKeyBinding QPlatformThemePrivate::keyBindings[] = {
189 {QKeySequence::HelpContents, 1, Qt::CTRL | Qt::Key_Question, KB_Mac},
190 {QKeySequence::HelpContents, 0, Qt::Key_F1, KB_Win | KB_X11},
191 {QKeySequence::HelpContents, 0, Qt::Key_Help, KB_All},
192 {QKeySequence::WhatsThis, 1, Qt::SHIFT | Qt::Key_F1, KB_All},
193 {QKeySequence::Open, 1, Qt::CTRL | Qt::Key_O, KB_All},
194 {QKeySequence::Open, 0, Qt::Key_Open, KB_All},
195 {QKeySequence::Close, 0, Qt::CTRL | Qt::Key_F4, KB_Mac},
196 {QKeySequence::Close, 1, Qt::CTRL | Qt::Key_F4, KB_Win},
197 {QKeySequence::Close, 1, Qt::CTRL | Qt::Key_W, KB_Mac},
198 {QKeySequence::Close, 0, Qt::CTRL | Qt::Key_W, KB_Win | KB_X11},
199 {QKeySequence::Close, 0, Qt::Key_Close, KB_All},
200 {QKeySequence::Save, 1, Qt::CTRL | Qt::Key_S, KB_All},
201 {QKeySequence::Save, 0, Qt::Key_Save, KB_All},
202 {QKeySequence::New, 1, Qt::CTRL | Qt::Key_N, KB_All},
203 {QKeySequence::New, 0, Qt::Key_New, KB_All},
204 {QKeySequence::Delete, 0, Qt::CTRL | Qt::Key_D, KB_X11},
205 {QKeySequence::Delete, 1, Qt::Key_Delete, KB_All},
206 {QKeySequence::Delete, 0, Qt::META | Qt::Key_D, KB_Mac},
207 {QKeySequence::Cut, 1, Qt::CTRL | Qt::Key_X, KB_All},
208 {QKeySequence::Cut, 0, Qt::SHIFT | Qt::Key_Delete, KB_Win | KB_X11},
209 {QKeySequence::Cut, 0, Qt::Key_F20, KB_X11},
210 {QKeySequence::Cut, 0, Qt::META | Qt::Key_K, KB_Mac},
211 {QKeySequence::Cut, 0, Qt::Key_Cut, KB_All},
212 {QKeySequence::Copy, 0, Qt::CTRL | Qt::Key_Insert, KB_X11 | KB_Win},
213 {QKeySequence::Copy, 1, Qt::CTRL | Qt::Key_C, KB_All},
214 {QKeySequence::Copy, 0, Qt::Key_F16, KB_X11},
215 {QKeySequence::Copy, 0, Qt::Key_Copy, KB_All},
216 {QKeySequence::Paste, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Insert, KB_X11},
217 {QKeySequence::Paste, 1, Qt::CTRL | Qt::Key_V, KB_All},
218 {QKeySequence::Paste, 0, Qt::SHIFT | Qt::Key_Insert, KB_Win | KB_X11},
219 {QKeySequence::Paste, 0, Qt::Key_F18, KB_X11},
220 {QKeySequence::Paste, 0, Qt::META | Qt::Key_Y, KB_Mac},
221 {QKeySequence::Paste, 0, Qt::Key_Paste, KB_All},
222 {QKeySequence::Undo, 0, Qt::ALT | Qt::Key_Backspace, KB_Win},
223 {QKeySequence::Undo, 1, Qt::CTRL | Qt::Key_Z, KB_All},
224 {QKeySequence::Undo, 0, Qt::Key_F14, KB_X11},
225 {QKeySequence::Undo, 0, Qt::Key_Undo, KB_All},
226 {QKeySequence::Redo, 0, Qt::ALT | Qt::SHIFT | Qt::Key_Backspace,KB_Win},
227 {QKeySequence::Redo, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Z, KB_Mac},
228 {QKeySequence::Redo, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Z, KB_Win | KB_X11},
229 {QKeySequence::Redo, 1, Qt::CTRL | Qt::Key_Y, KB_Win},
230 {QKeySequence::Redo, 0, Qt::Key_Redo, KB_All},
231 {QKeySequence::Back, 1, Qt::ALT | Qt::Key_Left, KB_Win | KB_X11},
232 {QKeySequence::Back, 0, Qt::CTRL | Qt::Key_Left, KB_Mac},
233 {QKeySequence::Back, 1, Qt::CTRL | Qt::Key_BracketLeft, KB_Mac},
234 {QKeySequence::Back, 0, Qt::Key_Backspace, KB_Win},
235 {QKeySequence::Back, 0, Qt::Key_Back, KB_All},
236 {QKeySequence::Forward, 1, Qt::ALT | Qt::Key_Right, KB_Win | KB_X11},
237 {QKeySequence::Forward, 0, Qt::CTRL | Qt::Key_Right, KB_Mac},
238 {QKeySequence::Forward, 1, Qt::CTRL | Qt::Key_BracketRight, KB_Mac},
239 {QKeySequence::Forward, 0, Qt::SHIFT | Qt::Key_Backspace, KB_Win},
240 {QKeySequence::Forward, 0, Qt::Key_Forward, KB_All},
241 {QKeySequence::Refresh, 1, Qt::CTRL | Qt::Key_R, KB_Gnome | KB_Mac},
242 {QKeySequence::Refresh, 0, Qt::Key_F5, KB_Win | KB_X11},
243 {QKeySequence::Refresh, 0, Qt::Key_Refresh, KB_All},
244 {QKeySequence::ZoomIn, 1, Qt::CTRL | Qt::Key_Plus, KB_All},
245 {QKeySequence::ZoomIn, 0, Qt::Key_ZoomIn, KB_All},
246 {QKeySequence::ZoomOut, 1, Qt::CTRL | Qt::Key_Minus, KB_All},
247 {QKeySequence::ZoomOut, 0, Qt::Key_ZoomOut, KB_All},
248 {QKeySequence::Print, 1, Qt::CTRL | Qt::Key_P, KB_All},
249 {QKeySequence::AddTab, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_N, KB_KDE},
250 {QKeySequence::AddTab, 0, Qt::CTRL | Qt::Key_T, KB_All},
251 {QKeySequence::NextChild, 0, Qt::CTRL | Qt::Key_F6, KB_Win},
252 {QKeySequence::NextChild, 0, Qt::CTRL | Qt::Key_Tab, KB_Mac},
253 {QKeySequence::NextChild, 1, Qt::CTRL | Qt::Key_Tab, KB_Win | KB_X11},
254 {QKeySequence::NextChild, 1, Qt::CTRL | Qt::Key_BraceRight, KB_Mac},
255 {QKeySequence::NextChild, 0, Qt::CTRL | Qt::Key_Comma, KB_KDE},
256 {QKeySequence::NextChild, 0, Qt::Key_Forward, KB_All},
257 {QKeySequence::PreviousChild, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_F6, KB_Win},
258 {QKeySequence::PreviousChild, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Backtab, KB_Mac },
259 {QKeySequence::PreviousChild, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_Backtab, KB_Win | KB_X11},
260 {QKeySequence::PreviousChild, 1, Qt::CTRL | Qt::Key_BraceLeft, KB_Mac},
261 {QKeySequence::PreviousChild, 0, Qt::CTRL | Qt::Key_Period, KB_KDE},
262 {QKeySequence::PreviousChild, 0, Qt::Key_Back, KB_All},
263 {QKeySequence::Find, 0, Qt::CTRL | Qt::Key_F, KB_All},
264 {QKeySequence::Find, 0, Qt::Key_Find, KB_All},
265 {QKeySequence::FindNext, 0, Qt::CTRL | Qt::Key_G, KB_Win},
266 {QKeySequence::FindNext, 1, Qt::CTRL | Qt::Key_G, KB_Gnome | KB_Mac},
267 {QKeySequence::FindNext, 1, Qt::Key_F3, KB_Win},
268 {QKeySequence::FindNext, 0, Qt::Key_F3, KB_X11},
269 {QKeySequence::FindPrevious, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_G, KB_Win},
270 {QKeySequence::FindPrevious, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_G, KB_Gnome | KB_Mac},
271 {QKeySequence::FindPrevious, 1, Qt::SHIFT | Qt::Key_F3, KB_Win},
272 {QKeySequence::FindPrevious, 0, Qt::SHIFT | Qt::Key_F3, KB_X11},
273 {QKeySequence::Replace, 0, Qt::CTRL | Qt::Key_R, KB_KDE},
274 {QKeySequence::Replace, 0, Qt::CTRL | Qt::Key_H, KB_Gnome},
275 {QKeySequence::Replace, 0, Qt::CTRL | Qt::Key_H, KB_Win},
276 {QKeySequence::SelectAll, 1, Qt::CTRL | Qt::Key_A, KB_All},
277 {QKeySequence::Bold, 1, Qt::CTRL | Qt::Key_B, KB_All},
278 {QKeySequence::Italic, 0, Qt::CTRL | Qt::Key_I, KB_All},
279 {QKeySequence::Underline, 1, Qt::CTRL | Qt::Key_U, KB_All},
280 {QKeySequence::MoveToNextChar, 1, Qt::Key_Right, KB_All},
281 {QKeySequence::MoveToNextChar, 0, Qt::META | Qt::Key_F, KB_Mac},
282 {QKeySequence::MoveToPreviousChar, 1, Qt::Key_Left, KB_All},
283 {QKeySequence::MoveToPreviousChar, 0, Qt::META | Qt::Key_B, KB_Mac},
284 {QKeySequence::MoveToNextWord, 0, Qt::ALT | Qt::Key_Right, KB_Mac},
285 {QKeySequence::MoveToNextWord, 0, Qt::CTRL | Qt::Key_Right, KB_Win | KB_X11},
286 {QKeySequence::MoveToPreviousWord, 0, Qt::ALT | Qt::Key_Left, KB_Mac},
287 {QKeySequence::MoveToPreviousWord, 0, Qt::CTRL | Qt::Key_Left, KB_Win | KB_X11},
288 {QKeySequence::MoveToNextLine, 1, Qt::Key_Down, KB_All},
289 {QKeySequence::MoveToNextLine, 0, Qt::META | Qt::Key_N, KB_Mac},
290 {QKeySequence::MoveToPreviousLine, 1, Qt::Key_Up, KB_All},
291 {QKeySequence::MoveToPreviousLine, 0, Qt::META | Qt::Key_P, KB_Mac},
292 {QKeySequence::MoveToNextPage, 0, Qt::META | Qt::Key_PageDown, KB_Mac},
293 {QKeySequence::MoveToNextPage, 0, Qt::META | Qt::Key_Down, KB_Mac},
294 {QKeySequence::MoveToNextPage, 0, Qt::META | Qt::Key_V, KB_Mac},
295 {QKeySequence::MoveToNextPage, 0, Qt::ALT | Qt::Key_PageDown, KB_Mac },
296 {QKeySequence::MoveToNextPage, 1, Qt::Key_PageDown, KB_All},
297 {QKeySequence::MoveToPreviousPage, 0, Qt::META | Qt::Key_PageUp, KB_Mac},
298 {QKeySequence::MoveToPreviousPage, 0, Qt::META | Qt::Key_Up, KB_Mac},
299 {QKeySequence::MoveToPreviousPage, 0, Qt::ALT | Qt::Key_PageUp, KB_Mac },
300 {QKeySequence::MoveToPreviousPage, 1, Qt::Key_PageUp, KB_All},
301 {QKeySequence::MoveToStartOfLine, 0, Qt::META | Qt::Key_Left, KB_Mac},
302 {QKeySequence::MoveToStartOfLine, 0, Qt::CTRL | Qt::Key_Left, KB_Mac },
303 {QKeySequence::MoveToStartOfLine, 0, Qt::Key_Home, KB_Win | KB_X11},
304 {QKeySequence::MoveToEndOfLine, 0, Qt::META | Qt::Key_Right, KB_Mac},
305 {QKeySequence::MoveToEndOfLine, 0, Qt::CTRL | Qt::Key_Right, KB_Mac },
306 {QKeySequence::MoveToEndOfLine, 0, Qt::Key_End, KB_Win | KB_X11},
307 {QKeySequence::MoveToEndOfLine, 0, Qt::CTRL | Qt::Key_E, KB_X11},
308 {QKeySequence::MoveToStartOfBlock, 0, Qt::META | Qt::Key_A, KB_Mac},
309 {QKeySequence::MoveToStartOfBlock, 1, Qt::ALT | Qt::Key_Up, KB_Mac},
310 {QKeySequence::MoveToEndOfBlock, 0, Qt::META | Qt::Key_E, KB_Mac},
311 {QKeySequence::MoveToEndOfBlock, 1, Qt::ALT | Qt::Key_Down, KB_Mac},
312 {QKeySequence::MoveToStartOfDocument, 1, Qt::CTRL | Qt::Key_Up, KB_Mac},
313 {QKeySequence::MoveToStartOfDocument, 0, Qt::CTRL | Qt::Key_Home, KB_Win | KB_X11},
314 {QKeySequence::MoveToStartOfDocument, 0, Qt::Key_Home, KB_Mac},
315 {QKeySequence::MoveToEndOfDocument, 1, Qt::CTRL | Qt::Key_Down, KB_Mac},
316 {QKeySequence::MoveToEndOfDocument, 0, Qt::CTRL | Qt::Key_End, KB_Win | KB_X11},
317 {QKeySequence::MoveToEndOfDocument, 0, Qt::Key_End, KB_Mac},
318 {QKeySequence::SelectNextChar, 0, Qt::SHIFT | Qt::Key_Right, KB_All},
319 {QKeySequence::SelectPreviousChar, 0, Qt::SHIFT | Qt::Key_Left, KB_All},
320 {QKeySequence::SelectNextWord, 0, Qt::ALT | Qt::SHIFT | Qt::Key_Right, KB_Mac},
321 {QKeySequence::SelectNextWord, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Right, KB_Win | KB_X11},
322 {QKeySequence::SelectPreviousWord, 0, Qt::ALT | Qt::SHIFT | Qt::Key_Left, KB_Mac},
323 {QKeySequence::SelectPreviousWord, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Left, KB_Win | KB_X11},
324 {QKeySequence::SelectNextLine, 0, Qt::SHIFT | Qt::Key_Down, KB_All},
325 {QKeySequence::SelectPreviousLine, 0, Qt::SHIFT | Qt::Key_Up, KB_All},
326 {QKeySequence::SelectNextPage, 0, Qt::SHIFT | Qt::Key_PageDown, KB_All},
327 {QKeySequence::SelectPreviousPage, 0, Qt::SHIFT | Qt::Key_PageUp, KB_All},
328 {QKeySequence::SelectStartOfLine, 0, Qt::META | Qt::SHIFT | Qt::Key_Left, KB_Mac},
329 {QKeySequence::SelectStartOfLine, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_Left, KB_Mac },
330 {QKeySequence::SelectStartOfLine, 0, Qt::SHIFT | Qt::Key_Home, KB_Win | KB_X11},
331 {QKeySequence::SelectEndOfLine, 0, Qt::META | Qt::SHIFT | Qt::Key_Right, KB_Mac},
332 {QKeySequence::SelectEndOfLine, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_Right, KB_Mac },
333 {QKeySequence::SelectEndOfLine, 0, Qt::SHIFT | Qt::Key_End, KB_Win | KB_X11},
334 {QKeySequence::SelectStartOfBlock, 1, Qt::ALT | Qt::SHIFT | Qt::Key_Up, KB_Mac},
335 {QKeySequence::SelectStartOfBlock, 0, Qt::META | Qt::SHIFT | Qt::Key_A, KB_Mac},
336 {QKeySequence::SelectEndOfBlock, 1, Qt::ALT | Qt::SHIFT | Qt::Key_Down, KB_Mac},
337 {QKeySequence::SelectEndOfBlock, 0, Qt::META | Qt::SHIFT | Qt::Key_E, KB_Mac},
338 {QKeySequence::SelectStartOfDocument, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_Up, KB_Mac},
339 {QKeySequence::SelectStartOfDocument, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Home, KB_Win | KB_X11},
340 {QKeySequence::SelectStartOfDocument, 0, Qt::SHIFT | Qt::Key_Home, KB_Mac},
341 {QKeySequence::SelectEndOfDocument, 1, Qt::CTRL | Qt::SHIFT | Qt::Key_Down, KB_Mac},
342 {QKeySequence::SelectEndOfDocument, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_End, KB_Win | KB_X11},
343 {QKeySequence::SelectEndOfDocument, 0, Qt::SHIFT | Qt::Key_End, KB_Mac},
344 {QKeySequence::DeleteStartOfWord, 0, Qt::ALT | Qt::Key_Backspace, KB_Mac},
345 {QKeySequence::DeleteStartOfWord, 0, Qt::CTRL | Qt::Key_Backspace, KB_X11 | KB_Win},
346 {QKeySequence::DeleteEndOfWord, 0, Qt::ALT | Qt::Key_Delete, KB_Mac},
347 {QKeySequence::DeleteEndOfWord, 0, Qt::CTRL | Qt::Key_Delete, KB_X11 | KB_Win},
348 {QKeySequence::DeleteEndOfLine, 0, Qt::CTRL | Qt::Key_K, KB_X11},
349 {QKeySequence::InsertParagraphSeparator,0, Qt::Key_Enter, KB_All},
350 {QKeySequence::InsertParagraphSeparator,0, Qt::Key_Return, KB_All},
351 {QKeySequence::InsertLineSeparator, 0, Qt::META | Qt::Key_Enter, KB_Mac},
352 {QKeySequence::InsertLineSeparator, 0, Qt::META | Qt::Key_Return, KB_Mac},
353 {QKeySequence::InsertLineSeparator, 0, Qt::SHIFT | Qt::Key_Enter, KB_All},
354 {QKeySequence::InsertLineSeparator, 0, Qt::SHIFT | Qt::Key_Return, KB_All},
355 {QKeySequence::InsertLineSeparator, 0, Qt::META | Qt::Key_O, KB_Mac},
356 {QKeySequence::SaveAs, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_S, KB_All},
357 {QKeySequence::SaveAs, 0, Qt::SHIFT | Qt::Key_Save, KB_All},
358 {QKeySequence::Preferences, 0, Qt::CTRL | Qt::Key_Comma, KB_Mac},
359 {QKeySequence::Preferences, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_Comma, KB_KDE},
360 {QKeySequence::Preferences, 0, Qt::Key_Settings, KB_Mac | KB_KDE},
361 {QKeySequence::Quit, 0, Qt::CTRL | Qt::Key_Q, KB_X11 | KB_Gnome | KB_KDE | KB_Mac},
362 {QKeySequence::Quit, 0, Qt::Key_Exit, KB_X11 | KB_Gnome | KB_KDE | KB_Mac},
363 {QKeySequence::FullScreen, 1, Qt::META | Qt::CTRL | Qt::Key_F, KB_Mac},
364 {QKeySequence::FullScreen, 0, Qt::ALT | Qt::Key_Enter, KB_Win},
365 {QKeySequence::FullScreen, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_F, KB_KDE},
366 {QKeySequence::FullScreen, 1, Qt::Key_F11, KB_Win | KB_Gnome | KB_KDE},
367 {QKeySequence::Deselect, 0, Qt::CTRL | Qt::SHIFT | Qt::Key_A, KB_X11},
368 {QKeySequence::DeleteCompleteLine, 0, Qt::CTRL | Qt::Key_U, KB_X11},
369 {QKeySequence::Backspace, 1, Qt::Key_Backspace, KB_Mac},
370 {QKeySequence::Backspace, 0, Qt::META | Qt::Key_H, KB_Mac},
371 {QKeySequence::Cancel, 0, Qt::Key_Escape, KB_All},
372 {QKeySequence::Cancel, 0, Qt::CTRL | Qt::Key_Period, KB_Mac},
373 {QKeySequence::Cancel, 0, Qt::Key_Cancel, KB_All}
376const uint QPlatformThemePrivate::numberOfKeyBindings =
sizeof(QPlatformThemePrivate::keyBindings)/(
sizeof(QKeyBinding));
379QPlatformThemePrivate::QPlatformThemePrivate()
380 : systemPalette(
nullptr)
383QPlatformThemePrivate::~QPlatformThemePrivate()
386 delete systemPalette;
391 auto theme = QGuiApplicationPrivate::platformTheme();
392 const bool darkAppearance = theme
393 ? theme->colorScheme() == Qt::ColorScheme::Dark
395 const QColor windowText = darkAppearance ? QColor(240, 240, 240) : Qt::black;
396 const QColor backGround = darkAppearance ? QColor(50, 50, 50) : QColor(239, 239, 239);
397 const QColor light = backGround.lighter(150);
398 const QColor mid = (backGround.darker(130));
399 const QColor midLight = mid.lighter(110);
400 const QColor base = darkAppearance ? backGround.darker(140) : Qt::white;
401 const QColor disabledBase(backGround);
402 const QColor dark = backGround.darker(150);
403 const QColor darkDisabled = QColor(209, 209, 209).darker(110);
404 const QColor text = darkAppearance ? windowText : Qt::black;
405 const QColor highlight = QColor(48, 140, 198);
406 const QColor hightlightedText = darkAppearance ? windowText : Qt::white;
407 const QColor disabledText = darkAppearance ? QColor(130, 130, 130) : QColor(190, 190, 190);
408 const QColor button = backGround;
409 const QColor shadow = dark.darker(135);
410 const QColor disabledShadow = shadow.lighter(150);
411 const QColor disabledHighlight(145, 145, 145);
412 QColor placeholder = text;
413 placeholder.setAlpha(128);
415 QPalette fusionPalette(windowText, backGround, light, dark, mid, text, base);
416 fusionPalette.setBrush(QPalette::Midlight, midLight);
417 fusionPalette.setBrush(QPalette::Button, button);
418 fusionPalette.setBrush(QPalette::Shadow, shadow);
419 fusionPalette.setBrush(QPalette::HighlightedText, hightlightedText);
421 fusionPalette.setBrush(QPalette::Disabled, QPalette::Text, disabledText);
422 fusionPalette.setBrush(QPalette::Disabled, QPalette::WindowText, disabledText);
423 fusionPalette.setBrush(QPalette::Disabled, QPalette::ButtonText, disabledText);
424 fusionPalette.setBrush(QPalette::Disabled, QPalette::Base, disabledBase);
425 fusionPalette.setBrush(QPalette::Disabled, QPalette::Dark, darkDisabled);
426 fusionPalette.setBrush(QPalette::Disabled, QPalette::Shadow, disabledShadow);
428 fusionPalette.setBrush(QPalette::Active, QPalette::Highlight, highlight);
429 fusionPalette.setBrush(QPalette::Inactive, QPalette::Highlight, highlight);
430 fusionPalette.setBrush(QPalette::Disabled, QPalette::Highlight, disabledHighlight);
432 fusionPalette.setBrush(QPalette::Active, QPalette::Accent, highlight);
433 fusionPalette.setBrush(QPalette::Inactive, QPalette::Accent, highlight);
434 fusionPalette.setBrush(QPalette::Disabled, QPalette::Accent, disabledHighlight);
436 fusionPalette.setBrush(QPalette::PlaceholderText, placeholder);
440 fusionPalette.setBrush(QPalette::Link, highlight);
442 return fusionPalette;
445void QPlatformThemePrivate::initializeSystemPalette()
447 Q_ASSERT(!systemPalette);
448 systemPalette =
new QPalette(qt_fusionPalette());
451QPlatformTheme::QPlatformTheme()
452 : d_ptr(
new QPlatformThemePrivate)
457QPlatformTheme::QPlatformTheme(QPlatformThemePrivate *priv)
461QPlatformTheme::~QPlatformTheme()
466bool QPlatformTheme::usePlatformNativeDialog(DialogType type)
const
472QPlatformDialogHelper *QPlatformTheme::createPlatformDialogHelper(DialogType type)
const
478Qt::ColorScheme QPlatformTheme::colorScheme()
const
480 return Qt::ColorScheme::Unknown;
483void QPlatformTheme::requestColorScheme(Qt::ColorScheme scheme)
487 if (d->systemPalette) {
488 delete d->systemPalette;
489 d->systemPalette =
nullptr;
493Qt::ContrastPreference QPlatformTheme::contrastPreference()
const
495 return Qt::ContrastPreference::NoPreference;
498Qt::MotionPreference QPlatformTheme::motionPreference()
const
500 return Qt::MotionPreference::NoPreference;
504
505
506
507
508
509
510
511
512const QPalette *QPlatformTheme::palette(Palette type)
const
514 Q_D(
const QPlatformTheme);
515 if (type == QPlatformTheme::SystemPalette) {
516 if (!d->systemPalette)
517 const_cast<QPlatformTheme *>(
this)->d_ptr->initializeSystemPalette();
518 return d->systemPalette;
523const QFont *QPlatformTheme::font(Font type)
const
530
531
532
533
534
535
536QPixmap QPlatformTheme::standardPixmap(StandardPixmap standardPixmap,
const QSizeF &size)
const
538 Q_UNUSED(standardPixmap);
545
546
547
548
549
550
551
552
554QIcon QPlatformTheme::fileIcon(
const QFileInfo &fileInfo, QPlatformTheme::IconOptions iconOptions)
const
557 Q_UNUSED(iconOptions);
562QVariant QPlatformTheme::themeHint(ThemeHint hint)
const
569 case QPlatformTheme::CursorFlashTime:
570 return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::CursorFlashTime);
571 case QPlatformTheme::KeyboardInputInterval:
572 return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::KeyboardInputInterval);
573 case QPlatformTheme::KeyboardAutoRepeatRate:
574 return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::KeyboardAutoRepeatRate);
575 case QPlatformTheme::MouseDoubleClickInterval:
576 return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::MouseDoubleClickInterval);
577 case QPlatformTheme::StartDragDistance:
578 return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::StartDragDistance);
579 case QPlatformTheme::StartDragTime:
580 return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::StartDragTime);
581 case QPlatformTheme::StartDragVelocity:
582 return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::StartDragVelocity);
583 case QPlatformTheme::PasswordMaskDelay:
584 return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::PasswordMaskDelay);
585 case QPlatformTheme::PasswordMaskCharacter:
586 return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::PasswordMaskCharacter);
587 case QPlatformTheme::MousePressAndHoldInterval:
588 return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::MousePressAndHoldInterval);
589 case QPlatformTheme::ItemViewActivateItemOnSingleClick:
590 return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::ItemViewActivateItemOnSingleClick);
591 case QPlatformTheme::UiEffects:
592 return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::UiEffects);
593 case QPlatformTheme::ShowShortcutsInContextMenus:
594 return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::ShowShortcutsInContextMenus);
595 case QPlatformTheme::SetFocusOnTouchRelease:
596 return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::SetFocusOnTouchRelease);
597 case QPlatformTheme::FlickStartDistance:
598 return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::FlickStartDistance);
599 case QPlatformTheme::FlickMaximumVelocity:
600 return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::FlickMaximumVelocity);
601 case QPlatformTheme::FlickDeceleration:
602 return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::FlickDeceleration);
603 case QPlatformTheme::UnderlineShortcut:
604 return QGuiApplicationPrivate::platformIntegration()->styleHint(QPlatformIntegration::UnderlineShortcut);
606 return QPlatformTheme::defaultThemeHint(hint);
610QVariant QPlatformTheme::defaultThemeHint(ThemeHint hint)
613 case QPlatformTheme::CursorFlashTime:
614 return QVariant(1000);
615 case QPlatformTheme::KeyboardInputInterval:
616 return QVariant(400);
617 case QPlatformTheme::KeyboardAutoRepeatRate:
619 case QPlatformTheme::MouseDoubleClickInterval:
620 return QVariant(400);
621 case QPlatformTheme::StartDragDistance:
623 case QPlatformTheme::StartDragTime:
624 return QVariant(500);
625 case QPlatformTheme::PasswordMaskDelay:
626 return QVariant(
int(0));
627 case QPlatformTheme::PasswordMaskCharacter:
628 return QVariant(QChar(u'\x25CF'));
629 case QPlatformTheme::StartDragVelocity:
630 return QVariant(
int(0));
631 case QPlatformTheme::UseFullScreenForPopupMenu:
632 return QVariant(
false);
633 case QPlatformTheme::WindowAutoPlacement:
634 return QVariant(
false);
635 case QPlatformTheme::DialogButtonBoxLayout:
636 return QVariant(
int(0));
637 case QPlatformTheme::DialogButtonBoxButtonsHaveIcons:
638 return QVariant(
false);
639 case QPlatformTheme::ItemViewActivateItemOnSingleClick:
640 return QVariant(
false);
641 case QPlatformTheme::ToolButtonStyle:
642 return QVariant(
int(Qt::ToolButtonIconOnly));
643 case QPlatformTheme::ToolBarIconSize:
644 return QVariant(
int(0));
645 case QPlatformTheme::SystemIconThemeName:
646 case QPlatformTheme::SystemIconFallbackThemeName:
647 return QVariant(QString());
648 case QPlatformTheme::IconThemeSearchPaths:
649 return QVariant(QStringList());
650 case QPlatformTheme::IconFallbackSearchPaths:
651 return QVariant(QStringList());
652 case QPlatformTheme::StyleNames:
653 return QVariant(QStringList());
654 case QPlatformTheme::ShowShortcutsInContextMenus:
655 return QVariant(
true);
656 case TextCursorWidth:
659 return QVariant(
false);
660 case MaximumScrollBarDragDistance:
663 return QVariant(
int(WindowsKeyboardScheme));
665 return QVariant(
int(0));
666 case SpellCheckUnderlineStyle:
667 return QVariant(
int(QTextCharFormat::WaveUnderline));
668 case TabFocusBehavior:
669 return QVariant(
int(Qt::TabFocusAllControls));
670 case IconPixmapSizes:
671 return QVariant::fromValue(QList<
int>());
672 case DialogSnapToDefaultButton:
673 case ContextMenuOnMouseRelease:
674 return QVariant(
false);
675 case MousePressAndHoldInterval:
676 return QVariant(800);
677 case MouseDoubleClickDistance:
680 const int dist = qEnvironmentVariableIntValue(
"QT_DBL_CLICK_DIST", &ok);
681 return QVariant(ok ? dist : 5);
683 case WheelScrollLines:
685 case TouchDoubleTapDistance:
688 int dist = qEnvironmentVariableIntValue(
"QT_DBL_TAP_DIST", &ok);
690 dist = defaultThemeHint(MouseDoubleClickDistance).toInt(&ok) * 2;
691 return QVariant(ok ? dist : 10);
693 case MouseQuickSelectionThreshold:
695 case InteractiveResizeAcrossScreens:
697 case ShowDirectoriesFirst:
699 case PreselectFirstFileInDirectory:
701 case ButtonPressKeys:
702 return QVariant::fromValue(QList<Qt::Key>({ Qt::Key_Space, Qt::Key_Select }));
703 case SetFocusOnTouchRelease:
705 case FlickStartDistance:
707 case FlickMaximumVelocity:
708 return QVariant(2500);
709 case FlickDeceleration:
710 return QVariant(1500);
711 case MenuBarFocusOnAltPressRelease:
713 case MouseCursorTheme:
714 return QVariant(QString());
715 case MouseCursorSize:
716 return QVariant(QSize(16, 16));
717 case UnderlineShortcut:
719 case ShowIconsInMenus:
721 case PreferFileIconFromTheme:
723 case MenuSelectionWraps:
725 case ScrollSingleStepDistance:
727 case MnemonicsEnabled:
734QPlatformMenuItem *QPlatformTheme::createPlatformMenuItem()
const
739QPlatformMenu *QPlatformTheme::createPlatformMenu()
const
744QPlatformMenuBar *QPlatformTheme::createPlatformMenuBar()
const
749#ifndef QT_NO_SYSTEMTRAYICON
751
752
753
754QPlatformSystemTrayIcon *QPlatformTheme::createPlatformSystemTrayIcon()
const
761
762
763
764
765
766
767
768
769
770QIconEngine *QPlatformTheme::createIconEngine(
const QString &iconName)
const
772 return new QIconLoaderEngine(iconName);
775#if QT_CONFIG(shortcut)
777struct ByStandardKey {
778 typedef bool result_type;
780 bool operator()(QKeySequence::StandardKey lhs, QKeySequence::StandardKey rhs)
const
781 {
return lhs < rhs; }
783 bool operator()(
const QKeyBinding& lhs,
const QKeyBinding& rhs)
const
784 {
return operator()(lhs.standardKey, rhs.standardKey); }
786 bool operator()(QKeySequence::StandardKey lhs,
const QKeyBinding& rhs)
const
787 {
return operator()(lhs, rhs.standardKey); }
789 bool operator()(
const QKeyBinding& lhs, QKeySequence::StandardKey rhs)
const
790 {
return operator()(lhs.standardKey, rhs); }
794
795
796
797
798QList<QKeySequence> QPlatformTheme::keyBindings(QKeySequence::StandardKey key)
const
800 const uint platform = QPlatformThemePrivate::currentKeyPlatforms();
801 QList <QKeySequence> list;
803 std::pair<
const QKeyBinding *,
const QKeyBinding *> range =
804 std::equal_range(QPlatformThemePrivate::keyBindings,
805 QPlatformThemePrivate::keyBindings + QPlatformThemePrivate::numberOfKeyBindings,
806 key, ByStandardKey());
808 for (
const QKeyBinding *it = range.first; it < range.second; ++it) {
809 if (!(it->platform & platform))
812 uint shortcut = it->shortcut.toCombined();
814 if (it->priority > 0)
815 list.prepend(QKeySequence(shortcut));
817 list.append(QKeySequence(shortcut));
825
826
827
828
829
831QString QPlatformTheme::standardButtonText(
int button)
const
833 return QPlatformTheme::defaultStandardButtonText(button);
836#if QT_CONFIG(shortcut)
838
839
840
841
842
844QKeySequence QPlatformTheme::standardButtonShortcut(
int button)
const
847 return QKeySequence();
851QString QPlatformTheme::defaultStandardButtonText(
int button)
854 case QPlatformDialogHelper::Ok:
855 return QCoreApplication::translate(
"QPlatformTheme",
"OK");
856 case QPlatformDialogHelper::Save:
857 return QCoreApplication::translate(
"QPlatformTheme",
"Save");
858 case QPlatformDialogHelper::SaveAll:
859 return QCoreApplication::translate(
"QPlatformTheme",
"Save All");
860 case QPlatformDialogHelper::Open:
861 return QCoreApplication::translate(
"QPlatformTheme",
"Open");
862 case QPlatformDialogHelper::Yes:
863 return QCoreApplication::translate(
"QPlatformTheme",
"&Yes");
864 case QPlatformDialogHelper::YesToAll:
865 return QCoreApplication::translate(
"QPlatformTheme",
"Yes to &All");
866 case QPlatformDialogHelper::No:
867 return QCoreApplication::translate(
"QPlatformTheme",
"&No");
868 case QPlatformDialogHelper::NoToAll:
869 return QCoreApplication::translate(
"QPlatformTheme",
"N&o to All");
870 case QPlatformDialogHelper::Abort:
871 return QCoreApplication::translate(
"QPlatformTheme",
"Abort");
872 case QPlatformDialogHelper::Retry:
873 return QCoreApplication::translate(
"QPlatformTheme",
"Retry");
874 case QPlatformDialogHelper::Ignore:
875 return QCoreApplication::translate(
"QPlatformTheme",
"Ignore");
876 case QPlatformDialogHelper::Close:
877 return QCoreApplication::translate(
"QPlatformTheme",
"Close");
878 case QPlatformDialogHelper::Cancel:
879 return QCoreApplication::translate(
"QPlatformTheme",
"Cancel");
880 case QPlatformDialogHelper::Discard:
881 return QCoreApplication::translate(
"QPlatformTheme",
"Discard");
882 case QPlatformDialogHelper::Help:
883 return QCoreApplication::translate(
"QPlatformTheme",
"Help");
884 case QPlatformDialogHelper::Apply:
885 return QCoreApplication::translate(
"QPlatformTheme",
"Apply");
886 case QPlatformDialogHelper::Reset:
887 return QCoreApplication::translate(
"QPlatformTheme",
"Reset");
888 case QPlatformDialogHelper::RestoreDefaults:
889 return QCoreApplication::translate(
"QPlatformTheme",
"Restore Defaults");
896QString QPlatformTheme::removeMnemonics(
const QString &original)
898 const auto mnemonicInParentheses = [](QStringView text) {
900
901
902
903 Q_ASSERT(text.size() == 4);
904 constexpr QChar wideOpen = u'\uff08', wideClose = u'\uff09';
905 if (!text.startsWith(u'(') && !text.startsWith(wideOpen))
907 if (text[1] != u'&' || text[2] == u'&')
909 return text.endsWith(u')') || text.endsWith(wideClose);
911 QString returnText(original.size(), u'\0');
913 QStringView text(original);
914 while (!text.isEmpty()) {
915 if (text.startsWith(u'&')) {
916 text = text.sliced(1);
919 }
else if (text.size() >= 4 && mnemonicInParentheses(text.first(4))) {
921 text = text.sliced(4);
923 while (finalDest > 0 && returnText.at(finalDest - 1).isSpace())
927 returnText[finalDest] = text.front();
928 text = text.sliced(1);
931 returnText.truncate(finalDest);
935unsigned QPlatformThemePrivate::currentKeyPlatforms()
937 const uint keyboardScheme = QGuiApplicationPrivate::platformTheme()->themeHint(QPlatformTheme::KeyboardScheme).toInt();
938 unsigned result = 1u << keyboardScheme;
939#if QT_CONFIG(shortcut)
940 if (keyboardScheme == QPlatformTheme::KdeKeyboardScheme
941 || keyboardScheme == QPlatformTheme::GnomeKeyboardScheme
942 || keyboardScheme == QPlatformTheme::CdeKeyboardScheme)
948QString QPlatformTheme::name()
const
950 return d_func()->name;
955#include "moc_qplatformtheme.cpp"
The QPalette class contains color groups for each widget state.