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
qfusionstyle_p_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 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
4#ifndef QFUSIONSTYLE_P_P_H
5#define QFUSIONSTYLE_P_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists for the convenience
12// of qapplication_*.cpp, qwidget*.cpp and qfiledialog.cpp. This header
13// file may change from version to version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtWidgets/private/qtwidgetsglobal_p.h>
19#include "qcommonstyle.h"
20#include "qcommonstyle_p.h"
21#include <qpa/qplatformtheme.h>
22#include "private/qguiapplication_p.h"
23
24#if QT_CONFIG(style_fusion)
25
27
28class QFusionStylePrivate : public QCommonStylePrivate
29{
30 Q_DECLARE_PUBLIC(QFusionStyle)
31
32public:
33 QFusionStylePrivate();
34
35 // Used for grip handles
36 QColor lightShade() const {
37 return QColor(255, 255, 255, 90);
38 }
39 QColor darkShade() const {
40 return QColor(0, 0, 0, 60);
41 }
42
43 QColor topShadow() const {
44 return QColor(0, 0, 0, 18);
45 }
46
47 QColor innerContrastLine() const {
48 return QColor(255, 255, 255, 30);
49 }
50
51 // On mac we want a standard blue color used when the system palette is used
52 bool isMacSystemPalette(const QPalette &pal) const {
53 Q_UNUSED(pal);
54#if defined(Q_OS_MACOS)
55 const QPalette *themePalette = QGuiApplicationPrivate::platformTheme()->palette();
56 if (themePalette && themePalette->color(QPalette::Normal, QPalette::Highlight) ==
58 themePalette->color(QPalette::Normal, QPalette::HighlightedText) ==
60 return true;
61#endif
62 return false;
63 }
64
65 QColor highlight(const QPalette &pal) const {
66 if (isMacSystemPalette(pal))
67 return QColor(60, 140, 230);
68 return pal.color(QPalette::Highlight);
69 }
70
71 QColor highlightedText(const QPalette &pal) const {
72 if (isMacSystemPalette(pal))
73 return Qt::white;
75 }
76
77 QColor outline(const QPalette &pal) const {
78 if (pal.window().style() == Qt::TexturePattern)
79 return QColor(0, 0, 0, 160);
80 return pal.window().color().darker(140);
81 }
82
83 QColor highlightedOutline(const QPalette &pal) const {
84 QColor highlightedOutline = highlight(pal).darker(125);
85 if (highlightedOutline.value() > 160)
86 highlightedOutline.setHsl(highlightedOutline.hue(), highlightedOutline.saturation(), 160);
87 return highlightedOutline;
88 }
89
90 QColor tabFrameColor(const QPalette &pal) const {
91 if (pal.window().style() == Qt::TexturePattern)
92 return QColor(255, 255, 255, 8);
93 return buttonColor(pal).lighter(104);
94 }
95
96 QColor buttonColor(const QPalette &pal) const {
97 QColor buttonColor = pal.button().color();
98 int val = qGray(buttonColor.rgb());
99 buttonColor = buttonColor.lighter(100 + qMax(1, (180 - val)/6));
100 buttonColor.setHsv(buttonColor.hue(), buttonColor.saturation() * 0.75, buttonColor.value());
101 return buttonColor;
102 }
103
104 enum {
105 menuItemHMargin = 3, // menu item hor text margin
106 menuArrowHMargin = 6, // menu arrow horizontal margin
107 menuRightBorder = 15, // right border on menus
108 menuCheckMarkWidth = 12 // checkmarks width on menus
109 };
110};
111
113
114#endif // style_fusion
115
116#endif //QFUSIONSTYLE_P_P_H
const QColor & color() const
Returns the brush color.
Definition qbrush.h:121
Qt::BrushStyle style() const
Returns the brush style.
Definition qbrush.h:120
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition qcolor.h:31
int saturation() const noexcept
Returns the HSV saturation color component of this color.
Definition qcolor.cpp:1734
QColor darker(int f=200) const noexcept
Definition qcolor.cpp:2857
void setHsl(int h, int s, int l, int a=255)
Definition qcolor.cpp:1215
QRgb rgb() const noexcept
Returns the RGB value of the color.
Definition qcolor.cpp:1439
int hue() const noexcept
Returns the HSV hue color component of this color.
Definition qcolor.cpp:1708
void setHsv(int h, int s, int v, int a=255)
Sets a HSV color value; h is the hue, s is the saturation, v is the value and a is the alpha componen...
Definition qcolor.cpp:1099
int value() const noexcept
Returns the value color component of this color.
Definition qcolor.cpp:1756
QColor lighter(int f=150) const noexcept
Definition qcolor.cpp:2812
static QPlatformTheme * platformTheme()
The QPalette class contains color groups for each widget state.
Definition qpalette.h:19
const QBrush & button() const
Returns the button brush of the current color group.
Definition qpalette.h:84
const QColor & color(ColorGroup cg, ColorRole cr) const
Returns the color in the specified color group, used for the given color role.
Definition qpalette.h:67
const QBrush & window() const
Returns the window (general background) brush of the current color group.
Definition qpalette.h:93
@ HighlightedText
Definition qpalette.h:53
@ Highlight
Definition qpalette.h:53
Combined button and popup list for selecting options.
@ white
Definition qnamespace.h:31
@ TexturePattern
constexpr const T & qMax(const T &a, const T &b)
Definition qminmax.h:42
GLuint GLfloat * val
constexpr int qGray(int r, int g, int b)
Definition qrgb.h:36
#define Q_UNUSED(x)