5#ifndef QFUSIONSTYLE_P_P_H
6#define QFUSIONSTYLE_P_P_H
19#include <QtWidgets/private/qtwidgetsglobal_p.h>
22#include <qpa/qplatformtheme.h>
23#include "private/qguiapplication_p.h"
25#if QT_CONFIG(style_fusion)
29class QFusionStylePrivate :
public QCommonStylePrivate
31 Q_DECLARE_PUBLIC(QFusionStyle)
34 QFusionStylePrivate();
37 static constexpr QColor lightShade = QColor(255, 255, 255, 90);
38 static constexpr QColor darkShade = QColor(0, 0, 0, 60);
39 static constexpr QColor topShadow = QColor(0, 0, 0, 18);
40 static constexpr QColor innerContrastLine = QColor(255, 255, 255, 30);
43 bool isMacSystemPalette(
const QPalette &pal)
const {
45#if defined(Q_OS_MACOS)
46 const QPalette *themePalette = QGuiApplicationPrivate::platformTheme()->palette();
47 if (themePalette && themePalette->color(QPalette::Normal, QPalette::Highlight) ==
48 pal.color(QPalette::Normal, QPalette::Highlight) &&
49 themePalette->color(QPalette::Normal, QPalette::HighlightedText) ==
50 pal.color(QPalette::Normal, QPalette::HighlightedText))
56 QColor highlight(
const QPalette &pal)
const {
57 if (isMacSystemPalette(pal))
58 return QColor(60, 140, 230);
59 return pal.color(QPalette::Highlight);
62 QColor highlightedText(
const QPalette &pal)
const {
63 if (isMacSystemPalette(pal))
65 return pal.color(QPalette::HighlightedText);
68 QColor outline(
const QPalette &pal)
const {
69 if (isHighContrast()) {
70 return pal.text().color();
72 if (pal.window().style() == Qt::TexturePattern)
73 return QColor(0, 0, 0, 160);
74 auto windowColor = pal.window().color();
75 if (!windowColor.isValid())
76 windowColor = QPalette().window().color();
77 return windowColor.darker(140);
80 QColor highlightedOutline(
const QPalette &pal)
const {
81 QColor highlightedOutline = highlight(pal).darker(125);
82 if (highlightedOutline.value() > 160)
83 highlightedOutline.setHsl(highlightedOutline.hue(), highlightedOutline.saturation(), 160);
84 return highlightedOutline;
87 QColor tabFrameColor(
const QPalette &pal)
const {
88 if (pal.window().style() == Qt::TexturePattern)
89 return QColor(255, 255, 255, 8);
90 return buttonColor(pal).lighter(104);
93 QColor buttonColor(
const QPalette &pal)
const {
94 QColor buttonColor = pal.button().color();
95 int val = qGray(buttonColor.rgb());
96 buttonColor = buttonColor.lighter(100 + qMax(1, (180 - val)/6));
97 buttonColor.setHsv(buttonColor.hue(), buttonColor.saturation() * 0.75, buttonColor.value());
103 menuArrowHMargin = 6,
104 menuRightBorder = 15,
105 menuCheckMarkWidth = 12
109 Qt::ColorScheme colorScheme()
const
111 return QGuiApplicationPrivate::platformTheme()->colorScheme();
114 bool isHighContrast()
const
116 return QGuiApplicationPrivate::platformTheme()->contrastPreference()
117 == Qt::ContrastPreference::HighContrast;