| 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 | |
| 26 | QT_BEGIN_NAMESPACE |
| 27 | |
| 28 | class QFusionStylePrivate : public QCommonStylePrivate |
| 29 | { |
| 30 | Q_DECLARE_PUBLIC(QFusionStyle) |
| 31 | |
| 32 | public: |
| 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) == |
| 57 | pal.color(QPalette::Normal, QPalette::Highlight) && |
| 58 | themePalette->color(QPalette::Normal, QPalette::HighlightedText) == |
| 59 | pal.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(cr: QPalette::Highlight); |
| 69 | } |
| 70 | |
| 71 | QColor highlightedText(const QPalette &pal) const { |
| 72 | if (isMacSystemPalette(pal)) |
| 73 | return Qt::white; |
| 74 | return pal.color(cr: QPalette::HighlightedText); |
| 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(f: 140); |
| 81 | } |
| 82 | |
| 83 | QColor highlightedOutline(const QPalette &pal) const { |
| 84 | QColor highlightedOutline = highlight(pal).darker(f: 125); |
| 85 | if (highlightedOutline.value() > 160) |
| 86 | highlightedOutline.setHsl(h: highlightedOutline.hue(), s: highlightedOutline.saturation(), l: 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(f: 104); |
| 94 | } |
| 95 | |
| 96 | QColor buttonColor(const QPalette &pal) const { |
| 97 | QColor buttonColor = pal.button().color(); |
| 98 | int val = qGray(rgb: buttonColor.rgb()); |
| 99 | buttonColor = buttonColor.lighter(f: 100 + qMax(a: 1, b: (180 - val)/6)); |
| 100 | buttonColor.setHsv(h: buttonColor.hue(), s: buttonColor.saturation() * 0.75, v: buttonColor.value()); |
| 101 | return buttonColor; |
| 102 | } |
| 103 | |
| 104 | enum { |
| 105 | = 3, // menu item hor text margin |
| 106 | = 6, // menu arrow horizontal margin |
| 107 | = 15, // right border on menus |
| 108 | = 12 // checkmarks width on menus |
| 109 | }; |
| 110 | }; |
| 111 | |
| 112 | QT_END_NAMESPACE |
| 113 | |
| 114 | #endif // style_fusion |
| 115 | |
| 116 | #endif //QFUSIONSTYLE_P_P_H |
| 117 | |