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
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
26QT_BEGIN_NAMESPACE
27
28class QFusionStylePrivate : public QCommonStylePrivate
29{
30 Q_DECLARE_PUBLIC(QFusionStyle)
31
32public:
33 QFusionStylePrivate();
34
35 // Used for grip handles
36 static constexpr QColor lightShade = QColor(255, 255, 255, 90);
37 static constexpr QColor darkShade = QColor(0, 0, 0, 60);
38 static constexpr QColor topShadow = QColor(0, 0, 0, 18);
39 static constexpr QColor innerContrastLine = QColor(255, 255, 255, 30);
40
41 // On mac we want a standard blue color used when the system palette is used
42 bool isMacSystemPalette(const QPalette &pal) const {
43 Q_UNUSED(pal);
44#if defined(Q_OS_MACOS)
45 const QPalette *themePalette = QGuiApplicationPrivate::platformTheme()->palette();
46 if (themePalette && themePalette->color(QPalette::Normal, QPalette::Highlight) ==
47 pal.color(QPalette::Normal, QPalette::Highlight) &&
48 themePalette->color(QPalette::Normal, QPalette::HighlightedText) ==
49 pal.color(QPalette::Normal, QPalette::HighlightedText))
50 return true;
51#endif
52 return false;
53 }
54
55 QColor highlight(const QPalette &pal) const {
56 if (isMacSystemPalette(pal))
57 return QColor(60, 140, 230);
58 return pal.color(QPalette::Highlight);
59 }
60
61 QColor highlightedText(const QPalette &pal) const {
62 if (isMacSystemPalette(pal))
63 return Qt::white;
64 return pal.color(QPalette::HighlightedText);
65 }
66
67 QColor outline(const QPalette &pal) const {
68 if (pal.window().style() == Qt::TexturePattern)
69 return QColor(0, 0, 0, 160);
70 return pal.window().color().darker(140);
71 }
72
73 QColor highlightedOutline(const QPalette &pal) const {
74 QColor highlightedOutline = highlight(pal).darker(125);
75 if (highlightedOutline.value() > 160)
76 highlightedOutline.setHsl(highlightedOutline.hue(), highlightedOutline.saturation(), 160);
77 return highlightedOutline;
78 }
79
80 QColor tabFrameColor(const QPalette &pal) const {
81 if (pal.window().style() == Qt::TexturePattern)
82 return QColor(255, 255, 255, 8);
83 return buttonColor(pal).lighter(104);
84 }
85
86 QColor buttonColor(const QPalette &pal) const {
87 QColor buttonColor = pal.button().color();
88 int val = qGray(buttonColor.rgb());
89 buttonColor = buttonColor.lighter(100 + qMax(1, (180 - val)/6));
90 buttonColor.setHsv(buttonColor.hue(), buttonColor.saturation() * 0.75, buttonColor.value());
91 return buttonColor;
92 }
93
94 enum {
95 menuItemHMargin = 3, // menu item hor text margin
96 menuArrowHMargin = 6, // menu arrow horizontal margin
97 menuRightBorder = 15, // right border on menus
98 menuCheckMarkWidth = 12 // checkmarks width on menus
99 };
100};
101
102QT_END_NAMESPACE
103
104#endif // style_fusion
105
106#endif //QFUSIONSTYLE_P_P_H
\inmodule QtSql