Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qquickfusionstyle.cpp
Go to the documentation of this file.
1// Copyright (C) 2017 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
5
6#include <QtGui/qcolor.h>
7#include <QtGui/qpalette.h>
8#include <QtGui/qpa/qplatformtheme.h>
9#include <QtGui/private/qguiapplication_p.h>
10
11#include <QtQuick/private/qquickpalette_p.h>
12
14
19
21{
22 return QColor(255, 255, 255, 90);
23}
24
26{
27 return QColor(0, 0, 0, 60);
28}
29
31{
32 return QColor(0, 0, 0, 18);
33}
34
36{
37 return QColor(255, 255, 255, 30);
38}
39
44
49
51{
52 return palette->window().darker(140);
53}
54
62
67
68QColor QQuickFusionStyle::buttonColor(QQuickPalette *palette, bool highlighted, bool down, bool hovered)
69{
70 QColor buttonColor = palette->button();
71 int val = qGray(buttonColor.rgb());
72 buttonColor = buttonColor.lighter(100 + qMax(1, (180 - val)/6));
73 buttonColor = buttonColor.toHsv();
74 buttonColor.setHsv(buttonColor.hue(), int(buttonColor.saturation() * 0.75), buttonColor.value());
75 if (highlighted)
77 if (!hovered)
78 buttonColor = buttonColor.darker(104);
79 if (down)
80 buttonColor = buttonColor.darker(110);
81 return buttonColor;
82}
83
85{
86 QColor darkOutline = enabled && highlighted ? highlightedOutline(palette) : outline(palette);
87 return !enabled ? darkOutline.lighter(115) : darkOutline;
88}
89
91{
92 return baseColor.lighter(124);
93}
94
96{
97 return baseColor.lighter(102);
98}
99
100QColor QQuickFusionStyle::mergedColors(const QColor &colorA, const QColor &colorB, int factor)
101{
102 const int maxFactor = 100;
103 const auto rgbColorB = colorB.toRgb();
104 QColor tmp = colorA.toRgb();
105 tmp.setRed((tmp.red() * factor) / maxFactor + (rgbColorB.red() * (maxFactor - factor)) / maxFactor);
106 tmp.setGreen((tmp.green() * factor) / maxFactor + (rgbColorB.green() * (maxFactor - factor)) / maxFactor);
107 tmp.setBlue((tmp.blue() * factor) / maxFactor + (rgbColorB.blue() * (maxFactor - factor)) / maxFactor);
108 return tmp;
109}
110
112{
113 QColor color = buttonColor(palette).toHsv();
114 color.setHsv(color.hue(),
115 qMin(255, color.saturation()),
116 qMin<int>(255, color.value() * 0.9));
117 return color;
118}
119
121
122#include "moc_qquickfusionstyle_p.cpp"
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition qcolor.h:31
QColor toRgb() const noexcept
Create and returns an RGB QColor based on this color.
Definition qcolor.cpp:2035
void setGreen(int green)
Sets the green color component of this color to green.
Definition qcolor.cpp:1568
void setBlue(int blue)
Sets the blue color component of this color to blue.
Definition qcolor.cpp:1597
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
QColor lighter(int f=150) const noexcept
Definition qcolor.cpp:2812
void setRed(int red)
Sets the red color component of this color to red.
Definition qcolor.cpp:1541
\inmodule QtCore
Definition qobject.h:103
static Q_INVOKABLE QColor highlight(QQuickPalette *palette)
static Q_INVOKABLE QColor mergedColors(const QColor &colorA, const QColor &colorB, int factor=50)
static Q_INVOKABLE QColor outline(QQuickPalette *palette)
static Q_INVOKABLE QColor highlightedOutline(QQuickPalette *palette)
static Q_INVOKABLE QColor tabFrameColor(QQuickPalette *palette)
static Q_INVOKABLE QColor gradientStop(const QColor &baseColor)
QQuickFusionStyle(QObject *parent=nullptr)
static Q_INVOKABLE QColor buttonOutline(QQuickPalette *palette, bool highlighted=false, bool enabled=true)
static Q_INVOKABLE QColor highlightedText(QQuickPalette *palette)
static Q_INVOKABLE QColor grooveColor(QQuickPalette *palette)
static Q_INVOKABLE QColor buttonColor(QQuickPalette *palette, bool highlighted=false, bool down=false, bool hovered=false)
static Q_INVOKABLE QColor gradientStart(const QColor &baseColor)
Contains color groups for each QML item state. \inmodule QtQuick.
Combined button and popup list for selecting options.
constexpr const T & qMin(const T &a, const T &b)
Definition qminmax.h:40
constexpr const T & qMax(const T &a, const T &b)
Definition qminmax.h:42
GLenum GLenum GLsizei const GLuint GLboolean enabled
GLuint color
[2]
GLuint GLfloat * val
constexpr int qGray(int r, int g, int b)
Definition qrgb.h:36