1 /**************************************************************************** 2 ** 3 ** Copyright (C) 2016 The Qt Company Ltd. 4 ** Contact: https://www.qt.io/licensing/ 5 ** 6 ** This file is part of the QtWidgets module of the Qt Toolkit. 7 ** 8 ** $QT_BEGIN_LICENSE:LGPL$ 9 ** Commercial License Usage 10 ** Licensees holding valid commercial Qt licenses may use this file in 11 ** accordance with the commercial license agreement provided with the 12 ** Software or, alternatively, in accordance with the terms contained in 13 ** a written agreement between you and The Qt Company. For licensing terms 14 ** and conditions see https://www.qt.io/terms-conditions. For further 15 ** information use the contact form at https://www.qt.io/contact-us. 16 ** 17 ** GNU Lesser General Public License Usage 18 ** Alternatively, this file may be used under the terms of the GNU Lesser 19 ** General Public License version 3 as published by the Free Software 20 ** Foundation and appearing in the file LICENSE.LGPL3 included in the 21 ** packaging of this file. Please review the following information to 22 ** ensure the GNU Lesser General Public License version 3 requirements 23 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. 24 ** 25 ** GNU General Public License Usage 26 ** Alternatively, this file may be used under the terms of the GNU 27 ** General Public License version 2.0 or (at your option) the GNU General 28 ** Public license version 3 or any later version approved by the KDE Free 29 ** Qt Foundation. The licenses are as published by the Free Software 30 ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 31 ** included in the packaging of this file. Please review the following 32 ** information to ensure the GNU General Public License requirements will 33 ** be met: https://www.gnu.org/licenses/gpl-2.0.html and 34 ** https://www.gnu.org/licenses/gpl-3.0.html. 35 ** 36 ** $QT_END_LICENSE$ 37 ** 38 ****************************************************************************/ 39 40 #ifndef QFUSIONSTYLE_P_P_H 41 #define QFUSIONSTYLE_P_P_H 42 43 // 44 // W A R N I N G 45 // ------------- 46 // 47 // This file is not part of the Qt API. It exists for the convenience 48 // of qapplication_*.cpp, qwidget*.cpp and qfiledialog.cpp. This header 49 // file may change from version to version without notice, or even be removed. 50 // 51 // We mean it. 52 // 53 54 #include <QtWidgets/private/qtwidgetsglobal_p.h> 55 #include "qcommonstyle.h" 56 #include "qcommonstyle_p.h" 57 #include <qpa/qplatformtheme.h> 58 #include "private/qguiapplication_p.h" 59 60 #if QT_CONFIG(style_fusion) 61 62 QT_BEGIN_NAMESPACE 63 64 class QFusionStylePrivate : public QCommonStylePrivate 65 { 66 Q_DECLARE_PUBLIC(QFusionStyle) 67 68 public: 69 QFusionStylePrivate(); 70 71 // Used for grip handles lightShade()72 QColor lightShade() const { 73 return QColor(255, 255, 255, 90); 74 } darkShade()75 QColor darkShade() const { 76 return QColor(0, 0, 0, 60); 77 } 78 topShadow()79 QColor topShadow() const { 80 return QColor(0, 0, 0, 18); 81 } 82 innerContrastLine()83 QColor innerContrastLine() const { 84 return QColor(255, 255, 255, 30); 85 } 86 87 // On mac we want a standard blue color used when the system palette is used isMacSystemPalette(const QPalette & pal)88 bool isMacSystemPalette(const QPalette &pal) const { 89 Q_UNUSED(pal); 90 #if defined(Q_OS_MACX) 91 const QPalette *themePalette = QGuiApplicationPrivate::platformTheme()->palette(); 92 if (themePalette && themePalette->color(QPalette::Normal, QPalette::Highlight) == 93 pal.color(QPalette::Normal, QPalette::Highlight) && 94 themePalette->color(QPalette::Normal, QPalette::HighlightedText) == 95 pal.color(QPalette::Normal, QPalette::HighlightedText)) 96 return true; 97 #endif 98 return false; 99 } 100 highlight(const QPalette & pal)101 QColor highlight(const QPalette &pal) const { 102 if (isMacSystemPalette(pal)) 103 return QColor(60, 140, 230); 104 return pal.color(QPalette::Highlight); 105 } 106 highlightedText(const QPalette & pal)107 QColor highlightedText(const QPalette &pal) const { 108 if (isMacSystemPalette(pal)) 109 return Qt::white; 110 return pal.color(QPalette::HighlightedText); 111 } 112 outline(const QPalette & pal)113 QColor outline(const QPalette &pal) const { 114 if (pal.window().style() == Qt::TexturePattern) 115 return QColor(0, 0, 0, 160); 116 return pal.window().color().darker(140); 117 } 118 highlightedOutline(const QPalette & pal)119 QColor highlightedOutline(const QPalette &pal) const { 120 QColor highlightedOutline = highlight(pal).darker(125); 121 if (highlightedOutline.value() > 160) 122 highlightedOutline.setHsl(highlightedOutline.hue(), highlightedOutline.saturation(), 160); 123 return highlightedOutline; 124 } 125 tabFrameColor(const QPalette & pal)126 QColor tabFrameColor(const QPalette &pal) const { 127 if (pal.window().style() == Qt::TexturePattern) 128 return QColor(255, 255, 255, 8); 129 return buttonColor(pal).lighter(104); 130 } 131 buttonColor(const QPalette & pal)132 QColor buttonColor(const QPalette &pal) const { 133 QColor buttonColor = pal.button().color(); 134 int val = qGray(buttonColor.rgb()); 135 buttonColor = buttonColor.lighter(100 + qMax(1, (180 - val)/6)); 136 buttonColor.setHsv(buttonColor.hue(), buttonColor.saturation() * 0.75, buttonColor.value()); 137 return buttonColor; 138 } 139 140 enum { 141 menuItemHMargin = 3, // menu item hor text margin 142 menuArrowHMargin = 6, // menu arrow horizontal margin 143 menuRightBorder = 15, // right border on menus 144 menuCheckMarkWidth = 12 // checkmarks width on menus 145 }; 146 }; 147 148 QT_END_NAMESPACE 149 150 #endif // style_fusion 151 152 #endif //QFUSIONSTYLE_P_P_H 153