18QQuickFusionStyle::QQuickFusionStyle(QObject *parent)
21 connect(QGuiApplication::styleHints()->accessibility(), &QAccessibilityHints::contrastPreferenceChanged,
this, &QQuickFusionStyle::highContrastChanged);
26 return QColor(255, 255, 255, 90);
41 return QColor(255, 255, 255, 30);
64QColor QQuickFusionStyle::highlightedOutline(QQuickPalette *palette)
66 if (isHighContrast()) {
67 if (QGuiApplication::styleHints()->colorScheme() == Qt::ColorScheme::Light) {
68 return highlight(palette).darker(125);
70 QColor highlightedOutline = highlight(palette).toHsv();
71 highlightedOutline.setHsv(highlightedOutline.hsvHue(), highlightedOutline.hsvSaturation(), 255);
72 return highlightedOutline;
75 QColor highlightedOutline = highlight(palette).darker(125).toHsv();
76 if (highlightedOutline.value() > 160)
77 highlightedOutline.setHsl(highlightedOutline.hue(), highlightedOutline.saturation(), 160);
78 return highlightedOutline;
86QColor QQuickFusionStyle::buttonColor(QQuickPalette *palette,
bool highlighted,
bool down,
bool hovered)
88 QColor buttonColor = palette->button();
89 int val = qGray(buttonColor.rgb());
90 buttonColor = buttonColor.lighter(100 + qMax(1, (180 - val)/6));
91 buttonColor = buttonColor.toHsv();
92 buttonColor.setHsv(buttonColor.hue(),
int(buttonColor.saturation() * 0.75), buttonColor.value());
94 buttonColor = mergedColors(buttonColor, highlightedOutline(palette).lighter(130), 90);
96 buttonColor = buttonColor.darker(104);
98 buttonColor = buttonColor.darker(110);
118QColor QQuickFusionStyle::mergedColors(
const QColor &colorA,
const QColor &colorB,
int factor)
120 const int maxFactor = 100;
121 const auto rgbColorB = colorB.toRgb();
122 QColor tmp = colorA.toRgb();
123 tmp.setRed((tmp.red() * factor) / maxFactor + (rgbColorB.red() * (maxFactor - factor)) / maxFactor);
124 tmp.setGreen((tmp.green() * factor) / maxFactor + (rgbColorB.green() * (maxFactor - factor)) / maxFactor);
125 tmp.setBlue((tmp.blue() * factor) / maxFactor + (rgbColorB.blue() * (maxFactor - factor)) / maxFactor);
129QColor QQuickFusionStyle::grooveColor(QQuickPalette *palette)
131 QColor color = buttonColor(palette).toHsv();
132 color.setHsv(color.hue(),
133 qMin(255, color.saturation()),
134 qMin<
int>(255, color.value() * 0.9));