Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
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// Qt-Security score:significant reason:default
4
5#ifndef QFUSIONSTYLE_P_P_H
6#define QFUSIONSTYLE_P_P_H
7
8//
9// W A R N I N G
10// -------------
11//
12// This file is not part of the Qt API. It exists for the convenience
13// of qapplication_*.cpp, qwidget*.cpp and qfiledialog.cpp. This header
14// file may change from version to version without notice, or even be removed.
15//
16// We mean it.
17//
18
19#include <QtWidgets/private/qtwidgetsglobal_p.h>
20#include "qcommonstyle.h"
21#include "qcommonstyle_p.h"
22#include <qpa/qplatformtheme.h>
23#include "private/qguiapplication_p.h"
24
25#if QT_CONFIG(style_fusion)
26
27QT_BEGIN_NAMESPACE
28
29class QFusionStylePrivate : public QCommonStylePrivate
30{
31 Q_DECLARE_PUBLIC(QFusionStyle)
32
33public:
34 QFusionStylePrivate();
35
36 // Used for grip handles
37 static constexpr QColor lightShade = QColor(255, 255, 255, 90);
38 static constexpr QColor darkShade = QColor(0, 0, 0, 60);
39 static constexpr QColor topShadow = QColor(0, 0, 0, 18);
40 static constexpr QColor innerContrastLine = QColor(255, 255, 255, 30);
41
42 // On mac we want a standard blue color used when the system palette is used
43 bool isMacSystemPalette(const QPalette &pal) const {
44 Q_UNUSED(pal);
45#if defined(Q_OS_MACOS)
46 const QPalette *themePalette = QGuiApplicationPrivate::platformTheme()->palette();
47 if (themePalette && themePalette->color(QPalette::Normal, QPalette::Highlight) ==
48 pal.color(QPalette::Normal, QPalette::Highlight) &&
49 themePalette->color(QPalette::Normal, QPalette::HighlightedText) ==
50 pal.color(QPalette::Normal, QPalette::HighlightedText))
51 return true;
52#endif
53 return false;
54 }
55
56 QColor highlight(const QPalette &pal) const {
57 if (isMacSystemPalette(pal))
58 return QColor(60, 140, 230);
59 return pal.color(QPalette::Highlight);
60 }
61
62 QColor highlightedText(const QPalette &pal) const {
63 if (isMacSystemPalette(pal))
64 return Qt::white;
65 return pal.color(QPalette::HighlightedText);
66 }
67
68 QColor outline(const QPalette &pal) const {
69 if (isHighContrast()) {
70 return pal.text().color();
71 }
72 if (pal.window().style() == Qt::TexturePattern)
73 return QColor(0, 0, 0, 160);
74 auto windowColor = pal.window().color();
75 if (!windowColor.isValid())
76 windowColor = QPalette().window().color();
77 return windowColor.darker(140);
78 }
79
80 QColor highlightedOutline(const QPalette &pal) const {
81 QColor highlightedOutline = highlight(pal).darker(125);
82 if (highlightedOutline.value() > 160)
83 highlightedOutline.setHsl(highlightedOutline.hue(), highlightedOutline.saturation(), 160);
84 return highlightedOutline;
85 }
86
87 QColor tabFrameColor(const QPalette &pal) const {
88 if (pal.window().style() == Qt::TexturePattern)
89 return QColor(255, 255, 255, 8);
90 return buttonColor(pal).lighter(104);
91 }
92
93 QColor buttonColor(const QPalette &pal) const {
94 QColor buttonColor = pal.button().color();
95 int val = qGray(buttonColor.rgb());
96 buttonColor = buttonColor.lighter(100 + qMax(1, (180 - val)/6));
97 buttonColor.setHsv(buttonColor.hue(), buttonColor.saturation() * 0.75, buttonColor.value());
98 return buttonColor;
99 }
100
101 enum {
102 menuItemHMargin = 3, // menu item hor text margin
103 menuArrowHMargin = 6, // menu arrow horizontal margin
104 menuRightBorder = 15, // right border on menus
105 menuCheckMarkWidth = 12 // checkmarks width on menus
106 };
107
108private:
109 Qt::ColorScheme colorScheme() const
110 {
111 return QGuiApplicationPrivate::platformTheme()->colorScheme();
112 }
113
114 bool isHighContrast() const
115 {
116 return QGuiApplicationPrivate::platformTheme()->contrastPreference()
117 == Qt::ContrastPreference::HighContrast;
118 }
119};
120
121QT_END_NAMESPACE
122
123#endif // style_fusion
124
125#endif //QFUSIONSTYLE_P_P_H
\inmodule QtSql