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);
66QColor QQuickFusionStyle::highlightedOutline(QQuickPalette *palette)
70 if (isHighContrast()) {
71 if (QGuiApplication::styleHints()->colorScheme() == Qt::ColorScheme::Light) {
72 return highlight(palette).darker(125);
74 QColor highlightedOutline = highlight(palette).toHsv();
75 highlightedOutline.setHsv(highlightedOutline.hsvHue(), highlightedOutline.hsvSaturation(), 255);
76 return highlightedOutline;
79 QColor highlightedOutline = highlight(palette).darker(125).toHsv();
80 if (highlightedOutline.value() > 160)
81 highlightedOutline.setHsl(highlightedOutline.hue(), highlightedOutline.saturation(), 160);
82 return highlightedOutline;
90QColor QQuickFusionStyle::buttonColor(QQuickPalette *palette,
bool highlighted,
bool down,
bool hovered)
94 QColor buttonColor = palette->button();
95 int val = qGray(buttonColor.rgb());
96 buttonColor = buttonColor.lighter(100 + qMax(1, (180 - val)/6));
97 buttonColor = buttonColor.toHsv();
98 buttonColor.setHsv(buttonColor.hue(),
int(buttonColor.saturation() * 0.75), buttonColor.value());
100 buttonColor = mergedColors(buttonColor, highlightedOutline(palette).lighter(130), 90);
102 buttonColor = buttonColor.darker(104);
104 buttonColor = buttonColor.darker(110);
126QColor QQuickFusionStyle::mergedColors(
const QColor &colorA,
const QColor &colorB,
int factor)
128 const int maxFactor = 100;
129 const auto rgbColorB = colorB.toRgb();
130 QColor tmp = colorA.toRgb();
131 tmp.setRed((tmp.red() * factor) / maxFactor + (rgbColorB.red() * (maxFactor - factor)) / maxFactor);
132 tmp.setGreen((tmp.green() * factor) / maxFactor + (rgbColorB.green() * (maxFactor - factor)) / maxFactor);
133 tmp.setBlue((tmp.blue() * factor) / maxFactor + (rgbColorB.blue() * (maxFactor - factor)) / maxFactor);
137QColor QQuickFusionStyle::grooveColor(QQuickPalette *palette)
141 QColor color = buttonColor(palette).toHsv();
142 color.setHsv(color.hue(),
143 qMin(255, color.saturation()),
144 qMin<
int>(255, color.value() * 0.9));