1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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
|
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qquickfusionstyle_p.h"
#include <QtGui/qcolor.h>
#include <QtGui/qpalette.h>
#include <QtGui/qpa/qplatformtheme.h>
#include <QtGui/private/qguiapplication_p.h>
#include <QtQuick/private/qquickpalette_p.h>
QT_BEGIN_NAMESPACE
QQuickFusionStyle::QQuickFusionStyle(QObject *parent)
: QObject(parent)
{
}
QColor QQuickFusionStyle::lightShade()
{
return QColor(255, 255, 255, 90);
}
QColor QQuickFusionStyle::darkShade()
{
return QColor(0, 0, 0, 60);
}
QColor QQuickFusionStyle::topShadow()
{
return QColor(0, 0, 0, 18);
}
QColor QQuickFusionStyle::innerContrastLine()
{
return QColor(255, 255, 255, 30);
}
QColor QQuickFusionStyle::highlight(QQuickPalette *palette)
{
return palette->highlight();
}
QColor QQuickFusionStyle::highlightedText(QQuickPalette *palette)
{
return palette->highlightedText();
}
QColor QQuickFusionStyle::outline(QQuickPalette *palette)
{
return palette->window().darker(140);
}
QColor QQuickFusionStyle::highlightedOutline(QQuickPalette *palette)
{
QColor highlightedOutline = highlight(palette).darker(125).toHsv();
if (highlightedOutline.value() > 160)
highlightedOutline.setHsl(highlightedOutline.hue(), highlightedOutline.saturation(), 160);
return highlightedOutline;
}
QColor QQuickFusionStyle::tabFrameColor(QQuickPalette *palette)
{
return buttonColor(palette).lighter(104);
}
QColor QQuickFusionStyle::buttonColor(QQuickPalette *palette, bool highlighted, bool down, bool hovered)
{
QColor buttonColor = palette->button();
int val = qGray(buttonColor.rgb());
buttonColor = buttonColor.lighter(100 + qMax(1, (180 - val)/6));
buttonColor = buttonColor.toHsv();
buttonColor.setHsv(buttonColor.hue(), int(buttonColor.saturation() * 0.75), buttonColor.value());
if (highlighted)
buttonColor = mergedColors(buttonColor, highlightedOutline(palette).lighter(130), 90);
if (!hovered)
buttonColor = buttonColor.darker(104);
if (down)
buttonColor = buttonColor.darker(110);
return buttonColor;
}
QColor QQuickFusionStyle::buttonOutline(QQuickPalette *palette, bool highlighted, bool enabled)
{
QColor darkOutline = enabled && highlighted ? highlightedOutline(palette) : outline(palette);
return !enabled ? darkOutline.lighter(115) : darkOutline;
}
QColor QQuickFusionStyle::gradientStart(const QColor &baseColor)
{
return baseColor.lighter(124);
}
QColor QQuickFusionStyle::gradientStop(const QColor &baseColor)
{
return baseColor.lighter(102);
}
QColor QQuickFusionStyle::mergedColors(const QColor &colorA, const QColor &colorB, int factor)
{
const int maxFactor = 100;
const auto rgbColorB = colorB.toRgb();
QColor tmp = colorA.toRgb();
tmp.setRed((tmp.red() * factor) / maxFactor + (rgbColorB.red() * (maxFactor - factor)) / maxFactor);
tmp.setGreen((tmp.green() * factor) / maxFactor + (rgbColorB.green() * (maxFactor - factor)) / maxFactor);
tmp.setBlue((tmp.blue() * factor) / maxFactor + (rgbColorB.blue() * (maxFactor - factor)) / maxFactor);
return tmp;
}
QColor QQuickFusionStyle::grooveColor(QQuickPalette *palette)
{
QColor color = buttonColor(palette).toHsv();
color.setHsv(color.hue(),
qMin(255, color.saturation()),
qMin<int>(255, color.value() * 0.9));
return color;
}
QT_END_NAMESPACE
#include "moc_qquickfusionstyle_p.cpp"
|