Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qwindowstheme.cpp
Go to the documentation of this file.
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 <QtCore/qt_windows.h>
5
6#include "qwindowstheme.h"
7#include "qwindowsmenu.h"
9#include "qwindowscontext.h"
10#include "qwindowsintegration.h"
11#if QT_CONFIG(systemtrayicon)
13#endif
14#include "qwindowsscreen.h"
15#include <commctrl.h>
16#include <objbase.h>
17#ifndef Q_CC_MINGW
18# include <commoncontrols.h>
19#endif
20#include <shellapi.h>
21
22#include <QtCore/qvariant.h>
23#include <QtCore/qcoreapplication.h>
24#include <QtCore/qdebug.h>
25#include <QtCore/qsysinfo.h>
26#include <QtCore/qcache.h>
27#include <QtCore/qthread.h>
28#include <QtCore/qmutex.h>
29#include <QtCore/qwaitcondition.h>
30#include <QtGui/qcolor.h>
31#include <QtGui/qpalette.h>
32#include <QtGui/qguiapplication.h>
33#include <QtGui/qpainter.h>
34#include <QtGui/qpixmapcache.h>
35#include <qpa/qwindowsysteminterface.h>
36#include <QtGui/private/qabstractfileiconengine_p.h>
37#include <QtGui/private/qwindowsfontdatabase_p.h>
38#include <private/qhighdpiscaling_p.h>
39#include <private/qsystemlibrary_p.h>
40#include <private/qwinregistry_p.h>
41#include <QtCore/private/qfunctions_win_p.h>
42
43#include <algorithm>
44
45#if QT_CONFIG(cpp_winrt)
46# include <QtCore/private/qt_winrtbase_p.h>
47
48# include <winrt/Windows.UI.ViewManagement.h>
49#endif // QT_CONFIG(cpp_winrt)
50
51#if defined(__IImageList_INTERFACE_DEFINED__) && defined(__IID_DEFINED__)
52# define USE_IIMAGELIST
53#endif
54
56
57using namespace Qt::StringLiterals;
58
59static inline bool booleanSystemParametersInfo(UINT what, bool defaultValue)
60{
61 BOOL result;
62 if (SystemParametersInfo(what, 0, &result, 0))
63 return result != FALSE;
64 return defaultValue;
65}
66
67static inline DWORD dWordSystemParametersInfo(UINT what, DWORD defaultValue)
68{
69 DWORD result;
70 if (SystemParametersInfo(what, 0, &result, 0))
71 return result;
72 return defaultValue;
73}
74
75static inline QColor mixColors(const QColor &c1, const QColor &c2)
76{
77 return {(c1.red() + c2.red()) / 2,
78 (c1.green() + c2.green()) / 2,
79 (c1.blue() + c2.blue()) / 2};
80}
81
82static inline QColor getSysColor(int index)
83{
84 COLORREF cr = GetSysColor(index);
85 return QColor(GetRValue(cr), GetGValue(cr), GetBValue(cr));
86}
87
88#if QT_CONFIG(cpp_winrt)
89static constexpr QColor getSysColor(winrt::Windows::UI::Color &&color)
90{
91 return QColor(color.R, color.G, color.B, color.A);
92}
93#endif
94
95// QTBUG-48823/Windows 10: SHGetFileInfo() (as called by item views on file system
96// models has been observed to trigger a WM_PAINT on the mainwindow. Suppress the
97// behavior by running it in a thread.
98
100{
101 QShGetFileInfoParams(const QString &fn, DWORD a, SHFILEINFO *i, UINT f, bool *r)
102 : fileName(fn), attributes(a), flags(f), info(i), result(r)
103 { }
104
106 const DWORD attributes;
107 const UINT flags;
108 SHFILEINFO *const info;
109 bool *const result;
110};
111
113{
114public:
116 : QThread(), m_params(nullptr)
117 {
119 }
120
121 void run() override
122 {
123 QComHelper comHelper(COINIT_MULTITHREADED);
124
125 QMutexLocker readyLocker(&m_readyMutex);
126 while (!m_cancelled.loadRelaxed()) {
127 if (!m_params && !m_cancelled.loadRelaxed()
128 && !m_readyCondition.wait(&m_readyMutex, QDeadlineTimer(1000ll)))
129 continue;
130
131 if (m_params) {
132 const QString fileName = m_params->fileName;
133 SHFILEINFO info;
134 const bool result = SHGetFileInfo(reinterpret_cast<const wchar_t *>(fileName.utf16()),
135 m_params->attributes, &info, sizeof(SHFILEINFO),
136 m_params->flags);
137 m_doneMutex.lock();
138 if (!m_cancelled.loadRelaxed()) {
139 *m_params->result = result;
140 memcpy(m_params->info, &info, sizeof(SHFILEINFO));
141 }
142 m_params = nullptr;
143
144 m_doneCondition.wakeAll();
145 m_doneMutex.unlock();
146 }
147 }
148 }
149
151 {
152 QMutexLocker doneLocker(&m_doneMutex);
153
154 m_readyMutex.lock();
155 m_params = params;
156 m_readyCondition.wakeAll();
157 m_readyMutex.unlock();
158
159 return m_doneCondition.wait(&m_doneMutex, QDeadlineTimer(timeOutMSecs));
160 }
161
162 void cancel()
163 {
164 QMutexLocker doneLocker(&m_doneMutex);
165 m_cancelled.storeRelaxed(1);
166 m_readyCondition.wakeAll();
167 }
168
169private:
170 QShGetFileInfoParams *m_params;
171 QAtomicInt m_cancelled;
172 QWaitCondition m_readyCondition;
173 QWaitCondition m_doneCondition;
174 QMutex m_readyMutex;
175 QMutex m_doneMutex;
176};
177
178static bool shGetFileInfoBackground(const QString &fileName, DWORD attributes,
179 SHFILEINFO *info, UINT flags,
180 qint64 timeOutMSecs = 5000)
181{
182 static QShGetFileInfoThread *getFileInfoThread = nullptr;
183 if (!getFileInfoThread) {
184 getFileInfoThread = new QShGetFileInfoThread;
185 getFileInfoThread->start();
186 }
187
188 bool result = false;
190 if (!getFileInfoThread->runWithParams(&params, timeOutMSecs)) {
191 // Cancel and reset getFileInfoThread. It'll
192 // be reinitialized the next time we get called.
193 getFileInfoThread->cancel();
194 getFileInfoThread = nullptr;
195 qWarning().noquote() << "SHGetFileInfo() timed out for " << fileName;
196 return false;
197 }
198 return result;
199}
200
201// from QStyle::standardPalette
203{
204 QColor backgroundColor(0xd4, 0xd0, 0xc8); // win 2000 grey
205 QColor lightColor(backgroundColor.lighter());
206 QColor darkColor(backgroundColor.darker());
207 const QBrush darkBrush(darkColor);
208 QColor midColor(Qt::gray);
209 QPalette palette(Qt::black, backgroundColor, lightColor, darkColor,
210 midColor, Qt::black, Qt::white);
211 palette.setBrush(QPalette::Disabled, QPalette::WindowText, darkBrush);
212 palette.setBrush(QPalette::Disabled, QPalette::Text, darkBrush);
213 palette.setBrush(QPalette::Disabled, QPalette::ButtonText, darkBrush);
214 palette.setBrush(QPalette::Disabled, QPalette::Base, QBrush(backgroundColor));
215 return palette;
216}
217
219{
220 textColor.setAlpha(128);
221 return textColor;
222}
223
224[[maybe_unused]] [[nodiscard]] static inline QColor qt_accentColor()
225{
226 const QWinRegistryKey registry(HKEY_CURRENT_USER, LR"(Software\Microsoft\Windows\DWM)");
227 if (!registry.isValid())
228 return {};
229 const QVariant value = registry.value(L"AccentColor");
230 if (!value.isValid())
231 return {};
232 // The retrieved value is in the #AABBGGRR format, we need to
233 // convert it to the #AARRGGBB format which Qt expects.
234 const QColor abgr = QColor::fromRgba(qvariant_cast<DWORD>(value));
235 if (!abgr.isValid())
236 return {};
237 return QColor::fromRgb(abgr.blue(), abgr.green(), abgr.red(), abgr.alpha());
238}
239
240/*
241 This is used when the theme is light mode, and when the theme is dark but the
242 application doesn't support dark mode. In the latter case, we need to check.
243*/
245{
246 const QColor background = getSysColor(COLOR_BTNFACE);
247 const QColor textColor = getSysColor(COLOR_WINDOWTEXT);
248
249#if QT_CONFIG(cpp_winrt)
250 // respect the Windows 11 accent color
251 using namespace winrt::Windows::UI::ViewManagement;
252 const auto settings = UISettings();
253
254 const QColor accent = getSysColor(settings.GetColorValue(UIColorType::Accent));
255 const QColor accentDarkest = getSysColor(settings.GetColorValue(UIColorType::AccentDark3));
256#else
257 const QColor accent = qt_accentColor();
258 const QColor accentDarkest = accent.darker(120 * 120 * 120);
259#endif
260
261 const QColor linkColor = accent;
262 const QColor btnFace = background;
263 const QColor btnHighlight = getSysColor(COLOR_BTNHIGHLIGHT);
264
265 result.setColor(QPalette::Highlight, getSysColor(COLOR_HIGHLIGHT));
266 result.setColor(QPalette::WindowText, getSysColor(COLOR_WINDOWTEXT));
267 result.setColor(QPalette::Button, btnFace);
268 result.setColor(QPalette::Light, btnHighlight);
269 result.setColor(QPalette::Dark, getSysColor(COLOR_BTNSHADOW));
270 result.setColor(QPalette::Mid, result.button().color().darker(150));
271 result.setColor(QPalette::Text, textColor);
273 result.setColor(QPalette::BrightText, btnHighlight);
274 result.setColor(QPalette::Base, getSysColor(COLOR_WINDOW));
275 result.setColor(QPalette::Window, btnFace);
276 result.setColor(QPalette::ButtonText, getSysColor(COLOR_BTNTEXT));
277 result.setColor(QPalette::Midlight, getSysColor(COLOR_3DLIGHT));
278 result.setColor(QPalette::Shadow, getSysColor(COLOR_3DDKSHADOW));
279 result.setColor(QPalette::HighlightedText, getSysColor(COLOR_HIGHLIGHTTEXT));
280 result.setColor(QPalette::AccentColor, accent);
281
282 result.setColor(QPalette::Link, linkColor);
283 result.setColor(QPalette::LinkVisited, accentDarkest);
284 result.setColor(QPalette::Inactive, QPalette::Button, result.button().color());
285 result.setColor(QPalette::Inactive, QPalette::Window, result.window().color());
286 result.setColor(QPalette::Inactive, QPalette::Light, result.light().color());
287 result.setColor(QPalette::Inactive, QPalette::Dark, result.dark().color());
288
289 if (result.midlight() == result.button())
290 result.setColor(QPalette::Midlight, result.button().color().lighter(110));
291}
292
294{
295#if QT_CONFIG(cpp_winrt)
296 using namespace winrt::Windows::UI::ViewManagement;
297 const auto settings = UISettings();
298
299 // We have to craft a palette from these colors. The settings.UIElementColor(UIElementType) API
300 // returns the old system colors, not the dark mode colors. If the background is black (which it
301 // usually), then override it with a dark gray instead so that we can go up and down the lightness.
302 const QColor foreground = getSysColor(settings.GetColorValue(UIColorType::Foreground));
303 const QColor background = [&settings]() -> QColor {
304 auto systemBackground = getSysColor(settings.GetColorValue(UIColorType::Background));
305 if (systemBackground == Qt::black)
306 systemBackground = QColor(0x1E, 0x1E, 0x1E);
307 return systemBackground;
308 }();
309
310 const QColor accent = getSysColor(settings.GetColorValue(UIColorType::Accent));
311 const QColor accentDark = getSysColor(settings.GetColorValue(UIColorType::AccentDark1));
312 const QColor accentDarker = getSysColor(settings.GetColorValue(UIColorType::AccentDark2));
313 const QColor accentDarkest = getSysColor(settings.GetColorValue(UIColorType::AccentDark3));
314 const QColor accentLight = getSysColor(settings.GetColorValue(UIColorType::AccentLight1));
315 const QColor accentLighter = getSysColor(settings.GetColorValue(UIColorType::AccentLight2));
316 const QColor accentLightest = getSysColor(settings.GetColorValue(UIColorType::AccentLight3));
317#else
318 const QColor foreground = Qt::white;
319 const QColor background = QColor(0x1E, 0x1E, 0x1E);
320 const QColor accent = qt_accentColor();
321 const QColor accentDark = accent.darker(120);
322 const QColor accentDarker = accentDark.darker(120);
323 const QColor accentDarkest = accentDarker.darker(120);
324 const QColor accentLight = accent.lighter(120);
325 const QColor accentLighter = accentLight.lighter(120);
326 const QColor accentLightest = accentLighter.lighter(120);
327#endif
328 const QColor linkColor = accent;
329 const QColor buttonColor = background.lighter(200);
330
331 result.setColor(QPalette::All, QPalette::WindowText, foreground);
332 result.setColor(QPalette::All, QPalette::Text, foreground);
333 result.setColor(QPalette::All, QPalette::BrightText, accentLightest);
334
335 result.setColor(QPalette::All, QPalette::Button, buttonColor);
336 result.setColor(QPalette::All, QPalette::ButtonText, foreground);
337 result.setColor(QPalette::All, QPalette::Light, buttonColor.lighter(200));
338 result.setColor(QPalette::All, QPalette::Midlight, buttonColor.lighter(150));
339 result.setColor(QPalette::All, QPalette::Dark, buttonColor.darker(200));
340 result.setColor(QPalette::All, QPalette::Mid, buttonColor.darker(150));
342
343 result.setColor(QPalette::All, QPalette::Base, background.lighter(150));
344 result.setColor(QPalette::All, QPalette::Window, background);
345
346 result.setColor(QPalette::All, QPalette::Highlight, accent);
348 result.setColor(QPalette::All, QPalette::Link, linkColor);
349 result.setColor(QPalette::All, QPalette::LinkVisited, accentDarkest);
350 result.setColor(QPalette::All, QPalette::AlternateBase, accentDarkest);
351 result.setColor(QPalette::All, QPalette::ToolTipBase, buttonColor);
352 result.setColor(QPalette::All, QPalette::ToolTipText, foreground.darker(120));
354 result.setColor(QPalette::All, QPalette::AccentColor, accent);
355}
356
357static inline QPalette toolTipPalette(const QPalette &systemPalette, bool light)
358{
359 QPalette result(systemPalette);
360 const QColor tipBgColor = light ? getSysColor(COLOR_INFOBK)
361 : systemPalette.button().color();
362 const QColor tipTextColor = light ? getSysColor(COLOR_INFOTEXT)
363 : systemPalette.buttonText().color().darker(120);
364
365 result.setColor(QPalette::All, QPalette::Button, tipBgColor);
366 result.setColor(QPalette::All, QPalette::Window, tipBgColor);
367 result.setColor(QPalette::All, QPalette::Text, tipTextColor);
368 result.setColor(QPalette::All, QPalette::WindowText, tipTextColor);
369 result.setColor(QPalette::All, QPalette::ButtonText, tipTextColor);
370 result.setColor(QPalette::All, QPalette::Button, tipBgColor);
371 result.setColor(QPalette::All, QPalette::Window, tipBgColor);
372 result.setColor(QPalette::All, QPalette::Text, tipTextColor);
373 result.setColor(QPalette::All, QPalette::WindowText, tipTextColor);
374 result.setColor(QPalette::All, QPalette::ButtonText, tipTextColor);
375 result.setColor(QPalette::All, QPalette::ToolTipBase, tipBgColor);
376 result.setColor(QPalette::All, QPalette::ToolTipText, tipTextColor);
377 const QColor disabled = mixColors(result.windowText().color(), result.button().color());
384 return result;
385}
386
387static inline QPalette menuPalette(const QPalette &systemPalette, bool light)
388{
389 if (!light)
390 return systemPalette;
391
392 QPalette result(systemPalette);
393 const QColor menuColor = getSysColor(COLOR_MENU);
394 const QColor menuTextColor = getSysColor(COLOR_MENUTEXT);
395 const QColor disabled = getSysColor(COLOR_GRAYTEXT);
396 // we might need a special color group for the result.
397 result.setColor(QPalette::Active, QPalette::Button, menuColor);
398 result.setColor(QPalette::Active, QPalette::Text, menuTextColor);
399 result.setColor(QPalette::Active, QPalette::WindowText, menuTextColor);
400 result.setColor(QPalette::Active, QPalette::ButtonText, menuTextColor);
403 const bool isFlat = booleanSystemParametersInfo(SPI_GETFLATMENU, false);
404 const QColor highlightColor = getSysColor(isFlat ? COLOR_MENUHILIGHT : COLOR_HIGHLIGHT);
405 result.setColor(QPalette::Disabled, QPalette::Highlight, highlightColor);
422 systemPalette.color(QPalette::Inactive, QPalette::Dark));
423 return result;
424}
425
426static inline QPalette *menuBarPalette(const QPalette &menuPalette, bool light)
427{
428 QPalette *result = nullptr;
429 if (!light || !booleanSystemParametersInfo(SPI_GETFLATMENU, false))
430 return result;
431
433 const QColor menubar(getSysColor(COLOR_MENUBAR));
434 result->setColor(QPalette::Active, QPalette::Button, menubar);
435 result->setColor(QPalette::Disabled, QPalette::Button, menubar);
436 result->setColor(QPalette::Inactive, QPalette::Button, menubar);
437 return result;
438}
439
440const char *QWindowsTheme::name = "windows";
441QWindowsTheme *QWindowsTheme::m_instance = nullptr;
442
444{
445 m_instance = this;
446 std::fill(m_fonts, m_fonts + NFonts, nullptr);
447 std::fill(m_palettes, m_palettes + NPalettes, nullptr);
448 refresh();
449 refreshIconPixmapSizes();
450}
451
453{
454 clearPalettes();
455 clearFonts();
456 m_instance = nullptr;
457}
458
460{
461 const QFileInfo appDir(QCoreApplication::applicationDirPath() + "/icons"_L1);
462 return appDir.isDir() ? QStringList(appDir.absoluteFilePath()) : QStringList();
463}
464
465static inline QStringList styleNames()
466{
467 return { QStringLiteral("WindowsVista"), QStringLiteral("Windows") };
468}
469
470static inline int uiEffects()
471{
483 return result;
484}
485
487{
488 switch (hint) {
490 return QVariant(true);
495 case StyleNames:
496 return QVariant(styleNames());
497 case TextCursorWidth:
498 return QVariant(int(dWordSystemParametersInfo(SPI_GETCARETWIDTH, 1u)));
499 case DropShadow:
500 return QVariant(booleanSystemParametersInfo(SPI_GETDROPSHADOW, false));
502 return QVariant(qRound(qreal(QWindowsContext::instance()->defaultDPI()) * 1.375));
503 case KeyboardScheme:
504 return QVariant(int(WindowsKeyboardScheme));
505 case UiEffects:
506 return QVariant(uiEffects());
507 case IconPixmapSizes:
508 return QVariant::fromValue(m_fileIconSizes);
510 return QVariant(booleanSystemParametersInfo(SPI_GETSNAPTODEFBUTTON, false));
512 return QVariant(true);
513 case WheelScrollLines: {
514 int result = 3;
515 const DWORD scrollLines = dWordSystemParametersInfo(SPI_GETWHEELSCROLLLINES, DWORD(result));
516 if (scrollLines != DWORD(-1)) // Special value meaning "scroll one screen", unimplemented in Qt.
517 result = int(scrollLines);
518 return QVariant(result);
519 }
521 return GetSystemMetrics(SM_CXDOUBLECLK);
523 return true;
524 default:
525 break;
526 }
528}
529
531{
533}
534
535void QWindowsTheme::clearPalettes()
536{
537 qDeleteAll(m_palettes, m_palettes + NPalettes);
538 std::fill(m_palettes, m_palettes + NPalettes, nullptr);
539}
540
541void QWindowsTheme::refreshPalettes()
542{
544 return;
545 const bool light =
547 || !QWindowsIntegration::instance()->darkModeHandling().testFlag(QWindowsApplication::DarkModeStyle);
548 clearPalettes();
550 m_palettes[ToolTipPalette] = new QPalette(toolTipPalette(*m_palettes[SystemPalette], light));
551 m_palettes[MenuPalette] = new QPalette(menuPalette(*m_palettes[SystemPalette], light));
552 m_palettes[MenuBarPalette] = menuBarPalette(*m_palettes[MenuPalette], light);
553 if (!light) {
554#if QT_CONFIG(cpp_winrt)
555 using namespace winrt::Windows::UI::ViewManagement;
556 const auto settings = UISettings();
557 const QColor accent = getSysColor(settings.GetColorValue(UIColorType::Accent));
558 const QColor accentLight = getSysColor(settings.GetColorValue(UIColorType::AccentLight1));
559 const QColor accentDarkest = getSysColor(settings.GetColorValue(UIColorType::AccentDark3));
560#else
561 const QColor accent = qt_accentColor();
562 const QColor accentLight = accent.lighter(120);
563 const QColor accentDarkest = accent.darker(120 * 120 * 120);
564#endif
565 m_palettes[CheckBoxPalette] = new QPalette(*m_palettes[SystemPalette]);
567 m_palettes[CheckBoxPalette]->setColor(QPalette::Active, QPalette::Button, accentLight);
568 m_palettes[CheckBoxPalette]->setColor(QPalette::Inactive, QPalette::Base, accentDarkest);
569 m_palettes[RadioButtonPalette] = new QPalette(*m_palettes[CheckBoxPalette]);
570 }
571}
572
574{
576
577 switch (colorScheme) {
580 break;
583 break;
584 default:
585 qFatal("Unknown color scheme");
586 break;
587 }
588
589 if (result.window() != result.base()) {
596 }
597
598 const QColor disabled = mixColors(result.windowText().color(), result.button().color());
599
600 result.setColorGroup(QPalette::Disabled, result.windowText(), result.button(),
601 result.light(), result.dark(), result.mid(),
602 result.text(), result.brightText(), result.base(),
603 result.window());
610 result.setColor(QPalette::Disabled, QPalette::Base, result.window().color());
611 return result;
612}
613
614void QWindowsTheme::clearFonts()
615{
616 qDeleteAll(m_fonts, m_fonts + NFonts);
617 std::fill(m_fonts, m_fonts + NFonts, nullptr);
618}
619
621{
622 refreshPalettes();
623 refreshFonts();
624}
625
626#ifndef QT_NO_DEBUG_STREAM
627QDebug operator<<(QDebug d, const NONCLIENTMETRICS &m)
628{
629 QDebugStateSaver saver(d);
630 d.nospace();
631 d.noquote();
632 d << "NONCLIENTMETRICS(iMenu=" << m.iMenuWidth << 'x' << m.iMenuHeight
633 << ", lfCaptionFont=";
634 QWindowsFontDatabase::debugFormat(d, m.lfCaptionFont);
635 d << ", lfSmCaptionFont=";
636 QWindowsFontDatabase::debugFormat(d, m.lfSmCaptionFont);
637 d << ", lfMenuFont=";
639 d << ", lfMessageFont=";
640 QWindowsFontDatabase::debugFormat(d, m.lfMessageFont);
641 d <<", lfStatusFont=";
643 d << ')';
644 return d;
645}
646#endif // QT_NO_DEBUG_STREAM
647
649{
650 clearFonts();
652 return;
653
654 const int dpi = 96;
655 NONCLIENTMETRICS ncm;
657 qCDebug(lcQpaWindow) << __FUNCTION__ << ncm;
658
659 const QFont menuFont = QWindowsFontDatabase::LOGFONT_to_QFont(ncm.lfMenuFont, dpi);
660 const QFont messageBoxFont = QWindowsFontDatabase::LOGFONT_to_QFont(ncm.lfMessageFont, dpi);
661 const QFont statusFont = QWindowsFontDatabase::LOGFONT_to_QFont(ncm.lfStatusFont, dpi);
662 const QFont titleFont = QWindowsFontDatabase::LOGFONT_to_QFont(ncm.lfCaptionFont, dpi);
663 QFont fixedFont(QStringLiteral("Courier New"), messageBoxFont.pointSize());
665
666 LOGFONT lfIconTitleFont;
667 SystemParametersInfoForDpi(SPI_GETICONTITLELOGFONT, sizeof(lfIconTitleFont), &lfIconTitleFont, 0, dpi);
668 const QFont iconTitleFont = QWindowsFontDatabase::LOGFONT_to_QFont(lfIconTitleFont, dpi);
669
671 m_fonts[MenuFont] = new QFont(menuFont);
672 m_fonts[MenuBarFont] = new QFont(menuFont);
673 m_fonts[MessageBoxFont] = new QFont(messageBoxFont);
674 m_fonts[TipLabelFont] = new QFont(statusFont);
675 m_fonts[StatusBarFont] = new QFont(statusFont);
676 m_fonts[MdiSubWindowTitleFont] = new QFont(titleFont);
677 m_fonts[DockWidgetTitleFont] = new QFont(titleFont);
678 m_fonts[ItemViewFont] = new QFont(iconTitleFont);
679 m_fonts[FixedFont] = new QFont(fixedFont);
680}
681
683 // Standard icons obtainable via shGetFileInfo(), SHGFI_SMALLICON, SHGFI_LARGEICON
685 // Larger icons obtainable via SHGetImageList()
687 JumboFileIcon, // Vista onwards
690
692{
694}
695
697{
699}
700
701#if QT_CONFIG(systemtrayicon)
703{
704 return new QWindowsSystemTrayIcon;
705}
706#endif
707
709{
710 refresh();
712}
713
715
716void QWindowsTheme::refreshIconPixmapSizes()
717{
718 // Standard sizes: 16, 32, 48, 256
719 fileIconSizes[SmallFileIcon] = GetSystemMetrics(SM_CXSMICON); // corresponds to SHGFI_SMALLICON);
720 fileIconSizes[LargeFileIcon] = GetSystemMetrics(SM_CXICON); // corresponds to SHGFI_LARGEICON
723 fileIconSizes[JumboFileIcon] = 8 * fileIconSizes[LargeFileIcon]; // empirical, has not been observed to work
724
725#ifdef USE_IIMAGELIST
726 int *availEnd = fileIconSizes + JumboFileIcon + 1;
727#else
728 int *availEnd = fileIconSizes + LargeFileIcon + 1;
729#endif // USE_IIMAGELIST
730 m_fileIconSizes = QAbstractFileIconEngine::toSizeList(fileIconSizes, availEnd);
731 qCDebug(lcQpaWindow) << __FUNCTION__ << m_fileIconSizes;
732}
733
734// Defined in qpixmap_win.cpp
735Q_GUI_EXPORT QPixmap qt_pixmapFromWinHICON(HICON icon);
736
737static QPixmap loadIconFromShell32(int resourceId, QSizeF size)
738{
739 if (const HMODULE hmod = QSystemLibrary::load(L"shell32")) {
740 auto iconHandle =
741 static_cast<HICON>(LoadImage(hmod, MAKEINTRESOURCE(resourceId),
742 IMAGE_ICON, int(size.width()), int(size.height()), 0));
743 if (iconHandle) {
744 QPixmap iconpixmap = qt_pixmapFromWinHICON(iconHandle);
745 DestroyIcon(iconHandle);
746 return iconpixmap;
747 }
748 }
749 return QPixmap();
750}
751
753{
754 int resourceId = -1;
755 SHSTOCKICONID stockId = SIID_INVALID;
756 UINT stockFlags = 0;
757 LPCTSTR iconName = nullptr;
758 switch (sp) {
759 case DriveCDIcon:
760 stockId = SIID_DRIVECD;
761 resourceId = 12;
762 break;
763 case DriveDVDIcon:
764 stockId = SIID_DRIVEDVD;
765 resourceId = 12;
766 break;
767 case DriveNetIcon:
768 stockId = SIID_DRIVENET;
769 resourceId = 10;
770 break;
771 case DriveHDIcon:
772 stockId = SIID_DRIVEFIXED;
773 resourceId = 9;
774 break;
775 case DriveFDIcon:
776 stockId = SIID_DRIVE35;
777 resourceId = 7;
778 break;
779 case FileLinkIcon:
780 stockFlags = SHGSI_LINKOVERLAY;
782 case FileIcon:
783 stockId = SIID_DOCNOASSOC;
784 resourceId = 1;
785 break;
786 case DirLinkIcon:
787 stockFlags = SHGSI_LINKOVERLAY;
789 case DirClosedIcon:
790 case DirIcon:
791 stockId = SIID_FOLDER;
792 resourceId = 4;
793 break;
794 case DesktopIcon:
795 resourceId = 35;
796 break;
797 case ComputerIcon:
798 resourceId = 16;
799 break;
800 case DirLinkOpenIcon:
801 stockFlags = SHGSI_LINKOVERLAY;
803 case DirOpenIcon:
804 stockId = SIID_FOLDEROPEN;
805 resourceId = 5;
806 break;
808 stockId = SIID_FOLDER;
809 resourceId = 319;
810 break;
811 case DirHomeIcon:
812 resourceId = 235;
813 break;
814 case TrashIcon:
815 stockId = SIID_RECYCLER;
816 resourceId = 191;
817 break;
819 stockId = SIID_INFO;
820 iconName = IDI_INFORMATION;
821 break;
823 stockId = SIID_WARNING;
824 iconName = IDI_WARNING;
825 break;
827 stockId = SIID_ERROR;
828 iconName = IDI_ERROR;
829 break;
831 stockId = SIID_HELP;
832 iconName = IDI_QUESTION;
833 break;
834 case VistaShield:
835 stockId = SIID_SHIELD;
836 break;
837 default:
838 break;
839 }
840
841 if (stockId != SIID_INVALID) {
843 SHSTOCKICONINFO iconInfo;
844 memset(&iconInfo, 0, sizeof(iconInfo));
845 iconInfo.cbSize = sizeof(iconInfo);
846 stockFlags |= (pixmapSize.width() > 16 ? SHGFI_LARGEICON : SHGFI_SMALLICON);
847 if (SHGetStockIconInfo(stockId, SHGFI_ICON | stockFlags, &iconInfo) == S_OK) {
848 pixmap = qt_pixmapFromWinHICON(iconInfo.hIcon);
849 DestroyIcon(iconInfo.hIcon);
850 return pixmap;
851 }
852 }
853
854 if (resourceId != -1) {
855 QPixmap pixmap = loadIconFromShell32(resourceId, pixmapSize);
856 if (!pixmap.isNull()) {
857 if (sp == FileLinkIcon || sp == DirLinkIcon || sp == DirLinkOpenIcon) {
859 QPixmap link = loadIconFromShell32(30, pixmapSize);
860 painter.drawPixmap(0, 0, int(pixmapSize.width()), int(pixmapSize.height()), link);
861 }
862 return pixmap;
863 }
864 }
865
866 if (iconName) {
867 HICON iconHandle = LoadIcon(nullptr, iconName);
869 DestroyIcon(iconHandle);
870 if (!pixmap.isNull())
871 return pixmap;
872 }
873
874 return QPlatformTheme::standardPixmap(sp, pixmapSize);
875}
876
877enum { // Shell image list ids
878 sHIL_EXTRALARGE = 0x2, // 48x48 or user-defined
879 sHIL_JUMBO = 0x4 // 256x256 (Vista or later)
881
882static QString dirIconPixmapCacheKey(int iIcon, int iconSize, int imageListSize)
883{
884 QString key = "qt_dir_"_L1 + QString::number(iIcon);
885 if (iconSize == SHGFI_LARGEICON)
886 key += u'l';
887 switch (imageListSize) {
888 case sHIL_EXTRALARGE:
889 key += u'e';
890 break;
891 case sHIL_JUMBO:
892 key += u'j';
893 break;
894 }
895 return key;
896}
897
898template <typename T>
900{
901public:
902
903 static_assert(sizeof(T) <= sizeof(void *), "FakePointers can only go that far.");
904
905 static FakePointer *create(T thing)
906 {
907 return reinterpret_cast<FakePointer *>(qintptr(thing));
908 }
909
910 T operator * () const
911 {
912 return T(qintptr(this));
913 }
914
915 void operator delete (void *) {}
916};
917
918// Shell image list helper functions.
919
920static QPixmap pixmapFromShellImageList(int iImageList, const SHFILEINFO &info)
921{
923#ifdef USE_IIMAGELIST
924 // For MinGW:
925 static const IID iID_IImageList = {0x46eb5926, 0x582e, 0x4017, {0x9f, 0xdf, 0xe8, 0x99, 0x8d, 0xaa, 0x9, 0x50}};
926
927 IImageList *imageList = nullptr;
928 HRESULT hr = SHGetImageList(iImageList, iID_IImageList, reinterpret_cast<void **>(&imageList));
929 if (hr != S_OK)
930 return result;
931 HICON hIcon;
932 hr = imageList->GetIcon(info.iIcon, ILD_TRANSPARENT, &hIcon);
933 if (hr == S_OK) {
935 DestroyIcon(hIcon);
936 }
937 imageList->Release();
938#else
939 Q_UNUSED(iImageList);
940 Q_UNUSED(info);
941#endif // USE_IIMAGELIST
942 return result;
943}
944
946{
947public:
948 explicit QWindowsFileIconEngine(const QFileInfo &info, QPlatformTheme::IconOptions opts) :
950
953
954protected:
955 QString cacheKey() const override;
957};
958
960{
961 // Cache directories unless custom or drives, which have custom icons depending on type
962 if ((options() & QPlatformTheme::DontUseCustomDirectoryIcons) && fileInfo().isDir() && !fileInfo().isRoot())
963 return QStringLiteral("qt_/directory/");
964 if (!fileInfo().isFile())
965 return QString();
966 // Return "" for .exe, .lnk and .ico extensions.
967 // It is faster to just look at the file extensions;
968 // avoiding slow QFileInfo::isExecutable() (QTBUG-13182)
969 QString suffix = fileInfo().suffix();
970 if (!suffix.compare(u"exe", Qt::CaseInsensitive)
971 || !suffix.compare(u"lnk", Qt::CaseInsensitive)
972 || !suffix.compare(u"ico", Qt::CaseInsensitive)) {
973 return QString();
974 }
975 return "qt_."_L1
976 + (suffix.isEmpty() ? fileInfo().fileName() : std::move(suffix).toUpper()); // handle "Makefile" ;)
977}
978
980{
981 QComHelper comHelper;
982
983 static QCache<QString, FakePointer<int> > dirIconEntryCache(1000);
984 Q_CONSTINIT static QMutex mx;
985 static int defaultFolderIIcon = -1;
986 const bool useDefaultFolderIcon = options() & QPlatformTheme::DontUseCustomDirectoryIcons;
987
989 const QString filePath = QDir::toNativeSeparators(fileInfo().filePath());
990 const int width = int(size.width());
991 const int iconSize = width > fileIconSizes[SmallFileIcon] ? SHGFI_LARGEICON : SHGFI_SMALLICON;
992 const int requestedImageListSize =
993#ifdef USE_IIMAGELIST
995 ? sHIL_JUMBO
997#else
998 0;
999#endif // !USE_IIMAGELIST
1000 bool cacheableDirIcon = fileInfo().isDir() && !fileInfo().isRoot();
1001 if (cacheableDirIcon) {
1002 QMutexLocker locker(&mx);
1003 int iIcon = (useDefaultFolderIcon && defaultFolderIIcon >= 0) ? defaultFolderIIcon
1004 : **dirIconEntryCache.object(filePath);
1005 if (iIcon) {
1006 QPixmapCache::find(dirIconPixmapCacheKey(iIcon, iconSize, requestedImageListSize),
1007 &pixmap);
1008 if (pixmap.isNull()) // Let's keep both caches in sync
1009 dirIconEntryCache.remove(filePath);
1010 else
1011 return pixmap;
1012 }
1013 }
1014
1015 SHFILEINFO info;
1016 unsigned int flags = SHGFI_ICON | iconSize | SHGFI_SYSICONINDEX | SHGFI_ADDOVERLAYS | SHGFI_OVERLAYINDEX;
1017 DWORD attributes = 0;
1018 QString path = filePath;
1019 if (cacheableDirIcon && useDefaultFolderIcon) {
1020 flags |= SHGFI_USEFILEATTRIBUTES;
1021 attributes |= FILE_ATTRIBUTE_DIRECTORY;
1022 path = QStringLiteral("dummy");
1023 } else if (!fileInfo().exists()) {
1024 flags |= SHGFI_USEFILEATTRIBUTES;
1025 attributes |= FILE_ATTRIBUTE_NORMAL;
1026 }
1027 const bool val = shGetFileInfoBackground(path, attributes, &info, flags);
1028
1029 // Even if GetFileInfo returns a valid result, hIcon can be empty in some cases
1030 if (val && info.hIcon) {
1031 QString key;
1032 if (cacheableDirIcon) {
1033 if (useDefaultFolderIcon && defaultFolderIIcon < 0)
1034 defaultFolderIIcon = info.iIcon;
1035
1036 //using the unique icon index provided by windows save us from duplicate keys
1037 key = dirIconPixmapCacheKey(info.iIcon, iconSize, requestedImageListSize);
1039 if (!pixmap.isNull()) {
1040 QMutexLocker locker(&mx);
1041 dirIconEntryCache.insert(filePath, FakePointer<int>::create(info.iIcon));
1042 }
1043 }
1044
1045 if (pixmap.isNull()) {
1046 if (requestedImageListSize) {
1047 pixmap = pixmapFromShellImageList(requestedImageListSize, info);
1048 if (pixmap.isNull() && requestedImageListSize == sHIL_JUMBO)
1050 }
1051 if (pixmap.isNull())
1053 if (!pixmap.isNull()) {
1054 if (cacheableDirIcon) {
1055 QMutexLocker locker(&mx);
1057 dirIconEntryCache.insert(filePath, FakePointer<int>::create(info.iIcon));
1058 }
1059 } else {
1060 qWarning("QWindowsTheme::fileIconPixmap() no icon found");
1061 }
1062 }
1063 DestroyIcon(info.hIcon);
1064 }
1065
1066 return pixmap;
1067}
1068
1069QIcon QWindowsTheme::fileIcon(const QFileInfo &fileInfo, QPlatformTheme::IconOptions iconOptions) const
1070{
1071 return QIcon(new QWindowsFileIconEngine(fileInfo, iconOptions));
1072}
1073
1074static inline bool doUseNativeMenus()
1075{
1076 const unsigned options = QWindowsIntegration::instance()->options();
1077 if ((options & QWindowsIntegration::NoNativeMenus) != 0)
1078 return false;
1079 if ((options & QWindowsIntegration::AlwaysUseNativeMenus) != 0)
1080 return true;
1081 // "Auto" mode: For non-widget or Quick Controls 2 applications
1082 if (!QCoreApplication::instance()->inherits("QApplication"))
1083 return true;
1084 const QWindowList &topLevels = QGuiApplication::topLevelWindows();
1085 for (const QWindow *t : topLevels) {
1086 if (t->inherits("QQuickApplicationWindow"))
1087 return true;
1088 }
1089 return false;
1090}
1091
1093{
1094 static const bool result = doUseNativeMenus();
1095 return result;
1096}
1097
1099{
1100 if (queryHighContrast()) {
1101 return false;
1102 }
1103 const auto setting = QWinRegistryKey(HKEY_CURRENT_USER, LR"(Software\Microsoft\Windows\CurrentVersion\Themes\Personalize)")
1104 .dwordValue(L"AppsUseLightTheme");
1105 return setting.second && setting.first == 0;
1106}
1107
1109{
1110 return booleanSystemParametersInfo(SPI_GETHIGHCONTRAST, false);
1111}
1112
1114{
1115 qCDebug(lcQpaMenus) << __FUNCTION__;
1116 return QWindowsTheme::useNativeMenus() ? new QWindowsMenuItem : nullptr;
1117}
1118
1120{
1121 qCDebug(lcQpaMenus) << __FUNCTION__;
1122 // We create a popup menu here, since it will likely be used as context
1123 // menu. Submenus should be created the factory functions of
1124 // QPlatformMenu/Bar. Note though that Quick Controls 1 will use this
1125 // function for submenus as well, but this has been found to work.
1126 return QWindowsTheme::useNativeMenus() ? new QWindowsPopupMenu : nullptr;
1127}
1128
1130{
1131 qCDebug(lcQpaMenus) << __FUNCTION__;
1132 return QWindowsTheme::useNativeMenus() ? new QWindowsMenuBar : nullptr;
1133}
1134
1136{
1137 qCDebug(lcQpaMenus) << __FUNCTION__;
1138}
1139
T operator*() const
static FakePointer * create(T thing)
Helper base class for retrieving icons for files for usage by QFileIconProvider and related.
QPlatformTheme::IconOptions options() const
static QList< QSize > toSizeList(It i1, It i2)
\inmodule QtCore
Definition qatomic.h:112
void storeRelaxed(T newValue) noexcept
T loadRelaxed() const noexcept
\inmodule QtGui
Definition qbrush.h:30
const QColor & color() const
Returns the brush color.
Definition qbrush.h:121
bool remove(const Key &key) noexcept(std::is_nothrow_destructible_v< Node >)
Definition qcache.h:222
T * object(const Key &key) const noexcept
Definition qcache.h:209
bool insert(const Key &key, T *object, qsizetype cost=1)
Definition qcache.h:184
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition qcolor.h:31
QColor darker(int f=200) const noexcept
Definition qcolor.cpp:2857
static QColor fromRgb(QRgb rgb) noexcept
Static convenience function that returns a QColor constructed from the given QRgb value rgb.
Definition qcolor.cpp:2369
int lightness() const noexcept
Definition qcolor.cpp:1860
static QColor fromRgba(QRgb rgba) noexcept
Static convenience function that returns a QColor constructed from the given QRgb value rgba.
Definition qcolor.cpp:2385
int alpha() const noexcept
Returns the alpha color component of this color.
Definition qcolor.cpp:1466
int red() const noexcept
Returns the red color component of this color.
Definition qcolor.cpp:1528
int blue() const noexcept
Returns the blue color component of this color.
Definition qcolor.cpp:1583
int green() const noexcept
Returns the green color component of this color.
Definition qcolor.cpp:1555
void setAlpha(int alpha)
Sets the alpha of this color to alpha.
Definition qcolor.cpp:1481
QColor lighter(int f=150) const noexcept
Definition qcolor.cpp:2812
bool isValid() const noexcept
Returns true if the color is valid; otherwise returns false.
Definition qcolor.h:285
static QCoreApplication * instance() noexcept
Returns a pointer to the application's QCoreApplication (or QGuiApplication/QApplication) instance.
static QString applicationDirPath()
Returns the directory that contains the application executable.
\inmodule QtCore
\inmodule QtCore
\inmodule QtCore
static QString toNativeSeparators(const QString &pathName)
Definition qdir.cpp:929
\inmodule QtCore \reentrant
Definition qfileinfo.h:22
QString suffix() const
Returns the suffix (extension) of the file.
bool isRoot() const
Returns true if the object points to a directory or to a symbolic link to a directory,...
QString fileName() const
Returns the name of the file, excluding the path.
QString absoluteFilePath() const
Returns an absolute path including the file name.
bool isDir() const
Returns true if this object points to a directory or to a symbolic link to a directory.
\reentrant
Definition qfont.h:20
@ TypeWriter
Definition qfont.h:26
int pointSize() const
Returns the point size of the font.
Definition qfont.cpp:863
void setStyleHint(StyleHint, StyleStrategy=PreferDefault)
Sets the style hint and strategy to hint and strategy, respectively.
Definition qfont.cpp:1482
static QWindowList topLevelWindows()
Returns a list of the top-level windows in the application.
static bool desktopSettingsAware()
Returns true if Qt is set to use the system's standard colors, fonts, etc.; otherwise returns false.
The QIcon class provides scalable icons in different modes and states.
Definition qicon.h:20
Mode
This enum type describes the mode for which a pixmap is intended to be used.
Definition qicon.h:22
@ Normal
Definition qicon.h:22
State
This enum describes the state for which a pixmap is intended to be used.
Definition qicon.h:23
@ Off
Definition qicon.h:23
Definition qlist.h:74
\inmodule QtCore
Definition qmutex.h:317
\inmodule QtCore
Definition qmutex.h:285
void unlock() noexcept
Unlocks the mutex.
Definition qmutex.h:293
void lock() noexcept
Locks the mutex.
Definition qmutex.h:290
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
Definition qobject.cpp:2823
void deleteLater()
\threadsafe
Definition qobject.cpp:2352
The QPainter class performs low-level painting on widgets and other paint devices.
Definition qpainter.h:46
void drawPixmap(const QRectF &targetRect, const QPixmap &pixmap, const QRectF &sourceRect)
Draws the rectangular portion source of the given pixmap into the given target in the paint device.
The QPalette class contains color groups for each widget state.
Definition qpalette.h:19
const QBrush & button() const
Returns the button brush of the current color group.
Definition qpalette.h:83
const QColor & color(ColorGroup cg, ColorRole cr) const
Returns the color in the specified color group, used for the given color role.
Definition qpalette.h:66
@ Inactive
Definition qpalette.h:48
@ Disabled
Definition qpalette.h:48
void setColor(ColorGroup cg, ColorRole cr, const QColor &color)
Sets the color in the specified color group, used for the given color role, to the specified solid co...
Definition qpalette.h:145
@ HighlightedText
Definition qpalette.h:52
@ ToolTipBase
Definition qpalette.h:56
@ BrightText
Definition qpalette.h:51
@ AlternateBase
Definition qpalette.h:54
@ ButtonText
Definition qpalette.h:51
@ WindowText
Definition qpalette.h:50
@ Highlight
Definition qpalette.h:52
@ ToolTipText
Definition qpalette.h:56
@ AccentColor
Definition qpalette.h:58
@ PlaceholderText
Definition qpalette.h:57
@ Midlight
Definition qpalette.h:50
@ LinkVisited
Definition qpalette.h:53
const QBrush & buttonText() const
Returns the button text foreground brush of the current color group.
Definition qpalette.h:95
static bool find(const QString &key, QPixmap *pixmap)
Looks for a cached pixmap associated with the given key in the cache.
static bool insert(const QString &key, const QPixmap &pixmap)
Inserts a copy of the pixmap pixmap associated with the key into the cache.
QString key() const override
\variable QIconEngine::ScaledPixmapArgument::size
Definition qicon.cpp:465
Returns a copy of the pixmap that is transformed using the given transformation transform and transfo...
Definition qpixmap.h:27
The QPlatformDialogHelper class allows for platform-specific customization of dialogs.
virtual QPixmap standardPixmap(StandardPixmap sp, const QSizeF &size) const
virtual QVariant themeHint(ThemeHint hint) const
virtual QPlatformSystemTrayIcon * createPlatformSystemTrayIcon() const
Factory function for QSystemTrayIcon.
ThemeHint
This enum describes the available theme hints.
bool runWithParams(QShGetFileInfoParams *params, qint64 timeOutMSecs)
\inmodule QtCore
Definition qsize.h:207
constexpr qreal width() const noexcept
Returns the width.
Definition qsize.h:321
constexpr qreal height() const noexcept
Returns the height.
Definition qsize.h:324
\inmodule QtCore
Definition qsize.h:25
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition qstring.h:1083
int compare(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
Definition qstring.cpp:6498
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qstring.cpp:7822
QString toUpper() const &
Definition qstring.h:372
void start(Priority=InheritPriority)
Definition qthread.cpp:923
void finished(QPrivateSignal)
\inmodule QtCore
Definition qvariant.h:64
static auto fromValue(T &&value) noexcept(std::is_nothrow_copy_constructible_v< T > &&Private::CanUseInternalSpace< T >) -> std::enable_if_t< std::conjunction_v< std::is_copy_constructible< T >, std::is_destructible< T > >, QVariant >
Definition qvariant.h:531
bool wait(QMutex *, QDeadlineTimer=QDeadlineTimer(QDeadlineTimer::Forever))
QPair< DWORD, bool > dwordValue(QStringView subKey) const
bool isValid() const
QVariant value(QStringView subKey) const
static void handleThemeChange(QWindow *window=nullptr)
\inmodule QtGui
Definition qwindow.h:63
DarkModeHandling darkModeHandling() const override
static bool isDarkMode()
static bool nonClientMetrics(NONCLIENTMETRICS *ncm, unsigned dpi=0)
static QWindowsContext * instance()
QList< QSize > availableSizes(QIcon::Mode=QIcon::Normal, QIcon::State=QIcon::Off) override
QPixmap filePixmap(const QSize &size, QIcon::Mode mode, QIcon::State) override
QWindowsFileIconEngine(const QFileInfo &info, QPlatformTheme::IconOptions opts)
QString cacheKey() const override
static QFont LOGFONT_to_QFont(const LOGFONT &lf, int verticalDPI=0)
static void debugFormat(QDebug &d, const LOGFONT &lf)
static QWindowsIntegration * instance()
Windows native menu bar.
Windows native system tray icon.
static bool useNativeMenus()
void windowsThemeChanged(QWindow *window)
void showPlatformMenuBar() override
QPlatformMenuBar * createPlatformMenuBar() const override
bool usePlatformNativeDialog(DialogType type) const override
static const char * name
QList< QSize > availableFileIconSizes() const
QPlatformMenuItem * createPlatformMenuItem() const override
Qt::ColorScheme colorScheme() const override
static QPalette systemPalette(Qt::ColorScheme)
QVariant themeHint(ThemeHint) const override
~QWindowsTheme() override
static bool queryHighContrast()
static bool queryDarkMode()
QIcon fileIcon(const QFileInfo &fileInfo, QPlatformTheme::IconOptions iconOptions={}) const override
Return an icon for fileInfo, observing iconOptions.
QPlatformDialogHelper * createPlatformDialogHelper(DialogType type) const override
static QWindowsTheme * instance()
QPixmap standardPixmap(StandardPixmap sp, const QSizeF &size) const override
QPlatformMenu * createPlatformMenu() const override
qDeleteAll(list.begin(), list.end())
opt iconSize
Combined button and popup list for selecting options.
bool useHelper(QPlatformTheme::DialogType type)
QPlatformDialogHelper * createHelper(QPlatformTheme::DialogType type)
ColorScheme
Definition qnamespace.h:49
@ gray
Definition qnamespace.h:32
@ white
Definition qnamespace.h:30
@ black
Definition qnamespace.h:29
@ CaseInsensitive
#define Q_FALLTHROUGH()
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
int qRound(qfloat16 d) noexcept
Definition qfloat16.h:281
#define qWarning
Definition qlogging.h:162
#define qFatal
Definition qlogging.h:164
#define qCDebug(category,...)
GLenum mode
const GLfloat * m
GLuint64 key
GLboolean GLboolean GLboolean GLboolean a
[7]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLuint index
[2]
GLboolean r
[2]
GLfloat GLfloat f
GLint GLsizei width
GLenum type
GLbitfield flags
void ** params
GLuint GLfloat * val
GLdouble GLdouble t
Definition qopenglext.h:243
GLsizei const GLchar *const * path
GLuint64EXT * result
[6]
QPixmap qt_pixmapFromWinHICON(HICON icon)
#define QStringLiteral(str)
static QT_BEGIN_NAMESPACE QVariant hint(QPlatformIntegration::StyleHint h)
#define sp
#define SPI_GETMENUANIMATION
Definition qt_windows.h:50
#define SPI_GETFLATMENU
Definition qt_windows.h:94
#define SPI_GETTOOLTIPANIMATION
Definition qt_windows.h:59
#define SPI_GETCOMBOBOXANIMATION
Definition qt_windows.h:56
#define SPI_GETUIEFFECTS
Definition qt_windows.h:65
#define SPI_GETMENUFADE
Definition qt_windows.h:53
#define Q_UNUSED(x)
long long qint64
Definition qtypes.h:55
double qreal
Definition qtypes.h:92
ptrdiff_t qintptr
Definition qtypes.h:71
long HRESULT
HINSTANCE HMODULE
#define disabled
QDebug operator<<(QDebug d, const NONCLIENTMETRICS &m)
static QStringList styleNames()
static bool doUseNativeMenus()
static QPalette toolTipPalette(const QPalette &systemPalette, bool light)
static bool shGetFileInfoBackground(const QString &fileName, DWORD attributes, SHFILEINFO *info, UINT flags, qint64 timeOutMSecs=5000)
static QStringList iconThemeSearchPaths()
static QColor getSysColor(int index)
static QPalette standardPalette()
static QPixmap pixmapFromShellImageList(int iImageList, const SHFILEINFO &info)
static int fileIconSizes[FileIconSizeCount]
static QString dirIconPixmapCacheKey(int iIcon, int iconSize, int imageListSize)
static QColor qt_accentColor()
static int uiEffects()
static void populateLightSystemBasePalette(QPalette &result)
static QColor mixColors(const QColor &c1, const QColor &c2)
FileIconSize
@ JumboFileIcon
@ ExtraLargeFileIcon
@ SmallFileIcon
@ LargeFileIcon
@ FileIconSizeCount
static QColor placeHolderColor(QColor textColor)
static DWORD dWordSystemParametersInfo(UINT what, DWORD defaultValue)
static void populateDarkSystemBasePalette(QPalette &result)
Q_GUI_EXPORT QPixmap qt_pixmapFromWinHICON(HICON icon)
static QPalette menuPalette(const QPalette &systemPalette, bool light)
@ sHIL_EXTRALARGE
@ sHIL_JUMBO
static QPixmap loadIconFromShell32(int resourceId, QSizeF size)
static QPalette * menuBarPalette(const QPalette &menuPalette, bool light)
static bool booleanSystemParametersInfo(UINT what, bool defaultValue)
QFileInfo info(fileName)
[8]
QSettings settings("MySoft", "Star Runner")
[0]
QObject::connect nullptr
timer inherits("QTimer")
MyCustomStruct c2
widget render & pixmap
QPainter painter(this)
[7]
aWidget window() -> setWindowTitle("New Window Title")
[2]
SHFILEINFO *const info
QShGetFileInfoParams(const QString &fn, DWORD a, SHFILEINFO *i, UINT f, bool *r)
const QString & fileName