| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/widgets/styles/qstylesheetstyle.cpp |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 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 | #include <qglobal.h> | - | ||||||||||||||||||||||||
| 41 | - | |||||||||||||||||||||||||
| 42 | #ifndef QT_NO_STYLE_STYLESHEET | - | ||||||||||||||||||||||||
| 43 | - | |||||||||||||||||||||||||
| 44 | #include "qstylesheetstyle_p.h" | - | ||||||||||||||||||||||||
| 45 | #include "private/qcssutil_p.h" | - | ||||||||||||||||||||||||
| 46 | #include <qdebug.h> | - | ||||||||||||||||||||||||
| 47 | #include <qapplication.h> | - | ||||||||||||||||||||||||
| 48 | #include <qmenu.h> | - | ||||||||||||||||||||||||
| 49 | #include <qmenubar.h> | - | ||||||||||||||||||||||||
| 50 | #include <qpainter.h> | - | ||||||||||||||||||||||||
| 51 | #include <qstyleoption.h> | - | ||||||||||||||||||||||||
| 52 | #include <qlineedit.h> | - | ||||||||||||||||||||||||
| 53 | #include <private/qwindowsstyle_p.h> | - | ||||||||||||||||||||||||
| 54 | #include <qcombobox.h> | - | ||||||||||||||||||||||||
| 55 | #include "private/qcssparser_p.h" | - | ||||||||||||||||||||||||
| 56 | #include "private/qmath_p.h" | - | ||||||||||||||||||||||||
| 57 | #include <qabstractscrollarea.h> | - | ||||||||||||||||||||||||
| 58 | #include "private/qabstractscrollarea_p.h" | - | ||||||||||||||||||||||||
| 59 | #include <qtooltip.h> | - | ||||||||||||||||||||||||
| 60 | #include <qshareddata.h> | - | ||||||||||||||||||||||||
| 61 | #include <qradiobutton.h> | - | ||||||||||||||||||||||||
| 62 | #include <qtoolbutton.h> | - | ||||||||||||||||||||||||
| 63 | #include <qscrollbar.h> | - | ||||||||||||||||||||||||
| 64 | #include <qstring.h> | - | ||||||||||||||||||||||||
| 65 | #include <qfile.h> | - | ||||||||||||||||||||||||
| 66 | #include <qcheckbox.h> | - | ||||||||||||||||||||||||
| 67 | #include <qstatusbar.h> | - | ||||||||||||||||||||||||
| 68 | #include <qheaderview.h> | - | ||||||||||||||||||||||||
| 69 | #include <private/qwindowsstyle_p_p.h> | - | ||||||||||||||||||||||||
| 70 | #include <private/qstyleanimation_p.h> | - | ||||||||||||||||||||||||
| 71 | #include <qtabbar.h> | - | ||||||||||||||||||||||||
| 72 | #include <QMetaProperty> | - | ||||||||||||||||||||||||
| 73 | #include <qmainwindow.h> | - | ||||||||||||||||||||||||
| 74 | #include <qdockwidget.h> | - | ||||||||||||||||||||||||
| 75 | #include <qmdisubwindow.h> | - | ||||||||||||||||||||||||
| 76 | #include <qdialog.h> | - | ||||||||||||||||||||||||
| 77 | #include <private/qwidget_p.h> | - | ||||||||||||||||||||||||
| 78 | #include <QAbstractSpinBox> | - | ||||||||||||||||||||||||
| 79 | #include <QLabel> | - | ||||||||||||||||||||||||
| 80 | #include "qdrawutil.h" | - | ||||||||||||||||||||||||
| 81 | - | |||||||||||||||||||||||||
| 82 | #include <limits.h> | - | ||||||||||||||||||||||||
| 83 | #include <QtWidgets/qtoolbar.h> | - | ||||||||||||||||||||||||
| 84 | - | |||||||||||||||||||||||||
| 85 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||||||||
| 86 | - | |||||||||||||||||||||||||
| 87 | using namespace QCss; | - | ||||||||||||||||||||||||
| 88 | - | |||||||||||||||||||||||||
| 89 | - | |||||||||||||||||||||||||
| 90 | class QStyleSheetStylePrivate : public QWindowsStylePrivate | - | ||||||||||||||||||||||||
| 91 | { | - | ||||||||||||||||||||||||
| 92 | Q_DECLARE_PUBLIC(QStyleSheetStyle) | - | ||||||||||||||||||||||||
| 93 | public: | - | ||||||||||||||||||||||||
| 94 | QStyleSheetStylePrivate() { } | - | ||||||||||||||||||||||||
| 95 | }; | - | ||||||||||||||||||||||||
| 96 | - | |||||||||||||||||||||||||
| 97 | - | |||||||||||||||||||||||||
| 98 | static QStyleSheetStyleCaches *styleSheetCaches = 0; | - | ||||||||||||||||||||||||
| 99 | - | |||||||||||||||||||||||||
| 100 | /* RECURSION_GUARD: | - | ||||||||||||||||||||||||
| 101 | * the QStyleSheetStyle is a proxy. If used with others proxy style, we may end up with something like: | - | ||||||||||||||||||||||||
| 102 | * QStyleSheetStyle -> ProxyStyle -> QStyleSheetStyle -> OriginalStyle | - | ||||||||||||||||||||||||
| 103 | * Recursion may happen if the style call the widget()->style() again. | - | ||||||||||||||||||||||||
| 104 | * Not to mention the performence penalty of having two lookup of rules. | - | ||||||||||||||||||||||||
| 105 | * | - | ||||||||||||||||||||||||
| 106 | * The first instance of QStyleSheetStyle will set globalStyleSheetStyle to itself. The second one | - | ||||||||||||||||||||||||
| 107 | * will notice the globalStyleSheetStyle is not istelf and call its base style directly. | - | ||||||||||||||||||||||||
| 108 | */ | - | ||||||||||||||||||||||||
| 109 | static const QStyleSheetStyle *globalStyleSheetStyle = 0; | - | ||||||||||||||||||||||||
| 110 | class QStyleSheetStyleRecursionGuard | - | ||||||||||||||||||||||||
| 111 | { | - | ||||||||||||||||||||||||
| 112 | public: | - | ||||||||||||||||||||||||
| 113 | QStyleSheetStyleRecursionGuard(const QStyleSheetStyle *that) | - | ||||||||||||||||||||||||
| 114 | : guarded(globalStyleSheetStyle == 0) | - | ||||||||||||||||||||||||
| 115 | { | - | ||||||||||||||||||||||||
| 116 | if (guarded) globalStyleSheetStyle = that; | - | ||||||||||||||||||||||||
| 117 | } | - | ||||||||||||||||||||||||
| 118 | ~QStyleSheetStyleRecursionGuard() { if (guarded) globalStyleSheetStyle = 0; } | - | ||||||||||||||||||||||||
| 119 | bool guarded; | - | ||||||||||||||||||||||||
| 120 | }; | - | ||||||||||||||||||||||||
| 121 | #define RECURSION_GUARD(RETURN) \ | - | ||||||||||||||||||||||||
| 122 | if (globalStyleSheetStyle != 0 && globalStyleSheetStyle != this) { RETURN; } \ | - | ||||||||||||||||||||||||
| 123 | QStyleSheetStyleRecursionGuard recursion_guard(this); | - | ||||||||||||||||||||||||
| 124 | - | |||||||||||||||||||||||||
| 125 | #define ceil(x) ((int)(x) + ((x) > 0 && (x) != (int)(x))) | - | ||||||||||||||||||||||||
| 126 | - | |||||||||||||||||||||||||
| 127 | enum PseudoElement { | - | ||||||||||||||||||||||||
| 128 | PseudoElement_None, | - | ||||||||||||||||||||||||
| 129 | PseudoElement_DownArrow, | - | ||||||||||||||||||||||||
| 130 | PseudoElement_UpArrow, | - | ||||||||||||||||||||||||
| 131 | PseudoElement_LeftArrow, | - | ||||||||||||||||||||||||
| 132 | PseudoElement_RightArrow, | - | ||||||||||||||||||||||||
| 133 | PseudoElement_Indicator, | - | ||||||||||||||||||||||||
| 134 | PseudoElement_ExclusiveIndicator, | - | ||||||||||||||||||||||||
| 135 | PseudoElement_PushButtonMenuIndicator, | - | ||||||||||||||||||||||||
| 136 | PseudoElement_ComboBoxDropDown, | - | ||||||||||||||||||||||||
| 137 | PseudoElement_ComboBoxArrow, | - | ||||||||||||||||||||||||
| 138 | PseudoElement_Item, | - | ||||||||||||||||||||||||
| 139 | PseudoElement_SpinBoxUpButton, | - | ||||||||||||||||||||||||
| 140 | PseudoElement_SpinBoxUpArrow, | - | ||||||||||||||||||||||||
| 141 | PseudoElement_SpinBoxDownButton, | - | ||||||||||||||||||||||||
| 142 | PseudoElement_SpinBoxDownArrow, | - | ||||||||||||||||||||||||
| 143 | PseudoElement_GroupBoxTitle, | - | ||||||||||||||||||||||||
| 144 | PseudoElement_GroupBoxIndicator, | - | ||||||||||||||||||||||||
| 145 | PseudoElement_ToolButtonMenu, | - | ||||||||||||||||||||||||
| 146 | PseudoElement_ToolButtonMenuArrow, | - | ||||||||||||||||||||||||
| 147 | PseudoElement_ToolButtonDownArrow, | - | ||||||||||||||||||||||||
| 148 | PseudoElement_ToolBoxTab, | - | ||||||||||||||||||||||||
| 149 | PseudoElement_ScrollBarSlider, | - | ||||||||||||||||||||||||
| 150 | PseudoElement_ScrollBarAddPage, | - | ||||||||||||||||||||||||
| 151 | PseudoElement_ScrollBarSubPage, | - | ||||||||||||||||||||||||
| 152 | PseudoElement_ScrollBarAddLine, | - | ||||||||||||||||||||||||
| 153 | PseudoElement_ScrollBarSubLine, | - | ||||||||||||||||||||||||
| 154 | PseudoElement_ScrollBarFirst, | - | ||||||||||||||||||||||||
| 155 | PseudoElement_ScrollBarLast, | - | ||||||||||||||||||||||||
| 156 | PseudoElement_ScrollBarUpArrow, | - | ||||||||||||||||||||||||
| 157 | PseudoElement_ScrollBarDownArrow, | - | ||||||||||||||||||||||||
| 158 | PseudoElement_ScrollBarLeftArrow, | - | ||||||||||||||||||||||||
| 159 | PseudoElement_ScrollBarRightArrow, | - | ||||||||||||||||||||||||
| 160 | PseudoElement_SplitterHandle, | - | ||||||||||||||||||||||||
| 161 | PseudoElement_ToolBarHandle, | - | ||||||||||||||||||||||||
| 162 | PseudoElement_ToolBarSeparator, | - | ||||||||||||||||||||||||
| 163 | PseudoElement_MenuScroller, | - | ||||||||||||||||||||||||
| 164 | PseudoElement_MenuTearoff, | - | ||||||||||||||||||||||||
| 165 | PseudoElement_MenuCheckMark, | - | ||||||||||||||||||||||||
| 166 | PseudoElement_MenuSeparator, | - | ||||||||||||||||||||||||
| 167 | PseudoElement_MenuIcon, | - | ||||||||||||||||||||||||
| 168 | PseudoElement_MenuRightArrow, | - | ||||||||||||||||||||||||
| 169 | PseudoElement_TreeViewBranch, | - | ||||||||||||||||||||||||
| 170 | PseudoElement_HeaderViewSection, | - | ||||||||||||||||||||||||
| 171 | PseudoElement_HeaderViewUpArrow, | - | ||||||||||||||||||||||||
| 172 | PseudoElement_HeaderViewDownArrow, | - | ||||||||||||||||||||||||
| 173 | PseudoElement_ProgressBarChunk, | - | ||||||||||||||||||||||||
| 174 | PseudoElement_TabBarTab, | - | ||||||||||||||||||||||||
| 175 | PseudoElement_TabBarScroller, | - | ||||||||||||||||||||||||
| 176 | PseudoElement_TabBarTear, | - | ||||||||||||||||||||||||
| 177 | PseudoElement_SliderGroove, | - | ||||||||||||||||||||||||
| 178 | PseudoElement_SliderHandle, | - | ||||||||||||||||||||||||
| 179 | PseudoElement_SliderAddPage, | - | ||||||||||||||||||||||||
| 180 | PseudoElement_SliderSubPage, | - | ||||||||||||||||||||||||
| 181 | PseudoElement_SliderTickmark, | - | ||||||||||||||||||||||||
| 182 | PseudoElement_TabWidgetPane, | - | ||||||||||||||||||||||||
| 183 | PseudoElement_TabWidgetTabBar, | - | ||||||||||||||||||||||||
| 184 | PseudoElement_TabWidgetLeftCorner, | - | ||||||||||||||||||||||||
| 185 | PseudoElement_TabWidgetRightCorner, | - | ||||||||||||||||||||||||
| 186 | PseudoElement_DockWidgetTitle, | - | ||||||||||||||||||||||||
| 187 | PseudoElement_DockWidgetCloseButton, | - | ||||||||||||||||||||||||
| 188 | PseudoElement_DockWidgetFloatButton, | - | ||||||||||||||||||||||||
| 189 | PseudoElement_DockWidgetSeparator, | - | ||||||||||||||||||||||||
| 190 | PseudoElement_MdiCloseButton, | - | ||||||||||||||||||||||||
| 191 | PseudoElement_MdiMinButton, | - | ||||||||||||||||||||||||
| 192 | PseudoElement_MdiNormalButton, | - | ||||||||||||||||||||||||
| 193 | PseudoElement_TitleBar, | - | ||||||||||||||||||||||||
| 194 | PseudoElement_TitleBarCloseButton, | - | ||||||||||||||||||||||||
| 195 | PseudoElement_TitleBarMinButton, | - | ||||||||||||||||||||||||
| 196 | PseudoElement_TitleBarMaxButton, | - | ||||||||||||||||||||||||
| 197 | PseudoElement_TitleBarShadeButton, | - | ||||||||||||||||||||||||
| 198 | PseudoElement_TitleBarUnshadeButton, | - | ||||||||||||||||||||||||
| 199 | PseudoElement_TitleBarNormalButton, | - | ||||||||||||||||||||||||
| 200 | PseudoElement_TitleBarContextHelpButton, | - | ||||||||||||||||||||||||
| 201 | PseudoElement_TitleBarSysMenu, | - | ||||||||||||||||||||||||
| 202 | PseudoElement_ViewItem, | - | ||||||||||||||||||||||||
| 203 | PseudoElement_ViewItemIcon, | - | ||||||||||||||||||||||||
| 204 | PseudoElement_ViewItemText, | - | ||||||||||||||||||||||||
| 205 | PseudoElement_ViewItemIndicator, | - | ||||||||||||||||||||||||
| 206 | PseudoElement_ScrollAreaCorner, | - | ||||||||||||||||||||||||
| 207 | PseudoElement_TabBarTabCloseButton, | - | ||||||||||||||||||||||||
| 208 | NumPseudoElements | - | ||||||||||||||||||||||||
| 209 | }; | - | ||||||||||||||||||||||||
| 210 | - | |||||||||||||||||||||||||
| 211 | struct PseudoElementInfo { | - | ||||||||||||||||||||||||
| 212 | QStyle::SubControl subControl; | - | ||||||||||||||||||||||||
| 213 | const char name[19]; | - | ||||||||||||||||||||||||
| 214 | }; | - | ||||||||||||||||||||||||
| 215 | - | |||||||||||||||||||||||||
| 216 | static const PseudoElementInfo knownPseudoElements[NumPseudoElements] = { | - | ||||||||||||||||||||||||
| 217 | { QStyle::SC_None, "" }, | - | ||||||||||||||||||||||||
| 218 | { QStyle::SC_None, "down-arrow" }, | - | ||||||||||||||||||||||||
| 219 | { QStyle::SC_None, "up-arrow" }, | - | ||||||||||||||||||||||||
| 220 | { QStyle::SC_None, "left-arrow" }, | - | ||||||||||||||||||||||||
| 221 | { QStyle::SC_None, "right-arrow" }, | - | ||||||||||||||||||||||||
| 222 | { QStyle::SC_None, "indicator" }, | - | ||||||||||||||||||||||||
| 223 | { QStyle::SC_None, "indicator" }, | - | ||||||||||||||||||||||||
| 224 | { QStyle::SC_None, "menu-indicator" }, | - | ||||||||||||||||||||||||
| 225 | { QStyle::SC_ComboBoxArrow, "drop-down" }, | - | ||||||||||||||||||||||||
| 226 | { QStyle::SC_ComboBoxArrow, "down-arrow" }, | - | ||||||||||||||||||||||||
| 227 | { QStyle::SC_None, "item" }, | - | ||||||||||||||||||||||||
| 228 | { QStyle::SC_SpinBoxUp, "up-button" }, | - | ||||||||||||||||||||||||
| 229 | { QStyle::SC_SpinBoxUp, "up-arrow" }, | - | ||||||||||||||||||||||||
| 230 | { QStyle::SC_SpinBoxDown, "down-button" }, | - | ||||||||||||||||||||||||
| 231 | { QStyle::SC_SpinBoxDown, "down-arrow" }, | - | ||||||||||||||||||||||||
| 232 | { QStyle::SC_GroupBoxLabel, "title" }, | - | ||||||||||||||||||||||||
| 233 | { QStyle::SC_GroupBoxCheckBox, "indicator" }, | - | ||||||||||||||||||||||||
| 234 | { QStyle::SC_ToolButtonMenu, "menu-button" }, | - | ||||||||||||||||||||||||
| 235 | { QStyle::SC_ToolButtonMenu, "menu-arrow" }, | - | ||||||||||||||||||||||||
| 236 | { QStyle::SC_None, "menu-indicator" }, | - | ||||||||||||||||||||||||
| 237 | { QStyle::SC_None, "tab" }, | - | ||||||||||||||||||||||||
| 238 | { QStyle::SC_ScrollBarSlider, "handle" }, | - | ||||||||||||||||||||||||
| 239 | { QStyle::SC_ScrollBarAddPage, "add-page" }, | - | ||||||||||||||||||||||||
| 240 | { QStyle::SC_ScrollBarSubPage, "sub-page" }, | - | ||||||||||||||||||||||||
| 241 | { QStyle::SC_ScrollBarAddLine, "add-line" }, | - | ||||||||||||||||||||||||
| 242 | { QStyle::SC_ScrollBarSubLine, "sub-line" }, | - | ||||||||||||||||||||||||
| 243 | { QStyle::SC_ScrollBarFirst, "first" }, | - | ||||||||||||||||||||||||
| 244 | { QStyle::SC_ScrollBarLast, "last" }, | - | ||||||||||||||||||||||||
| 245 | { QStyle::SC_ScrollBarSubLine, "up-arrow" }, | - | ||||||||||||||||||||||||
| 246 | { QStyle::SC_ScrollBarAddLine, "down-arrow" }, | - | ||||||||||||||||||||||||
| 247 | { QStyle::SC_ScrollBarSubLine, "left-arrow" }, | - | ||||||||||||||||||||||||
| 248 | { QStyle::SC_ScrollBarAddLine, "right-arrow" }, | - | ||||||||||||||||||||||||
| 249 | { QStyle::SC_None, "handle" }, | - | ||||||||||||||||||||||||
| 250 | { QStyle::SC_None, "handle" }, | - | ||||||||||||||||||||||||
| 251 | { QStyle::SC_None, "separator" }, | - | ||||||||||||||||||||||||
| 252 | { QStyle::SC_None, "scroller" }, | - | ||||||||||||||||||||||||
| 253 | { QStyle::SC_None, "tearoff" }, | - | ||||||||||||||||||||||||
| 254 | { QStyle::SC_None, "indicator" }, | - | ||||||||||||||||||||||||
| 255 | { QStyle::SC_None, "separator" }, | - | ||||||||||||||||||||||||
| 256 | { QStyle::SC_None, "icon" }, | - | ||||||||||||||||||||||||
| 257 | { QStyle::SC_None, "right-arrow" }, | - | ||||||||||||||||||||||||
| 258 | { QStyle::SC_None, "branch" }, | - | ||||||||||||||||||||||||
| 259 | { QStyle::SC_None, "section" }, | - | ||||||||||||||||||||||||
| 260 | { QStyle::SC_None, "down-arrow" }, | - | ||||||||||||||||||||||||
| 261 | { QStyle::SC_None, "up-arrow" }, | - | ||||||||||||||||||||||||
| 262 | { QStyle::SC_None, "chunk" }, | - | ||||||||||||||||||||||||
| 263 | { QStyle::SC_None, "tab" }, | - | ||||||||||||||||||||||||
| 264 | { QStyle::SC_None, "scroller" }, | - | ||||||||||||||||||||||||
| 265 | { QStyle::SC_None, "tear" }, | - | ||||||||||||||||||||||||
| 266 | { QStyle::SC_SliderGroove, "groove" }, | - | ||||||||||||||||||||||||
| 267 | { QStyle::SC_SliderHandle, "handle" }, | - | ||||||||||||||||||||||||
| 268 | { QStyle::SC_None, "add-page" }, | - | ||||||||||||||||||||||||
| 269 | { QStyle::SC_None, "sub-page"}, | - | ||||||||||||||||||||||||
| 270 | { QStyle::SC_SliderTickmarks, "tick-mark" }, | - | ||||||||||||||||||||||||
| 271 | { QStyle::SC_None, "pane" }, | - | ||||||||||||||||||||||||
| 272 | { QStyle::SC_None, "tab-bar" }, | - | ||||||||||||||||||||||||
| 273 | { QStyle::SC_None, "left-corner" }, | - | ||||||||||||||||||||||||
| 274 | { QStyle::SC_None, "right-corner" }, | - | ||||||||||||||||||||||||
| 275 | { QStyle::SC_None, "title" }, | - | ||||||||||||||||||||||||
| 276 | { QStyle::SC_None, "close-button" }, | - | ||||||||||||||||||||||||
| 277 | { QStyle::SC_None, "float-button" }, | - | ||||||||||||||||||||||||
| 278 | { QStyle::SC_None, "separator" }, | - | ||||||||||||||||||||||||
| 279 | { QStyle::SC_MdiCloseButton, "close-button" }, | - | ||||||||||||||||||||||||
| 280 | { QStyle::SC_MdiMinButton, "minimize-button" }, | - | ||||||||||||||||||||||||
| 281 | { QStyle::SC_MdiNormalButton, "normal-button" }, | - | ||||||||||||||||||||||||
| 282 | { QStyle::SC_TitleBarLabel, "title" }, | - | ||||||||||||||||||||||||
| 283 | { QStyle::SC_TitleBarCloseButton, "close-button" }, | - | ||||||||||||||||||||||||
| 284 | { QStyle::SC_TitleBarMinButton, "minimize-button" }, | - | ||||||||||||||||||||||||
| 285 | { QStyle::SC_TitleBarMaxButton, "maximize-button" }, | - | ||||||||||||||||||||||||
| 286 | { QStyle::SC_TitleBarShadeButton, "shade-button" }, | - | ||||||||||||||||||||||||
| 287 | { QStyle::SC_TitleBarUnshadeButton, "unshade-button" }, | - | ||||||||||||||||||||||||
| 288 | { QStyle::SC_TitleBarNormalButton, "normal-button" }, | - | ||||||||||||||||||||||||
| 289 | { QStyle::SC_TitleBarContextHelpButton, "contexthelp-button" }, | - | ||||||||||||||||||||||||
| 290 | { QStyle::SC_TitleBarSysMenu, "sys-menu" }, | - | ||||||||||||||||||||||||
| 291 | { QStyle::SC_None, "item" }, | - | ||||||||||||||||||||||||
| 292 | { QStyle::SC_None, "icon" }, | - | ||||||||||||||||||||||||
| 293 | { QStyle::SC_None, "text" }, | - | ||||||||||||||||||||||||
| 294 | { QStyle::SC_None, "indicator" }, | - | ||||||||||||||||||||||||
| 295 | { QStyle::SC_None, "corner" }, | - | ||||||||||||||||||||||||
| 296 | { QStyle::SC_None, "close-button" }, | - | ||||||||||||||||||||||||
| 297 | }; | - | ||||||||||||||||||||||||
| 298 | - | |||||||||||||||||||||||||
| 299 | - | |||||||||||||||||||||||||
| 300 | struct QStyleSheetBorderImageData : public QSharedData | - | ||||||||||||||||||||||||
| 301 | { | - | ||||||||||||||||||||||||
| 302 | QStyleSheetBorderImageData() | - | ||||||||||||||||||||||||
| 303 | : horizStretch(QCss::TileMode_Unknown), vertStretch(QCss::TileMode_Unknown) | - | ||||||||||||||||||||||||
| 304 | { | - | ||||||||||||||||||||||||
| 305 | for (int i = 0; i < 4; i++) | - | ||||||||||||||||||||||||
| 306 | cuts[i] = -1; | - | ||||||||||||||||||||||||
| 307 | } | - | ||||||||||||||||||||||||
| 308 | int cuts[4]; | - | ||||||||||||||||||||||||
| 309 | QPixmap pixmap; | - | ||||||||||||||||||||||||
| 310 | QImage image; | - | ||||||||||||||||||||||||
| 311 | QCss::TileMode horizStretch, vertStretch; | - | ||||||||||||||||||||||||
| 312 | }; | - | ||||||||||||||||||||||||
| 313 | - | |||||||||||||||||||||||||
| 314 | struct QStyleSheetBackgroundData : public QSharedData | - | ||||||||||||||||||||||||
| 315 | { | - | ||||||||||||||||||||||||
| 316 | QStyleSheetBackgroundData(const QBrush& b, const QPixmap& p, QCss::Repeat r, | - | ||||||||||||||||||||||||
| 317 | Qt::Alignment a, QCss::Origin o, Attachment t, QCss::Origin c) | - | ||||||||||||||||||||||||
| 318 | : brush(b), pixmap(p), repeat(r), position(a), origin(o), attachment(t), clip(c) { } | - | ||||||||||||||||||||||||
| 319 | - | |||||||||||||||||||||||||
| 320 | bool isTransparent() const { | - | ||||||||||||||||||||||||
| 321 | if (brush.style() != Qt::NoBrush) | - | ||||||||||||||||||||||||
| 322 | return !brush.isOpaque(); | - | ||||||||||||||||||||||||
| 323 | return pixmap.isNull() ? false : pixmap.hasAlpha(); | - | ||||||||||||||||||||||||
| 324 | } | - | ||||||||||||||||||||||||
| 325 | QBrush brush; | - | ||||||||||||||||||||||||
| 326 | QPixmap pixmap; | - | ||||||||||||||||||||||||
| 327 | QCss::Repeat repeat; | - | ||||||||||||||||||||||||
| 328 | Qt::Alignment position; | - | ||||||||||||||||||||||||
| 329 | QCss::Origin origin; | - | ||||||||||||||||||||||||
| 330 | QCss::Attachment attachment; | - | ||||||||||||||||||||||||
| 331 | QCss::Origin clip; | - | ||||||||||||||||||||||||
| 332 | }; | - | ||||||||||||||||||||||||
| 333 | - | |||||||||||||||||||||||||
| 334 | struct QStyleSheetBorderData : public QSharedData | - | ||||||||||||||||||||||||
| 335 | { | - | ||||||||||||||||||||||||
| 336 | QStyleSheetBorderData() : bi(0) | - | ||||||||||||||||||||||||
| 337 | { | - | ||||||||||||||||||||||||
| 338 | for (int i = 0; i < 4; i++) { | - | ||||||||||||||||||||||||
| 339 | borders[i] = 0; | - | ||||||||||||||||||||||||
| 340 | styles[i] = QCss::BorderStyle_None; | - | ||||||||||||||||||||||||
| 341 | } | - | ||||||||||||||||||||||||
| 342 | } | - | ||||||||||||||||||||||||
| 343 | - | |||||||||||||||||||||||||
| 344 | QStyleSheetBorderData(int *b, QBrush *c, QCss::BorderStyle *s, QSize *r) : bi(0) | - | ||||||||||||||||||||||||
| 345 | { | - | ||||||||||||||||||||||||
| 346 | for (int i = 0; i < 4; i++) { | - | ||||||||||||||||||||||||
| 347 | borders[i] = b[i]; | - | ||||||||||||||||||||||||
| 348 | styles[i] = s[i]; | - | ||||||||||||||||||||||||
| 349 | colors[i] = c[i]; | - | ||||||||||||||||||||||||
| 350 | radii[i] = r[i]; | - | ||||||||||||||||||||||||
| 351 | } | - | ||||||||||||||||||||||||
| 352 | } | - | ||||||||||||||||||||||||
| 353 | - | |||||||||||||||||||||||||
| 354 | int borders[4]; | - | ||||||||||||||||||||||||
| 355 | QBrush colors[4]; | - | ||||||||||||||||||||||||
| 356 | QCss::BorderStyle styles[4]; | - | ||||||||||||||||||||||||
| 357 | QSize radii[4]; // topleft, topright, bottomleft, bottomright | - | ||||||||||||||||||||||||
| 358 | - | |||||||||||||||||||||||||
| 359 | const QStyleSheetBorderImageData *borderImage() const | - | ||||||||||||||||||||||||
| 360 | { return bi; } | - | ||||||||||||||||||||||||
| 361 | bool hasBorderImage() const { return bi!=0; } | - | ||||||||||||||||||||||||
| 362 | - | |||||||||||||||||||||||||
| 363 | QSharedDataPointer<QStyleSheetBorderImageData> bi; | - | ||||||||||||||||||||||||
| 364 | - | |||||||||||||||||||||||||
| 365 | bool isOpaque() const | - | ||||||||||||||||||||||||
| 366 | { | - | ||||||||||||||||||||||||
| 367 | for (int i = 0; i < 4; i++) { | - | ||||||||||||||||||||||||
| 368 | if (styles[i] == QCss::BorderStyle_Native || styles[i] == QCss::BorderStyle_None) | - | ||||||||||||||||||||||||
| 369 | continue; | - | ||||||||||||||||||||||||
| 370 | if (styles[i] >= QCss::BorderStyle_Dotted && styles[i] <= QCss::BorderStyle_DotDotDash | - | ||||||||||||||||||||||||
| 371 | && styles[i] != BorderStyle_Solid) | - | ||||||||||||||||||||||||
| 372 | return false; | - | ||||||||||||||||||||||||
| 373 | if (!colors[i].isOpaque()) | - | ||||||||||||||||||||||||
| 374 | return false; | - | ||||||||||||||||||||||||
| 375 | if (!radii[i].isEmpty()) | - | ||||||||||||||||||||||||
| 376 | return false; | - | ||||||||||||||||||||||||
| 377 | } | - | ||||||||||||||||||||||||
| 378 | if (bi != 0 && bi->pixmap.hasAlpha()) | - | ||||||||||||||||||||||||
| 379 | return false; | - | ||||||||||||||||||||||||
| 380 | return true; | - | ||||||||||||||||||||||||
| 381 | } | - | ||||||||||||||||||||||||
| 382 | }; | - | ||||||||||||||||||||||||
| 383 | - | |||||||||||||||||||||||||
| 384 | - | |||||||||||||||||||||||||
| 385 | struct QStyleSheetOutlineData : public QStyleSheetBorderData | - | ||||||||||||||||||||||||
| 386 | { | - | ||||||||||||||||||||||||
| 387 | QStyleSheetOutlineData() | - | ||||||||||||||||||||||||
| 388 | { | - | ||||||||||||||||||||||||
| 389 | for (int i = 0; i < 4; i++) { | - | ||||||||||||||||||||||||
| 390 | offsets[i] = 0; | - | ||||||||||||||||||||||||
| 391 | } | - | ||||||||||||||||||||||||
| 392 | } | - | ||||||||||||||||||||||||
| 393 | - | |||||||||||||||||||||||||
| 394 | QStyleSheetOutlineData(int *b, QBrush *c, QCss::BorderStyle *s, QSize *r, int *o) | - | ||||||||||||||||||||||||
| 395 | : QStyleSheetBorderData(b, c, s, r) | - | ||||||||||||||||||||||||
| 396 | { | - | ||||||||||||||||||||||||
| 397 | for (int i = 0; i < 4; i++) { | - | ||||||||||||||||||||||||
| 398 | offsets[i] = o[i]; | - | ||||||||||||||||||||||||
| 399 | } | - | ||||||||||||||||||||||||
| 400 | } | - | ||||||||||||||||||||||||
| 401 | - | |||||||||||||||||||||||||
| 402 | int offsets[4]; | - | ||||||||||||||||||||||||
| 403 | }; | - | ||||||||||||||||||||||||
| 404 | - | |||||||||||||||||||||||||
| 405 | struct QStyleSheetBoxData : public QSharedData | - | ||||||||||||||||||||||||
| 406 | { | - | ||||||||||||||||||||||||
| 407 | QStyleSheetBoxData(int *m, int *p, int s) : spacing(s) | - | ||||||||||||||||||||||||
| 408 | { | - | ||||||||||||||||||||||||
| 409 | for (int i = 0; i < 4; i++) { | - | ||||||||||||||||||||||||
| 410 | margins[i] = m[i]; | - | ||||||||||||||||||||||||
| 411 | paddings[i] = p[i]; | - | ||||||||||||||||||||||||
| 412 | } | - | ||||||||||||||||||||||||
| 413 | } | - | ||||||||||||||||||||||||
| 414 | - | |||||||||||||||||||||||||
| 415 | int margins[4]; | - | ||||||||||||||||||||||||
| 416 | int paddings[4]; | - | ||||||||||||||||||||||||
| 417 | - | |||||||||||||||||||||||||
| 418 | int spacing; | - | ||||||||||||||||||||||||
| 419 | }; | - | ||||||||||||||||||||||||
| 420 | - | |||||||||||||||||||||||||
| 421 | struct QStyleSheetPaletteData : public QSharedData | - | ||||||||||||||||||||||||
| 422 | { | - | ||||||||||||||||||||||||
| 423 | QStyleSheetPaletteData(const QBrush &fg, const QBrush &sfg, const QBrush &sbg, | - | ||||||||||||||||||||||||
| 424 | const QBrush &abg) | - | ||||||||||||||||||||||||
| 425 | : foreground(fg), selectionForeground(sfg), selectionBackground(sbg), | - | ||||||||||||||||||||||||
| 426 | alternateBackground(abg) { } | - | ||||||||||||||||||||||||
| 427 | - | |||||||||||||||||||||||||
| 428 | QBrush foreground; | - | ||||||||||||||||||||||||
| 429 | QBrush selectionForeground; | - | ||||||||||||||||||||||||
| 430 | QBrush selectionBackground; | - | ||||||||||||||||||||||||
| 431 | QBrush alternateBackground; | - | ||||||||||||||||||||||||
| 432 | }; | - | ||||||||||||||||||||||||
| 433 | - | |||||||||||||||||||||||||
| 434 | struct QStyleSheetGeometryData : public QSharedData | - | ||||||||||||||||||||||||
| 435 | { | - | ||||||||||||||||||||||||
| 436 | QStyleSheetGeometryData(int w, int h, int minw, int minh, int maxw, int maxh) | - | ||||||||||||||||||||||||
| 437 | : minWidth(minw), minHeight(minh), width(w), height(h), maxWidth(maxw), maxHeight(maxh) { } | - | ||||||||||||||||||||||||
| 438 | - | |||||||||||||||||||||||||
| 439 | int minWidth, minHeight, width, height, maxWidth, maxHeight; | - | ||||||||||||||||||||||||
| 440 | }; | - | ||||||||||||||||||||||||
| 441 | - | |||||||||||||||||||||||||
| 442 | struct QStyleSheetPositionData : public QSharedData | - | ||||||||||||||||||||||||
| 443 | { | - | ||||||||||||||||||||||||
| 444 | QStyleSheetPositionData(int l, int t, int r, int b, Origin o, Qt::Alignment p, QCss::PositionMode m, Qt::Alignment a = 0) | - | ||||||||||||||||||||||||
| 445 | : left(l), top(t), bottom(b), right(r), origin(o), position(p), mode(m), textAlignment(a) { } | - | ||||||||||||||||||||||||
| 446 | - | |||||||||||||||||||||||||
| 447 | int left, top, bottom, right; | - | ||||||||||||||||||||||||
| 448 | Origin origin; | - | ||||||||||||||||||||||||
| 449 | Qt::Alignment position; | - | ||||||||||||||||||||||||
| 450 | QCss::PositionMode mode; | - | ||||||||||||||||||||||||
| 451 | Qt::Alignment textAlignment; | - | ||||||||||||||||||||||||
| 452 | }; | - | ||||||||||||||||||||||||
| 453 | - | |||||||||||||||||||||||||
| 454 | struct QStyleSheetImageData : public QSharedData | - | ||||||||||||||||||||||||
| 455 | { | - | ||||||||||||||||||||||||
| 456 | QStyleSheetImageData(const QIcon &i, Qt::Alignment a, const QSize &sz) | - | ||||||||||||||||||||||||
| 457 | : icon(i), alignment(a), size(sz) { } | - | ||||||||||||||||||||||||
| 458 | - | |||||||||||||||||||||||||
| 459 | QIcon icon; | - | ||||||||||||||||||||||||
| 460 | Qt::Alignment alignment; | - | ||||||||||||||||||||||||
| 461 | QSize size; | - | ||||||||||||||||||||||||
| 462 | }; | - | ||||||||||||||||||||||||
| 463 | - | |||||||||||||||||||||||||
| 464 | class QRenderRule | - | ||||||||||||||||||||||||
| 465 | { | - | ||||||||||||||||||||||||
| 466 | public: | - | ||||||||||||||||||||||||
| 467 | QRenderRule() : features(0), hasFont(false), pal(0), b(0), bg(0), bd(0), ou(0), geo(0), p(0), img(0), clipset(0) { } | - | ||||||||||||||||||||||||
| 468 | QRenderRule(const QVector<QCss::Declaration> &, const QObject *); | - | ||||||||||||||||||||||||
| 469 | - | |||||||||||||||||||||||||
| 470 | QRect borderRect(const QRect &r) const; | - | ||||||||||||||||||||||||
| 471 | QRect outlineRect(const QRect &r) const; | - | ||||||||||||||||||||||||
| 472 | QRect paddingRect(const QRect &r) const; | - | ||||||||||||||||||||||||
| 473 | QRect contentsRect(const QRect &r) const; | - | ||||||||||||||||||||||||
| 474 | - | |||||||||||||||||||||||||
| 475 | enum { Margin = 1, Border = 2, Padding = 4, All=Margin|Border|Padding }; | - | ||||||||||||||||||||||||
| 476 | QRect boxRect(const QRect &r, int flags = All) const; | - | ||||||||||||||||||||||||
| 477 | QSize boxSize(const QSize &s, int flags = All) const; | - | ||||||||||||||||||||||||
| 478 | QRect originRect(const QRect &rect, Origin origin) const; | - | ||||||||||||||||||||||||
| 479 | - | |||||||||||||||||||||||||
| 480 | QPainterPath borderClip(QRect rect); | - | ||||||||||||||||||||||||
| 481 | void drawBorder(QPainter *, const QRect&); | - | ||||||||||||||||||||||||
| 482 | void drawOutline(QPainter *, const QRect&); | - | ||||||||||||||||||||||||
| 483 | void drawBorderImage(QPainter *, const QRect&); | - | ||||||||||||||||||||||||
| 484 | void drawBackground(QPainter *, const QRect&, const QPoint& = QPoint(0, 0)); | - | ||||||||||||||||||||||||
| 485 | void drawBackgroundImage(QPainter *, const QRect&, QPoint = QPoint(0, 0)); | - | ||||||||||||||||||||||||
| 486 | void drawFrame(QPainter *, const QRect&); | - | ||||||||||||||||||||||||
| 487 | void drawImage(QPainter *p, const QRect &rect); | - | ||||||||||||||||||||||||
| 488 | void drawRule(QPainter *, const QRect&); | - | ||||||||||||||||||||||||
| 489 | void configurePalette(QPalette *, QPalette::ColorGroup, const QWidget *, bool); | - | ||||||||||||||||||||||||
| 490 | void configurePalette(QPalette *p, QPalette::ColorRole fr, QPalette::ColorRole br); | - | ||||||||||||||||||||||||
| 491 | - | |||||||||||||||||||||||||
| 492 | const QStyleSheetPaletteData *palette() const { return pal; } | - | ||||||||||||||||||||||||
| 493 | const QStyleSheetBoxData *box() const { return b; } | - | ||||||||||||||||||||||||
| 494 | const QStyleSheetBackgroundData *background() const { return bg; } | - | ||||||||||||||||||||||||
| 495 | const QStyleSheetBorderData *border() const { return bd; } | - | ||||||||||||||||||||||||
| 496 | const QStyleSheetOutlineData *outline() const { return ou; } | - | ||||||||||||||||||||||||
| 497 | const QStyleSheetGeometryData *geometry() const { return geo; } | - | ||||||||||||||||||||||||
| 498 | const QStyleSheetPositionData *position() const { return p; } | - | ||||||||||||||||||||||||
| 499 | - | |||||||||||||||||||||||||
| 500 | bool hasPalette() const { return pal != 0; } | - | ||||||||||||||||||||||||
| 501 | bool hasBackground() const { return bg != 0 && (!bg->pixmap.isNull() || bg->brush.style() != Qt::NoBrush); } | - | ||||||||||||||||||||||||
| 502 | bool hasGradientBackground() const { return bg && bg->brush.style() >= Qt::LinearGradientPattern | - | ||||||||||||||||||||||||
| 503 | && bg->brush.style() <= Qt::ConicalGradientPattern; } | - | ||||||||||||||||||||||||
| 504 | - | |||||||||||||||||||||||||
| 505 | bool hasNativeBorder() const { | - | ||||||||||||||||||||||||
| 506 | return bd == 0 | - | ||||||||||||||||||||||||
| 507 | || (!bd->hasBorderImage() && bd->styles[0] == BorderStyle_Native); | - | ||||||||||||||||||||||||
| 508 | } | - | ||||||||||||||||||||||||
| 509 | - | |||||||||||||||||||||||||
| 510 | bool hasNativeOutline() const { | - | ||||||||||||||||||||||||
| 511 | return (ou == 0 | - | ||||||||||||||||||||||||
| 512 | || (!ou->hasBorderImage() && ou->styles[0] == BorderStyle_Native)); | - | ||||||||||||||||||||||||
| 513 | } | - | ||||||||||||||||||||||||
| 514 | - | |||||||||||||||||||||||||
| 515 | bool baseStyleCanDraw() const { | - | ||||||||||||||||||||||||
| 516 | if (!hasBackground() || (background()->brush.style() == Qt::NoBrush && bg->pixmap.isNull())) | - | ||||||||||||||||||||||||
| 517 | return true; | - | ||||||||||||||||||||||||
| 518 | if (bg && !bg->pixmap.isNull()) | - | ||||||||||||||||||||||||
| 519 | return false; | - | ||||||||||||||||||||||||
| 520 | if (hasGradientBackground()) | - | ||||||||||||||||||||||||
| 521 | return features & StyleFeature_BackgroundGradient; | - | ||||||||||||||||||||||||
| 522 | return features & StyleFeature_BackgroundColor; | - | ||||||||||||||||||||||||
| 523 | } | - | ||||||||||||||||||||||||
| 524 | - | |||||||||||||||||||||||||
| 525 | bool hasBox() const { return b != 0; } | - | ||||||||||||||||||||||||
| 526 | bool hasBorder() const { return bd != 0; } | - | ||||||||||||||||||||||||
| 527 | bool hasOutline() const { return ou != 0; } | - | ||||||||||||||||||||||||
| 528 | bool hasPosition() const { return p != 0; } | - | ||||||||||||||||||||||||
| 529 | bool hasGeometry() const { return geo != 0; } | - | ||||||||||||||||||||||||
| 530 | bool hasDrawable() const { return !hasNativeBorder() || hasBackground() || hasImage(); } | - | ||||||||||||||||||||||||
| 531 | bool hasImage() const { return img != 0; } | - | ||||||||||||||||||||||||
| 532 | - | |||||||||||||||||||||||||
| 533 | QSize minimumContentsSize() const | - | ||||||||||||||||||||||||
| 534 | { return geo ? QSize(geo->minWidth, geo->minHeight) : QSize(0, 0); } | - | ||||||||||||||||||||||||
| 535 | QSize minimumSize() const | - | ||||||||||||||||||||||||
| 536 | { return boxSize(minimumContentsSize()); } | - | ||||||||||||||||||||||||
| 537 | - | |||||||||||||||||||||||||
| 538 | QSize contentsSize() const | - | ||||||||||||||||||||||||
| 539 | { return geo ? QSize(geo->width, geo->height) | - | ||||||||||||||||||||||||
| 540 | : ((img && img->size.isValid()) ? img->size : QSize()); } | - | ||||||||||||||||||||||||
| 541 | QSize contentsSize(const QSize &sz) const | - | ||||||||||||||||||||||||
| 542 | { | - | ||||||||||||||||||||||||
| 543 | QSize csz = contentsSize(); | - | ||||||||||||||||||||||||
| 544 | if (csz.width() == -1) csz.setWidth(sz.width()); | - | ||||||||||||||||||||||||
| 545 | if (csz.height() == -1) csz.setHeight(sz.height()); | - | ||||||||||||||||||||||||
| 546 | return csz; | - | ||||||||||||||||||||||||
| 547 | } | - | ||||||||||||||||||||||||
| 548 | bool hasContentsSize() const | - | ||||||||||||||||||||||||
| 549 | { return (geo && (geo->width != -1 || geo->height != -1)) || (img && img->size.isValid()); } | - | ||||||||||||||||||||||||
| 550 | - | |||||||||||||||||||||||||
| 551 | QSize size() const { return boxSize(contentsSize()); } | - | ||||||||||||||||||||||||
| 552 | QSize size(const QSize &sz) const { return boxSize(contentsSize(sz)); } | - | ||||||||||||||||||||||||
| 553 | QSize adjustSize(const QSize &sz) | - | ||||||||||||||||||||||||
| 554 | { | - | ||||||||||||||||||||||||
| 555 | if (!geo) | - | ||||||||||||||||||||||||
| 556 | return sz; | - | ||||||||||||||||||||||||
| 557 | QSize csz = contentsSize(); | - | ||||||||||||||||||||||||
| 558 | if (csz.width() == -1) csz.setWidth(sz.width()); | - | ||||||||||||||||||||||||
| 559 | if (csz.height() == -1) csz.setHeight(sz.height()); | - | ||||||||||||||||||||||||
| 560 | if (geo->maxWidth != -1 && csz.width() > geo->maxWidth) csz.setWidth(geo->maxWidth); | - | ||||||||||||||||||||||||
| 561 | if (geo->maxHeight != -1 && csz.height() > geo->maxHeight) csz.setHeight(geo->maxHeight); | - | ||||||||||||||||||||||||
| 562 | csz=csz.expandedTo(QSize(geo->minWidth, geo->minHeight)); | - | ||||||||||||||||||||||||
| 563 | return csz; | - | ||||||||||||||||||||||||
| 564 | } | - | ||||||||||||||||||||||||
| 565 | - | |||||||||||||||||||||||||
| 566 | bool hasStyleHint(const QString &sh) const { return styleHints.contains(sh); } | - | ||||||||||||||||||||||||
| 567 | QVariant styleHint(const QString &sh) const { return styleHints.value(sh); } | - | ||||||||||||||||||||||||
| 568 | - | |||||||||||||||||||||||||
| 569 | void fixupBorder(int); | - | ||||||||||||||||||||||||
| 570 | - | |||||||||||||||||||||||||
| 571 | // Shouldn't be here | - | ||||||||||||||||||||||||
| 572 | void setClip(QPainter *p, const QRect &rect); | - | ||||||||||||||||||||||||
| 573 | void unsetClip(QPainter *); | - | ||||||||||||||||||||||||
| 574 | - | |||||||||||||||||||||||||
| 575 | public: | - | ||||||||||||||||||||||||
| 576 | int features; | - | ||||||||||||||||||||||||
| 577 | QBrush defaultBackground; | - | ||||||||||||||||||||||||
| 578 | QFont font; | - | ||||||||||||||||||||||||
| 579 | bool hasFont; | - | ||||||||||||||||||||||||
| 580 | - | |||||||||||||||||||||||||
| 581 | QHash<QString, QVariant> styleHints; | - | ||||||||||||||||||||||||
| 582 | - | |||||||||||||||||||||||||
| 583 | QSharedDataPointer<QStyleSheetPaletteData> pal; | - | ||||||||||||||||||||||||
| 584 | QSharedDataPointer<QStyleSheetBoxData> b; | - | ||||||||||||||||||||||||
| 585 | QSharedDataPointer<QStyleSheetBackgroundData> bg; | - | ||||||||||||||||||||||||
| 586 | QSharedDataPointer<QStyleSheetBorderData> bd; | - | ||||||||||||||||||||||||
| 587 | QSharedDataPointer<QStyleSheetOutlineData> ou; | - | ||||||||||||||||||||||||
| 588 | QSharedDataPointer<QStyleSheetGeometryData> geo; | - | ||||||||||||||||||||||||
| 589 | QSharedDataPointer<QStyleSheetPositionData> p; | - | ||||||||||||||||||||||||
| 590 | QSharedDataPointer<QStyleSheetImageData> img; | - | ||||||||||||||||||||||||
| 591 | - | |||||||||||||||||||||||||
| 592 | int clipset; | - | ||||||||||||||||||||||||
| 593 | QPainterPath clipPath; | - | ||||||||||||||||||||||||
| 594 | }; | - | ||||||||||||||||||||||||
| 595 | Q_DECLARE_TYPEINFO(QRenderRule, Q_MOVABLE_TYPE); | - | ||||||||||||||||||||||||
| 596 | - | |||||||||||||||||||||||||
| 597 | /////////////////////////////////////////////////////////////////////////////////////////// | - | ||||||||||||||||||||||||
| 598 | static const char knownStyleHints[][45] = { | - | ||||||||||||||||||||||||
| 599 | "activate-on-singleclick", | - | ||||||||||||||||||||||||
| 600 | "alignment", | - | ||||||||||||||||||||||||
| 601 | "arrow-keys-navigate-into-children", | - | ||||||||||||||||||||||||
| 602 | "backward-icon", | - | ||||||||||||||||||||||||
| 603 | "button-layout", | - | ||||||||||||||||||||||||
| 604 | "cd-icon", | - | ||||||||||||||||||||||||
| 605 | "combobox-list-mousetracking", | - | ||||||||||||||||||||||||
| 606 | "combobox-popup", | - | ||||||||||||||||||||||||
| 607 | "computer-icon", | - | ||||||||||||||||||||||||
| 608 | "desktop-icon", | - | ||||||||||||||||||||||||
| 609 | "dialog-apply-icon", | - | ||||||||||||||||||||||||
| 610 | "dialog-cancel-icon", | - | ||||||||||||||||||||||||
| 611 | "dialog-close-icon", | - | ||||||||||||||||||||||||
| 612 | "dialog-discard-icon", | - | ||||||||||||||||||||||||
| 613 | "dialog-help-icon", | - | ||||||||||||||||||||||||
| 614 | "dialog-no-icon", | - | ||||||||||||||||||||||||
| 615 | "dialog-ok-icon", | - | ||||||||||||||||||||||||
| 616 | "dialog-open-icon", | - | ||||||||||||||||||||||||
| 617 | "dialog-reset-icon", | - | ||||||||||||||||||||||||
| 618 | "dialog-save-icon", | - | ||||||||||||||||||||||||
| 619 | "dialog-yes-icon", | - | ||||||||||||||||||||||||
| 620 | "dialogbuttonbox-buttons-have-icons", | - | ||||||||||||||||||||||||
| 621 | "directory-closed-icon", | - | ||||||||||||||||||||||||
| 622 | "directory-icon", | - | ||||||||||||||||||||||||
| 623 | "directory-link-icon", | - | ||||||||||||||||||||||||
| 624 | "directory-open-icon", | - | ||||||||||||||||||||||||
| 625 | "dither-disable-text", | - | ||||||||||||||||||||||||
| 626 | "dockwidget-close-icon", | - | ||||||||||||||||||||||||
| 627 | "downarrow-icon", | - | ||||||||||||||||||||||||
| 628 | "dvd-icon", | - | ||||||||||||||||||||||||
| 629 | "etch-disabled-text", | - | ||||||||||||||||||||||||
| 630 | "file-icon", | - | ||||||||||||||||||||||||
| 631 | "file-link-icon", | - | ||||||||||||||||||||||||
| 632 | "filedialog-backward-icon", // unused | - | ||||||||||||||||||||||||
| 633 | "filedialog-contentsview-icon", | - | ||||||||||||||||||||||||
| 634 | "filedialog-detailedview-icon", | - | ||||||||||||||||||||||||
| 635 | "filedialog-end-icon", | - | ||||||||||||||||||||||||
| 636 | "filedialog-infoview-icon", | - | ||||||||||||||||||||||||
| 637 | "filedialog-listview-icon", | - | ||||||||||||||||||||||||
| 638 | "filedialog-new-directory-icon", | - | ||||||||||||||||||||||||
| 639 | "filedialog-parent-directory-icon", | - | ||||||||||||||||||||||||
| 640 | "filedialog-start-icon", | - | ||||||||||||||||||||||||
| 641 | "floppy-icon", | - | ||||||||||||||||||||||||
| 642 | "forward-icon", | - | ||||||||||||||||||||||||
| 643 | "gridline-color", | - | ||||||||||||||||||||||||
| 644 | "harddisk-icon", | - | ||||||||||||||||||||||||
| 645 | "home-icon", | - | ||||||||||||||||||||||||
| 646 | "icon-size", | - | ||||||||||||||||||||||||
| 647 | "leftarrow-icon", | - | ||||||||||||||||||||||||
| 648 | "lineedit-password-character", | - | ||||||||||||||||||||||||
| 649 | "lineedit-password-mask-delay", | - | ||||||||||||||||||||||||
| 650 | "mdi-fill-space-on-maximize", | - | ||||||||||||||||||||||||
| 651 | "menu-scrollable", | - | ||||||||||||||||||||||||
| 652 | "menubar-altkey-navigation", | - | ||||||||||||||||||||||||
| 653 | "menubar-separator", | - | ||||||||||||||||||||||||
| 654 | "messagebox-critical-icon", | - | ||||||||||||||||||||||||
| 655 | "messagebox-information-icon", | - | ||||||||||||||||||||||||
| 656 | "messagebox-question-icon", | - | ||||||||||||||||||||||||
| 657 | "messagebox-text-interaction-flags", | - | ||||||||||||||||||||||||
| 658 | "messagebox-warning-icon", | - | ||||||||||||||||||||||||
| 659 | "mouse-tracking", | - | ||||||||||||||||||||||||
| 660 | "network-icon", | - | ||||||||||||||||||||||||
| 661 | "opacity", | - | ||||||||||||||||||||||||
| 662 | "paint-alternating-row-colors-for-empty-area", | - | ||||||||||||||||||||||||
| 663 | "rightarrow-icon", | - | ||||||||||||||||||||||||
| 664 | "scrollbar-contextmenu", | - | ||||||||||||||||||||||||
| 665 | "scrollbar-leftclick-absolute-position", | - | ||||||||||||||||||||||||
| 666 | "scrollbar-middleclick-absolute-position", | - | ||||||||||||||||||||||||
| 667 | "scrollbar-roll-between-buttons", | - | ||||||||||||||||||||||||
| 668 | "scrollbar-scroll-when-pointer-leaves-control", | - | ||||||||||||||||||||||||
| 669 | "scrollview-frame-around-contents", | - | ||||||||||||||||||||||||
| 670 | "show-decoration-selected", | - | ||||||||||||||||||||||||
| 671 | "spinbox-click-autorepeat-rate", | - | ||||||||||||||||||||||||
| 672 | "spincontrol-disable-on-bounds", | - | ||||||||||||||||||||||||
| 673 | "tabbar-elide-mode", | - | ||||||||||||||||||||||||
| 674 | "tabbar-prefer-no-arrows", | - | ||||||||||||||||||||||||
| 675 | "titlebar-close-icon", | - | ||||||||||||||||||||||||
| 676 | "titlebar-contexthelp-icon", | - | ||||||||||||||||||||||||
| 677 | "titlebar-maximize-icon", | - | ||||||||||||||||||||||||
| 678 | "titlebar-menu-icon", | - | ||||||||||||||||||||||||
| 679 | "titlebar-minimize-icon", | - | ||||||||||||||||||||||||
| 680 | "titlebar-normal-icon", | - | ||||||||||||||||||||||||
| 681 | "titlebar-shade-icon", | - | ||||||||||||||||||||||||
| 682 | "titlebar-unshade-icon", | - | ||||||||||||||||||||||||
| 683 | "toolbutton-popup-delay", | - | ||||||||||||||||||||||||
| 684 | "trash-icon", | - | ||||||||||||||||||||||||
| 685 | "uparrow-icon" | - | ||||||||||||||||||||||||
| 686 | }; | - | ||||||||||||||||||||||||
| 687 | - | |||||||||||||||||||||||||
| 688 | static const int numKnownStyleHints = sizeof(knownStyleHints)/sizeof(knownStyleHints[0]); | - | ||||||||||||||||||||||||
| 689 | - | |||||||||||||||||||||||||
| 690 | static QList<QVariant> subControlLayout(const QString& layout) | - | ||||||||||||||||||||||||
| 691 | { | - | ||||||||||||||||||||||||
| 692 | QList<QVariant> buttons; | - | ||||||||||||||||||||||||
| 693 | for (int i = 0; i < layout.count(); i++) { | - | ||||||||||||||||||||||||
| 694 | int button = layout[i].toLatin1(); | - | ||||||||||||||||||||||||
| 695 | switch (button) { | - | ||||||||||||||||||||||||
| 696 | case 'm': | - | ||||||||||||||||||||||||
| 697 | buttons.append(PseudoElement_MdiMinButton); | - | ||||||||||||||||||||||||
| 698 | buttons.append(PseudoElement_TitleBarMinButton); | - | ||||||||||||||||||||||||
| 699 | break; | - | ||||||||||||||||||||||||
| 700 | case 'M': | - | ||||||||||||||||||||||||
| 701 | buttons.append(PseudoElement_TitleBarMaxButton); | - | ||||||||||||||||||||||||
| 702 | break; | - | ||||||||||||||||||||||||
| 703 | case 'X': | - | ||||||||||||||||||||||||
| 704 | buttons.append(PseudoElement_MdiCloseButton); | - | ||||||||||||||||||||||||
| 705 | buttons.append(PseudoElement_TitleBarCloseButton); | - | ||||||||||||||||||||||||
| 706 | break; | - | ||||||||||||||||||||||||
| 707 | case 'N': | - | ||||||||||||||||||||||||
| 708 | buttons.append(PseudoElement_MdiNormalButton); | - | ||||||||||||||||||||||||
| 709 | buttons.append(PseudoElement_TitleBarNormalButton); | - | ||||||||||||||||||||||||
| 710 | break; | - | ||||||||||||||||||||||||
| 711 | case 'I': | - | ||||||||||||||||||||||||
| 712 | buttons.append(PseudoElement_TitleBarSysMenu); | - | ||||||||||||||||||||||||
| 713 | break; | - | ||||||||||||||||||||||||
| 714 | case 'T': | - | ||||||||||||||||||||||||
| 715 | buttons.append(PseudoElement_TitleBar); | - | ||||||||||||||||||||||||
| 716 | break; | - | ||||||||||||||||||||||||
| 717 | case 'H': | - | ||||||||||||||||||||||||
| 718 | buttons.append(PseudoElement_TitleBarContextHelpButton); | - | ||||||||||||||||||||||||
| 719 | break; | - | ||||||||||||||||||||||||
| 720 | case 'S': | - | ||||||||||||||||||||||||
| 721 | buttons.append(PseudoElement_TitleBarShadeButton); | - | ||||||||||||||||||||||||
| 722 | break; | - | ||||||||||||||||||||||||
| 723 | default: | - | ||||||||||||||||||||||||
| 724 | buttons.append(button); | - | ||||||||||||||||||||||||
| 725 | break; | - | ||||||||||||||||||||||||
| 726 | } | - | ||||||||||||||||||||||||
| 727 | } | - | ||||||||||||||||||||||||
| 728 | return buttons; | - | ||||||||||||||||||||||||
| 729 | } | - | ||||||||||||||||||||||||
| 730 | - | |||||||||||||||||||||||||
| 731 | namespace { | - | ||||||||||||||||||||||||
| 732 | struct ButtonInfo { | - | ||||||||||||||||||||||||
| 733 | QRenderRule rule; | - | ||||||||||||||||||||||||
| 734 | int element; | - | ||||||||||||||||||||||||
| 735 | int offset; | - | ||||||||||||||||||||||||
| 736 | int where; | - | ||||||||||||||||||||||||
| 737 | int width; | - | ||||||||||||||||||||||||
| 738 | }; | - | ||||||||||||||||||||||||
| 739 | } | - | ||||||||||||||||||||||||
| 740 | template <> class QTypeInfo<ButtonInfo> : public QTypeInfoMerger<ButtonInfo, QRenderRule, int> {}; | - | ||||||||||||||||||||||||
| 741 | - | |||||||||||||||||||||||||
| 742 | QHash<QStyle::SubControl, QRect> QStyleSheetStyle::titleBarLayout(const QWidget *w, const QStyleOptionTitleBar *tb) const | - | ||||||||||||||||||||||||
| 743 | { | - | ||||||||||||||||||||||||
| 744 | QHash<QStyle::SubControl, QRect> layoutRects; | - | ||||||||||||||||||||||||
| 745 | const bool isMinimized = tb->titleBarState & Qt::WindowMinimized; | - | ||||||||||||||||||||||||
| 746 | const bool isMaximized = tb->titleBarState & Qt::WindowMaximized; | - | ||||||||||||||||||||||||
| 747 | QRenderRule subRule = renderRule(w, tb); | - | ||||||||||||||||||||||||
| 748 | QRect cr = subRule.contentsRect(tb->rect); | - | ||||||||||||||||||||||||
| 749 | QList<QVariant> layout = subRule.styleHint(QLatin1String("button-layout")).toList(); | - | ||||||||||||||||||||||||
| 750 | if (layout.isEmpty()) | - | ||||||||||||||||||||||||
| 751 | layout = subControlLayout(QLatin1String("I(T)HSmMX")); | - | ||||||||||||||||||||||||
| 752 | - | |||||||||||||||||||||||||
| 753 | int offsets[3] = { 0, 0, 0 }; | - | ||||||||||||||||||||||||
| 754 | enum Where { Left, Right, Center, NoWhere } where = Left; | - | ||||||||||||||||||||||||
| 755 | QVector<ButtonInfo> infos; | - | ||||||||||||||||||||||||
| 756 | const int numLayouts = layout.size(); | - | ||||||||||||||||||||||||
| 757 | infos.reserve(numLayouts); | - | ||||||||||||||||||||||||
| 758 | for (int i = 0; i < numLayouts; i++) { | - | ||||||||||||||||||||||||
| 759 | const int element = layout[i].toInt(); | - | ||||||||||||||||||||||||
| 760 | if (element == '(') { | - | ||||||||||||||||||||||||
| 761 | where = Center; | - | ||||||||||||||||||||||||
| 762 | } else if (element == ')') { | - | ||||||||||||||||||||||||
| 763 | where = Right; | - | ||||||||||||||||||||||||
| 764 | } else { | - | ||||||||||||||||||||||||
| 765 | ButtonInfo info; | - | ||||||||||||||||||||||||
| 766 | info.element = element; | - | ||||||||||||||||||||||||
| 767 | switch (element) { | - | ||||||||||||||||||||||||
| 768 | case PseudoElement_TitleBar: | - | ||||||||||||||||||||||||
| 769 | if (!(tb->titleBarFlags & (Qt::WindowTitleHint | Qt::WindowSystemMenuHint))) | - | ||||||||||||||||||||||||
| 770 | continue; | - | ||||||||||||||||||||||||
| 771 | break; | - | ||||||||||||||||||||||||
| 772 | case PseudoElement_TitleBarContextHelpButton: | - | ||||||||||||||||||||||||
| 773 | if (!(tb->titleBarFlags & Qt::WindowContextHelpButtonHint)) | - | ||||||||||||||||||||||||
| 774 | continue; | - | ||||||||||||||||||||||||
| 775 | break; | - | ||||||||||||||||||||||||
| 776 | case PseudoElement_TitleBarMinButton: | - | ||||||||||||||||||||||||
| 777 | if (!(tb->titleBarFlags & Qt::WindowMinimizeButtonHint)) | - | ||||||||||||||||||||||||
| 778 | continue; | - | ||||||||||||||||||||||||
| 779 | if (isMinimized) | - | ||||||||||||||||||||||||
| 780 | info.element = PseudoElement_TitleBarNormalButton; | - | ||||||||||||||||||||||||
| 781 | break; | - | ||||||||||||||||||||||||
| 782 | case PseudoElement_TitleBarMaxButton: | - | ||||||||||||||||||||||||
| 783 | if (!(tb->titleBarFlags & Qt::WindowMaximizeButtonHint)) | - | ||||||||||||||||||||||||
| 784 | continue; | - | ||||||||||||||||||||||||
| 785 | if (isMaximized) | - | ||||||||||||||||||||||||
| 786 | info.element = PseudoElement_TitleBarNormalButton; | - | ||||||||||||||||||||||||
| 787 | break; | - | ||||||||||||||||||||||||
| 788 | case PseudoElement_TitleBarShadeButton: | - | ||||||||||||||||||||||||
| 789 | if (!(tb->titleBarFlags & Qt::WindowShadeButtonHint)) | - | ||||||||||||||||||||||||
| 790 | continue; | - | ||||||||||||||||||||||||
| 791 | if (isMinimized) | - | ||||||||||||||||||||||||
| 792 | info.element = PseudoElement_TitleBarUnshadeButton; | - | ||||||||||||||||||||||||
| 793 | break; | - | ||||||||||||||||||||||||
| 794 | case PseudoElement_TitleBarCloseButton: | - | ||||||||||||||||||||||||
| 795 | case PseudoElement_TitleBarSysMenu: | - | ||||||||||||||||||||||||
| 796 | if (!(tb->titleBarFlags & Qt::WindowSystemMenuHint)) | - | ||||||||||||||||||||||||
| 797 | continue; | - | ||||||||||||||||||||||||
| 798 | break; | - | ||||||||||||||||||||||||
| 799 | default: | - | ||||||||||||||||||||||||
| 800 | continue; | - | ||||||||||||||||||||||||
| 801 | } | - | ||||||||||||||||||||||||
| 802 | if (info.element == PseudoElement_TitleBar) { | - | ||||||||||||||||||||||||
| 803 | info.width = tb->fontMetrics.width(tb->text) + 6; | - | ||||||||||||||||||||||||
| 804 | subRule.geo = new QStyleSheetGeometryData(info.width, tb->fontMetrics.height(), -1, -1, -1, -1); | - | ||||||||||||||||||||||||
| 805 | } else { | - | ||||||||||||||||||||||||
| 806 | subRule = renderRule(w, tb, info.element); | - | ||||||||||||||||||||||||
| 807 | info.width = subRule.size().width(); | - | ||||||||||||||||||||||||
| 808 | } | - | ||||||||||||||||||||||||
| 809 | info.rule = subRule; | - | ||||||||||||||||||||||||
| 810 | info.offset = offsets[where]; | - | ||||||||||||||||||||||||
| 811 | info.where = where; | - | ||||||||||||||||||||||||
| 812 | infos.append(qMove(info)); | - | ||||||||||||||||||||||||
| 813 | - | |||||||||||||||||||||||||
| 814 | offsets[where] += info.width; | - | ||||||||||||||||||||||||
| 815 | } | - | ||||||||||||||||||||||||
| 816 | } | - | ||||||||||||||||||||||||
| 817 | - | |||||||||||||||||||||||||
| 818 | for (int i = 0; i < infos.size(); i++) { | - | ||||||||||||||||||||||||
| 819 | const ButtonInfo &info = infos[i]; | - | ||||||||||||||||||||||||
| 820 | QRect lr = cr; | - | ||||||||||||||||||||||||
| 821 | switch (info.where) { | - | ||||||||||||||||||||||||
| 822 | case Center: { | - | ||||||||||||||||||||||||
| 823 | lr.setLeft(cr.left() + offsets[Left]); | - | ||||||||||||||||||||||||
| 824 | lr.setRight(cr.right() - offsets[Right]); | - | ||||||||||||||||||||||||
| 825 | QRect r(0, 0, offsets[Center], lr.height()); | - | ||||||||||||||||||||||||
| 826 | r.moveCenter(lr.center()); | - | ||||||||||||||||||||||||
| 827 | r.setLeft(r.left()+info.offset); | - | ||||||||||||||||||||||||
| 828 | r.setWidth(info.width); | - | ||||||||||||||||||||||||
| 829 | lr = r; | - | ||||||||||||||||||||||||
| 830 | break; } | - | ||||||||||||||||||||||||
| 831 | case Left: | - | ||||||||||||||||||||||||
| 832 | lr.translate(info.offset, 0); | - | ||||||||||||||||||||||||
| 833 | lr.setWidth(info.width); | - | ||||||||||||||||||||||||
| 834 | break; | - | ||||||||||||||||||||||||
| 835 | case Right: | - | ||||||||||||||||||||||||
| 836 | lr.moveLeft(cr.right() + 1 - offsets[Right] + info.offset); | - | ||||||||||||||||||||||||
| 837 | lr.setWidth(info.width); | - | ||||||||||||||||||||||||
| 838 | break; | - | ||||||||||||||||||||||||
| 839 | default: | - | ||||||||||||||||||||||||
| 840 | break; | - | ||||||||||||||||||||||||
| 841 | } | - | ||||||||||||||||||||||||
| 842 | QStyle::SubControl control = knownPseudoElements[info.element].subControl; | - | ||||||||||||||||||||||||
| 843 | layoutRects[control] = positionRect(w, info.rule, info.element, lr, tb->direction); | - | ||||||||||||||||||||||||
| 844 | } | - | ||||||||||||||||||||||||
| 845 | - | |||||||||||||||||||||||||
| 846 | return layoutRects; | - | ||||||||||||||||||||||||
| 847 | } | - | ||||||||||||||||||||||||
| 848 | - | |||||||||||||||||||||||||
| 849 | static QStyle::StandardPixmap subControlIcon(int pe) | - | ||||||||||||||||||||||||
| 850 | { | - | ||||||||||||||||||||||||
| 851 | switch (pe) { | - | ||||||||||||||||||||||||
| 852 | case PseudoElement_MdiCloseButton: return QStyle::SP_TitleBarCloseButton; | - | ||||||||||||||||||||||||
| 853 | case PseudoElement_MdiMinButton: return QStyle::SP_TitleBarMinButton; | - | ||||||||||||||||||||||||
| 854 | case PseudoElement_MdiNormalButton: return QStyle::SP_TitleBarNormalButton; | - | ||||||||||||||||||||||||
| 855 | case PseudoElement_TitleBarCloseButton: return QStyle::SP_TitleBarCloseButton; | - | ||||||||||||||||||||||||
| 856 | case PseudoElement_TitleBarMinButton: return QStyle::SP_TitleBarMinButton; | - | ||||||||||||||||||||||||
| 857 | case PseudoElement_TitleBarMaxButton: return QStyle::SP_TitleBarMaxButton; | - | ||||||||||||||||||||||||
| 858 | case PseudoElement_TitleBarShadeButton: return QStyle::SP_TitleBarShadeButton; | - | ||||||||||||||||||||||||
| 859 | case PseudoElement_TitleBarUnshadeButton: return QStyle::SP_TitleBarUnshadeButton; | - | ||||||||||||||||||||||||
| 860 | case PseudoElement_TitleBarNormalButton: return QStyle::SP_TitleBarNormalButton; | - | ||||||||||||||||||||||||
| 861 | case PseudoElement_TitleBarContextHelpButton: return QStyle::SP_TitleBarContextHelpButton; | - | ||||||||||||||||||||||||
| 862 | default: break; | - | ||||||||||||||||||||||||
| 863 | } | - | ||||||||||||||||||||||||
| 864 | return QStyle::SP_CustomBase; | - | ||||||||||||||||||||||||
| 865 | } | - | ||||||||||||||||||||||||
| 866 | - | |||||||||||||||||||||||||
| 867 | QRenderRule::QRenderRule(const QVector<Declaration> &declarations, const QObject *object) | - | ||||||||||||||||||||||||
| 868 | : features(0), hasFont(false), pal(0), b(0), bg(0), bd(0), ou(0), geo(0), p(0), img(0), clipset(0) | - | ||||||||||||||||||||||||
| 869 | { | - | ||||||||||||||||||||||||
| 870 | QPalette palette = QApplication::palette(); // ###: ideally widget's palette | - | ||||||||||||||||||||||||
| 871 | ValueExtractor v(declarations, palette); | - | ||||||||||||||||||||||||
| 872 | features = v.extractStyleFeatures(); | - | ||||||||||||||||||||||||
| 873 | - | |||||||||||||||||||||||||
| 874 | int w = -1, h = -1, minw = -1, minh = -1, maxw = -1, maxh = -1; | - | ||||||||||||||||||||||||
| 875 | if (v.extractGeometry(&w, &h, &minw, &minh, &maxw, &maxh)) | - | ||||||||||||||||||||||||
| 876 | geo = new QStyleSheetGeometryData(w, h, minw, minh, maxw, maxh); | - | ||||||||||||||||||||||||
| 877 | - | |||||||||||||||||||||||||
| 878 | int left = 0, top = 0, right = 0, bottom = 0; | - | ||||||||||||||||||||||||
| 879 | Origin origin = Origin_Unknown; | - | ||||||||||||||||||||||||
| 880 | Qt::Alignment position = 0; | - | ||||||||||||||||||||||||
| 881 | QCss::PositionMode mode = PositionMode_Unknown; | - | ||||||||||||||||||||||||
| 882 | Qt::Alignment textAlignment = 0; | - | ||||||||||||||||||||||||
| 883 | if (v.extractPosition(&left, &top, &right, &bottom, &origin, &position, &mode, &textAlignment)) | - | ||||||||||||||||||||||||
| 884 | p = new QStyleSheetPositionData(left, top, right, bottom, origin, position, mode, textAlignment); | - | ||||||||||||||||||||||||
| 885 | - | |||||||||||||||||||||||||
| 886 | int margins[4], paddings[4], spacing = -1; | - | ||||||||||||||||||||||||
| 887 | for (int i = 0; i < 4; i++) | - | ||||||||||||||||||||||||
| 888 | margins[i] = paddings[i] = 0; | - | ||||||||||||||||||||||||
| 889 | if (v.extractBox(margins, paddings, &spacing)) | - | ||||||||||||||||||||||||
| 890 | b = new QStyleSheetBoxData(margins, paddings, spacing); | - | ||||||||||||||||||||||||
| 891 | - | |||||||||||||||||||||||||
| 892 | int borders[4]; | - | ||||||||||||||||||||||||
| 893 | QBrush colors[4]; | - | ||||||||||||||||||||||||
| 894 | QCss::BorderStyle styles[4]; | - | ||||||||||||||||||||||||
| 895 | QSize radii[4]; | - | ||||||||||||||||||||||||
| 896 | for (int i = 0; i < 4; i++) { | - | ||||||||||||||||||||||||
| 897 | borders[i] = 0; | - | ||||||||||||||||||||||||
| 898 | styles[i] = BorderStyle_None; | - | ||||||||||||||||||||||||
| 899 | } | - | ||||||||||||||||||||||||
| 900 | if (v.extractBorder(borders, colors, styles, radii)) | - | ||||||||||||||||||||||||
| 901 | bd = new QStyleSheetBorderData(borders, colors, styles, radii); | - | ||||||||||||||||||||||||
| 902 | - | |||||||||||||||||||||||||
| 903 | int offsets[4]; | - | ||||||||||||||||||||||||
| 904 | for (int i = 0; i < 4; i++) { | - | ||||||||||||||||||||||||
| 905 | borders[i] = offsets[i] = 0; | - | ||||||||||||||||||||||||
| 906 | styles[i] = BorderStyle_None; | - | ||||||||||||||||||||||||
| 907 | } | - | ||||||||||||||||||||||||
| 908 | if (v.extractOutline(borders, colors, styles, radii, offsets)) | - | ||||||||||||||||||||||||
| 909 | ou = new QStyleSheetOutlineData(borders, colors, styles, radii, offsets); | - | ||||||||||||||||||||||||
| 910 | - | |||||||||||||||||||||||||
| 911 | QBrush brush; | - | ||||||||||||||||||||||||
| 912 | QString uri; | - | ||||||||||||||||||||||||
| 913 | Repeat repeat = Repeat_XY; | - | ||||||||||||||||||||||||
| 914 | Qt::Alignment alignment = Qt::AlignTop | Qt::AlignLeft; | - | ||||||||||||||||||||||||
| 915 | Attachment attachment = Attachment_Scroll; | - | ||||||||||||||||||||||||
| 916 | origin = Origin_Padding; | - | ||||||||||||||||||||||||
| 917 | Origin clip = Origin_Border; | - | ||||||||||||||||||||||||
| 918 | if (v.extractBackground(&brush, &uri, &repeat, &alignment, &origin, &attachment, &clip)) | - | ||||||||||||||||||||||||
| 919 | bg = new QStyleSheetBackgroundData(brush, QPixmap(uri), repeat, alignment, origin, attachment, clip); | - | ||||||||||||||||||||||||
| 920 | - | |||||||||||||||||||||||||
| 921 | QBrush sfg, fg; | - | ||||||||||||||||||||||||
| 922 | QBrush sbg, abg; | - | ||||||||||||||||||||||||
| 923 | if (v.extractPalette(&fg, &sfg, &sbg, &abg)) | - | ||||||||||||||||||||||||
| 924 | pal = new QStyleSheetPaletteData(fg, sfg, sbg, abg); | - | ||||||||||||||||||||||||
| 925 | - | |||||||||||||||||||||||||
| 926 | QIcon icon; | - | ||||||||||||||||||||||||
| 927 | alignment = Qt::AlignCenter; | - | ||||||||||||||||||||||||
| 928 | QSize size; | - | ||||||||||||||||||||||||
| 929 | if (v.extractImage(&icon, &alignment, &size)) | - | ||||||||||||||||||||||||
| 930 | img = new QStyleSheetImageData(icon, alignment, size); | - | ||||||||||||||||||||||||
| 931 | - | |||||||||||||||||||||||||
| 932 | int adj = -255; | - | ||||||||||||||||||||||||
| 933 | hasFont = v.extractFont(&font, &adj); | - | ||||||||||||||||||||||||
| 934 | - | |||||||||||||||||||||||||
| 935 | #ifndef QT_NO_TOOLTIP | - | ||||||||||||||||||||||||
| 936 | if (object && qstrcmp(object->metaObject()->className(), "QTipLabel") == 0) | - | ||||||||||||||||||||||||
| 937 | palette = QToolTip::palette(); | - | ||||||||||||||||||||||||
| 938 | #endif | - | ||||||||||||||||||||||||
| 939 | - | |||||||||||||||||||||||||
| 940 | for (int i = 0; i < declarations.count(); i++) { | - | ||||||||||||||||||||||||
| 941 | const Declaration& decl = declarations.at(i); | - | ||||||||||||||||||||||||
| 942 | if (decl.d->propertyId == BorderImage) { | - | ||||||||||||||||||||||||
| 943 | QString uri; | - | ||||||||||||||||||||||||
| 944 | QCss::TileMode horizStretch, vertStretch; | - | ||||||||||||||||||||||||
| 945 | int cuts[4]; | - | ||||||||||||||||||||||||
| 946 | - | |||||||||||||||||||||||||
| 947 | decl.borderImageValue(&uri, cuts, &horizStretch, &vertStretch); | - | ||||||||||||||||||||||||
| 948 | if (uri.isEmpty() || uri == QLatin1String("none")) { | - | ||||||||||||||||||||||||
| 949 | if (bd && bd->bi) | - | ||||||||||||||||||||||||
| 950 | bd->bi->pixmap = QPixmap(); | - | ||||||||||||||||||||||||
| 951 | } else { | - | ||||||||||||||||||||||||
| 952 | if (!bd) | - | ||||||||||||||||||||||||
| 953 | bd = new QStyleSheetBorderData; | - | ||||||||||||||||||||||||
| 954 | if (!bd->bi) | - | ||||||||||||||||||||||||
| 955 | bd->bi = new QStyleSheetBorderImageData; | - | ||||||||||||||||||||||||
| 956 | - | |||||||||||||||||||||||||
| 957 | QStyleSheetBorderImageData *bi = bd->bi; | - | ||||||||||||||||||||||||
| 958 | bi->pixmap = QPixmap(uri); | - | ||||||||||||||||||||||||
| 959 | for (int i = 0; i < 4; i++) | - | ||||||||||||||||||||||||
| 960 | bi->cuts[i] = cuts[i]; | - | ||||||||||||||||||||||||
| 961 | bi->horizStretch = horizStretch; | - | ||||||||||||||||||||||||
| 962 | bi->vertStretch = vertStretch; | - | ||||||||||||||||||||||||
| 963 | } | - | ||||||||||||||||||||||||
| 964 | } else if (decl.d->propertyId == QtBackgroundRole) { | - | ||||||||||||||||||||||||
| 965 | if (bg && bg->brush.style() != Qt::NoBrush) | - | ||||||||||||||||||||||||
| 966 | continue; | - | ||||||||||||||||||||||||
| 967 | int role = decl.d->values.at(0).variant.toInt(); | - | ||||||||||||||||||||||||
| 968 | if (role >= Value_FirstColorRole && role <= Value_LastColorRole) | - | ||||||||||||||||||||||||
| 969 | defaultBackground = palette.color((QPalette::ColorRole)(role-Value_FirstColorRole)); | - | ||||||||||||||||||||||||
| 970 | } else if (decl.d->property.startsWith(QLatin1String("qproperty-"), Qt::CaseInsensitive)) { | - | ||||||||||||||||||||||||
| 971 | // intentionally left blank... | - | ||||||||||||||||||||||||
| 972 | } else if (decl.d->propertyId == UnknownProperty) { | - | ||||||||||||||||||||||||
| 973 | bool knownStyleHint = false; | - | ||||||||||||||||||||||||
| 974 | for (int i = 0; i < numKnownStyleHints; i++) { | - | ||||||||||||||||||||||||
| 975 | QLatin1String styleHint(knownStyleHints[i]); | - | ||||||||||||||||||||||||
| 976 | if (decl.d->property.compare(styleHint) == 0) { | - | ||||||||||||||||||||||||
| 977 | QString hintName = QString(styleHint); | - | ||||||||||||||||||||||||
| 978 | QVariant hintValue; | - | ||||||||||||||||||||||||
| 979 | if (hintName.endsWith(QLatin1String("alignment"))) { | - | ||||||||||||||||||||||||
| 980 | hintValue = (int) decl.alignmentValue(); | - | ||||||||||||||||||||||||
| 981 | } else if (hintName.endsWith(QLatin1String("color"))) { | - | ||||||||||||||||||||||||
| 982 | hintValue = (int) decl.colorValue().rgba(); | - | ||||||||||||||||||||||||
| 983 | } else if (hintName.endsWith(QLatin1String("size"))) { | - | ||||||||||||||||||||||||
| 984 | hintValue = decl.sizeValue(); | - | ||||||||||||||||||||||||
| 985 | } else if (hintName.endsWith(QLatin1String("icon"))) { | - | ||||||||||||||||||||||||
| 986 | hintValue = decl.iconValue(); | - | ||||||||||||||||||||||||
| 987 | } else if (hintName == QLatin1String("button-layout") | - | ||||||||||||||||||||||||
| 988 | && decl.d->values.count() != 0 && decl.d->values.at(0).type == Value::String) { | - | ||||||||||||||||||||||||
| 989 | hintValue = subControlLayout(decl.d->values.at(0).variant.toString()); | - | ||||||||||||||||||||||||
| 990 | } else { | - | ||||||||||||||||||||||||
| 991 | int integer; | - | ||||||||||||||||||||||||
| 992 | decl.intValue(&integer); | - | ||||||||||||||||||||||||
| 993 | hintValue = integer; | - | ||||||||||||||||||||||||
| 994 | } | - | ||||||||||||||||||||||||
| 995 | styleHints[decl.d->property] = hintValue; | - | ||||||||||||||||||||||||
| 996 | knownStyleHint = true; | - | ||||||||||||||||||||||||
| 997 | break; | - | ||||||||||||||||||||||||
| 998 | } | - | ||||||||||||||||||||||||
| 999 | } | - | ||||||||||||||||||||||||
| 1000 | if (!knownStyleHint) | - | ||||||||||||||||||||||||
| 1001 | qDebug("Unknown property %s", qPrintable(decl.d->property)); | - | ||||||||||||||||||||||||
| 1002 | } | - | ||||||||||||||||||||||||
| 1003 | } | - | ||||||||||||||||||||||||
| 1004 | - | |||||||||||||||||||||||||
| 1005 | if (hasBorder()) { | - | ||||||||||||||||||||||||
| 1006 | if (const QWidget *widget = qobject_cast<const QWidget *>(object)) { | - | ||||||||||||||||||||||||
| 1007 | QStyleSheetStyle *style = const_cast<QStyleSheetStyle *>(globalStyleSheetStyle); | - | ||||||||||||||||||||||||
| 1008 | if (!style) | - | ||||||||||||||||||||||||
| 1009 | style = qobject_cast<QStyleSheetStyle *>(widget->style()); | - | ||||||||||||||||||||||||
| 1010 | if (style) | - | ||||||||||||||||||||||||
| 1011 | fixupBorder(style->nativeFrameWidth(widget)); | - | ||||||||||||||||||||||||
| 1012 | } | - | ||||||||||||||||||||||||
| 1013 | if (border()->hasBorderImage()) | - | ||||||||||||||||||||||||
| 1014 | defaultBackground = QBrush(); | - | ||||||||||||||||||||||||
| 1015 | } | - | ||||||||||||||||||||||||
| 1016 | } | - | ||||||||||||||||||||||||
| 1017 | - | |||||||||||||||||||||||||
| 1018 | QRect QRenderRule::borderRect(const QRect& r) const | - | ||||||||||||||||||||||||
| 1019 | { | - | ||||||||||||||||||||||||
| 1020 | if (!hasBox()) | - | ||||||||||||||||||||||||
| 1021 | return r; | - | ||||||||||||||||||||||||
| 1022 | const int* m = box()->margins; | - | ||||||||||||||||||||||||
| 1023 | return r.adjusted(m[LeftEdge], m[TopEdge], -m[RightEdge], -m[BottomEdge]); | - | ||||||||||||||||||||||||
| 1024 | } | - | ||||||||||||||||||||||||
| 1025 | - | |||||||||||||||||||||||||
| 1026 | QRect QRenderRule::outlineRect(const QRect& r) const | - | ||||||||||||||||||||||||
| 1027 | { | - | ||||||||||||||||||||||||
| 1028 | QRect br = borderRect(r); | - | ||||||||||||||||||||||||
| 1029 | if (!hasOutline()) | - | ||||||||||||||||||||||||
| 1030 | return br; | - | ||||||||||||||||||||||||
| 1031 | const int *b = outline()->borders; | - | ||||||||||||||||||||||||
| 1032 | return r.adjusted(b[LeftEdge], b[TopEdge], -b[RightEdge], -b[BottomEdge]); | - | ||||||||||||||||||||||||
| 1033 | } | - | ||||||||||||||||||||||||
| 1034 | - | |||||||||||||||||||||||||
| 1035 | QRect QRenderRule::paddingRect(const QRect& r) const | - | ||||||||||||||||||||||||
| 1036 | { | - | ||||||||||||||||||||||||
| 1037 | QRect br = borderRect(r); | - | ||||||||||||||||||||||||
| 1038 | if (!hasBorder()) | - | ||||||||||||||||||||||||
| 1039 | return br; | - | ||||||||||||||||||||||||
| 1040 | const int *b = border()->borders; | - | ||||||||||||||||||||||||
| 1041 | return br.adjusted(b[LeftEdge], b[TopEdge], -b[RightEdge], -b[BottomEdge]); | - | ||||||||||||||||||||||||
| 1042 | } | - | ||||||||||||||||||||||||
| 1043 | - | |||||||||||||||||||||||||
| 1044 | QRect QRenderRule::contentsRect(const QRect& r) const | - | ||||||||||||||||||||||||
| 1045 | { | - | ||||||||||||||||||||||||
| 1046 | QRect pr = paddingRect(r); | - | ||||||||||||||||||||||||
| 1047 | if (!hasBox()) | - | ||||||||||||||||||||||||
| 1048 | return pr; | - | ||||||||||||||||||||||||
| 1049 | const int *p = box()->paddings; | - | ||||||||||||||||||||||||
| 1050 | return pr.adjusted(p[LeftEdge], p[TopEdge], -p[RightEdge], -p[BottomEdge]); | - | ||||||||||||||||||||||||
| 1051 | } | - | ||||||||||||||||||||||||
| 1052 | - | |||||||||||||||||||||||||
| 1053 | QRect QRenderRule::boxRect(const QRect& cr, int flags) const | - | ||||||||||||||||||||||||
| 1054 | { | - | ||||||||||||||||||||||||
| 1055 | QRect r = cr; | - | ||||||||||||||||||||||||
| 1056 | if (hasBox()) { | - | ||||||||||||||||||||||||
| 1057 | if (flags & Margin) { | - | ||||||||||||||||||||||||
| 1058 | const int *m = box()->margins; | - | ||||||||||||||||||||||||
| 1059 | r.adjust(-m[LeftEdge], -m[TopEdge], m[RightEdge], m[BottomEdge]); | - | ||||||||||||||||||||||||
| 1060 | } | - | ||||||||||||||||||||||||
| 1061 | if (flags & Padding) { | - | ||||||||||||||||||||||||
| 1062 | const int *p = box()->paddings; | - | ||||||||||||||||||||||||
| 1063 | r.adjust(-p[LeftEdge], -p[TopEdge], p[RightEdge], p[BottomEdge]); | - | ||||||||||||||||||||||||
| 1064 | } | - | ||||||||||||||||||||||||
| 1065 | } | - | ||||||||||||||||||||||||
| 1066 | if (hasBorder() && (flags & Border)) { | - | ||||||||||||||||||||||||
| 1067 | const int *b = border()->borders; | - | ||||||||||||||||||||||||
| 1068 | r.adjust(-b[LeftEdge], -b[TopEdge], b[RightEdge], b[BottomEdge]); | - | ||||||||||||||||||||||||
| 1069 | } | - | ||||||||||||||||||||||||
| 1070 | return r; | - | ||||||||||||||||||||||||
| 1071 | } | - | ||||||||||||||||||||||||
| 1072 | - | |||||||||||||||||||||||||
| 1073 | QSize QRenderRule::boxSize(const QSize &cs, int flags) const | - | ||||||||||||||||||||||||
| 1074 | { | - | ||||||||||||||||||||||||
| 1075 | QSize bs = boxRect(QRect(QPoint(0, 0), cs), flags).size(); | - | ||||||||||||||||||||||||
| 1076 | if (cs.width() < 0) bs.setWidth(-1); | - | ||||||||||||||||||||||||
| 1077 | if (cs.height() < 0) bs.setHeight(-1); | - | ||||||||||||||||||||||||
| 1078 | return bs; | - | ||||||||||||||||||||||||
| 1079 | } | - | ||||||||||||||||||||||||
| 1080 | - | |||||||||||||||||||||||||
| 1081 | void QRenderRule::fixupBorder(int nativeWidth) | - | ||||||||||||||||||||||||
| 1082 | { | - | ||||||||||||||||||||||||
| 1083 | if (bd == 0) | - | ||||||||||||||||||||||||
| 1084 | return; | - | ||||||||||||||||||||||||
| 1085 | - | |||||||||||||||||||||||||
| 1086 | if (!bd->hasBorderImage() || bd->bi->pixmap.isNull()) { | - | ||||||||||||||||||||||||
| 1087 | bd->bi = 0; | - | ||||||||||||||||||||||||
| 1088 | // ignore the color, border of edges that have none border-style | - | ||||||||||||||||||||||||
| 1089 | QBrush color = pal ? pal->foreground : QBrush(); | - | ||||||||||||||||||||||||
| 1090 | const bool hasRadius = bd->radii[0].isValid() || bd->radii[1].isValid() | - | ||||||||||||||||||||||||
| 1091 | || bd->radii[2].isValid() || bd->radii[3].isValid(); | - | ||||||||||||||||||||||||
| 1092 | for (int i = 0; i < 4; i++) { | - | ||||||||||||||||||||||||
| 1093 | if ((bd->styles[i] == BorderStyle_Native) && hasRadius) | - | ||||||||||||||||||||||||
| 1094 | bd->styles[i] = BorderStyle_None; | - | ||||||||||||||||||||||||
| 1095 | - | |||||||||||||||||||||||||
| 1096 | switch (bd->styles[i]) { | - | ||||||||||||||||||||||||
| 1097 | case BorderStyle_None: | - | ||||||||||||||||||||||||
| 1098 | // border-style: none forces width to be 0 | - | ||||||||||||||||||||||||
| 1099 | bd->colors[i] = QBrush(); | - | ||||||||||||||||||||||||
| 1100 | bd->borders[i] = 0; | - | ||||||||||||||||||||||||
| 1101 | break; | - | ||||||||||||||||||||||||
| 1102 | case BorderStyle_Native: | - | ||||||||||||||||||||||||
| 1103 | if (bd->borders[i] == 0) | - | ||||||||||||||||||||||||
| 1104 | bd->borders[i] = nativeWidth; | - | ||||||||||||||||||||||||
| 1105 | // intentional fall through | - | ||||||||||||||||||||||||
| 1106 | default: | - | ||||||||||||||||||||||||
| 1107 | if (bd->colors[i].style() == Qt::NoBrush) // auto-acquire 'color' | - | ||||||||||||||||||||||||
| 1108 | bd->colors[i] = color; | - | ||||||||||||||||||||||||
| 1109 | break; | - | ||||||||||||||||||||||||
| 1110 | } | - | ||||||||||||||||||||||||
| 1111 | } | - | ||||||||||||||||||||||||
| 1112 | - | |||||||||||||||||||||||||
| 1113 | return; | - | ||||||||||||||||||||||||
| 1114 | } | - | ||||||||||||||||||||||||
| 1115 | - | |||||||||||||||||||||||||
| 1116 | // inspect the border image | - | ||||||||||||||||||||||||
| 1117 | QStyleSheetBorderImageData *bi = bd->bi; | - | ||||||||||||||||||||||||
| 1118 | if (bi->cuts[0] == -1) { | - | ||||||||||||||||||||||||
| 1119 | for (int i = 0; i < 4; i++) // assume, cut = border | - | ||||||||||||||||||||||||
| 1120 | bi->cuts[i] = int(border()->borders[i]); | - | ||||||||||||||||||||||||
| 1121 | } | - | ||||||||||||||||||||||||
| 1122 | } | - | ||||||||||||||||||||||||
| 1123 | - | |||||||||||||||||||||||||
| 1124 | void QRenderRule::drawBorderImage(QPainter *p, const QRect& rect) | - | ||||||||||||||||||||||||
| 1125 | { | - | ||||||||||||||||||||||||
| 1126 | setClip(p, rect); | - | ||||||||||||||||||||||||
| 1127 | static const Qt::TileRule tileMode2TileRule[] = { | - | ||||||||||||||||||||||||
| 1128 | Qt::StretchTile, Qt::RoundTile, Qt::StretchTile, Qt::RepeatTile, Qt::StretchTile }; | - | ||||||||||||||||||||||||
| 1129 | - | |||||||||||||||||||||||||
| 1130 | const QStyleSheetBorderImageData *borderImageData = border()->borderImage(); | - | ||||||||||||||||||||||||
| 1131 | const int *targetBorders = border()->borders; | - | ||||||||||||||||||||||||
| 1132 | const int *sourceBorders = borderImageData->cuts; | - | ||||||||||||||||||||||||
| 1133 | QMargins sourceMargins(sourceBorders[LeftEdge], sourceBorders[TopEdge], | - | ||||||||||||||||||||||||
| 1134 | sourceBorders[RightEdge], sourceBorders[BottomEdge]); | - | ||||||||||||||||||||||||
| 1135 | QMargins targetMargins(targetBorders[LeftEdge], targetBorders[TopEdge], | - | ||||||||||||||||||||||||
| 1136 | targetBorders[RightEdge], targetBorders[BottomEdge]); | - | ||||||||||||||||||||||||
| 1137 | - | |||||||||||||||||||||||||
| 1138 | bool wasSmoothPixmapTransform = p->renderHints() & QPainter::SmoothPixmapTransform; | - | ||||||||||||||||||||||||
| 1139 | p->setRenderHint(QPainter::SmoothPixmapTransform); | - | ||||||||||||||||||||||||
| 1140 | qDrawBorderPixmap(p, rect, targetMargins, borderImageData->pixmap, | - | ||||||||||||||||||||||||
| 1141 | QRect(QPoint(), borderImageData->pixmap.size()), sourceMargins, | - | ||||||||||||||||||||||||
| 1142 | QTileRules(tileMode2TileRule[borderImageData->horizStretch], tileMode2TileRule[borderImageData->vertStretch])); | - | ||||||||||||||||||||||||
| 1143 | p->setRenderHint(QPainter::SmoothPixmapTransform, wasSmoothPixmapTransform); | - | ||||||||||||||||||||||||
| 1144 | unsetClip(p); | - | ||||||||||||||||||||||||
| 1145 | } | - | ||||||||||||||||||||||||
| 1146 | - | |||||||||||||||||||||||||
| 1147 | QRect QRenderRule::originRect(const QRect &rect, Origin origin) const | - | ||||||||||||||||||||||||
| 1148 | { | - | ||||||||||||||||||||||||
| 1149 | switch (origin) { | - | ||||||||||||||||||||||||
| 1150 | case Origin_Padding: | - | ||||||||||||||||||||||||
| 1151 | return paddingRect(rect); | - | ||||||||||||||||||||||||
| 1152 | case Origin_Border: | - | ||||||||||||||||||||||||
| 1153 | return borderRect(rect); | - | ||||||||||||||||||||||||
| 1154 | case Origin_Content: | - | ||||||||||||||||||||||||
| 1155 | return contentsRect(rect); | - | ||||||||||||||||||||||||
| 1156 | case Origin_Margin: | - | ||||||||||||||||||||||||
| 1157 | default: | - | ||||||||||||||||||||||||
| 1158 | return rect; | - | ||||||||||||||||||||||||
| 1159 | } | - | ||||||||||||||||||||||||
| 1160 | } | - | ||||||||||||||||||||||||
| 1161 | - | |||||||||||||||||||||||||
| 1162 | void QRenderRule::drawBackgroundImage(QPainter *p, const QRect &rect, QPoint off) | - | ||||||||||||||||||||||||
| 1163 | { | - | ||||||||||||||||||||||||
| 1164 | if (!hasBackground()) | - | ||||||||||||||||||||||||
| 1165 | return; | - | ||||||||||||||||||||||||
| 1166 | - | |||||||||||||||||||||||||
| 1167 | const QPixmap& bgp = background()->pixmap; | - | ||||||||||||||||||||||||
| 1168 | if (bgp.isNull()) | - | ||||||||||||||||||||||||
| 1169 | return; | - | ||||||||||||||||||||||||
| 1170 | - | |||||||||||||||||||||||||
| 1171 | setClip(p, borderRect(rect)); | - | ||||||||||||||||||||||||
| 1172 | - | |||||||||||||||||||||||||
| 1173 | if (background()->origin != background()->clip) { | - | ||||||||||||||||||||||||
| 1174 | p->save(); | - | ||||||||||||||||||||||||
| 1175 | p->setClipRect(originRect(rect, background()->clip), Qt::IntersectClip); | - | ||||||||||||||||||||||||
| 1176 | } | - | ||||||||||||||||||||||||
| 1177 | - | |||||||||||||||||||||||||
| 1178 | if (background()->attachment == Attachment_Fixed) | - | ||||||||||||||||||||||||
| 1179 | off = QPoint(0, 0); | - | ||||||||||||||||||||||||
| 1180 | - | |||||||||||||||||||||||||
| 1181 | QRect r = originRect(rect, background()->origin); | - | ||||||||||||||||||||||||
| 1182 | QRect aligned = QStyle::alignedRect(Qt::LeftToRight, background()->position, bgp.size(), r); | - | ||||||||||||||||||||||||
| 1183 | QRect inter = aligned.translated(-off).intersected(r); | - | ||||||||||||||||||||||||
| 1184 | - | |||||||||||||||||||||||||
| 1185 | switch (background()->repeat) { | - | ||||||||||||||||||||||||
| 1186 | case Repeat_Y: | - | ||||||||||||||||||||||||
| 1187 | p->drawTiledPixmap(inter.x(), r.y(), inter.width(), r.height(), bgp, | - | ||||||||||||||||||||||||
| 1188 | inter.x() - aligned.x() + off.x(), | - | ||||||||||||||||||||||||
| 1189 | bgp.height() - int(aligned.y() - r.y()) % bgp.height() + off.y()); | - | ||||||||||||||||||||||||
| 1190 | break; | - | ||||||||||||||||||||||||
| 1191 | case Repeat_X: | - | ||||||||||||||||||||||||
| 1192 | p->drawTiledPixmap(r.x(), inter.y(), r.width(), inter.height(), bgp, | - | ||||||||||||||||||||||||
| 1193 | bgp.width() - int(aligned.x() - r.x())%bgp.width() + off.x(), | - | ||||||||||||||||||||||||
| 1194 | inter.y() - aligned.y() + off.y()); | - | ||||||||||||||||||||||||
| 1195 | break; | - | ||||||||||||||||||||||||
| 1196 | case Repeat_XY: | - | ||||||||||||||||||||||||
| 1197 | p->drawTiledPixmap(r, bgp, | - | ||||||||||||||||||||||||
| 1198 | QPoint(bgp.width() - int(aligned.x() - r.x())% bgp.width() + off.x(), | - | ||||||||||||||||||||||||
| 1199 | bgp.height() - int(aligned.y() - r.y())%bgp.height() + off.y())); | - | ||||||||||||||||||||||||
| 1200 | break; | - | ||||||||||||||||||||||||
| 1201 | case Repeat_None: | - | ||||||||||||||||||||||||
| 1202 | default: | - | ||||||||||||||||||||||||
| 1203 | p->drawPixmap(inter.x(), inter.y(), bgp, inter.x() - aligned.x() + off.x(), | - | ||||||||||||||||||||||||
| 1204 | inter.y() - aligned.y() + off.y(), inter.width(), inter.height()); | - | ||||||||||||||||||||||||
| 1205 | break; | - | ||||||||||||||||||||||||
| 1206 | } | - | ||||||||||||||||||||||||
| 1207 | - | |||||||||||||||||||||||||
| 1208 | - | |||||||||||||||||||||||||
| 1209 | if (background()->origin != background()->clip) | - | ||||||||||||||||||||||||
| 1210 | p->restore(); | - | ||||||||||||||||||||||||
| 1211 | - | |||||||||||||||||||||||||
| 1212 | unsetClip(p); | - | ||||||||||||||||||||||||
| 1213 | } | - | ||||||||||||||||||||||||
| 1214 | - | |||||||||||||||||||||||||
| 1215 | void QRenderRule::drawOutline(QPainter *p, const QRect &rect) | - | ||||||||||||||||||||||||
| 1216 | { | - | ||||||||||||||||||||||||
| 1217 | if (!hasOutline()) | - | ||||||||||||||||||||||||
| 1218 | return; | - | ||||||||||||||||||||||||
| 1219 | - | |||||||||||||||||||||||||
| 1220 | bool wasAntialiased = p->renderHints() & QPainter::Antialiasing; | - | ||||||||||||||||||||||||
| 1221 | p->setRenderHint(QPainter::Antialiasing); | - | ||||||||||||||||||||||||
| 1222 | qDrawBorder(p, rect, ou->styles, ou->borders, ou->colors, ou->radii); | - | ||||||||||||||||||||||||
| 1223 | p->setRenderHint(QPainter::Antialiasing, wasAntialiased); | - | ||||||||||||||||||||||||
| 1224 | } | - | ||||||||||||||||||||||||
| 1225 | - | |||||||||||||||||||||||||
| 1226 | void QRenderRule::drawBorder(QPainter *p, const QRect& rect) | - | ||||||||||||||||||||||||
| 1227 | { | - | ||||||||||||||||||||||||
| 1228 | if (!hasBorder()) | - | ||||||||||||||||||||||||
| 1229 | return; | - | ||||||||||||||||||||||||
| 1230 | - | |||||||||||||||||||||||||
| 1231 | if (border()->hasBorderImage()) { | - | ||||||||||||||||||||||||
| 1232 | drawBorderImage(p, rect); | - | ||||||||||||||||||||||||
| 1233 | return; | - | ||||||||||||||||||||||||
| 1234 | } | - | ||||||||||||||||||||||||
| 1235 | - | |||||||||||||||||||||||||
| 1236 | bool wasAntialiased = p->renderHints() & QPainter::Antialiasing; | - | ||||||||||||||||||||||||
| 1237 | p->setRenderHint(QPainter::Antialiasing); | - | ||||||||||||||||||||||||
| 1238 | qDrawBorder(p, rect, bd->styles, bd->borders, bd->colors, bd->radii); | - | ||||||||||||||||||||||||
| 1239 | p->setRenderHint(QPainter::Antialiasing, wasAntialiased); | - | ||||||||||||||||||||||||
| 1240 | } | - | ||||||||||||||||||||||||
| 1241 | - | |||||||||||||||||||||||||
| 1242 | QPainterPath QRenderRule::borderClip(QRect r) | - | ||||||||||||||||||||||||
| 1243 | { | - | ||||||||||||||||||||||||
| 1244 | if (!hasBorder()) | - | ||||||||||||||||||||||||
| 1245 | return QPainterPath(); | - | ||||||||||||||||||||||||
| 1246 | - | |||||||||||||||||||||||||
| 1247 | QSize tlr, trr, blr, brr; | - | ||||||||||||||||||||||||
| 1248 | qNormalizeRadii(r, bd->radii, &tlr, &trr, &blr, &brr); | - | ||||||||||||||||||||||||
| 1249 | if (tlr.isNull() && trr.isNull() && blr.isNull() && brr.isNull()) | - | ||||||||||||||||||||||||
| 1250 | return QPainterPath(); | - | ||||||||||||||||||||||||
| 1251 | - | |||||||||||||||||||||||||
| 1252 | const QRectF rect(r); | - | ||||||||||||||||||||||||
| 1253 | const int *borders = border()->borders; | - | ||||||||||||||||||||||||
| 1254 | QPainterPath path; | - | ||||||||||||||||||||||||
| 1255 | qreal curY = rect.y() + borders[TopEdge]/2.0; | - | ||||||||||||||||||||||||
| 1256 | path.moveTo(rect.x() + tlr.width(), curY); | - | ||||||||||||||||||||||||
| 1257 | path.lineTo(rect.right() - trr.width(), curY); | - | ||||||||||||||||||||||||
| 1258 | qreal curX = rect.right() - borders[RightEdge]/2.0; | - | ||||||||||||||||||||||||
| 1259 | path.arcTo(curX - 2*trr.width() + borders[RightEdge], curY, | - | ||||||||||||||||||||||||
| 1260 | trr.width()*2 - borders[RightEdge], trr.height()*2 - borders[TopEdge], 90, -90); | - | ||||||||||||||||||||||||
| 1261 | - | |||||||||||||||||||||||||
| 1262 | path.lineTo(curX, rect.bottom() - brr.height()); | - | ||||||||||||||||||||||||
| 1263 | curY = rect.bottom() - borders[BottomEdge]/2.0; | - | ||||||||||||||||||||||||
| 1264 | path.arcTo(curX - 2*brr.width() + borders[RightEdge], curY - 2*brr.height() + borders[BottomEdge], | - | ||||||||||||||||||||||||
| 1265 | brr.width()*2 - borders[RightEdge], brr.height()*2 - borders[BottomEdge], 0, -90); | - | ||||||||||||||||||||||||
| 1266 | - | |||||||||||||||||||||||||
| 1267 | path.lineTo(rect.x() + blr.width(), curY); | - | ||||||||||||||||||||||||
| 1268 | curX = rect.left() + borders[LeftEdge]/2.0; | - | ||||||||||||||||||||||||
| 1269 | path.arcTo(curX, rect.bottom() - 2*blr.height() + borders[BottomEdge]/2, | - | ||||||||||||||||||||||||
| 1270 | blr.width()*2 - borders[LeftEdge], blr.height()*2 - borders[BottomEdge], 270, -90); | - | ||||||||||||||||||||||||
| 1271 | - | |||||||||||||||||||||||||
| 1272 | path.lineTo(curX, rect.top() + tlr.height()); | - | ||||||||||||||||||||||||
| 1273 | path.arcTo(curX, rect.top() + borders[TopEdge]/2, | - | ||||||||||||||||||||||||
| 1274 | tlr.width()*2 - borders[LeftEdge], tlr.height()*2 - borders[TopEdge], 180, -90); | - | ||||||||||||||||||||||||
| 1275 | - | |||||||||||||||||||||||||
| 1276 | path.closeSubpath(); | - | ||||||||||||||||||||||||
| 1277 | return path; | - | ||||||||||||||||||||||||
| 1278 | } | - | ||||||||||||||||||||||||
| 1279 | - | |||||||||||||||||||||||||
| 1280 | /*! \internal | - | ||||||||||||||||||||||||
| 1281 | Clip the painter to the border (in case we are using radius border) | - | ||||||||||||||||||||||||
| 1282 | */ | - | ||||||||||||||||||||||||
| 1283 | void QRenderRule::setClip(QPainter *p, const QRect &rect) | - | ||||||||||||||||||||||||
| 1284 | { | - | ||||||||||||||||||||||||
| 1285 | if (clipset++) | - | ||||||||||||||||||||||||
| 1286 | return; | - | ||||||||||||||||||||||||
| 1287 | clipPath = borderClip(rect); | - | ||||||||||||||||||||||||
| 1288 | if (!clipPath.isEmpty()) { | - | ||||||||||||||||||||||||
| 1289 | p->save(); | - | ||||||||||||||||||||||||
| 1290 | p->setClipPath(clipPath, Qt::IntersectClip); | - | ||||||||||||||||||||||||
| 1291 | } | - | ||||||||||||||||||||||||
| 1292 | } | - | ||||||||||||||||||||||||
| 1293 | - | |||||||||||||||||||||||||
| 1294 | void QRenderRule::unsetClip(QPainter *p) | - | ||||||||||||||||||||||||
| 1295 | { | - | ||||||||||||||||||||||||
| 1296 | if (--clipset) | - | ||||||||||||||||||||||||
| 1297 | return; | - | ||||||||||||||||||||||||
| 1298 | if (!clipPath.isEmpty()) | - | ||||||||||||||||||||||||
| 1299 | p->restore(); | - | ||||||||||||||||||||||||
| 1300 | } | - | ||||||||||||||||||||||||
| 1301 | - | |||||||||||||||||||||||||
| 1302 | void QRenderRule::drawBackground(QPainter *p, const QRect& rect, const QPoint& off) | - | ||||||||||||||||||||||||
| 1303 | { | - | ||||||||||||||||||||||||
| 1304 | QBrush brush = hasBackground() ? background()->brush : QBrush(); | - | ||||||||||||||||||||||||
| 1305 | if (brush.style() == Qt::NoBrush) | - | ||||||||||||||||||||||||
| 1306 | brush = defaultBackground; | - | ||||||||||||||||||||||||
| 1307 | - | |||||||||||||||||||||||||
| 1308 | if (brush.style() != Qt::NoBrush) { | - | ||||||||||||||||||||||||
| 1309 | Origin origin = hasBackground() ? background()->clip : Origin_Border; | - | ||||||||||||||||||||||||
| 1310 | // ### fix for gradients | - | ||||||||||||||||||||||||
| 1311 | const QPainterPath &borderPath = borderClip(originRect(rect, origin)); | - | ||||||||||||||||||||||||
| 1312 | if (!borderPath.isEmpty()) { | - | ||||||||||||||||||||||||
| 1313 | // Drawn intead of being used as clipping path for better visual quality | - | ||||||||||||||||||||||||
| 1314 | bool wasAntialiased = p->renderHints() & QPainter::Antialiasing; | - | ||||||||||||||||||||||||
| 1315 | p->setRenderHint(QPainter::Antialiasing); | - | ||||||||||||||||||||||||
| 1316 | p->fillPath(borderPath, brush); | - | ||||||||||||||||||||||||
| 1317 | p->setRenderHint(QPainter::Antialiasing, wasAntialiased); | - | ||||||||||||||||||||||||
| 1318 | } else { | - | ||||||||||||||||||||||||
| 1319 | p->fillRect(originRect(rect, origin), brush); | - | ||||||||||||||||||||||||
| 1320 | } | - | ||||||||||||||||||||||||
| 1321 | } | - | ||||||||||||||||||||||||
| 1322 | - | |||||||||||||||||||||||||
| 1323 | drawBackgroundImage(p, rect, off); | - | ||||||||||||||||||||||||
| 1324 | } | - | ||||||||||||||||||||||||
| 1325 | - | |||||||||||||||||||||||||
| 1326 | void QRenderRule::drawFrame(QPainter *p, const QRect& rect) | - | ||||||||||||||||||||||||
| 1327 | { | - | ||||||||||||||||||||||||
| 1328 | drawBackground(p, rect); | - | ||||||||||||||||||||||||
| 1329 | if (hasBorder()) | - | ||||||||||||||||||||||||
| 1330 | drawBorder(p, borderRect(rect)); | - | ||||||||||||||||||||||||
| 1331 | } | - | ||||||||||||||||||||||||
| 1332 | - | |||||||||||||||||||||||||
| 1333 | void QRenderRule::drawImage(QPainter *p, const QRect &rect) | - | ||||||||||||||||||||||||
| 1334 | { | - | ||||||||||||||||||||||||
| 1335 | if (!hasImage()) | - | ||||||||||||||||||||||||
| 1336 | return; | - | ||||||||||||||||||||||||
| 1337 | img->icon.paint(p, rect, img->alignment); | - | ||||||||||||||||||||||||
| 1338 | } | - | ||||||||||||||||||||||||
| 1339 | - | |||||||||||||||||||||||||
| 1340 | void QRenderRule::drawRule(QPainter *p, const QRect& rect) | - | ||||||||||||||||||||||||
| 1341 | { | - | ||||||||||||||||||||||||
| 1342 | drawFrame(p, rect); | - | ||||||||||||||||||||||||
| 1343 | drawImage(p, contentsRect(rect)); | - | ||||||||||||||||||||||||
| 1344 | } | - | ||||||||||||||||||||||||
| 1345 | - | |||||||||||||||||||||||||
| 1346 | // *shudder* , *horror*, *whoa* <-- what you might feel when you see the functions below | - | ||||||||||||||||||||||||
| 1347 | void QRenderRule::configurePalette(QPalette *p, QPalette::ColorRole fr, QPalette::ColorRole br) | - | ||||||||||||||||||||||||
| 1348 | { | - | ||||||||||||||||||||||||
| 1349 | if (bg && bg->brush.style() != Qt::NoBrush) { | - | ||||||||||||||||||||||||
| 1350 | if (br != QPalette::NoRole) | - | ||||||||||||||||||||||||
| 1351 | p->setBrush(br, bg->brush); | - | ||||||||||||||||||||||||
| 1352 | p->setBrush(QPalette::Window, bg->brush); | - | ||||||||||||||||||||||||
| 1353 | if (bg->brush.style() == Qt::SolidPattern) { | - | ||||||||||||||||||||||||
| 1354 | p->setBrush(QPalette::Light, bg->brush.color().lighter(115)); | - | ||||||||||||||||||||||||
| 1355 | p->setBrush(QPalette::Midlight, bg->brush.color().lighter(107)); | - | ||||||||||||||||||||||||
| 1356 | p->setBrush(QPalette::Dark, bg->brush.color().darker(150)); | - | ||||||||||||||||||||||||
| 1357 | p->setBrush(QPalette::Shadow, bg->brush.color().darker(300)); | - | ||||||||||||||||||||||||
| 1358 | } | - | ||||||||||||||||||||||||
| 1359 | } | - | ||||||||||||||||||||||||
| 1360 | - | |||||||||||||||||||||||||
| 1361 | if (!hasPalette()) | - | ||||||||||||||||||||||||
| 1362 | return; | - | ||||||||||||||||||||||||
| 1363 | - | |||||||||||||||||||||||||
| 1364 | if (pal->foreground.style() != Qt::NoBrush) { | - | ||||||||||||||||||||||||
| 1365 | if (fr != QPalette::NoRole) | - | ||||||||||||||||||||||||
| 1366 | p->setBrush(fr, pal->foreground); | - | ||||||||||||||||||||||||
| 1367 | p->setBrush(QPalette::WindowText, pal->foreground); | - | ||||||||||||||||||||||||
| 1368 | p->setBrush(QPalette::Text, pal->foreground); | - | ||||||||||||||||||||||||
| 1369 | } | - | ||||||||||||||||||||||||
| 1370 | if (pal->selectionBackground.style() != Qt::NoBrush) | - | ||||||||||||||||||||||||
| 1371 | p->setBrush(QPalette::Highlight, pal->selectionBackground); | - | ||||||||||||||||||||||||
| 1372 | if (pal->selectionForeground.style() != Qt::NoBrush) | - | ||||||||||||||||||||||||
| 1373 | p->setBrush(QPalette::HighlightedText, pal->selectionForeground); | - | ||||||||||||||||||||||||
| 1374 | if (pal->alternateBackground.style() != Qt::NoBrush) | - | ||||||||||||||||||||||||
| 1375 | p->setBrush(QPalette::AlternateBase, pal->alternateBackground); | - | ||||||||||||||||||||||||
| 1376 | } | - | ||||||||||||||||||||||||
| 1377 | - | |||||||||||||||||||||||||
| 1378 | void QRenderRule::configurePalette(QPalette *p, QPalette::ColorGroup cg, const QWidget *w, bool embedded) | - | ||||||||||||||||||||||||
| 1379 | { | - | ||||||||||||||||||||||||
| 1380 | if (bg && bg->brush.style() != Qt::NoBrush) { | - | ||||||||||||||||||||||||
| 1381 | p->setBrush(cg, QPalette::Base, bg->brush); // for windows, windowxp | - | ||||||||||||||||||||||||
| 1382 | p->setBrush(cg, QPalette::Button, bg->brush); // for plastique | - | ||||||||||||||||||||||||
| 1383 | p->setBrush(cg, w->backgroundRole(), bg->brush); | - | ||||||||||||||||||||||||
| 1384 | p->setBrush(cg, QPalette::Window, bg->brush); | - | ||||||||||||||||||||||||
| 1385 | } | - | ||||||||||||||||||||||||
| 1386 | - | |||||||||||||||||||||||||
| 1387 | if (embedded) { | - | ||||||||||||||||||||||||
| 1388 | /* For embedded widgets (ComboBox, SpinBox and ScrollArea) we want the embedded widget | - | ||||||||||||||||||||||||
| 1389 | * to be transparent when we have a transparent background or border image */ | - | ||||||||||||||||||||||||
| 1390 | if ((hasBackground() && background()->isTransparent()) | - | ||||||||||||||||||||||||
| 1391 | || (hasBorder() && border()->hasBorderImage() && !border()->borderImage()->pixmap.isNull())) | - | ||||||||||||||||||||||||
| 1392 | p->setBrush(cg, w->backgroundRole(), Qt::NoBrush); | - | ||||||||||||||||||||||||
| 1393 | } | - | ||||||||||||||||||||||||
| 1394 | - | |||||||||||||||||||||||||
| 1395 | if (!hasPalette()) | - | ||||||||||||||||||||||||
| 1396 | return; | - | ||||||||||||||||||||||||
| 1397 | - | |||||||||||||||||||||||||
| 1398 | if (pal->foreground.style() != Qt::NoBrush) { | - | ||||||||||||||||||||||||
| 1399 | p->setBrush(cg, QPalette::ButtonText, pal->foreground); | - | ||||||||||||||||||||||||
| 1400 | p->setBrush(cg, w->foregroundRole(), pal->foreground); | - | ||||||||||||||||||||||||
| 1401 | p->setBrush(cg, QPalette::WindowText, pal->foreground); | - | ||||||||||||||||||||||||
| 1402 | p->setBrush(cg, QPalette::Text, pal->foreground); | - | ||||||||||||||||||||||||
| 1403 | } | - | ||||||||||||||||||||||||
| 1404 | if (pal->selectionBackground.style() != Qt::NoBrush) | - | ||||||||||||||||||||||||
| 1405 | p->setBrush(cg, QPalette::Highlight, pal->selectionBackground); | - | ||||||||||||||||||||||||
| 1406 | if (pal->selectionForeground.style() != Qt::NoBrush) | - | ||||||||||||||||||||||||
| 1407 | p->setBrush(cg, QPalette::HighlightedText, pal->selectionForeground); | - | ||||||||||||||||||||||||
| 1408 | if (pal->alternateBackground.style() != Qt::NoBrush) | - | ||||||||||||||||||||||||
| 1409 | p->setBrush(cg, QPalette::AlternateBase, pal->alternateBackground); | - | ||||||||||||||||||||||||
| 1410 | } | - | ||||||||||||||||||||||||
| 1411 | - | |||||||||||||||||||||||||
| 1412 | /////////////////////////////////////////////////////////////////////////////// | - | ||||||||||||||||||||||||
| 1413 | // Style rules | - | ||||||||||||||||||||||||
| 1414 | #define OBJECT_PTR(x) (static_cast<QObject *>(x.ptr)) | - | ||||||||||||||||||||||||
| 1415 | - | |||||||||||||||||||||||||
| 1416 | static inline QObject *parentObject(const QObject *obj) | - | ||||||||||||||||||||||||
| 1417 | { | - | ||||||||||||||||||||||||
| 1418 | if (qobject_cast<const QLabel *>(obj) && qstrcmp(obj->metaObject()->className(), "QTipLabel") == 0) { | - | ||||||||||||||||||||||||
| 1419 | QObject *p = qvariant_cast<QObject *>(obj->property("_q_stylesheet_parent")); | - | ||||||||||||||||||||||||
| 1420 | if (p) | - | ||||||||||||||||||||||||
| 1421 | return p; | - | ||||||||||||||||||||||||
| 1422 | } | - | ||||||||||||||||||||||||
| 1423 | return obj->parent(); | - | ||||||||||||||||||||||||
| 1424 | } | - | ||||||||||||||||||||||||
| 1425 | - | |||||||||||||||||||||||||
| 1426 | class QStyleSheetStyleSelector : public StyleSelector | - | ||||||||||||||||||||||||
| 1427 | { | - | ||||||||||||||||||||||||
| 1428 | public: | - | ||||||||||||||||||||||||
| 1429 | QStyleSheetStyleSelector() { } | - | ||||||||||||||||||||||||
| 1430 | - | |||||||||||||||||||||||||
| 1431 | QStringList nodeNames(NodePtr node) const Q_DECL_OVERRIDE | - | ||||||||||||||||||||||||
| 1432 | { | - | ||||||||||||||||||||||||
| 1433 | if (isNullNode(node)) | - | ||||||||||||||||||||||||
| 1434 | return QStringList(); | - | ||||||||||||||||||||||||
| 1435 | const QMetaObject *metaObject = OBJECT_PTR(node)->metaObject(); | - | ||||||||||||||||||||||||
| 1436 | #ifndef QT_NO_TOOLTIP | - | ||||||||||||||||||||||||
| 1437 | if (qstrcmp(metaObject->className(), "QTipLabel") == 0) | - | ||||||||||||||||||||||||
| 1438 | return QStringList(QLatin1String("QToolTip")); | - | ||||||||||||||||||||||||
| 1439 | #endif | - | ||||||||||||||||||||||||
| 1440 | QStringList result; | - | ||||||||||||||||||||||||
| 1441 | do { | - | ||||||||||||||||||||||||
| 1442 | result += QString::fromLatin1(metaObject->className()).replace(QLatin1Char(':'), QLatin1Char('-')); | - | ||||||||||||||||||||||||
| 1443 | metaObject = metaObject->superClass(); | - | ||||||||||||||||||||||||
| 1444 | } while (metaObject != 0); | - | ||||||||||||||||||||||||
| 1445 | return result; | - | ||||||||||||||||||||||||
| 1446 | } | - | ||||||||||||||||||||||||
| 1447 | QString attribute(NodePtr node, const QString& name) const Q_DECL_OVERRIDE | - | ||||||||||||||||||||||||
| 1448 | { | - | ||||||||||||||||||||||||
| 1449 | if (isNullNode(node)) | - | ||||||||||||||||||||||||
| 1450 | return QString(); | - | ||||||||||||||||||||||||
| 1451 | - | |||||||||||||||||||||||||
| 1452 | QHash<QString, QString> &cache = m_attributeCache[OBJECT_PTR(node)]; | - | ||||||||||||||||||||||||
| 1453 | QHash<QString, QString>::const_iterator cacheIt = cache.constFind(name); | - | ||||||||||||||||||||||||
| 1454 | if (cacheIt != cache.constEnd()) | - | ||||||||||||||||||||||||
| 1455 | return cacheIt.value(); | - | ||||||||||||||||||||||||
| 1456 | - | |||||||||||||||||||||||||
| 1457 | QObject *obj = OBJECT_PTR(node); | - | ||||||||||||||||||||||||
| 1458 | QVariant value = obj->property(name.toLatin1()); | - | ||||||||||||||||||||||||
| 1459 | if (!value.isValid()) { | - | ||||||||||||||||||||||||
| 1460 | if (name == QLatin1String("class")) { | - | ||||||||||||||||||||||||
| 1461 | QString className = QString::fromLatin1(obj->metaObject()->className()); | - | ||||||||||||||||||||||||
| 1462 | if (className.contains(QLatin1Char(':'))) | - | ||||||||||||||||||||||||
| 1463 | className.replace(QLatin1Char(':'), QLatin1Char('-')); | - | ||||||||||||||||||||||||
| 1464 | cache[name] = className; | - | ||||||||||||||||||||||||
| 1465 | return className; | - | ||||||||||||||||||||||||
| 1466 | } else if (name == QLatin1String("style")) { | - | ||||||||||||||||||||||||
| 1467 | QWidget *w = qobject_cast<QWidget *>(obj); | - | ||||||||||||||||||||||||
| 1468 | QStyleSheetStyle *proxy = w ? qobject_cast<QStyleSheetStyle *>(w->style()) : 0; | - | ||||||||||||||||||||||||
| 1469 | if (proxy) { | - | ||||||||||||||||||||||||
| 1470 | QString styleName = QString::fromLatin1(proxy->baseStyle()->metaObject()->className()); | - | ||||||||||||||||||||||||
| 1471 | cache[name] = styleName; | - | ||||||||||||||||||||||||
| 1472 | return styleName; | - | ||||||||||||||||||||||||
| 1473 | } | - | ||||||||||||||||||||||||
| 1474 | } | - | ||||||||||||||||||||||||
| 1475 | } | - | ||||||||||||||||||||||||
| 1476 | QString valueStr; | - | ||||||||||||||||||||||||
| 1477 | if(value.type() == QVariant::StringList || value.type() == QVariant::List) | - | ||||||||||||||||||||||||
| 1478 | valueStr = value.toStringList().join(QLatin1Char(' ')); | - | ||||||||||||||||||||||||
| 1479 | else | - | ||||||||||||||||||||||||
| 1480 | valueStr = value.toString(); | - | ||||||||||||||||||||||||
| 1481 | cache[name] = valueStr; | - | ||||||||||||||||||||||||
| 1482 | return valueStr; | - | ||||||||||||||||||||||||
| 1483 | } | - | ||||||||||||||||||||||||
| 1484 | bool nodeNameEquals(NodePtr node, const QString& nodeName) const Q_DECL_OVERRIDE | - | ||||||||||||||||||||||||
| 1485 | { | - | ||||||||||||||||||||||||
| 1486 | if (isNullNode(node)) | - | ||||||||||||||||||||||||
| 1487 | return false; | - | ||||||||||||||||||||||||
| 1488 | const QMetaObject *metaObject = OBJECT_PTR(node)->metaObject(); | - | ||||||||||||||||||||||||
| 1489 | #ifndef QT_NO_TOOLTIP | - | ||||||||||||||||||||||||
| 1490 | if (qstrcmp(metaObject->className(), "QTipLabel") == 0) | - | ||||||||||||||||||||||||
| 1491 | return nodeName == QLatin1String("QToolTip"); | - | ||||||||||||||||||||||||
| 1492 | #endif | - | ||||||||||||||||||||||||
| 1493 | do { | - | ||||||||||||||||||||||||
| 1494 | const ushort *uc = (const ushort *)nodeName.constData(); | - | ||||||||||||||||||||||||
| 1495 | const ushort *e = uc + nodeName.length(); | - | ||||||||||||||||||||||||
| 1496 | const uchar *c = (const uchar *)metaObject->className(); | - | ||||||||||||||||||||||||
| 1497 | while (*c && uc != e && (*uc == *c || (*c == ':' && *uc == '-'))) { | - | ||||||||||||||||||||||||
| 1498 | ++uc; | - | ||||||||||||||||||||||||
| 1499 | ++c; | - | ||||||||||||||||||||||||
| 1500 | } | - | ||||||||||||||||||||||||
| 1501 | if (uc == e && !*c) | - | ||||||||||||||||||||||||
| 1502 | return true; | - | ||||||||||||||||||||||||
| 1503 | metaObject = metaObject->superClass(); | - | ||||||||||||||||||||||||
| 1504 | } while (metaObject != 0); | - | ||||||||||||||||||||||||
| 1505 | return false; | - | ||||||||||||||||||||||||
| 1506 | } | - | ||||||||||||||||||||||||
| 1507 | bool hasAttributes(NodePtr) const Q_DECL_OVERRIDE | - | ||||||||||||||||||||||||
| 1508 | { return true; } | - | ||||||||||||||||||||||||
| 1509 | QStringList nodeIds(NodePtr node) const Q_DECL_OVERRIDE | - | ||||||||||||||||||||||||
| 1510 | { return isNullNode(node) ? QStringList() : QStringList(OBJECT_PTR(node)->objectName()); } | - | ||||||||||||||||||||||||
| 1511 | bool isNullNode(NodePtr node) const Q_DECL_OVERRIDE | - | ||||||||||||||||||||||||
| 1512 | { return node.ptr == 0; } | - | ||||||||||||||||||||||||
| 1513 | NodePtr parentNode(NodePtr node) const Q_DECL_OVERRIDE | - | ||||||||||||||||||||||||
| 1514 | { NodePtr n; n.ptr = isNullNode(node) ? 0 : parentObject(OBJECT_PTR(node)); return n; } | - | ||||||||||||||||||||||||
| 1515 | NodePtr previousSiblingNode(NodePtr) const Q_DECL_OVERRIDE | - | ||||||||||||||||||||||||
| 1516 | { NodePtr n; n.ptr = 0; return n; } | - | ||||||||||||||||||||||||
| 1517 | NodePtr duplicateNode(NodePtr node) const Q_DECL_OVERRIDE | - | ||||||||||||||||||||||||
| 1518 | { return node; } | - | ||||||||||||||||||||||||
| 1519 | void freeNode(NodePtr) const Q_DECL_OVERRIDE | - | ||||||||||||||||||||||||
| 1520 | { } | - | ||||||||||||||||||||||||
| 1521 | - | |||||||||||||||||||||||||
| 1522 | private: | - | ||||||||||||||||||||||||
| 1523 | mutable QHash<const QObject *, QHash<QString, QString> > m_attributeCache; | - | ||||||||||||||||||||||||
| 1524 | }; | - | ||||||||||||||||||||||||
| 1525 | - | |||||||||||||||||||||||||
| 1526 | QVector<QCss::StyleRule> QStyleSheetStyle::styleRules(const QObject *obj) const | - | ||||||||||||||||||||||||
| 1527 | { | - | ||||||||||||||||||||||||
| 1528 | QHash<const QObject *, QVector<StyleRule> >::const_iterator cacheIt = styleSheetCaches->styleRulesCache.constFind(obj); | - | ||||||||||||||||||||||||
| 1529 | if (cacheIt != styleSheetCaches->styleRulesCache.constEnd())
| 0 | ||||||||||||||||||||||||
| 1530 | return cacheIt.value(); never executed: return cacheIt.value(); | 0 | ||||||||||||||||||||||||
| 1531 | - | |||||||||||||||||||||||||
| 1532 | if (!initObject(obj)) {
| 0 | ||||||||||||||||||||||||
| 1533 | return QVector<StyleRule>(); never executed: return QVector<StyleRule>(); | 0 | ||||||||||||||||||||||||
| 1534 | } | - | ||||||||||||||||||||||||
| 1535 | - | |||||||||||||||||||||||||
| 1536 | QStyleSheetStyleSelector styleSelector; | - | ||||||||||||||||||||||||
| 1537 | - | |||||||||||||||||||||||||
| 1538 | StyleSheet defaultSs; | - | ||||||||||||||||||||||||
| 1539 | QHash<const void *, StyleSheet>::const_iterator defaultCacheIt = styleSheetCaches->styleSheetCache.constFind(baseStyle()); | - | ||||||||||||||||||||||||
| 1540 | if (defaultCacheIt == styleSheetCaches->styleSheetCache.constEnd()) {
| 0 | ||||||||||||||||||||||||
| 1541 | defaultSs = getDefaultStyleSheet(); | - | ||||||||||||||||||||||||
| 1542 | QStyle *bs = baseStyle(); | - | ||||||||||||||||||||||||
| 1543 | styleSheetCaches->styleSheetCache.insert(bs, defaultSs); | - | ||||||||||||||||||||||||
| 1544 | QObject::connect(bs, SIGNAL(destroyed(QObject*)), styleSheetCaches, SLOT(styleDestroyed(QObject*)), Qt::UniqueConnection); | - | ||||||||||||||||||||||||
| 1545 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 1546 | defaultSs = defaultCacheIt.value(); | - | ||||||||||||||||||||||||
| 1547 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1548 | styleSelector.styleSheets += defaultSs; | - | ||||||||||||||||||||||||
| 1549 | - | |||||||||||||||||||||||||
| 1550 | if (!qApp->styleSheet().isEmpty()) {
| 0 | ||||||||||||||||||||||||
| 1551 | StyleSheet appSs; | - | ||||||||||||||||||||||||
| 1552 | QHash<const void *, StyleSheet>::const_iterator appCacheIt = styleSheetCaches->styleSheetCache.constFind(qApp); | - | ||||||||||||||||||||||||
| 1553 | if (appCacheIt == styleSheetCaches->styleSheetCache.constEnd()) {
| 0 | ||||||||||||||||||||||||
| 1554 | QString ss = qApp->styleSheet(); | - | ||||||||||||||||||||||||
| 1555 | if (ss.startsWith(QLatin1String("file:///")))
| 0 | ||||||||||||||||||||||||
| 1556 | ss.remove(0, 8); never executed: ss.remove(0, 8); | 0 | ||||||||||||||||||||||||
| 1557 | parser.init(ss, qApp->styleSheet() != ss); | - | ||||||||||||||||||||||||
| 1558 | if (Q_UNLIKELY(!parser.parse(&appSs)))))
| 0 | ||||||||||||||||||||||||
| 1559 | qWarning("Could not parse application stylesheet"); never executed: QMessageLogger(__FILE__, 1559, __PRETTY_FUNCTION__).warning("Could not parse application stylesheet"); | 0 | ||||||||||||||||||||||||
| 1560 | appSs.origin = StyleSheetOrigin_Inline; | - | ||||||||||||||||||||||||
| 1561 | appSs.depth = 1; | - | ||||||||||||||||||||||||
| 1562 | styleSheetCaches->styleSheetCache.insert(qApp, appSs); | - | ||||||||||||||||||||||||
| 1563 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 1564 | appSs = appCacheIt.value(); | - | ||||||||||||||||||||||||
| 1565 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1566 | styleSelector.styleSheets += appSs; | - | ||||||||||||||||||||||||
| 1567 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1568 | - | |||||||||||||||||||||||||
| 1569 | QVector<QCss::StyleSheet> objectSs; | - | ||||||||||||||||||||||||
| 1570 | for (const QObject *o = obj; o; o = parentObject(o)) {
| 0 | ||||||||||||||||||||||||
| 1571 | QString styleSheet = o->property("styleSheet").toString(); | - | ||||||||||||||||||||||||
| 1572 | if (styleSheet.isEmpty())
| 0 | ||||||||||||||||||||||||
| 1573 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 1574 | StyleSheet ss; | - | ||||||||||||||||||||||||
| 1575 | QHash<const void *, StyleSheet>::const_iterator objCacheIt = styleSheetCaches->styleSheetCache.constFind(o); | - | ||||||||||||||||||||||||
| 1576 | if (objCacheIt == styleSheetCaches->styleSheetCache.constEnd()) {
| 0 | ||||||||||||||||||||||||
| 1577 | parser.init(styleSheet); | - | ||||||||||||||||||||||||
| 1578 | if (!parser.parse(&ss)) {
| 0 | ||||||||||||||||||||||||
| 1579 | parser.init(QLatin1String("* {") + styleSheet + QLatin1Char('}')); | - | ||||||||||||||||||||||||
| 1580 | if (Q_UNLIKELY(!parser.parse(&ss)))))
| 0 | ||||||||||||||||||||||||
| 1581 | qWarning("Could not parse stylesheet of object %p", o); never executed: QMessageLogger(__FILE__, 1581, __PRETTY_FUNCTION__).warning("Could not parse stylesheet of object %p", o); | 0 | ||||||||||||||||||||||||
| 1582 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1583 | ss.origin = StyleSheetOrigin_Inline; | - | ||||||||||||||||||||||||
| 1584 | styleSheetCaches->styleSheetCache.insert(o, ss); | - | ||||||||||||||||||||||||
| 1585 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 1586 | ss = objCacheIt.value(); | - | ||||||||||||||||||||||||
| 1587 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1588 | objectSs.append(ss); | - | ||||||||||||||||||||||||
| 1589 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 1590 | - | |||||||||||||||||||||||||
| 1591 | for (int i = 0; i < objectSs.count(); i++)
| 0 | ||||||||||||||||||||||||
| 1592 | objectSs[i].depth = objectSs.count() - i + 2; never executed: objectSs[i].depth = objectSs.count() - i + 2; | 0 | ||||||||||||||||||||||||
| 1593 | - | |||||||||||||||||||||||||
| 1594 | styleSelector.styleSheets += objectSs; | - | ||||||||||||||||||||||||
| 1595 | - | |||||||||||||||||||||||||
| 1596 | StyleSelector::NodePtr n; | - | ||||||||||||||||||||||||
| 1597 | n.ptr = const_cast<QObject *>(obj); | - | ||||||||||||||||||||||||
| 1598 | QVector<QCss::StyleRule> rules = styleSelector.styleRulesForNode(n); | - | ||||||||||||||||||||||||
| 1599 | styleSheetCaches->styleRulesCache.insert(obj, rules); | - | ||||||||||||||||||||||||
| 1600 | return rules; never executed: return rules; | 0 | ||||||||||||||||||||||||
| 1601 | } | - | ||||||||||||||||||||||||
| 1602 | - | |||||||||||||||||||||||||
| 1603 | ///////////////////////////////////////////////////////////////////////////////////////// | - | ||||||||||||||||||||||||
| 1604 | // Rendering rules | - | ||||||||||||||||||||||||
| 1605 | static QVector<Declaration> declarations(const QVector<StyleRule> &styleRules, const QString &part, quint64 pseudoClass = PseudoClass_Unspecified) | - | ||||||||||||||||||||||||
| 1606 | { | - | ||||||||||||||||||||||||
| 1607 | QVector<Declaration> decls; | - | ||||||||||||||||||||||||
| 1608 | for (int i = 0; i < styleRules.count(); i++) { | - | ||||||||||||||||||||||||
| 1609 | const Selector& selector = styleRules.at(i).selectors.at(0); | - | ||||||||||||||||||||||||
| 1610 | // Rules with pseudo elements don't cascade. This is an intentional | - | ||||||||||||||||||||||||
| 1611 | // diversion for CSS | - | ||||||||||||||||||||||||
| 1612 | if (part.compare(selector.pseudoElement(), Qt::CaseInsensitive) != 0) | - | ||||||||||||||||||||||||
| 1613 | continue; | - | ||||||||||||||||||||||||
| 1614 | quint64 negated = 0; | - | ||||||||||||||||||||||||
| 1615 | quint64 cssClass = selector.pseudoClass(&negated); | - | ||||||||||||||||||||||||
| 1616 | if ((pseudoClass == PseudoClass_Any) || (cssClass == PseudoClass_Unspecified) | - | ||||||||||||||||||||||||
| 1617 | || ((((cssClass & pseudoClass) == cssClass)) && ((negated & pseudoClass) == 0))) | - | ||||||||||||||||||||||||
| 1618 | decls += styleRules.at(i).declarations; | - | ||||||||||||||||||||||||
| 1619 | } | - | ||||||||||||||||||||||||
| 1620 | return decls; | - | ||||||||||||||||||||||||
| 1621 | } | - | ||||||||||||||||||||||||
| 1622 | - | |||||||||||||||||||||||||
| 1623 | int QStyleSheetStyle::nativeFrameWidth(const QWidget *w) | - | ||||||||||||||||||||||||
| 1624 | { | - | ||||||||||||||||||||||||
| 1625 | QStyle *base = baseStyle(); | - | ||||||||||||||||||||||||
| 1626 | - | |||||||||||||||||||||||||
| 1627 | #ifndef QT_NO_SPINBOX | - | ||||||||||||||||||||||||
| 1628 | if (qobject_cast<const QAbstractSpinBox *>(w)) | - | ||||||||||||||||||||||||
| 1629 | return base->pixelMetric(QStyle::PM_SpinBoxFrameWidth, 0, w); | - | ||||||||||||||||||||||||
| 1630 | #endif | - | ||||||||||||||||||||||||
| 1631 | - | |||||||||||||||||||||||||
| 1632 | #ifndef QT_NO_COMBOBOX | - | ||||||||||||||||||||||||
| 1633 | if (qobject_cast<const QComboBox *>(w)) | - | ||||||||||||||||||||||||
| 1634 | return base->pixelMetric(QStyle::PM_ComboBoxFrameWidth, 0, w); | - | ||||||||||||||||||||||||
| 1635 | #endif | - | ||||||||||||||||||||||||
| 1636 | - | |||||||||||||||||||||||||
| 1637 | #ifndef QT_NO_MENU | - | ||||||||||||||||||||||||
| 1638 | if (qobject_cast<const QMenu *>(w)) | - | ||||||||||||||||||||||||
| 1639 | return base->pixelMetric(QStyle::PM_MenuPanelWidth, 0, w); | - | ||||||||||||||||||||||||
| 1640 | #endif | - | ||||||||||||||||||||||||
| 1641 | - | |||||||||||||||||||||||||
| 1642 | #ifndef QT_NO_MENUBAR | - | ||||||||||||||||||||||||
| 1643 | if (qobject_cast<const QMenuBar *>(w)) | - | ||||||||||||||||||||||||
| 1644 | return base->pixelMetric(QStyle::PM_MenuBarPanelWidth, 0, w); | - | ||||||||||||||||||||||||
| 1645 | #endif | - | ||||||||||||||||||||||||
| 1646 | #ifndef QT_NO_FRAME | - | ||||||||||||||||||||||||
| 1647 | if (const QFrame *frame = qobject_cast<const QFrame *>(w)) { | - | ||||||||||||||||||||||||
| 1648 | if (frame->frameShape() == QFrame::NoFrame) | - | ||||||||||||||||||||||||
| 1649 | return 0; | - | ||||||||||||||||||||||||
| 1650 | } | - | ||||||||||||||||||||||||
| 1651 | #endif | - | ||||||||||||||||||||||||
| 1652 | - | |||||||||||||||||||||||||
| 1653 | if (qstrcmp(w->metaObject()->className(), "QTipLabel") == 0) | - | ||||||||||||||||||||||||
| 1654 | return base->pixelMetric(QStyle::PM_ToolTipLabelFrameWidth, 0, w); | - | ||||||||||||||||||||||||
| 1655 | - | |||||||||||||||||||||||||
| 1656 | return base->pixelMetric(QStyle::PM_DefaultFrameWidth, 0, w); | - | ||||||||||||||||||||||||
| 1657 | } | - | ||||||||||||||||||||||||
| 1658 | - | |||||||||||||||||||||||||
| 1659 | static quint64 pseudoClass(QStyle::State state) | - | ||||||||||||||||||||||||
| 1660 | { | - | ||||||||||||||||||||||||
| 1661 | quint64 pc = 0; | - | ||||||||||||||||||||||||
| 1662 | if (state & QStyle::State_Enabled) { | - | ||||||||||||||||||||||||
| 1663 | pc |= PseudoClass_Enabled; | - | ||||||||||||||||||||||||
| 1664 | if (state & QStyle::State_MouseOver) | - | ||||||||||||||||||||||||
| 1665 | pc |= PseudoClass_Hover; | - | ||||||||||||||||||||||||
| 1666 | } else { | - | ||||||||||||||||||||||||
| 1667 | pc |= PseudoClass_Disabled; | - | ||||||||||||||||||||||||
| 1668 | } | - | ||||||||||||||||||||||||
| 1669 | if (state & QStyle::State_Active) | - | ||||||||||||||||||||||||
| 1670 | pc |= PseudoClass_Active; | - | ||||||||||||||||||||||||
| 1671 | if (state & QStyle::State_Window) | - | ||||||||||||||||||||||||
| 1672 | pc |= PseudoClass_Window; | - | ||||||||||||||||||||||||
| 1673 | if (state & QStyle::State_Sunken) | - | ||||||||||||||||||||||||
| 1674 | pc |= PseudoClass_Pressed; | - | ||||||||||||||||||||||||
| 1675 | if (state & QStyle::State_HasFocus) | - | ||||||||||||||||||||||||
| 1676 | pc |= PseudoClass_Focus; | - | ||||||||||||||||||||||||
| 1677 | if (state & QStyle::State_On) | - | ||||||||||||||||||||||||
| 1678 | pc |= (PseudoClass_On | PseudoClass_Checked); | - | ||||||||||||||||||||||||
| 1679 | if (state & QStyle::State_Off) | - | ||||||||||||||||||||||||
| 1680 | pc |= (PseudoClass_Off | PseudoClass_Unchecked); | - | ||||||||||||||||||||||||
| 1681 | if (state & QStyle::State_NoChange) | - | ||||||||||||||||||||||||
| 1682 | pc |= PseudoClass_Indeterminate; | - | ||||||||||||||||||||||||
| 1683 | if (state & QStyle::State_Selected) | - | ||||||||||||||||||||||||
| 1684 | pc |= PseudoClass_Selected; | - | ||||||||||||||||||||||||
| 1685 | if (state & QStyle::State_Horizontal) | - | ||||||||||||||||||||||||
| 1686 | pc |= PseudoClass_Horizontal; | - | ||||||||||||||||||||||||
| 1687 | else | - | ||||||||||||||||||||||||
| 1688 | pc |= PseudoClass_Vertical; | - | ||||||||||||||||||||||||
| 1689 | if (state & (QStyle::State_Open | QStyle::State_On | QStyle::State_Sunken)) | - | ||||||||||||||||||||||||
| 1690 | pc |= PseudoClass_Open; | - | ||||||||||||||||||||||||
| 1691 | else | - | ||||||||||||||||||||||||
| 1692 | pc |= PseudoClass_Closed; | - | ||||||||||||||||||||||||
| 1693 | if (state & QStyle::State_Children) | - | ||||||||||||||||||||||||
| 1694 | pc |= PseudoClass_Children; | - | ||||||||||||||||||||||||
| 1695 | if (state & QStyle::State_Sibling) | - | ||||||||||||||||||||||||
| 1696 | pc |= PseudoClass_Sibling; | - | ||||||||||||||||||||||||
| 1697 | if (state & QStyle::State_ReadOnly) | - | ||||||||||||||||||||||||
| 1698 | pc |= PseudoClass_ReadOnly; | - | ||||||||||||||||||||||||
| 1699 | if (state & QStyle::State_Item) | - | ||||||||||||||||||||||||
| 1700 | pc |= PseudoClass_Item; | - | ||||||||||||||||||||||||
| 1701 | #ifdef QT_KEYPAD_NAVIGATION | - | ||||||||||||||||||||||||
| 1702 | if (state & QStyle::State_HasEditFocus) | - | ||||||||||||||||||||||||
| 1703 | pc |= PseudoClass_EditFocus; | - | ||||||||||||||||||||||||
| 1704 | #endif | - | ||||||||||||||||||||||||
| 1705 | return pc; | - | ||||||||||||||||||||||||
| 1706 | } | - | ||||||||||||||||||||||||
| 1707 | - | |||||||||||||||||||||||||
| 1708 | static void qt_check_if_internal_object(const QObject **obj, int *element) | - | ||||||||||||||||||||||||
| 1709 | { | - | ||||||||||||||||||||||||
| 1710 | #ifdef QT_NO_DOCKWIDGET | - | ||||||||||||||||||||||||
| 1711 | Q_UNUSED(obj); | - | ||||||||||||||||||||||||
| 1712 | Q_UNUSED(element); | - | ||||||||||||||||||||||||
| 1713 | #else | - | ||||||||||||||||||||||||
| 1714 | if (*obj && qstrcmp((*obj)->metaObject()->className(), "QDockWidgetTitleButton") == 0) { | - | ||||||||||||||||||||||||
| 1715 | if ((*obj)->objectName() == QLatin1String("qt_dockwidget_closebutton")) { | - | ||||||||||||||||||||||||
| 1716 | *element = PseudoElement_DockWidgetCloseButton; | - | ||||||||||||||||||||||||
| 1717 | } else if ((*obj)->objectName() == QLatin1String("qt_dockwidget_floatbutton")) { | - | ||||||||||||||||||||||||
| 1718 | *element = PseudoElement_DockWidgetFloatButton; | - | ||||||||||||||||||||||||
| 1719 | } | - | ||||||||||||||||||||||||
| 1720 | *obj = (*obj)->parent(); | - | ||||||||||||||||||||||||
| 1721 | } | - | ||||||||||||||||||||||||
| 1722 | #endif | - | ||||||||||||||||||||||||
| 1723 | } | - | ||||||||||||||||||||||||
| 1724 | - | |||||||||||||||||||||||||
| 1725 | QRenderRule QStyleSheetStyle::renderRule(const QObject *obj, int element, quint64 state) const | - | ||||||||||||||||||||||||
| 1726 | { | - | ||||||||||||||||||||||||
| 1727 | qt_check_if_internal_object(&obj, &element); | - | ||||||||||||||||||||||||
| 1728 | QHash<quint64, QRenderRule> &cache = styleSheetCaches->renderRulesCache[obj][element]; | - | ||||||||||||||||||||||||
| 1729 | QHash<quint64, QRenderRule>::const_iterator cacheIt = cache.constFind(state); | - | ||||||||||||||||||||||||
| 1730 | if (cacheIt != cache.constEnd()) | - | ||||||||||||||||||||||||
| 1731 | return cacheIt.value(); | - | ||||||||||||||||||||||||
| 1732 | - | |||||||||||||||||||||||||
| 1733 | if (!initObject(obj)) | - | ||||||||||||||||||||||||
| 1734 | return QRenderRule(); | - | ||||||||||||||||||||||||
| 1735 | - | |||||||||||||||||||||||||
| 1736 | quint64 stateMask = 0; | - | ||||||||||||||||||||||||
| 1737 | const QVector<StyleRule> rules = styleRules(obj); | - | ||||||||||||||||||||||||
| 1738 | for (int i = 0; i < rules.count(); i++) { | - | ||||||||||||||||||||||||
| 1739 | const Selector& selector = rules.at(i).selectors.at(0); | - | ||||||||||||||||||||||||
| 1740 | quint64 negated = 0; | - | ||||||||||||||||||||||||
| 1741 | stateMask |= selector.pseudoClass(&negated); | - | ||||||||||||||||||||||||
| 1742 | stateMask |= negated; | - | ||||||||||||||||||||||||
| 1743 | } | - | ||||||||||||||||||||||||
| 1744 | - | |||||||||||||||||||||||||
| 1745 | cacheIt = cache.constFind(state & stateMask); | - | ||||||||||||||||||||||||
| 1746 | if (cacheIt != cache.constEnd()) { | - | ||||||||||||||||||||||||
| 1747 | const QRenderRule &newRule = cacheIt.value(); | - | ||||||||||||||||||||||||
| 1748 | cache[state] = newRule; | - | ||||||||||||||||||||||||
| 1749 | return newRule; | - | ||||||||||||||||||||||||
| 1750 | } | - | ||||||||||||||||||||||||
| 1751 | - | |||||||||||||||||||||||||
| 1752 | - | |||||||||||||||||||||||||
| 1753 | const QString part = QLatin1String(knownPseudoElements[element].name); | - | ||||||||||||||||||||||||
| 1754 | QVector<Declaration> decls = declarations(rules, part, state); | - | ||||||||||||||||||||||||
| 1755 | QRenderRule newRule(decls, obj); | - | ||||||||||||||||||||||||
| 1756 | cache[state] = newRule; | - | ||||||||||||||||||||||||
| 1757 | if ((state & stateMask) != state) | - | ||||||||||||||||||||||||
| 1758 | cache[state&stateMask] = newRule; | - | ||||||||||||||||||||||||
| 1759 | return newRule; | - | ||||||||||||||||||||||||
| 1760 | } | - | ||||||||||||||||||||||||
| 1761 | - | |||||||||||||||||||||||||
| 1762 | QRenderRule QStyleSheetStyle::renderRule(const QObject *obj, const QStyleOption *opt, int pseudoElement) const | - | ||||||||||||||||||||||||
| 1763 | { | - | ||||||||||||||||||||||||
| 1764 | quint64 extraClass = 0; | - | ||||||||||||||||||||||||
| 1765 | QStyle::State state = opt ? opt->state : QStyle::State(QStyle::State_None); | - | ||||||||||||||||||||||||
| 1766 | - | |||||||||||||||||||||||||
| 1767 | if (const QStyleOptionComplex *complex = qstyleoption_cast<const QStyleOptionComplex *>(opt)) { | - | ||||||||||||||||||||||||
| 1768 | if (pseudoElement != PseudoElement_None) { | - | ||||||||||||||||||||||||
| 1769 | // if not an active subcontrol, just pass enabled/disabled | - | ||||||||||||||||||||||||
| 1770 | QStyle::SubControl subControl = knownPseudoElements[pseudoElement].subControl; | - | ||||||||||||||||||||||||
| 1771 | - | |||||||||||||||||||||||||
| 1772 | if (!(complex->activeSubControls & subControl)) | - | ||||||||||||||||||||||||
| 1773 | state &= (QStyle::State_Enabled | QStyle::State_Horizontal | QStyle::State_HasFocus); | - | ||||||||||||||||||||||||
| 1774 | } | - | ||||||||||||||||||||||||
| 1775 | - | |||||||||||||||||||||||||
| 1776 | switch (pseudoElement) { | - | ||||||||||||||||||||||||
| 1777 | case PseudoElement_ComboBoxDropDown: | - | ||||||||||||||||||||||||
| 1778 | case PseudoElement_ComboBoxArrow: | - | ||||||||||||||||||||||||
| 1779 | state |= (complex->state & (QStyle::State_On|QStyle::State_ReadOnly)); | - | ||||||||||||||||||||||||
| 1780 | break; | - | ||||||||||||||||||||||||
| 1781 | case PseudoElement_SpinBoxUpButton: | - | ||||||||||||||||||||||||
| 1782 | case PseudoElement_SpinBoxDownButton: | - | ||||||||||||||||||||||||
| 1783 | case PseudoElement_SpinBoxUpArrow: | - | ||||||||||||||||||||||||
| 1784 | case PseudoElement_SpinBoxDownArrow: | - | ||||||||||||||||||||||||
| 1785 | #ifndef QT_NO_SPINBOX | - | ||||||||||||||||||||||||
| 1786 | if (const QStyleOptionSpinBox *sb = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) { | - | ||||||||||||||||||||||||
| 1787 | bool on = false; | - | ||||||||||||||||||||||||
| 1788 | bool up = pseudoElement == PseudoElement_SpinBoxUpButton | - | ||||||||||||||||||||||||
| 1789 | || pseudoElement == PseudoElement_SpinBoxUpArrow; | - | ||||||||||||||||||||||||
| 1790 | if ((sb->stepEnabled & QAbstractSpinBox::StepUpEnabled) && up) | - | ||||||||||||||||||||||||
| 1791 | on = true; | - | ||||||||||||||||||||||||
| 1792 | else if ((sb->stepEnabled & QAbstractSpinBox::StepDownEnabled) && !up) | - | ||||||||||||||||||||||||
| 1793 | on = true; | - | ||||||||||||||||||||||||
| 1794 | state |= (on ? QStyle::State_On : QStyle::State_Off); | - | ||||||||||||||||||||||||
| 1795 | } | - | ||||||||||||||||||||||||
| 1796 | #endif // QT_NO_SPINBOX | - | ||||||||||||||||||||||||
| 1797 | break; | - | ||||||||||||||||||||||||
| 1798 | case PseudoElement_GroupBoxTitle: | - | ||||||||||||||||||||||||
| 1799 | state |= (complex->state & (QStyle::State_MouseOver | QStyle::State_Sunken)); | - | ||||||||||||||||||||||||
| 1800 | break; | - | ||||||||||||||||||||||||
| 1801 | case PseudoElement_ToolButtonMenu: | - | ||||||||||||||||||||||||
| 1802 | case PseudoElement_ToolButtonMenuArrow: | - | ||||||||||||||||||||||||
| 1803 | case PseudoElement_ToolButtonDownArrow: | - | ||||||||||||||||||||||||
| 1804 | state |= complex->state & QStyle::State_MouseOver; | - | ||||||||||||||||||||||||
| 1805 | if (complex->state & QStyle::State_Sunken || | - | ||||||||||||||||||||||||
| 1806 | complex->activeSubControls & QStyle::SC_ToolButtonMenu) | - | ||||||||||||||||||||||||
| 1807 | state |= QStyle::State_Sunken; | - | ||||||||||||||||||||||||
| 1808 | break; | - | ||||||||||||||||||||||||
| 1809 | case PseudoElement_SliderGroove: | - | ||||||||||||||||||||||||
| 1810 | state |= complex->state & QStyle::State_MouseOver; | - | ||||||||||||||||||||||||
| 1811 | break; | - | ||||||||||||||||||||||||
| 1812 | default: | - | ||||||||||||||||||||||||
| 1813 | break; | - | ||||||||||||||||||||||||
| 1814 | } | - | ||||||||||||||||||||||||
| 1815 | - | |||||||||||||||||||||||||
| 1816 | if (const QStyleOptionComboBox *combo = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) { | - | ||||||||||||||||||||||||
| 1817 | // QStyle::State_On is set when the popup is being shown | - | ||||||||||||||||||||||||
| 1818 | // Propagate EditField Pressed state | - | ||||||||||||||||||||||||
| 1819 | if (pseudoElement == PseudoElement_None | - | ||||||||||||||||||||||||
| 1820 | && (complex->activeSubControls & QStyle::SC_ComboBoxEditField) | - | ||||||||||||||||||||||||
| 1821 | && (!(state & QStyle::State_MouseOver))) { | - | ||||||||||||||||||||||||
| 1822 | state |= QStyle::State_Sunken; | - | ||||||||||||||||||||||||
| 1823 | } | - | ||||||||||||||||||||||||
| 1824 | - | |||||||||||||||||||||||||
| 1825 | if (!combo->frame) | - | ||||||||||||||||||||||||
| 1826 | extraClass |= PseudoClass_Frameless; | - | ||||||||||||||||||||||||
| 1827 | if (!combo->editable) | - | ||||||||||||||||||||||||
| 1828 | extraClass |= PseudoClass_ReadOnly; | - | ||||||||||||||||||||||||
| 1829 | else | - | ||||||||||||||||||||||||
| 1830 | extraClass |= PseudoClass_Editable; | - | ||||||||||||||||||||||||
| 1831 | #ifndef QT_NO_SPINBOX | - | ||||||||||||||||||||||||
| 1832 | } else if (const QStyleOptionSpinBox *spin = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) { | - | ||||||||||||||||||||||||
| 1833 | if (!spin->frame) | - | ||||||||||||||||||||||||
| 1834 | extraClass |= PseudoClass_Frameless; | - | ||||||||||||||||||||||||
| 1835 | #endif // QT_NO_SPINBOX | - | ||||||||||||||||||||||||
| 1836 | } else if (const QStyleOptionGroupBox *gb = qstyleoption_cast<const QStyleOptionGroupBox *>(opt)) { | - | ||||||||||||||||||||||||
| 1837 | if (gb->features & QStyleOptionFrame::Flat) | - | ||||||||||||||||||||||||
| 1838 | extraClass |= PseudoClass_Flat; | - | ||||||||||||||||||||||||
| 1839 | if (gb->lineWidth == 0) | - | ||||||||||||||||||||||||
| 1840 | extraClass |= PseudoClass_Frameless; | - | ||||||||||||||||||||||||
| 1841 | } else if (const QStyleOptionTitleBar *tb = qstyleoption_cast<const QStyleOptionTitleBar *>(opt)) { | - | ||||||||||||||||||||||||
| 1842 | if (tb->titleBarState & Qt::WindowMinimized) { | - | ||||||||||||||||||||||||
| 1843 | extraClass |= PseudoClass_Minimized; | - | ||||||||||||||||||||||||
| 1844 | } | - | ||||||||||||||||||||||||
| 1845 | else if (tb->titleBarState & Qt::WindowMaximized) | - | ||||||||||||||||||||||||
| 1846 | extraClass |= PseudoClass_Maximized; | - | ||||||||||||||||||||||||
| 1847 | } | - | ||||||||||||||||||||||||
| 1848 | } else { | - | ||||||||||||||||||||||||
| 1849 | // handle simple style options | - | ||||||||||||||||||||||||
| 1850 | if (const QStyleOptionMenuItem *mi = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) { | - | ||||||||||||||||||||||||
| 1851 | if (mi->menuItemType == QStyleOptionMenuItem::DefaultItem) | - | ||||||||||||||||||||||||
| 1852 | extraClass |= PseudoClass_Default; | - | ||||||||||||||||||||||||
| 1853 | if (mi->checkType == QStyleOptionMenuItem::Exclusive) | - | ||||||||||||||||||||||||
| 1854 | extraClass |= PseudoClass_Exclusive; | - | ||||||||||||||||||||||||
| 1855 | else if (mi->checkType == QStyleOptionMenuItem::NonExclusive) | - | ||||||||||||||||||||||||
| 1856 | extraClass |= PseudoClass_NonExclusive; | - | ||||||||||||||||||||||||
| 1857 | if (mi->checkType != QStyleOptionMenuItem::NotCheckable) | - | ||||||||||||||||||||||||
| 1858 | extraClass |= (mi->checked) ? (PseudoClass_On|PseudoClass_Checked) | - | ||||||||||||||||||||||||
| 1859 | : (PseudoClass_Off|PseudoClass_Unchecked); | - | ||||||||||||||||||||||||
| 1860 | } else if (const QStyleOptionHeader *hdr = qstyleoption_cast<const QStyleOptionHeader *>(opt)) { | - | ||||||||||||||||||||||||
| 1861 | if (hdr->position == QStyleOptionHeader::OnlyOneSection) | - | ||||||||||||||||||||||||
| 1862 | extraClass |= PseudoClass_OnlyOne; | - | ||||||||||||||||||||||||
| 1863 | else if (hdr->position == QStyleOptionHeader::Beginning) | - | ||||||||||||||||||||||||
| 1864 | extraClass |= PseudoClass_First; | - | ||||||||||||||||||||||||
| 1865 | else if (hdr->position == QStyleOptionHeader::End) | - | ||||||||||||||||||||||||
| 1866 | extraClass |= PseudoClass_Last; | - | ||||||||||||||||||||||||
| 1867 | else if (hdr->position == QStyleOptionHeader::Middle) | - | ||||||||||||||||||||||||
| 1868 | extraClass |= PseudoClass_Middle; | - | ||||||||||||||||||||||||
| 1869 | - | |||||||||||||||||||||||||
| 1870 | if (hdr->selectedPosition == QStyleOptionHeader::NextAndPreviousAreSelected) | - | ||||||||||||||||||||||||
| 1871 | extraClass |= (PseudoClass_NextSelected | PseudoClass_PreviousSelected); | - | ||||||||||||||||||||||||
| 1872 | else if (hdr->selectedPosition == QStyleOptionHeader::NextIsSelected) | - | ||||||||||||||||||||||||
| 1873 | extraClass |= PseudoClass_NextSelected; | - | ||||||||||||||||||||||||
| 1874 | else if (hdr->selectedPosition == QStyleOptionHeader::PreviousIsSelected) | - | ||||||||||||||||||||||||
| 1875 | extraClass |= PseudoClass_PreviousSelected; | - | ||||||||||||||||||||||||
| 1876 | #ifndef QT_NO_TABWIDGET | - | ||||||||||||||||||||||||
| 1877 | } else if (const QStyleOptionTabWidgetFrame *tab = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(opt)) { | - | ||||||||||||||||||||||||
| 1878 | switch (tab->shape) { | - | ||||||||||||||||||||||||
| 1879 | case QTabBar::RoundedNorth: | - | ||||||||||||||||||||||||
| 1880 | case QTabBar::TriangularNorth: | - | ||||||||||||||||||||||||
| 1881 | extraClass |= PseudoClass_Top; | - | ||||||||||||||||||||||||
| 1882 | break; | - | ||||||||||||||||||||||||
| 1883 | case QTabBar::RoundedSouth: | - | ||||||||||||||||||||||||
| 1884 | case QTabBar::TriangularSouth: | - | ||||||||||||||||||||||||
| 1885 | extraClass |= PseudoClass_Bottom; | - | ||||||||||||||||||||||||
| 1886 | break; | - | ||||||||||||||||||||||||
| 1887 | case QTabBar::RoundedEast: | - | ||||||||||||||||||||||||
| 1888 | case QTabBar::TriangularEast: | - | ||||||||||||||||||||||||
| 1889 | extraClass |= PseudoClass_Left; | - | ||||||||||||||||||||||||
| 1890 | break; | - | ||||||||||||||||||||||||
| 1891 | case QTabBar::RoundedWest: | - | ||||||||||||||||||||||||
| 1892 | case QTabBar::TriangularWest: | - | ||||||||||||||||||||||||
| 1893 | extraClass |= PseudoClass_Right; | - | ||||||||||||||||||||||||
| 1894 | break; | - | ||||||||||||||||||||||||
| 1895 | default: | - | ||||||||||||||||||||||||
| 1896 | break; | - | ||||||||||||||||||||||||
| 1897 | } | - | ||||||||||||||||||||||||
| 1898 | #endif | - | ||||||||||||||||||||||||
| 1899 | #ifndef QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 1900 | } else if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) { | - | ||||||||||||||||||||||||
| 1901 | if (tab->position == QStyleOptionTab::OnlyOneTab) | - | ||||||||||||||||||||||||
| 1902 | extraClass |= PseudoClass_OnlyOne; | - | ||||||||||||||||||||||||
| 1903 | else if (tab->position == QStyleOptionTab::Beginning) | - | ||||||||||||||||||||||||
| 1904 | extraClass |= PseudoClass_First; | - | ||||||||||||||||||||||||
| 1905 | else if (tab->position == QStyleOptionTab::End) | - | ||||||||||||||||||||||||
| 1906 | extraClass |= PseudoClass_Last; | - | ||||||||||||||||||||||||
| 1907 | else if (tab->position == QStyleOptionTab::Middle) | - | ||||||||||||||||||||||||
| 1908 | extraClass |= PseudoClass_Middle; | - | ||||||||||||||||||||||||
| 1909 | - | |||||||||||||||||||||||||
| 1910 | if (tab->selectedPosition == QStyleOptionTab::NextIsSelected) | - | ||||||||||||||||||||||||
| 1911 | extraClass |= PseudoClass_NextSelected; | - | ||||||||||||||||||||||||
| 1912 | else if (tab->selectedPosition == QStyleOptionTab::PreviousIsSelected) | - | ||||||||||||||||||||||||
| 1913 | extraClass |= PseudoClass_PreviousSelected; | - | ||||||||||||||||||||||||
| 1914 | - | |||||||||||||||||||||||||
| 1915 | switch (tab->shape) { | - | ||||||||||||||||||||||||
| 1916 | case QTabBar::RoundedNorth: | - | ||||||||||||||||||||||||
| 1917 | case QTabBar::TriangularNorth: | - | ||||||||||||||||||||||||
| 1918 | extraClass |= PseudoClass_Top; | - | ||||||||||||||||||||||||
| 1919 | break; | - | ||||||||||||||||||||||||
| 1920 | case QTabBar::RoundedSouth: | - | ||||||||||||||||||||||||
| 1921 | case QTabBar::TriangularSouth: | - | ||||||||||||||||||||||||
| 1922 | extraClass |= PseudoClass_Bottom; | - | ||||||||||||||||||||||||
| 1923 | break; | - | ||||||||||||||||||||||||
| 1924 | case QTabBar::RoundedEast: | - | ||||||||||||||||||||||||
| 1925 | case QTabBar::TriangularEast: | - | ||||||||||||||||||||||||
| 1926 | extraClass |= PseudoClass_Left; | - | ||||||||||||||||||||||||
| 1927 | break; | - | ||||||||||||||||||||||||
| 1928 | case QTabBar::RoundedWest: | - | ||||||||||||||||||||||||
| 1929 | case QTabBar::TriangularWest: | - | ||||||||||||||||||||||||
| 1930 | extraClass |= PseudoClass_Right; | - | ||||||||||||||||||||||||
| 1931 | break; | - | ||||||||||||||||||||||||
| 1932 | default: | - | ||||||||||||||||||||||||
| 1933 | break; | - | ||||||||||||||||||||||||
| 1934 | } | - | ||||||||||||||||||||||||
| 1935 | #endif // QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 1936 | } else if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) { | - | ||||||||||||||||||||||||
| 1937 | if (btn->features & QStyleOptionButton::Flat) | - | ||||||||||||||||||||||||
| 1938 | extraClass |= PseudoClass_Flat; | - | ||||||||||||||||||||||||
| 1939 | if (btn->features & QStyleOptionButton::DefaultButton) | - | ||||||||||||||||||||||||
| 1940 | extraClass |= PseudoClass_Default; | - | ||||||||||||||||||||||||
| 1941 | } else if (const QStyleOptionFrame *frm = qstyleoption_cast<const QStyleOptionFrame *>(opt)) { | - | ||||||||||||||||||||||||
| 1942 | if (frm->lineWidth == 0) | - | ||||||||||||||||||||||||
| 1943 | extraClass |= PseudoClass_Frameless; | - | ||||||||||||||||||||||||
| 1944 | if (frm->features & QStyleOptionFrame::Flat) | - | ||||||||||||||||||||||||
| 1945 | extraClass |= PseudoClass_Flat; | - | ||||||||||||||||||||||||
| 1946 | } | - | ||||||||||||||||||||||||
| 1947 | #ifndef QT_NO_TOOLBAR | - | ||||||||||||||||||||||||
| 1948 | else if (const QStyleOptionToolBar *tb = qstyleoption_cast<const QStyleOptionToolBar *>(opt)) { | - | ||||||||||||||||||||||||
| 1949 | if (tb->toolBarArea == Qt::LeftToolBarArea) | - | ||||||||||||||||||||||||
| 1950 | extraClass |= PseudoClass_Left; | - | ||||||||||||||||||||||||
| 1951 | else if (tb->toolBarArea == Qt::RightToolBarArea) | - | ||||||||||||||||||||||||
| 1952 | extraClass |= PseudoClass_Right; | - | ||||||||||||||||||||||||
| 1953 | else if (tb->toolBarArea == Qt::TopToolBarArea) | - | ||||||||||||||||||||||||
| 1954 | extraClass |= PseudoClass_Top; | - | ||||||||||||||||||||||||
| 1955 | else if (tb->toolBarArea == Qt::BottomToolBarArea) | - | ||||||||||||||||||||||||
| 1956 | extraClass |= PseudoClass_Bottom; | - | ||||||||||||||||||||||||
| 1957 | - | |||||||||||||||||||||||||
| 1958 | if (tb->positionWithinLine == QStyleOptionToolBar::Beginning) | - | ||||||||||||||||||||||||
| 1959 | extraClass |= PseudoClass_First; | - | ||||||||||||||||||||||||
| 1960 | else if (tb->positionWithinLine == QStyleOptionToolBar::Middle) | - | ||||||||||||||||||||||||
| 1961 | extraClass |= PseudoClass_Middle; | - | ||||||||||||||||||||||||
| 1962 | else if (tb->positionWithinLine == QStyleOptionToolBar::End) | - | ||||||||||||||||||||||||
| 1963 | extraClass |= PseudoClass_Last; | - | ||||||||||||||||||||||||
| 1964 | else if (tb->positionWithinLine == QStyleOptionToolBar::OnlyOne) | - | ||||||||||||||||||||||||
| 1965 | extraClass |= PseudoClass_OnlyOne; | - | ||||||||||||||||||||||||
| 1966 | } | - | ||||||||||||||||||||||||
| 1967 | #endif // QT_NO_TOOLBAR | - | ||||||||||||||||||||||||
| 1968 | #ifndef QT_NO_TOOLBOX | - | ||||||||||||||||||||||||
| 1969 | else if (const QStyleOptionToolBox *tb = qstyleoption_cast<const QStyleOptionToolBox *>(opt)) { | - | ||||||||||||||||||||||||
| 1970 | if (tb->position == QStyleOptionToolBox::OnlyOneTab) | - | ||||||||||||||||||||||||
| 1971 | extraClass |= PseudoClass_OnlyOne; | - | ||||||||||||||||||||||||
| 1972 | else if (tb->position == QStyleOptionToolBox::Beginning) | - | ||||||||||||||||||||||||
| 1973 | extraClass |= PseudoClass_First; | - | ||||||||||||||||||||||||
| 1974 | else if (tb->position == QStyleOptionToolBox::End) | - | ||||||||||||||||||||||||
| 1975 | extraClass |= PseudoClass_Last; | - | ||||||||||||||||||||||||
| 1976 | else if (tb->position == QStyleOptionToolBox::Middle) | - | ||||||||||||||||||||||||
| 1977 | extraClass |= PseudoClass_Middle; | - | ||||||||||||||||||||||||
| 1978 | - | |||||||||||||||||||||||||
| 1979 | if (tb->selectedPosition == QStyleOptionToolBox::NextIsSelected) | - | ||||||||||||||||||||||||
| 1980 | extraClass |= PseudoClass_NextSelected; | - | ||||||||||||||||||||||||
| 1981 | else if (tb->selectedPosition == QStyleOptionToolBox::PreviousIsSelected) | - | ||||||||||||||||||||||||
| 1982 | extraClass |= PseudoClass_PreviousSelected; | - | ||||||||||||||||||||||||
| 1983 | } | - | ||||||||||||||||||||||||
| 1984 | #endif // QT_NO_TOOLBOX | - | ||||||||||||||||||||||||
| 1985 | #ifndef QT_NO_DOCKWIDGET | - | ||||||||||||||||||||||||
| 1986 | else if (const QStyleOptionDockWidget *dw = qstyleoption_cast<const QStyleOptionDockWidget *>(opt)) { | - | ||||||||||||||||||||||||
| 1987 | if (dw->verticalTitleBar) | - | ||||||||||||||||||||||||
| 1988 | extraClass |= PseudoClass_Vertical; | - | ||||||||||||||||||||||||
| 1989 | else | - | ||||||||||||||||||||||||
| 1990 | extraClass |= PseudoClass_Horizontal; | - | ||||||||||||||||||||||||
| 1991 | if (dw->closable) | - | ||||||||||||||||||||||||
| 1992 | extraClass |= PseudoClass_Closable; | - | ||||||||||||||||||||||||
| 1993 | if (dw->floatable) | - | ||||||||||||||||||||||||
| 1994 | extraClass |= PseudoClass_Floatable; | - | ||||||||||||||||||||||||
| 1995 | if (dw->movable) | - | ||||||||||||||||||||||||
| 1996 | extraClass |= PseudoClass_Movable; | - | ||||||||||||||||||||||||
| 1997 | } | - | ||||||||||||||||||||||||
| 1998 | #endif // QT_NO_DOCKWIDGET | - | ||||||||||||||||||||||||
| 1999 | #ifndef QT_NO_ITEMVIEWS | - | ||||||||||||||||||||||||
| 2000 | else if (const QStyleOptionViewItem *vopt = qstyleoption_cast<const QStyleOptionViewItem *>(opt)) { | - | ||||||||||||||||||||||||
| 2001 | if (vopt->features & QStyleOptionViewItem::Alternate) | - | ||||||||||||||||||||||||
| 2002 | extraClass |= PseudoClass_Alternate; | - | ||||||||||||||||||||||||
| 2003 | if (vopt->viewItemPosition == QStyleOptionViewItem::OnlyOne) | - | ||||||||||||||||||||||||
| 2004 | extraClass |= PseudoClass_OnlyOne; | - | ||||||||||||||||||||||||
| 2005 | else if (vopt->viewItemPosition == QStyleOptionViewItem::Beginning) | - | ||||||||||||||||||||||||
| 2006 | extraClass |= PseudoClass_First; | - | ||||||||||||||||||||||||
| 2007 | else if (vopt->viewItemPosition == QStyleOptionViewItem::End) | - | ||||||||||||||||||||||||
| 2008 | extraClass |= PseudoClass_Last; | - | ||||||||||||||||||||||||
| 2009 | else if (vopt->viewItemPosition == QStyleOptionViewItem::Middle) | - | ||||||||||||||||||||||||
| 2010 | extraClass |= PseudoClass_Middle; | - | ||||||||||||||||||||||||
| 2011 | - | |||||||||||||||||||||||||
| 2012 | } | - | ||||||||||||||||||||||||
| 2013 | #endif | - | ||||||||||||||||||||||||
| 2014 | #ifndef QT_NO_LINEEDIT | - | ||||||||||||||||||||||||
| 2015 | // LineEdit sets Sunken flag to indicate Sunken frame (argh) | - | ||||||||||||||||||||||||
| 2016 | if (const QLineEdit *lineEdit = qobject_cast<const QLineEdit *>(obj)) { | - | ||||||||||||||||||||||||
| 2017 | state &= ~QStyle::State_Sunken; | - | ||||||||||||||||||||||||
| 2018 | if (lineEdit->hasFrame()) { | - | ||||||||||||||||||||||||
| 2019 | extraClass &= ~PseudoClass_Frameless; | - | ||||||||||||||||||||||||
| 2020 | } else { | - | ||||||||||||||||||||||||
| 2021 | extraClass |= PseudoClass_Frameless; | - | ||||||||||||||||||||||||
| 2022 | } | - | ||||||||||||||||||||||||
| 2023 | } else | - | ||||||||||||||||||||||||
| 2024 | #endif | - | ||||||||||||||||||||||||
| 2025 | if (const QFrame *frm = qobject_cast<const QFrame *>(obj)) { | - | ||||||||||||||||||||||||
| 2026 | if (frm->lineWidth() == 0) | - | ||||||||||||||||||||||||
| 2027 | extraClass |= PseudoClass_Frameless; | - | ||||||||||||||||||||||||
| 2028 | } | - | ||||||||||||||||||||||||
| 2029 | } | - | ||||||||||||||||||||||||
| 2030 | - | |||||||||||||||||||||||||
| 2031 | return renderRule(obj, pseudoElement, pseudoClass(state) | extraClass); | - | ||||||||||||||||||||||||
| 2032 | } | - | ||||||||||||||||||||||||
| 2033 | - | |||||||||||||||||||||||||
| 2034 | bool QStyleSheetStyle::hasStyleRule(const QObject *obj, int part) const | - | ||||||||||||||||||||||||
| 2035 | { | - | ||||||||||||||||||||||||
| 2036 | QHash<int, bool> &cache = styleSheetCaches->hasStyleRuleCache[obj]; | - | ||||||||||||||||||||||||
| 2037 | QHash<int, bool>::const_iterator cacheIt = cache.constFind(part); | - | ||||||||||||||||||||||||
| 2038 | if (cacheIt != cache.constEnd()) | - | ||||||||||||||||||||||||
| 2039 | return cacheIt.value(); | - | ||||||||||||||||||||||||
| 2040 | - | |||||||||||||||||||||||||
| 2041 | if (!initObject(obj)) | - | ||||||||||||||||||||||||
| 2042 | return false; | - | ||||||||||||||||||||||||
| 2043 | - | |||||||||||||||||||||||||
| 2044 | - | |||||||||||||||||||||||||
| 2045 | const QVector<StyleRule> &rules = styleRules(obj); | - | ||||||||||||||||||||||||
| 2046 | if (part == PseudoElement_None) { | - | ||||||||||||||||||||||||
| 2047 | bool result = obj && !rules.isEmpty(); | - | ||||||||||||||||||||||||
| 2048 | cache[part] = result; | - | ||||||||||||||||||||||||
| 2049 | return result; | - | ||||||||||||||||||||||||
| 2050 | } | - | ||||||||||||||||||||||||
| 2051 | - | |||||||||||||||||||||||||
| 2052 | QString pseudoElement = QLatin1String(knownPseudoElements[part].name); | - | ||||||||||||||||||||||||
| 2053 | for (int i = 0; i < rules.count(); i++) { | - | ||||||||||||||||||||||||
| 2054 | const Selector& selector = rules.at(i).selectors.at(0); | - | ||||||||||||||||||||||||
| 2055 | if (pseudoElement.compare(selector.pseudoElement(), Qt::CaseInsensitive) == 0) { | - | ||||||||||||||||||||||||
| 2056 | cache[part] = true; | - | ||||||||||||||||||||||||
| 2057 | return true; | - | ||||||||||||||||||||||||
| 2058 | } | - | ||||||||||||||||||||||||
| 2059 | } | - | ||||||||||||||||||||||||
| 2060 | - | |||||||||||||||||||||||||
| 2061 | cache[part] = false; | - | ||||||||||||||||||||||||
| 2062 | return false; | - | ||||||||||||||||||||||||
| 2063 | } | - | ||||||||||||||||||||||||
| 2064 | - | |||||||||||||||||||||||||
| 2065 | static Origin defaultOrigin(int pe) | - | ||||||||||||||||||||||||
| 2066 | { | - | ||||||||||||||||||||||||
| 2067 | switch (pe) { | - | ||||||||||||||||||||||||
| 2068 | case PseudoElement_ScrollBarAddPage: | - | ||||||||||||||||||||||||
| 2069 | case PseudoElement_ScrollBarSubPage: | - | ||||||||||||||||||||||||
| 2070 | case PseudoElement_ScrollBarAddLine: | - | ||||||||||||||||||||||||
| 2071 | case PseudoElement_ScrollBarSubLine: | - | ||||||||||||||||||||||||
| 2072 | case PseudoElement_ScrollBarFirst: | - | ||||||||||||||||||||||||
| 2073 | case PseudoElement_ScrollBarLast: | - | ||||||||||||||||||||||||
| 2074 | case PseudoElement_GroupBoxTitle: | - | ||||||||||||||||||||||||
| 2075 | case PseudoElement_GroupBoxIndicator: // never used | - | ||||||||||||||||||||||||
| 2076 | case PseudoElement_ToolButtonMenu: | - | ||||||||||||||||||||||||
| 2077 | case PseudoElement_SliderAddPage: | - | ||||||||||||||||||||||||
| 2078 | case PseudoElement_SliderSubPage: | - | ||||||||||||||||||||||||
| 2079 | return Origin_Border; | - | ||||||||||||||||||||||||
| 2080 | - | |||||||||||||||||||||||||
| 2081 | case PseudoElement_SpinBoxUpButton: | - | ||||||||||||||||||||||||
| 2082 | case PseudoElement_SpinBoxDownButton: | - | ||||||||||||||||||||||||
| 2083 | case PseudoElement_PushButtonMenuIndicator: | - | ||||||||||||||||||||||||
| 2084 | case PseudoElement_ComboBoxDropDown: | - | ||||||||||||||||||||||||
| 2085 | case PseudoElement_ToolButtonDownArrow: | - | ||||||||||||||||||||||||
| 2086 | case PseudoElement_MenuCheckMark: | - | ||||||||||||||||||||||||
| 2087 | case PseudoElement_MenuIcon: | - | ||||||||||||||||||||||||
| 2088 | case PseudoElement_MenuRightArrow: | - | ||||||||||||||||||||||||
| 2089 | return Origin_Padding; | - | ||||||||||||||||||||||||
| 2090 | - | |||||||||||||||||||||||||
| 2091 | case PseudoElement_Indicator: | - | ||||||||||||||||||||||||
| 2092 | case PseudoElement_ExclusiveIndicator: | - | ||||||||||||||||||||||||
| 2093 | case PseudoElement_ComboBoxArrow: | - | ||||||||||||||||||||||||
| 2094 | case PseudoElement_ScrollBarSlider: | - | ||||||||||||||||||||||||
| 2095 | case PseudoElement_ScrollBarUpArrow: | - | ||||||||||||||||||||||||
| 2096 | case PseudoElement_ScrollBarDownArrow: | - | ||||||||||||||||||||||||
| 2097 | case PseudoElement_ScrollBarLeftArrow: | - | ||||||||||||||||||||||||
| 2098 | case PseudoElement_ScrollBarRightArrow: | - | ||||||||||||||||||||||||
| 2099 | case PseudoElement_SpinBoxUpArrow: | - | ||||||||||||||||||||||||
| 2100 | case PseudoElement_SpinBoxDownArrow: | - | ||||||||||||||||||||||||
| 2101 | case PseudoElement_ToolButtonMenuArrow: | - | ||||||||||||||||||||||||
| 2102 | case PseudoElement_HeaderViewUpArrow: | - | ||||||||||||||||||||||||
| 2103 | case PseudoElement_HeaderViewDownArrow: | - | ||||||||||||||||||||||||
| 2104 | case PseudoElement_SliderGroove: | - | ||||||||||||||||||||||||
| 2105 | case PseudoElement_SliderHandle: | - | ||||||||||||||||||||||||
| 2106 | return Origin_Content; | - | ||||||||||||||||||||||||
| 2107 | - | |||||||||||||||||||||||||
| 2108 | default: | - | ||||||||||||||||||||||||
| 2109 | return Origin_Margin; | - | ||||||||||||||||||||||||
| 2110 | } | - | ||||||||||||||||||||||||
| 2111 | } | - | ||||||||||||||||||||||||
| 2112 | - | |||||||||||||||||||||||||
| 2113 | static Qt::Alignment defaultPosition(int pe) | - | ||||||||||||||||||||||||
| 2114 | { | - | ||||||||||||||||||||||||
| 2115 | switch (pe) { | - | ||||||||||||||||||||||||
| 2116 | case PseudoElement_Indicator: | - | ||||||||||||||||||||||||
| 2117 | case PseudoElement_ExclusiveIndicator: | - | ||||||||||||||||||||||||
| 2118 | case PseudoElement_MenuCheckMark: | - | ||||||||||||||||||||||||
| 2119 | case PseudoElement_MenuIcon: | - | ||||||||||||||||||||||||
| 2120 | return Qt::AlignLeft | Qt::AlignVCenter; | - | ||||||||||||||||||||||||
| 2121 | - | |||||||||||||||||||||||||
| 2122 | case PseudoElement_ScrollBarAddLine: | - | ||||||||||||||||||||||||
| 2123 | case PseudoElement_ScrollBarLast: | - | ||||||||||||||||||||||||
| 2124 | case PseudoElement_SpinBoxDownButton: | - | ||||||||||||||||||||||||
| 2125 | case PseudoElement_PushButtonMenuIndicator: | - | ||||||||||||||||||||||||
| 2126 | case PseudoElement_ToolButtonDownArrow: | - | ||||||||||||||||||||||||
| 2127 | return Qt::AlignRight | Qt::AlignBottom; | - | ||||||||||||||||||||||||
| 2128 | - | |||||||||||||||||||||||||
| 2129 | case PseudoElement_ScrollBarSubLine: | - | ||||||||||||||||||||||||
| 2130 | case PseudoElement_ScrollBarFirst: | - | ||||||||||||||||||||||||
| 2131 | case PseudoElement_SpinBoxUpButton: | - | ||||||||||||||||||||||||
| 2132 | case PseudoElement_ComboBoxDropDown: | - | ||||||||||||||||||||||||
| 2133 | case PseudoElement_ToolButtonMenu: | - | ||||||||||||||||||||||||
| 2134 | case PseudoElement_DockWidgetCloseButton: | - | ||||||||||||||||||||||||
| 2135 | case PseudoElement_DockWidgetFloatButton: | - | ||||||||||||||||||||||||
| 2136 | return Qt::AlignRight | Qt::AlignTop; | - | ||||||||||||||||||||||||
| 2137 | - | |||||||||||||||||||||||||
| 2138 | case PseudoElement_ScrollBarUpArrow: | - | ||||||||||||||||||||||||
| 2139 | case PseudoElement_ScrollBarDownArrow: | - | ||||||||||||||||||||||||
| 2140 | case PseudoElement_ScrollBarLeftArrow: | - | ||||||||||||||||||||||||
| 2141 | case PseudoElement_ScrollBarRightArrow: | - | ||||||||||||||||||||||||
| 2142 | case PseudoElement_SpinBoxUpArrow: | - | ||||||||||||||||||||||||
| 2143 | case PseudoElement_SpinBoxDownArrow: | - | ||||||||||||||||||||||||
| 2144 | case PseudoElement_ComboBoxArrow: | - | ||||||||||||||||||||||||
| 2145 | case PseudoElement_DownArrow: | - | ||||||||||||||||||||||||
| 2146 | case PseudoElement_ToolButtonMenuArrow: | - | ||||||||||||||||||||||||
| 2147 | case PseudoElement_SliderGroove: | - | ||||||||||||||||||||||||
| 2148 | return Qt::AlignCenter; | - | ||||||||||||||||||||||||
| 2149 | - | |||||||||||||||||||||||||
| 2150 | case PseudoElement_GroupBoxTitle: | - | ||||||||||||||||||||||||
| 2151 | case PseudoElement_GroupBoxIndicator: // never used | - | ||||||||||||||||||||||||
| 2152 | return Qt::AlignLeft | Qt::AlignTop; | - | ||||||||||||||||||||||||
| 2153 | - | |||||||||||||||||||||||||
| 2154 | case PseudoElement_HeaderViewUpArrow: | - | ||||||||||||||||||||||||
| 2155 | case PseudoElement_HeaderViewDownArrow: | - | ||||||||||||||||||||||||
| 2156 | case PseudoElement_MenuRightArrow: | - | ||||||||||||||||||||||||
| 2157 | return Qt::AlignRight | Qt::AlignVCenter; | - | ||||||||||||||||||||||||
| 2158 | - | |||||||||||||||||||||||||
| 2159 | default: | - | ||||||||||||||||||||||||
| 2160 | return 0; | - | ||||||||||||||||||||||||
| 2161 | } | - | ||||||||||||||||||||||||
| 2162 | } | - | ||||||||||||||||||||||||
| 2163 | - | |||||||||||||||||||||||||
| 2164 | QSize QStyleSheetStyle::defaultSize(const QWidget *w, QSize sz, const QRect& rect, int pe) const | - | ||||||||||||||||||||||||
| 2165 | { | - | ||||||||||||||||||||||||
| 2166 | QStyle *base = baseStyle(); | - | ||||||||||||||||||||||||
| 2167 | - | |||||||||||||||||||||||||
| 2168 | switch (pe) { | - | ||||||||||||||||||||||||
| 2169 | case PseudoElement_Indicator: | - | ||||||||||||||||||||||||
| 2170 | case PseudoElement_MenuCheckMark: | - | ||||||||||||||||||||||||
| 2171 | if (sz.width() == -1) | - | ||||||||||||||||||||||||
| 2172 | sz.setWidth(base->pixelMetric(PM_IndicatorWidth, 0, w)); | - | ||||||||||||||||||||||||
| 2173 | if (sz.height() == -1) | - | ||||||||||||||||||||||||
| 2174 | sz.setHeight(base->pixelMetric(PM_IndicatorHeight, 0, w)); | - | ||||||||||||||||||||||||
| 2175 | break; | - | ||||||||||||||||||||||||
| 2176 | - | |||||||||||||||||||||||||
| 2177 | case PseudoElement_ExclusiveIndicator: | - | ||||||||||||||||||||||||
| 2178 | case PseudoElement_GroupBoxIndicator: | - | ||||||||||||||||||||||||
| 2179 | if (sz.width() == -1) | - | ||||||||||||||||||||||||
| 2180 | sz.setWidth(base->pixelMetric(PM_ExclusiveIndicatorWidth, 0, w)); | - | ||||||||||||||||||||||||
| 2181 | if (sz.height() == -1) | - | ||||||||||||||||||||||||
| 2182 | sz.setHeight(base->pixelMetric(PM_ExclusiveIndicatorHeight, 0, w)); | - | ||||||||||||||||||||||||
| 2183 | break; | - | ||||||||||||||||||||||||
| 2184 | - | |||||||||||||||||||||||||
| 2185 | case PseudoElement_PushButtonMenuIndicator: { | - | ||||||||||||||||||||||||
| 2186 | int pm = base->pixelMetric(PM_MenuButtonIndicator, 0, w); | - | ||||||||||||||||||||||||
| 2187 | if (sz.width() == -1) | - | ||||||||||||||||||||||||
| 2188 | sz.setWidth(pm); | - | ||||||||||||||||||||||||
| 2189 | if (sz.height() == -1) | - | ||||||||||||||||||||||||
| 2190 | sz.setHeight(pm); | - | ||||||||||||||||||||||||
| 2191 | } | - | ||||||||||||||||||||||||
| 2192 | break; | - | ||||||||||||||||||||||||
| 2193 | - | |||||||||||||||||||||||||
| 2194 | case PseudoElement_ComboBoxDropDown: | - | ||||||||||||||||||||||||
| 2195 | if (sz.width() == -1) | - | ||||||||||||||||||||||||
| 2196 | sz.setWidth(16); | - | ||||||||||||||||||||||||
| 2197 | break; | - | ||||||||||||||||||||||||
| 2198 | - | |||||||||||||||||||||||||
| 2199 | case PseudoElement_ComboBoxArrow: | - | ||||||||||||||||||||||||
| 2200 | case PseudoElement_DownArrow: | - | ||||||||||||||||||||||||
| 2201 | case PseudoElement_ToolButtonMenuArrow: | - | ||||||||||||||||||||||||
| 2202 | case PseudoElement_ToolButtonDownArrow: | - | ||||||||||||||||||||||||
| 2203 | case PseudoElement_MenuRightArrow: | - | ||||||||||||||||||||||||
| 2204 | if (sz.width() == -1) | - | ||||||||||||||||||||||||
| 2205 | sz.setWidth(13); | - | ||||||||||||||||||||||||
| 2206 | if (sz.height() == -1) | - | ||||||||||||||||||||||||
| 2207 | sz.setHeight(13); | - | ||||||||||||||||||||||||
| 2208 | break; | - | ||||||||||||||||||||||||
| 2209 | - | |||||||||||||||||||||||||
| 2210 | case PseudoElement_SpinBoxUpButton: | - | ||||||||||||||||||||||||
| 2211 | case PseudoElement_SpinBoxDownButton: | - | ||||||||||||||||||||||||
| 2212 | if (sz.width() == -1) | - | ||||||||||||||||||||||||
| 2213 | sz.setWidth(16); | - | ||||||||||||||||||||||||
| 2214 | if (sz.height() == -1) | - | ||||||||||||||||||||||||
| 2215 | sz.setHeight(rect.height()/2); | - | ||||||||||||||||||||||||
| 2216 | break; | - | ||||||||||||||||||||||||
| 2217 | - | |||||||||||||||||||||||||
| 2218 | case PseudoElement_ToolButtonMenu: | - | ||||||||||||||||||||||||
| 2219 | if (sz.width() == -1) | - | ||||||||||||||||||||||||
| 2220 | sz.setWidth(base->pixelMetric(PM_MenuButtonIndicator, 0, w)); | - | ||||||||||||||||||||||||
| 2221 | break; | - | ||||||||||||||||||||||||
| 2222 | - | |||||||||||||||||||||||||
| 2223 | case PseudoElement_HeaderViewUpArrow: | - | ||||||||||||||||||||||||
| 2224 | case PseudoElement_HeaderViewDownArrow: { | - | ||||||||||||||||||||||||
| 2225 | int pm = base->pixelMetric(PM_HeaderMargin, 0, w); | - | ||||||||||||||||||||||||
| 2226 | if (sz.width() == -1) | - | ||||||||||||||||||||||||
| 2227 | sz.setWidth(pm); | - | ||||||||||||||||||||||||
| 2228 | if (sz.height() == 1) | - | ||||||||||||||||||||||||
| 2229 | sz.setHeight(pm); | - | ||||||||||||||||||||||||
| 2230 | break; | - | ||||||||||||||||||||||||
| 2231 | } | - | ||||||||||||||||||||||||
| 2232 | - | |||||||||||||||||||||||||
| 2233 | case PseudoElement_ScrollBarFirst: | - | ||||||||||||||||||||||||
| 2234 | case PseudoElement_ScrollBarLast: | - | ||||||||||||||||||||||||
| 2235 | case PseudoElement_ScrollBarAddLine: | - | ||||||||||||||||||||||||
| 2236 | case PseudoElement_ScrollBarSubLine: | - | ||||||||||||||||||||||||
| 2237 | case PseudoElement_ScrollBarSlider: { | - | ||||||||||||||||||||||||
| 2238 | int pm = pixelMetric(QStyle::PM_ScrollBarExtent, 0, w); | - | ||||||||||||||||||||||||
| 2239 | if (sz.width() == -1) | - | ||||||||||||||||||||||||
| 2240 | sz.setWidth(pm); | - | ||||||||||||||||||||||||
| 2241 | if (sz.height() == -1) | - | ||||||||||||||||||||||||
| 2242 | sz.setHeight(pm); | - | ||||||||||||||||||||||||
| 2243 | break; | - | ||||||||||||||||||||||||
| 2244 | } | - | ||||||||||||||||||||||||
| 2245 | - | |||||||||||||||||||||||||
| 2246 | case PseudoElement_DockWidgetCloseButton: | - | ||||||||||||||||||||||||
| 2247 | case PseudoElement_DockWidgetFloatButton: { | - | ||||||||||||||||||||||||
| 2248 | int iconSize = pixelMetric(PM_SmallIconSize, 0, w); | - | ||||||||||||||||||||||||
| 2249 | return QSize(iconSize, iconSize); | - | ||||||||||||||||||||||||
| 2250 | } | - | ||||||||||||||||||||||||
| 2251 | - | |||||||||||||||||||||||||
| 2252 | default: | - | ||||||||||||||||||||||||
| 2253 | break; | - | ||||||||||||||||||||||||
| 2254 | } | - | ||||||||||||||||||||||||
| 2255 | - | |||||||||||||||||||||||||
| 2256 | // expand to rectangle | - | ||||||||||||||||||||||||
| 2257 | if (sz.height() == -1) | - | ||||||||||||||||||||||||
| 2258 | sz.setHeight(rect.height()); | - | ||||||||||||||||||||||||
| 2259 | if (sz.width() == -1) | - | ||||||||||||||||||||||||
| 2260 | sz.setWidth(rect.width()); | - | ||||||||||||||||||||||||
| 2261 | - | |||||||||||||||||||||||||
| 2262 | return sz; | - | ||||||||||||||||||||||||
| 2263 | } | - | ||||||||||||||||||||||||
| 2264 | - | |||||||||||||||||||||||||
| 2265 | static PositionMode defaultPositionMode(int pe) | - | ||||||||||||||||||||||||
| 2266 | { | - | ||||||||||||||||||||||||
| 2267 | switch (pe) { | - | ||||||||||||||||||||||||
| 2268 | case PseudoElement_ScrollBarFirst: | - | ||||||||||||||||||||||||
| 2269 | case PseudoElement_ScrollBarLast: | - | ||||||||||||||||||||||||
| 2270 | case PseudoElement_ScrollBarAddLine: | - | ||||||||||||||||||||||||
| 2271 | case PseudoElement_ScrollBarSubLine: | - | ||||||||||||||||||||||||
| 2272 | case PseudoElement_ScrollBarAddPage: | - | ||||||||||||||||||||||||
| 2273 | case PseudoElement_ScrollBarSubPage: | - | ||||||||||||||||||||||||
| 2274 | case PseudoElement_ScrollBarSlider: | - | ||||||||||||||||||||||||
| 2275 | case PseudoElement_SliderGroove: | - | ||||||||||||||||||||||||
| 2276 | case PseudoElement_SliderHandle: | - | ||||||||||||||||||||||||
| 2277 | case PseudoElement_TabWidgetPane: | - | ||||||||||||||||||||||||
| 2278 | return PositionMode_Absolute; | - | ||||||||||||||||||||||||
| 2279 | default: | - | ||||||||||||||||||||||||
| 2280 | return PositionMode_Static; | - | ||||||||||||||||||||||||
| 2281 | } | - | ||||||||||||||||||||||||
| 2282 | } | - | ||||||||||||||||||||||||
| 2283 | - | |||||||||||||||||||||||||
| 2284 | QRect QStyleSheetStyle::positionRect(const QWidget *w, const QRenderRule &rule2, int pe, | - | ||||||||||||||||||||||||
| 2285 | const QRect &originRect, Qt::LayoutDirection dir) const | - | ||||||||||||||||||||||||
| 2286 | { | - | ||||||||||||||||||||||||
| 2287 | const QStyleSheetPositionData *p = rule2.position(); | - | ||||||||||||||||||||||||
| 2288 | PositionMode mode = (p && p->mode != PositionMode_Unknown) ? p->mode : defaultPositionMode(pe); | - | ||||||||||||||||||||||||
| 2289 | Qt::Alignment position = (p && p->position != 0) ? p->position : defaultPosition(pe); | - | ||||||||||||||||||||||||
| 2290 | QRect r; | - | ||||||||||||||||||||||||
| 2291 | - | |||||||||||||||||||||||||
| 2292 | if (mode != PositionMode_Absolute) { | - | ||||||||||||||||||||||||
| 2293 | QSize sz = defaultSize(w, rule2.size(), originRect, pe); | - | ||||||||||||||||||||||||
| 2294 | sz = sz.expandedTo(rule2.minimumContentsSize()); | - | ||||||||||||||||||||||||
| 2295 | r = QStyle::alignedRect(dir, position, sz, originRect); | - | ||||||||||||||||||||||||
| 2296 | if (p) { | - | ||||||||||||||||||||||||
| 2297 | int left = p->left ? p->left : -p->right; | - | ||||||||||||||||||||||||
| 2298 | int top = p->top ? p->top : -p->bottom; | - | ||||||||||||||||||||||||
| 2299 | r.translate(dir == Qt::LeftToRight ? left : -left, top); | - | ||||||||||||||||||||||||
| 2300 | } | - | ||||||||||||||||||||||||
| 2301 | } else { | - | ||||||||||||||||||||||||
| 2302 | r = p ? originRect.adjusted(dir == Qt::LeftToRight ? p->left : p->right, p->top, | - | ||||||||||||||||||||||||
| 2303 | dir == Qt::LeftToRight ? -p->right : -p->left, -p->bottom) | - | ||||||||||||||||||||||||
| 2304 | : originRect; | - | ||||||||||||||||||||||||
| 2305 | if (rule2.hasContentsSize()) { | - | ||||||||||||||||||||||||
| 2306 | QSize sz = rule2.size().expandedTo(rule2.minimumContentsSize()); | - | ||||||||||||||||||||||||
| 2307 | if (sz.width() == -1) sz.setWidth(r.width()); | - | ||||||||||||||||||||||||
| 2308 | if (sz.height() == -1) sz.setHeight(r.height()); | - | ||||||||||||||||||||||||
| 2309 | r = QStyle::alignedRect(dir, position, sz, r); | - | ||||||||||||||||||||||||
| 2310 | } | - | ||||||||||||||||||||||||
| 2311 | } | - | ||||||||||||||||||||||||
| 2312 | return r; | - | ||||||||||||||||||||||||
| 2313 | } | - | ||||||||||||||||||||||||
| 2314 | - | |||||||||||||||||||||||||
| 2315 | QRect QStyleSheetStyle::positionRect(const QWidget *w, const QRenderRule& rule1, const QRenderRule& rule2, int pe, | - | ||||||||||||||||||||||||
| 2316 | const QRect& rect, Qt::LayoutDirection dir) const | - | ||||||||||||||||||||||||
| 2317 | { | - | ||||||||||||||||||||||||
| 2318 | const QStyleSheetPositionData *p = rule2.position(); | - | ||||||||||||||||||||||||
| 2319 | Origin origin = (p && p->origin != Origin_Unknown) ? p->origin : defaultOrigin(pe); | - | ||||||||||||||||||||||||
| 2320 | QRect originRect = rule1.originRect(rect, origin); | - | ||||||||||||||||||||||||
| 2321 | return positionRect(w, rule2, pe, originRect, dir); | - | ||||||||||||||||||||||||
| 2322 | } | - | ||||||||||||||||||||||||
| 2323 | - | |||||||||||||||||||||||||
| 2324 | - | |||||||||||||||||||||||||
| 2325 | /** \internal | - | ||||||||||||||||||||||||
| 2326 | For widget that have an embedded widget (such as combobox) return that embedded widget. | - | ||||||||||||||||||||||||
| 2327 | otherwise return the widget itself | - | ||||||||||||||||||||||||
| 2328 | */ | - | ||||||||||||||||||||||||
| 2329 | static QWidget *embeddedWidget(QWidget *w) | - | ||||||||||||||||||||||||
| 2330 | { | - | ||||||||||||||||||||||||
| 2331 | #ifndef QT_NO_COMBOBOX | - | ||||||||||||||||||||||||
| 2332 | if (QComboBox *cmb = qobject_cast<QComboBox *>(w)) { | - | ||||||||||||||||||||||||
| 2333 | if (cmb->isEditable()) | - | ||||||||||||||||||||||||
| 2334 | return cmb->lineEdit(); | - | ||||||||||||||||||||||||
| 2335 | else | - | ||||||||||||||||||||||||
| 2336 | return cmb; | - | ||||||||||||||||||||||||
| 2337 | } | - | ||||||||||||||||||||||||
| 2338 | #endif | - | ||||||||||||||||||||||||
| 2339 | - | |||||||||||||||||||||||||
| 2340 | #ifndef QT_NO_SPINBOX | - | ||||||||||||||||||||||||
| 2341 | if (QAbstractSpinBox *sb = qobject_cast<QAbstractSpinBox *>(w)) | - | ||||||||||||||||||||||||
| 2342 | return sb->findChild<QLineEdit *>(); | - | ||||||||||||||||||||||||
| 2343 | #endif | - | ||||||||||||||||||||||||
| 2344 | - | |||||||||||||||||||||||||
| 2345 | #ifndef QT_NO_SCROLLAREA | - | ||||||||||||||||||||||||
| 2346 | if (QAbstractScrollArea *sa = qobject_cast<QAbstractScrollArea *>(w)) | - | ||||||||||||||||||||||||
| 2347 | return sa->viewport(); | - | ||||||||||||||||||||||||
| 2348 | #endif | - | ||||||||||||||||||||||||
| 2349 | - | |||||||||||||||||||||||||
| 2350 | return w; | - | ||||||||||||||||||||||||
| 2351 | } | - | ||||||||||||||||||||||||
| 2352 | - | |||||||||||||||||||||||||
| 2353 | /** \internal | - | ||||||||||||||||||||||||
| 2354 | in case w is an embedded widget, return the container widget | - | ||||||||||||||||||||||||
| 2355 | (i.e, the widget for which the rules actualy apply) | - | ||||||||||||||||||||||||
| 2356 | (exemple, if w is a lineedit embedded in a combobox, return the combobox) | - | ||||||||||||||||||||||||
| 2357 | - | |||||||||||||||||||||||||
| 2358 | if w is not embedded, return w itself | - | ||||||||||||||||||||||||
| 2359 | */ | - | ||||||||||||||||||||||||
| 2360 | static QWidget *containerWidget(const QWidget *w) | - | ||||||||||||||||||||||||
| 2361 | { | - | ||||||||||||||||||||||||
| 2362 | #ifndef QT_NO_LINEEDIT | - | ||||||||||||||||||||||||
| 2363 | if (qobject_cast<const QLineEdit *>(w)) { | - | ||||||||||||||||||||||||
| 2364 | //if the QLineEdit is an embeddedWidget, we need the rule of the real widget | - | ||||||||||||||||||||||||
| 2365 | #ifndef QT_NO_COMBOBOX | - | ||||||||||||||||||||||||
| 2366 | if (qobject_cast<const QComboBox *>(w->parentWidget())) | - | ||||||||||||||||||||||||
| 2367 | return w->parentWidget(); | - | ||||||||||||||||||||||||
| 2368 | #endif | - | ||||||||||||||||||||||||
| 2369 | #ifndef QT_NO_SPINBOX | - | ||||||||||||||||||||||||
| 2370 | if (qobject_cast<const QAbstractSpinBox *>(w->parentWidget())) | - | ||||||||||||||||||||||||
| 2371 | return w->parentWidget(); | - | ||||||||||||||||||||||||
| 2372 | #endif | - | ||||||||||||||||||||||||
| 2373 | } | - | ||||||||||||||||||||||||
| 2374 | #endif // QT_NO_LINEEDIT | - | ||||||||||||||||||||||||
| 2375 | - | |||||||||||||||||||||||||
| 2376 | #ifndef QT_NO_SCROLLAREA | - | ||||||||||||||||||||||||
| 2377 | if (const QAbstractScrollArea *sa = qobject_cast<const QAbstractScrollArea *>(w->parentWidget())) { | - | ||||||||||||||||||||||||
| 2378 | if (sa->viewport() == w) | - | ||||||||||||||||||||||||
| 2379 | return w->parentWidget(); | - | ||||||||||||||||||||||||
| 2380 | } | - | ||||||||||||||||||||||||
| 2381 | #endif | - | ||||||||||||||||||||||||
| 2382 | - | |||||||||||||||||||||||||
| 2383 | return const_cast<QWidget *>(w); | - | ||||||||||||||||||||||||
| 2384 | } | - | ||||||||||||||||||||||||
| 2385 | - | |||||||||||||||||||||||||
| 2386 | /** \internal | - | ||||||||||||||||||||||||
| 2387 | returns \c true if the widget can NOT be styled directly | - | ||||||||||||||||||||||||
| 2388 | */ | - | ||||||||||||||||||||||||
| 2389 | static bool unstylable(const QWidget *w) | - | ||||||||||||||||||||||||
| 2390 | { | - | ||||||||||||||||||||||||
| 2391 | if (w->windowType() == Qt::Desktop) | - | ||||||||||||||||||||||||
| 2392 | return true; | - | ||||||||||||||||||||||||
| 2393 | - | |||||||||||||||||||||||||
| 2394 | if (!w->styleSheet().isEmpty()) | - | ||||||||||||||||||||||||
| 2395 | return false; | - | ||||||||||||||||||||||||
| 2396 | - | |||||||||||||||||||||||||
| 2397 | if (containerWidget(w) != w) | - | ||||||||||||||||||||||||
| 2398 | return true; | - | ||||||||||||||||||||||||
| 2399 | - | |||||||||||||||||||||||||
| 2400 | #ifndef QT_NO_FRAME | - | ||||||||||||||||||||||||
| 2401 | // detect QComboBoxPrivateContainer | - | ||||||||||||||||||||||||
| 2402 | else if (qobject_cast<const QFrame *>(w)) { | - | ||||||||||||||||||||||||
| 2403 | if (0 | - | ||||||||||||||||||||||||
| 2404 | #ifndef QT_NO_COMBOBOX | - | ||||||||||||||||||||||||
| 2405 | || qobject_cast<const QComboBox *>(w->parentWidget()) | - | ||||||||||||||||||||||||
| 2406 | #endif | - | ||||||||||||||||||||||||
| 2407 | ) | - | ||||||||||||||||||||||||
| 2408 | return true; | - | ||||||||||||||||||||||||
| 2409 | } | - | ||||||||||||||||||||||||
| 2410 | #endif | - | ||||||||||||||||||||||||
| 2411 | - | |||||||||||||||||||||||||
| 2412 | #ifndef QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 2413 | if (w->metaObject() == &QWidget::staticMetaObject | - | ||||||||||||||||||||||||
| 2414 | && qobject_cast<const QTabBar*>(w->parentWidget())) | - | ||||||||||||||||||||||||
| 2415 | return true; // The moving tab of a QTabBar | - | ||||||||||||||||||||||||
| 2416 | #endif | - | ||||||||||||||||||||||||
| 2417 | - | |||||||||||||||||||||||||
| 2418 | return false; | - | ||||||||||||||||||||||||
| 2419 | } | - | ||||||||||||||||||||||||
| 2420 | - | |||||||||||||||||||||||||
| 2421 | static quint64 extendedPseudoClass(const QWidget *w) | - | ||||||||||||||||||||||||
| 2422 | { | - | ||||||||||||||||||||||||
| 2423 | quint64 pc = w->isWindow() ? quint64(PseudoClass_Window) : 0; | - | ||||||||||||||||||||||||
| 2424 | if (const QAbstractSlider *slider = qobject_cast<const QAbstractSlider *>(w)) { | - | ||||||||||||||||||||||||
| 2425 | pc |= ((slider->orientation() == Qt::Vertical) ? PseudoClass_Vertical : PseudoClass_Horizontal); | - | ||||||||||||||||||||||||
| 2426 | } else | - | ||||||||||||||||||||||||
| 2427 | #ifndef QT_NO_COMBOBOX | - | ||||||||||||||||||||||||
| 2428 | if (const QComboBox *combo = qobject_cast<const QComboBox *>(w)) { | - | ||||||||||||||||||||||||
| 2429 | if (combo->isEditable()) | - | ||||||||||||||||||||||||
| 2430 | pc |= (combo->isEditable() ? PseudoClass_Editable : PseudoClass_ReadOnly); | - | ||||||||||||||||||||||||
| 2431 | } else | - | ||||||||||||||||||||||||
| 2432 | #endif | - | ||||||||||||||||||||||||
| 2433 | #ifndef QT_NO_LINEEDIT | - | ||||||||||||||||||||||||
| 2434 | if (const QLineEdit *edit = qobject_cast<const QLineEdit *>(w)) { | - | ||||||||||||||||||||||||
| 2435 | pc |= (edit->isReadOnly() ? PseudoClass_ReadOnly : PseudoClass_Editable); | - | ||||||||||||||||||||||||
| 2436 | } else | - | ||||||||||||||||||||||||
| 2437 | #endif | - | ||||||||||||||||||||||||
| 2438 | { } // required for the above ifdef'ery to work | - | ||||||||||||||||||||||||
| 2439 | return pc; | - | ||||||||||||||||||||||||
| 2440 | } | - | ||||||||||||||||||||||||
| 2441 | - | |||||||||||||||||||||||||
| 2442 | // sets up the geometry of the widget. We set a dynamic property when | - | ||||||||||||||||||||||||
| 2443 | // we modify the min/max size of the widget. The min/max size is restored | - | ||||||||||||||||||||||||
| 2444 | // to their original value when a new stylesheet that does not contain | - | ||||||||||||||||||||||||
| 2445 | // the CSS properties is set and when the widget has this dynamic property set. | - | ||||||||||||||||||||||||
| 2446 | // This way we don't trample on users who had setup a min/max size in code and | - | ||||||||||||||||||||||||
| 2447 | // don't use stylesheets at all. | - | ||||||||||||||||||||||||
| 2448 | void QStyleSheetStyle::setGeometry(QWidget *w) | - | ||||||||||||||||||||||||
| 2449 | { | - | ||||||||||||||||||||||||
| 2450 | QRenderRule rule = renderRule(w, PseudoElement_None, PseudoClass_Enabled | extendedPseudoClass(w)); | - | ||||||||||||||||||||||||
| 2451 | const QStyleSheetGeometryData *geo = rule.geometry(); | - | ||||||||||||||||||||||||
| 2452 | if (w->property("_q_stylesheet_minw").toBool() | - | ||||||||||||||||||||||||
| 2453 | && ((!rule.hasGeometry() || geo->minWidth == -1))) { | - | ||||||||||||||||||||||||
| 2454 | w->setMinimumWidth(0); | - | ||||||||||||||||||||||||
| 2455 | w->setProperty("_q_stylesheet_minw", QVariant()); | - | ||||||||||||||||||||||||
| 2456 | } | - | ||||||||||||||||||||||||
| 2457 | if (w->property("_q_stylesheet_minh").toBool() | - | ||||||||||||||||||||||||
| 2458 | && ((!rule.hasGeometry() || geo->minHeight == -1))) { | - | ||||||||||||||||||||||||
| 2459 | w->setMinimumHeight(0); | - | ||||||||||||||||||||||||
| 2460 | w->setProperty("_q_stylesheet_minh", QVariant()); | - | ||||||||||||||||||||||||
| 2461 | } | - | ||||||||||||||||||||||||
| 2462 | if (w->property("_q_stylesheet_maxw").toBool() | - | ||||||||||||||||||||||||
| 2463 | && ((!rule.hasGeometry() || geo->maxWidth == -1))) { | - | ||||||||||||||||||||||||
| 2464 | w->setMaximumWidth(QWIDGETSIZE_MAX); | - | ||||||||||||||||||||||||
| 2465 | w->setProperty("_q_stylesheet_maxw", QVariant()); | - | ||||||||||||||||||||||||
| 2466 | } | - | ||||||||||||||||||||||||
| 2467 | if (w->property("_q_stylesheet_maxh").toBool() | - | ||||||||||||||||||||||||
| 2468 | && ((!rule.hasGeometry() || geo->maxHeight == -1))) { | - | ||||||||||||||||||||||||
| 2469 | w->setMaximumHeight(QWIDGETSIZE_MAX); | - | ||||||||||||||||||||||||
| 2470 | w->setProperty("_q_stylesheet_maxh", QVariant()); | - | ||||||||||||||||||||||||
| 2471 | } | - | ||||||||||||||||||||||||
| 2472 | - | |||||||||||||||||||||||||
| 2473 | - | |||||||||||||||||||||||||
| 2474 | if (rule.hasGeometry()) { | - | ||||||||||||||||||||||||
| 2475 | if (geo->minWidth != -1) { | - | ||||||||||||||||||||||||
| 2476 | w->setProperty("_q_stylesheet_minw", true); | - | ||||||||||||||||||||||||
| 2477 | w->setMinimumWidth(rule.boxSize(QSize(qMax(geo->width, geo->minWidth), 0)).width()); | - | ||||||||||||||||||||||||
| 2478 | } | - | ||||||||||||||||||||||||
| 2479 | if (geo->minHeight != -1) { | - | ||||||||||||||||||||||||
| 2480 | w->setProperty("_q_stylesheet_minh", true); | - | ||||||||||||||||||||||||
| 2481 | w->setMinimumHeight(rule.boxSize(QSize(0, qMax(geo->height, geo->minHeight))).height()); | - | ||||||||||||||||||||||||
| 2482 | } | - | ||||||||||||||||||||||||
| 2483 | if (geo->maxWidth != -1) { | - | ||||||||||||||||||||||||
| 2484 | w->setProperty("_q_stylesheet_maxw", true); | - | ||||||||||||||||||||||||
| 2485 | w->setMaximumWidth(rule.boxSize(QSize(qMin(geo->width == -1 ? QWIDGETSIZE_MAX : geo->width, | - | ||||||||||||||||||||||||
| 2486 | geo->maxWidth == -1 ? QWIDGETSIZE_MAX : geo->maxWidth), 0)).width()); | - | ||||||||||||||||||||||||
| 2487 | } | - | ||||||||||||||||||||||||
| 2488 | if (geo->maxHeight != -1) { | - | ||||||||||||||||||||||||
| 2489 | w->setProperty("_q_stylesheet_maxh", true); | - | ||||||||||||||||||||||||
| 2490 | w->setMaximumHeight(rule.boxSize(QSize(0, qMin(geo->height == -1 ? QWIDGETSIZE_MAX : geo->height, | - | ||||||||||||||||||||||||
| 2491 | geo->maxHeight == -1 ? QWIDGETSIZE_MAX : geo->maxHeight))).height()); | - | ||||||||||||||||||||||||
| 2492 | } | - | ||||||||||||||||||||||||
| 2493 | } | - | ||||||||||||||||||||||||
| 2494 | } | - | ||||||||||||||||||||||||
| 2495 | - | |||||||||||||||||||||||||
| 2496 | void QStyleSheetStyle::setProperties(QWidget *w) | - | ||||||||||||||||||||||||
| 2497 | { | - | ||||||||||||||||||||||||
| 2498 | // The final occurrence of each property is authoritative. | - | ||||||||||||||||||||||||
| 2499 | // Set value for each property in the order of property final occurrence | - | ||||||||||||||||||||||||
| 2500 | // since properties interact. | - | ||||||||||||||||||||||||
| 2501 | - | |||||||||||||||||||||||||
| 2502 | const QVector<Declaration> decls = declarations(styleRules(w), QString()); | - | ||||||||||||||||||||||||
| 2503 | QVector<int> finals; // indices in reverse order of each property's final occurrence | - | ||||||||||||||||||||||||
| 2504 | - | |||||||||||||||||||||||||
| 2505 | { | - | ||||||||||||||||||||||||
| 2506 | // scan decls for final occurrence of each "qproperty" | - | ||||||||||||||||||||||||
| 2507 | QSet<const QString> propertySet; | - | ||||||||||||||||||||||||
| 2508 | for (int i = decls.count() - 1; i >= 0; --i) {
| 0 | ||||||||||||||||||||||||
| 2509 | const QString property = decls.at(i).d->property; | - | ||||||||||||||||||||||||
| 2510 | if (!property.startsWith(QLatin1String("qproperty-"), Qt::CaseInsensitive))
| 0 | ||||||||||||||||||||||||
| 2511 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 2512 | if (!propertySet.contains(property)) {
| 0 | ||||||||||||||||||||||||
| 2513 | propertySet.insert(property); | - | ||||||||||||||||||||||||
| 2514 | finals.append(i); | - | ||||||||||||||||||||||||
| 2515 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2516 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2517 | } | - | ||||||||||||||||||||||||
| 2518 | - | |||||||||||||||||||||||||
| 2519 | for (int i = finals.count() - 1; i >= 0; --i) {
| 0 | ||||||||||||||||||||||||
| 2520 | const Declaration &decl = decls.at(finals[i]); | - | ||||||||||||||||||||||||
| 2521 | QString property = decl.d->property; | - | ||||||||||||||||||||||||
| 2522 | property.remove(0, 10); // strip "qproperty-" | - | ||||||||||||||||||||||||
| 2523 | - | |||||||||||||||||||||||||
| 2524 | const QMetaObject *metaObject = w->metaObject(); | - | ||||||||||||||||||||||||
| 2525 | int index = metaObject->indexOfProperty(property.toLatin1()); | - | ||||||||||||||||||||||||
| 2526 | if (Q_UNLIKELY(index == -1))) {
| 0 | ||||||||||||||||||||||||
| 2527 | qWarning() << w << " does not have a property named " << property; | - | ||||||||||||||||||||||||
| 2528 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 2529 | } | - | ||||||||||||||||||||||||
| 2530 | const QMetaProperty metaProperty = metaObject->property(index); | - | ||||||||||||||||||||||||
| 2531 | if (Q_UNLIKELY(!metaProperty.isWritable() || !metaProperty.isDesignable())())) {
| 0 | ||||||||||||||||||||||||
| 2532 | qWarning() << w << " cannot design property named " << property; | - | ||||||||||||||||||||||||
| 2533 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 2534 | } | - | ||||||||||||||||||||||||
| 2535 | - | |||||||||||||||||||||||||
| 2536 | QVariant v; | - | ||||||||||||||||||||||||
| 2537 | const QVariant value = w->property(property.toLatin1()); | - | ||||||||||||||||||||||||
| 2538 | switch (value.type()) { | - | ||||||||||||||||||||||||
| 2539 | case QVariant::Icon: v = decl.iconValue(); break; never executed: break;never executed: case QVariant::Icon: | 0 | ||||||||||||||||||||||||
| 2540 | case QVariant::Image: v = QImage(decl.uriValue()); break; never executed: break;never executed: case QVariant::Image: | 0 | ||||||||||||||||||||||||
| 2541 | case QVariant::Pixmap: v = QPixmap(decl.uriValue()); break; never executed: break;never executed: case QVariant::Pixmap: | 0 | ||||||||||||||||||||||||
| 2542 | case QVariant::Rect: v = decl.rectValue(); break; never executed: break;never executed: case QVariant::Rect: | 0 | ||||||||||||||||||||||||
| 2543 | case QVariant::Size: v = decl.sizeValue(); break; never executed: break;never executed: case QVariant::Size: | 0 | ||||||||||||||||||||||||
| 2544 | case QVariant::Color: v = decl.colorValue(); break; never executed: break;never executed: case QVariant::Color: | 0 | ||||||||||||||||||||||||
| 2545 | case QVariant::Brush: v = decl.brushValue(); break; never executed: break;never executed: case QVariant::Brush: | 0 | ||||||||||||||||||||||||
| 2546 | #ifndef QT_NO_SHORTCUT | - | ||||||||||||||||||||||||
| 2547 | case QVariant::KeySequence: v = QKeySequence(decl.d->values.at(0).variant.toString()); break; never executed: break;never executed: case QVariant::KeySequence: | 0 | ||||||||||||||||||||||||
| 2548 | #endif | - | ||||||||||||||||||||||||
| 2549 | default: v = decl.d->values.at(0).variant; break; never executed: break;never executed: default: | 0 | ||||||||||||||||||||||||
| 2550 | } | - | ||||||||||||||||||||||||
| 2551 | - | |||||||||||||||||||||||||
| 2552 | w->setProperty(property.toLatin1(), v); | - | ||||||||||||||||||||||||
| 2553 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2554 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2555 | - | |||||||||||||||||||||||||
| 2556 | void QStyleSheetStyle::setPalette(QWidget *w) | - | ||||||||||||||||||||||||
| 2557 | { | - | ||||||||||||||||||||||||
| 2558 | struct RuleRoleMap { | - | ||||||||||||||||||||||||
| 2559 | int state; | - | ||||||||||||||||||||||||
| 2560 | QPalette::ColorGroup group; | - | ||||||||||||||||||||||||
| 2561 | } map[3] = { | - | ||||||||||||||||||||||||
| 2562 | { int(PseudoClass_Active | PseudoClass_Enabled), QPalette::Active }, | - | ||||||||||||||||||||||||
| 2563 | { PseudoClass_Disabled, QPalette::Disabled }, | - | ||||||||||||||||||||||||
| 2564 | { PseudoClass_Enabled, QPalette::Inactive } | - | ||||||||||||||||||||||||
| 2565 | }; | - | ||||||||||||||||||||||||
| 2566 | - | |||||||||||||||||||||||||
| 2567 | const bool useStyleSheetPropagationInWidgetStyles = | - | ||||||||||||||||||||||||
| 2568 | QCoreApplication::testAttribute(Qt::AA_UseStyleSheetPropagationInWidgetStyles); | - | ||||||||||||||||||||||||
| 2569 | - | |||||||||||||||||||||||||
| 2570 | QPalette p; | - | ||||||||||||||||||||||||
| 2571 | if (!useStyleSheetPropagationInWidgetStyles)
| 0 | ||||||||||||||||||||||||
| 2572 | p = w->palette(); never executed: p = w->palette(); | 0 | ||||||||||||||||||||||||
| 2573 | - | |||||||||||||||||||||||||
| 2574 | QWidget *ew = embeddedWidget(w); | - | ||||||||||||||||||||||||
| 2575 | - | |||||||||||||||||||||||||
| 2576 | for (int i = 0; i < 3; i++) {
| 0 | ||||||||||||||||||||||||
| 2577 | QRenderRule rule = renderRule(w, PseudoElement_None, map[i].state | extendedPseudoClass(w)); | - | ||||||||||||||||||||||||
| 2578 | if (i == 0) {
| 0 | ||||||||||||||||||||||||
| 2579 | if (!w->property("_q_styleSheetWidgetFont").isValid()) {
| 0 | ||||||||||||||||||||||||
| 2580 | saveWidgetFont(w, w->font()); | - | ||||||||||||||||||||||||
| 2581 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2582 | updateStyleSheetFont(w); | - | ||||||||||||||||||||||||
| 2583 | if (ew != w)
| 0 | ||||||||||||||||||||||||
| 2584 | updateStyleSheetFont(ew); never executed: updateStyleSheetFont(ew); | 0 | ||||||||||||||||||||||||
| 2585 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2586 | - | |||||||||||||||||||||||||
| 2587 | rule.configurePalette(&p, map[i].group, ew, ew != w); | - | ||||||||||||||||||||||||
| 2588 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2589 | - | |||||||||||||||||||||||||
| 2590 | if (!useStyleSheetPropagationInWidgetStyles || p.resolve() != 0) {
| 0 | ||||||||||||||||||||||||
| 2591 | QPalette wp = w->palette(); | - | ||||||||||||||||||||||||
| 2592 | styleSheetCaches->customPaletteWidgets.insert(w, w->paletteqMakePair(wp, p.resolve())); | - | ||||||||||||||||||||||||
| 2593 | - | |||||||||||||||||||||||||
| 2594 | if (useStyleSheetPropagationInWidgetStyles) {
| 0 | ||||||||||||||||||||||||
| 2595 | p = p.resolve(wp); | - | ||||||||||||||||||||||||
| 2596 | p.resolve(p.resolve() | wp.resolve()); | - | ||||||||||||||||||||||||
| 2597 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2598 | - | |||||||||||||||||||||||||
| 2599 | w->setPalette(p); | - | ||||||||||||||||||||||||
| 2600 | if (ew != w)
| 0 | ||||||||||||||||||||||||
| 2601 | ew->setPalette(p); never executed: ew->setPalette(p); | 0 | ||||||||||||||||||||||||
| 2602 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2603 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2604 | - | |||||||||||||||||||||||||
| 2605 | void QStyleSheetStyle::unsetPalette(QWidget *w) | - | ||||||||||||||||||||||||
| 2606 | { | - | ||||||||||||||||||||||||
| 2607 | const bool useStyleSheetPropagationInWidgetStyles = | - | ||||||||||||||||||||||||
| 2608 | QCoreApplication::testAttribute(Qt::AA_UseStyleSheetPropagationInWidgetStyles); | - | ||||||||||||||||||||||||
| 2609 | - | |||||||||||||||||||||||||
| 2610 | if (styleSheetCaches->customPaletteWidgets.contains(w)) {
| 0 | ||||||||||||||||||||||||
| 2611 | QPair<QPalette, uint> p = styleSheetCaches->customPaletteWidgets.value(w); | - | ||||||||||||||||||||||||
| 2612 | styleSheetCaches->customPaletteWidgets.remove(w); | - | ||||||||||||||||||||||||
| 2613 | - | |||||||||||||||||||||||||
| 2614 | QPalette original = p.first; | - | ||||||||||||||||||||||||
| 2615 | - | |||||||||||||||||||||||||
| 2616 | if (useStyleSheetPropagationInWidgetStyles) {
| 0 | ||||||||||||||||||||||||
| 2617 | original.resolve(original.resolve() & p.second); | - | ||||||||||||||||||||||||
| 2618 | - | |||||||||||||||||||||||||
| 2619 | QPalette wp = w->setPalettepalette(); | - | ||||||||||||||||||||||||
| 2620 | wp.resolve(wp.resolve() & ~p.second); | - | ||||||||||||||||||||||||
| 2621 | wp.resolve(original); | - | ||||||||||||||||||||||||
| 2622 | wp.resolve(wp.resolve() | original.resolve()); | - | ||||||||||||||||||||||||
| 2623 | original = wp; | - | ||||||||||||||||||||||||
| 2624 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2625 | - | |||||||||||||||||||||||||
| 2626 | w->setPalette(original); | - | ||||||||||||||||||||||||
| 2627 | QWidget *ew = embeddedWidget(w); | - | ||||||||||||||||||||||||
| 2628 | if (ew != w)
| 0 | ||||||||||||||||||||||||
| 2629 | ew->setPalette(poriginal); never executed: ew->setPalette(original); | 0 | ||||||||||||||||||||||||
| 2630 | styleSheetCaches->customPaletteWidgets.remove} never executed: end of block | 0 | ||||||||||||||||||||||||
| 2631 | - | |||||||||||||||||||||||||
| 2632 | if (useStyleSheetPropagationInWidgetStyles) {
| 0 | ||||||||||||||||||||||||
| 2633 | unsetStyleSheetFont(w); | - | ||||||||||||||||||||||||
| 2634 | QWidget *ew = embeddedWidget(w); | - | ||||||||||||||||||||||||
| 2635 | if
| 0 | ||||||||||||||||||||||||
| 2636 | unsetStyleSheetFont(ew never executed: );unsetStyleSheetFont(ew);never executed: unsetStyleSheetFont(ew); | 0 | ||||||||||||||||||||||||
| 2637 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 2638 | QVariant oldFont = w->property("_q_styleSheetWidgetFont"); | - | ||||||||||||||||||||||||
| 2639 | if (oldFont.isValid()) {
| 0 | ||||||||||||||||||||||||
| 2640 | w->setFont(qvariant_cast<QFont>(oldFont)); | - | ||||||||||||||||||||||||
| 2641 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2642 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2643 | - | |||||||||||||||||||||||||
| 2644 | if (styleSheetCaches->autoFillDisabledWidgets.contains(w)) {
| 0 | ||||||||||||||||||||||||
| 2645 | embeddedWidget(w)->setAutoFillBackground(true); | - | ||||||||||||||||||||||||
| 2646 | styleSheetCaches->autoFillDisabledWidgets.remove(w); | - | ||||||||||||||||||||||||
| 2647 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2648 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2649 | - | |||||||||||||||||||||||||
| 2650 | void QStyleSheetStyle::unsetStyleSheetFont(QWidget *w) const | - | ||||||||||||||||||||||||
| 2651 | { | - | ||||||||||||||||||||||||
| 2652 | if (styleSheetCaches->customFontWidgets.contains(w)) {
| 0 | ||||||||||||||||||||||||
| 2653 | QPair<QFont, uint> f = styleSheetCaches->customFontWidgets.value(w); | - | ||||||||||||||||||||||||
| 2654 | styleSheetCaches->customFontWidgets.remove(w); | - | ||||||||||||||||||||||||
| 2655 | - | |||||||||||||||||||||||||
| 2656 | QFont original = f.first; | - | ||||||||||||||||||||||||
| 2657 | original.resolve(original.resolve() & f.second); | - | ||||||||||||||||||||||||
| 2658 | - | |||||||||||||||||||||||||
| 2659 | QFont font = w->font(); | - | ||||||||||||||||||||||||
| 2660 | font.resolve(font.resolve() & ~f.second); | - | ||||||||||||||||||||||||
| 2661 | font.resolve(original); | - | ||||||||||||||||||||||||
| 2662 | font.resolve(font.resolve() | original.resolve()); | - | ||||||||||||||||||||||||
| 2663 | - | |||||||||||||||||||||||||
| 2664 | w->setFont(font); | - | ||||||||||||||||||||||||
| 2665 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2666 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2667 | - | |||||||||||||||||||||||||
| 2668 | static void updateObjects(const QList<const QObject *>& objects) | - | ||||||||||||||||||||||||
| 2669 | { | - | ||||||||||||||||||||||||
| 2670 | if (!styleSheetCaches->styleRulesCache.isEmpty() || !styleSheetCaches->hasStyleRuleCache.isEmpty() || !styleSheetCaches->renderRulesCache.isEmpty()) { | - | ||||||||||||||||||||||||
| 2671 | for (int i = 0; i < objects.size(); ++i) { | - | ||||||||||||||||||||||||
| 2672 | const QObject *object = objects.at(i); | - | ||||||||||||||||||||||||
| 2673 | styleSheetCaches->styleRulesCache.remove(object); | - | ||||||||||||||||||||||||
| 2674 | styleSheetCaches->hasStyleRuleCache.remove(object); | - | ||||||||||||||||||||||||
| 2675 | styleSheetCaches->renderRulesCache.remove(object); | - | ||||||||||||||||||||||||
| 2676 | } | - | ||||||||||||||||||||||||
| 2677 | } | - | ||||||||||||||||||||||||
| 2678 | - | |||||||||||||||||||||||||
| 2679 | QWidgetList widgets; | - | ||||||||||||||||||||||||
| 2680 | foreach (const QObject *object, objects) { | - | ||||||||||||||||||||||||
| 2681 | if (QWidget *w = qobject_cast<QWidget*>(const_cast<QObject*>(object))) | - | ||||||||||||||||||||||||
| 2682 | widgets << w; | - | ||||||||||||||||||||||||
| 2683 | } | - | ||||||||||||||||||||||||
| 2684 | - | |||||||||||||||||||||||||
| 2685 | QEvent event(QEvent::StyleChange); | - | ||||||||||||||||||||||||
| 2686 | foreach (QWidget *widget, widgets) { | - | ||||||||||||||||||||||||
| 2687 | widget->style()->polish(widget); | - | ||||||||||||||||||||||||
| 2688 | QApplication::sendEvent(widget, &event); | - | ||||||||||||||||||||||||
| 2689 | } | - | ||||||||||||||||||||||||
| 2690 | } | - | ||||||||||||||||||||||||
| 2691 | - | |||||||||||||||||||||||||
| 2692 | ///////////////////////////////////////////////////////////////////////////////////////// | - | ||||||||||||||||||||||||
| 2693 | // The stylesheet style | - | ||||||||||||||||||||||||
| 2694 | int QStyleSheetStyle::numinstances = 0; | - | ||||||||||||||||||||||||
| 2695 | - | |||||||||||||||||||||||||
| 2696 | QStyleSheetStyle::QStyleSheetStyle(QStyle *base) | - | ||||||||||||||||||||||||
| 2697 | : QWindowsStyle(*new QStyleSheetStylePrivate), base(base), refcount(1) | - | ||||||||||||||||||||||||
| 2698 | { | - | ||||||||||||||||||||||||
| 2699 | ++numinstances; | - | ||||||||||||||||||||||||
| 2700 | if (numinstances == 1) { | - | ||||||||||||||||||||||||
| 2701 | styleSheetCaches = new QStyleSheetStyleCaches; | - | ||||||||||||||||||||||||
| 2702 | } | - | ||||||||||||||||||||||||
| 2703 | } | - | ||||||||||||||||||||||||
| 2704 | - | |||||||||||||||||||||||||
| 2705 | QStyleSheetStyle::~QStyleSheetStyle() | - | ||||||||||||||||||||||||
| 2706 | { | - | ||||||||||||||||||||||||
| 2707 | --numinstances; | - | ||||||||||||||||||||||||
| 2708 | if (numinstances == 0) { | - | ||||||||||||||||||||||||
| 2709 | delete styleSheetCaches; | - | ||||||||||||||||||||||||
| 2710 | } | - | ||||||||||||||||||||||||
| 2711 | } | - | ||||||||||||||||||||||||
| 2712 | QStyle *QStyleSheetStyle::baseStyle() const | - | ||||||||||||||||||||||||
| 2713 | { | - | ||||||||||||||||||||||||
| 2714 | if (base) | - | ||||||||||||||||||||||||
| 2715 | return base; | - | ||||||||||||||||||||||||
| 2716 | if (QStyleSheetStyle *me = qobject_cast<QStyleSheetStyle *>(QApplication::style())) | - | ||||||||||||||||||||||||
| 2717 | return me->base; | - | ||||||||||||||||||||||||
| 2718 | return QApplication::style(); | - | ||||||||||||||||||||||||
| 2719 | } | - | ||||||||||||||||||||||||
| 2720 | - | |||||||||||||||||||||||||
| 2721 | void QStyleSheetStyleCaches::objectDestroyed(QObject *o) | - | ||||||||||||||||||||||||
| 2722 | { | - | ||||||||||||||||||||||||
| 2723 | styleRulesCache.remove(o); | - | ||||||||||||||||||||||||
| 2724 | hasStyleRuleCache.remove(o); | - | ||||||||||||||||||||||||
| 2725 | renderRulesCache.remove(o); | - | ||||||||||||||||||||||||
| 2726 | customPaletteWidgets.remove((const QWidget *)o); | - | ||||||||||||||||||||||||
| 2727 | customFontWidgets.remove(static_cast<QWidget *>(o)); | - | ||||||||||||||||||||||||
| 2728 | styleSheetCache.remove(o); | - | ||||||||||||||||||||||||
| 2729 | autoFillDisabledWidgets.remove((const QWidget *)o); | - | ||||||||||||||||||||||||
| 2730 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 2731 | - | |||||||||||||||||||||||||
| 2732 | void QStyleSheetStyleCaches::styleDestroyed(QObject *o) | - | ||||||||||||||||||||||||
| 2733 | { | - | ||||||||||||||||||||||||
| 2734 | styleSheetCache.remove(o); | - | ||||||||||||||||||||||||
| 2735 | } | - | ||||||||||||||||||||||||
| 2736 | - | |||||||||||||||||||||||||
| 2737 | /*! | - | ||||||||||||||||||||||||
| 2738 | * Make sure that the cache will be clean by connecting destroyed if needed. | - | ||||||||||||||||||||||||
| 2739 | * return false if the widget is not stylable; | - | ||||||||||||||||||||||||
| 2740 | */ | - | ||||||||||||||||||||||||
| 2741 | bool QStyleSheetStyle::initObject(const QObject *obj) const | - | ||||||||||||||||||||||||
| 2742 | { | - | ||||||||||||||||||||||||
| 2743 | if (!obj) | - | ||||||||||||||||||||||||
| 2744 | return false; | - | ||||||||||||||||||||||||
| 2745 | if (const QWidget *w = qobject_cast<const QWidget*>(obj)) { | - | ||||||||||||||||||||||||
| 2746 | if (w->testAttribute(Qt::WA_StyleSheet)) | - | ||||||||||||||||||||||||
| 2747 | return true; | - | ||||||||||||||||||||||||
| 2748 | if (unstylable(w)) | - | ||||||||||||||||||||||||
| 2749 | return false; | - | ||||||||||||||||||||||||
| 2750 | const_cast<QWidget *>(w)->setAttribute(Qt::WA_StyleSheet, true); | - | ||||||||||||||||||||||||
| 2751 | } | - | ||||||||||||||||||||||||
| 2752 | - | |||||||||||||||||||||||||
| 2753 | QObject::connect(obj, SIGNAL(destroyed(QObject*)), styleSheetCaches, SLOT(objectDestroyed(QObject*)), Qt::UniqueConnection); | - | ||||||||||||||||||||||||
| 2754 | return true; | - | ||||||||||||||||||||||||
| 2755 | } | - | ||||||||||||||||||||||||
| 2756 | - | |||||||||||||||||||||||||
| 2757 | void QStyleSheetStyle::polish(QWidget *w) | - | ||||||||||||||||||||||||
| 2758 | { | - | ||||||||||||||||||||||||
| 2759 | baseStyle()->polish(w); | - | ||||||||||||||||||||||||
| 2760 | RECURSION_GUARD(return) | - | ||||||||||||||||||||||||
| 2761 | - | |||||||||||||||||||||||||
| 2762 | if (!initObject(w)) | - | ||||||||||||||||||||||||
| 2763 | return; | - | ||||||||||||||||||||||||
| 2764 | - | |||||||||||||||||||||||||
| 2765 | if (styleSheetCaches->styleRulesCache.contains(w)) { | - | ||||||||||||||||||||||||
| 2766 | // the widget accessed its style pointer before polish (or repolish) | - | ||||||||||||||||||||||||
| 2767 | // (exemple: the QAbstractSpinBox constructor ask for the stylehint) | - | ||||||||||||||||||||||||
| 2768 | styleSheetCaches->styleRulesCache.remove(w); | - | ||||||||||||||||||||||||
| 2769 | styleSheetCaches->hasStyleRuleCache.remove(w); | - | ||||||||||||||||||||||||
| 2770 | styleSheetCaches->renderRulesCache.remove(w); | - | ||||||||||||||||||||||||
| 2771 | styleSheetCaches->styleSheetCache.remove(w); | - | ||||||||||||||||||||||||
| 2772 | } | - | ||||||||||||||||||||||||
| 2773 | setGeometry(w); | - | ||||||||||||||||||||||||
| 2774 | setProperties(w); | - | ||||||||||||||||||||||||
| 2775 | unsetPalette(w); | - | ||||||||||||||||||||||||
| 2776 | setPalette(w); | - | ||||||||||||||||||||||||
| 2777 | - | |||||||||||||||||||||||||
| 2778 | //set the WA_Hover attribute if one of the selector depends of the hover state | - | ||||||||||||||||||||||||
| 2779 | QVector<StyleRule> rules = styleRules(w); | - | ||||||||||||||||||||||||
| 2780 | for (int i = 0; i < rules.count(); i++) { | - | ||||||||||||||||||||||||
| 2781 | const Selector& selector = rules.at(i).selectors.at(0); | - | ||||||||||||||||||||||||
| 2782 | quint64 negated = 0; | - | ||||||||||||||||||||||||
| 2783 | quint64 cssClass = selector.pseudoClass(&negated); | - | ||||||||||||||||||||||||
| 2784 | if ( cssClass & PseudoClass_Hover || negated & PseudoClass_Hover) { | - | ||||||||||||||||||||||||
| 2785 | w->setAttribute(Qt::WA_Hover); | - | ||||||||||||||||||||||||
| 2786 | embeddedWidget(w)->setAttribute(Qt::WA_Hover); | - | ||||||||||||||||||||||||
| 2787 | } | - | ||||||||||||||||||||||||
| 2788 | } | - | ||||||||||||||||||||||||
| 2789 | - | |||||||||||||||||||||||||
| 2790 | - | |||||||||||||||||||||||||
| 2791 | #ifndef QT_NO_SCROLLAREA | - | ||||||||||||||||||||||||
| 2792 | if (QAbstractScrollArea *sa = qobject_cast<QAbstractScrollArea *>(w)) { | - | ||||||||||||||||||||||||
| 2793 | QRenderRule rule = renderRule(sa, PseudoElement_None, PseudoClass_Enabled); | - | ||||||||||||||||||||||||
| 2794 | if ((rule.hasBorder() && rule.border()->hasBorderImage()) | - | ||||||||||||||||||||||||
| 2795 | || (rule.hasBackground() && !rule.background()->pixmap.isNull())) { | - | ||||||||||||||||||||||||
| 2796 | QObject::connect(sa->horizontalScrollBar(), SIGNAL(valueChanged(int)), | - | ||||||||||||||||||||||||
| 2797 | sa, SLOT(update()), Qt::UniqueConnection); | - | ||||||||||||||||||||||||
| 2798 | QObject::connect(sa->verticalScrollBar(), SIGNAL(valueChanged(int)), | - | ||||||||||||||||||||||||
| 2799 | sa, SLOT(update()), Qt::UniqueConnection); | - | ||||||||||||||||||||||||
| 2800 | } | - | ||||||||||||||||||||||||
| 2801 | } | - | ||||||||||||||||||||||||
| 2802 | #endif | - | ||||||||||||||||||||||||
| 2803 | - | |||||||||||||||||||||||||
| 2804 | QRenderRule rule = renderRule(w, PseudoElement_None, PseudoClass_Any); | - | ||||||||||||||||||||||||
| 2805 | if (rule.hasDrawable() || rule.hasBox()) { | - | ||||||||||||||||||||||||
| 2806 | if (w->metaObject() == &QWidget::staticMetaObject | - | ||||||||||||||||||||||||
| 2807 | #ifndef QT_NO_ITEMVIEWS | - | ||||||||||||||||||||||||
| 2808 | || qobject_cast<QHeaderView *>(w) | - | ||||||||||||||||||||||||
| 2809 | #endif | - | ||||||||||||||||||||||||
| 2810 | #ifndef QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 2811 | || qobject_cast<QTabBar *>(w) | - | ||||||||||||||||||||||||
| 2812 | #endif | - | ||||||||||||||||||||||||
| 2813 | #ifndef QT_NO_FRAME | - | ||||||||||||||||||||||||
| 2814 | || qobject_cast<QFrame *>(w) | - | ||||||||||||||||||||||||
| 2815 | #endif | - | ||||||||||||||||||||||||
| 2816 | #ifndef QT_NO_MAINWINDOW | - | ||||||||||||||||||||||||
| 2817 | || qobject_cast<QMainWindow *>(w) | - | ||||||||||||||||||||||||
| 2818 | #endif | - | ||||||||||||||||||||||||
| 2819 | #ifndef QT_NO_MDIAREA | - | ||||||||||||||||||||||||
| 2820 | || qobject_cast<QMdiSubWindow *>(w) | - | ||||||||||||||||||||||||
| 2821 | #endif | - | ||||||||||||||||||||||||
| 2822 | #ifndef QT_NO_MENUBAR | - | ||||||||||||||||||||||||
| 2823 | || qobject_cast<QMenuBar *>(w) | - | ||||||||||||||||||||||||
| 2824 | #endif | - | ||||||||||||||||||||||||
| 2825 | || qobject_cast<QDialog *>(w)) { | - | ||||||||||||||||||||||||
| 2826 | w->setAttribute(Qt::WA_StyledBackground, true); | - | ||||||||||||||||||||||||
| 2827 | } | - | ||||||||||||||||||||||||
| 2828 | QWidget *ew = embeddedWidget(w); | - | ||||||||||||||||||||||||
| 2829 | if (ew->autoFillBackground()) { | - | ||||||||||||||||||||||||
| 2830 | ew->setAutoFillBackground(false); | - | ||||||||||||||||||||||||
| 2831 | styleSheetCaches->autoFillDisabledWidgets.insert(w); | - | ||||||||||||||||||||||||
| 2832 | if (ew != w) { //eg. viewport of a scrollarea | - | ||||||||||||||||||||||||
| 2833 | //(in order to draw the background anyway in case we don't.) | - | ||||||||||||||||||||||||
| 2834 | ew->setAttribute(Qt::WA_StyledBackground, true); | - | ||||||||||||||||||||||||
| 2835 | } | - | ||||||||||||||||||||||||
| 2836 | } | - | ||||||||||||||||||||||||
| 2837 | if (!rule.hasBackground() || rule.background()->isTransparent() || rule.hasBox() | - | ||||||||||||||||||||||||
| 2838 | || (!rule.hasNativeBorder() && !rule.border()->isOpaque())) | - | ||||||||||||||||||||||||
| 2839 | w->setAttribute(Qt::WA_OpaquePaintEvent, false); | - | ||||||||||||||||||||||||
| 2840 | } | - | ||||||||||||||||||||||||
| 2841 | } | - | ||||||||||||||||||||||||
| 2842 | - | |||||||||||||||||||||||||
| 2843 | void QStyleSheetStyle::polish(QApplication *app) | - | ||||||||||||||||||||||||
| 2844 | { | - | ||||||||||||||||||||||||
| 2845 | baseStyle()->polish(app); | - | ||||||||||||||||||||||||
| 2846 | } | - | ||||||||||||||||||||||||
| 2847 | - | |||||||||||||||||||||||||
| 2848 | void QStyleSheetStyle::polish(QPalette &pal) | - | ||||||||||||||||||||||||
| 2849 | { | - | ||||||||||||||||||||||||
| 2850 | baseStyle()->polish(pal); | - | ||||||||||||||||||||||||
| 2851 | } | - | ||||||||||||||||||||||||
| 2852 | - | |||||||||||||||||||||||||
| 2853 | void QStyleSheetStyle::repolish(QWidget *w) | - | ||||||||||||||||||||||||
| 2854 | { | - | ||||||||||||||||||||||||
| 2855 | QList<const QObject *> children = w->findChildren<const QObject *>(QString()); | - | ||||||||||||||||||||||||
| 2856 | children.append(w); | - | ||||||||||||||||||||||||
| 2857 | styleSheetCaches->styleSheetCache.remove(w); | - | ||||||||||||||||||||||||
| 2858 | updateObjects(children); | - | ||||||||||||||||||||||||
| 2859 | } | - | ||||||||||||||||||||||||
| 2860 | - | |||||||||||||||||||||||||
| 2861 | void QStyleSheetStyle::repolish(QApplication *app) | - | ||||||||||||||||||||||||
| 2862 | { | - | ||||||||||||||||||||||||
| 2863 | Q_UNUSED(app); | - | ||||||||||||||||||||||||
| 2864 | const QList<const QObject*> allObjects = styleSheetCaches->styleRulesCache.keys(); | - | ||||||||||||||||||||||||
| 2865 | styleSheetCaches->styleSheetCache.remove(qApp); | - | ||||||||||||||||||||||||
| 2866 | styleSheetCaches->styleRulesCache.clear(); | - | ||||||||||||||||||||||||
| 2867 | styleSheetCaches->hasStyleRuleCache.clear(); | - | ||||||||||||||||||||||||
| 2868 | styleSheetCaches->renderRulesCache.clear(); | - | ||||||||||||||||||||||||
| 2869 | updateObjects(allObjects); | - | ||||||||||||||||||||||||
| 2870 | } | - | ||||||||||||||||||||||||
| 2871 | - | |||||||||||||||||||||||||
| 2872 | void QStyleSheetStyle::unpolish(QWidget *w) | - | ||||||||||||||||||||||||
| 2873 | { | - | ||||||||||||||||||||||||
| 2874 | if (!w || !w->testAttribute(Qt::WA_StyleSheet)) { | - | ||||||||||||||||||||||||
| 2875 | baseStyle()->unpolish(w); | - | ||||||||||||||||||||||||
| 2876 | return; | - | ||||||||||||||||||||||||
| 2877 | } | - | ||||||||||||||||||||||||
| 2878 | - | |||||||||||||||||||||||||
| 2879 | styleSheetCaches->styleRulesCache.remove(w); | - | ||||||||||||||||||||||||
| 2880 | styleSheetCaches->hasStyleRuleCache.remove(w); | - | ||||||||||||||||||||||||
| 2881 | styleSheetCaches->renderRulesCache.remove(w); | - | ||||||||||||||||||||||||
| 2882 | styleSheetCaches->styleSheetCache.remove(w); | - | ||||||||||||||||||||||||
| 2883 | unsetPalette(w); | - | ||||||||||||||||||||||||
| 2884 | w->setProperty("_q_stylesheet_minw", QVariant()); | - | ||||||||||||||||||||||||
| 2885 | w->setProperty("_q_stylesheet_minh", QVariant()); | - | ||||||||||||||||||||||||
| 2886 | w->setProperty("_q_stylesheet_maxw", QVariant()); | - | ||||||||||||||||||||||||
| 2887 | w->setProperty("_q_stylesheet_maxh", QVariant()); | - | ||||||||||||||||||||||||
| 2888 | w->setAttribute(Qt::WA_StyleSheet, false); | - | ||||||||||||||||||||||||
| 2889 | QObject::disconnect(w, 0, this, 0); | - | ||||||||||||||||||||||||
| 2890 | #ifndef QT_NO_SCROLLAREA | - | ||||||||||||||||||||||||
| 2891 | if (QAbstractScrollArea *sa = qobject_cast<QAbstractScrollArea *>(w)) { | - | ||||||||||||||||||||||||
| 2892 | QObject::disconnect(sa->horizontalScrollBar(), SIGNAL(valueChanged(int)), | - | ||||||||||||||||||||||||
| 2893 | sa, SLOT(update())); | - | ||||||||||||||||||||||||
| 2894 | QObject::disconnect(sa->verticalScrollBar(), SIGNAL(valueChanged(int)), | - | ||||||||||||||||||||||||
| 2895 | sa, SLOT(update())); | - | ||||||||||||||||||||||||
| 2896 | } | - | ||||||||||||||||||||||||
| 2897 | #endif | - | ||||||||||||||||||||||||
| 2898 | baseStyle()->unpolish(w); | - | ||||||||||||||||||||||||
| 2899 | } | - | ||||||||||||||||||||||||
| 2900 | - | |||||||||||||||||||||||||
| 2901 | void QStyleSheetStyle::unpolish(QApplication *app) | - | ||||||||||||||||||||||||
| 2902 | { | - | ||||||||||||||||||||||||
| 2903 | baseStyle()->unpolish(app); | - | ||||||||||||||||||||||||
| 2904 | RECURSION_GUARD(return) | - | ||||||||||||||||||||||||
| 2905 | styleSheetCaches->styleRulesCache.clear(); | - | ||||||||||||||||||||||||
| 2906 | styleSheetCaches->hasStyleRuleCache.clear(); | - | ||||||||||||||||||||||||
| 2907 | styleSheetCaches->renderRulesCache.clear(); | - | ||||||||||||||||||||||||
| 2908 | styleSheetCaches->styleSheetCache.remove(qApp); | - | ||||||||||||||||||||||||
| 2909 | } | - | ||||||||||||||||||||||||
| 2910 | - | |||||||||||||||||||||||||
| 2911 | #ifndef QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 2912 | inline static bool verticalTabs(QTabBar::Shape shape) | - | ||||||||||||||||||||||||
| 2913 | { | - | ||||||||||||||||||||||||
| 2914 | return shape == QTabBar::RoundedWest | - | ||||||||||||||||||||||||
| 2915 | || shape == QTabBar::RoundedEast | - | ||||||||||||||||||||||||
| 2916 | || shape == QTabBar::TriangularWest | - | ||||||||||||||||||||||||
| 2917 | || shape == QTabBar::TriangularEast; | - | ||||||||||||||||||||||||
| 2918 | } | - | ||||||||||||||||||||||||
| 2919 | #endif // QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 2920 | - | |||||||||||||||||||||||||
| 2921 | void QStyleSheetStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p, | - | ||||||||||||||||||||||||
| 2922 | const QWidget *w) const | - | ||||||||||||||||||||||||
| 2923 | { | - | ||||||||||||||||||||||||
| 2924 | RECURSION_GUARD(baseStyle()->drawComplexControl(cc, opt, p, w); return) | - | ||||||||||||||||||||||||
| 2925 | - | |||||||||||||||||||||||||
| 2926 | QRenderRule rule = renderRule(w, opt); | - | ||||||||||||||||||||||||
| 2927 | - | |||||||||||||||||||||||||
| 2928 | switch (cc) { | - | ||||||||||||||||||||||||
| 2929 | case CC_ComboBox: | - | ||||||||||||||||||||||||
| 2930 | if (const QStyleOptionComboBox *cmb = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) { | - | ||||||||||||||||||||||||
| 2931 | QStyleOptionComboBox cmbOpt(*cmb); | - | ||||||||||||||||||||||||
| 2932 | cmbOpt.rect = rule.borderRect(opt->rect); | - | ||||||||||||||||||||||||
| 2933 | if (rule.hasNativeBorder()) { | - | ||||||||||||||||||||||||
| 2934 | rule.drawBackgroundImage(p, cmbOpt.rect); | - | ||||||||||||||||||||||||
| 2935 | rule.configurePalette(&cmbOpt.palette, QPalette::ButtonText, QPalette::Button); | - | ||||||||||||||||||||||||
| 2936 | bool customDropDown = (opt->subControls & QStyle::SC_ComboBoxArrow) | - | ||||||||||||||||||||||||
| 2937 | && (hasStyleRule(w, PseudoElement_ComboBoxDropDown) || hasStyleRule(w, PseudoElement_ComboBoxArrow)); | - | ||||||||||||||||||||||||
| 2938 | if (customDropDown) | - | ||||||||||||||||||||||||
| 2939 | cmbOpt.subControls &= ~QStyle::SC_ComboBoxArrow; | - | ||||||||||||||||||||||||
| 2940 | if (rule.baseStyleCanDraw()) { | - | ||||||||||||||||||||||||
| 2941 | baseStyle()->drawComplexControl(cc, &cmbOpt, p, w); | - | ||||||||||||||||||||||||
| 2942 | } else { | - | ||||||||||||||||||||||||
| 2943 | QWindowsStyle::drawComplexControl(cc, &cmbOpt, p, w); | - | ||||||||||||||||||||||||
| 2944 | } | - | ||||||||||||||||||||||||
| 2945 | if (!customDropDown) | - | ||||||||||||||||||||||||
| 2946 | return; | - | ||||||||||||||||||||||||
| 2947 | } else { | - | ||||||||||||||||||||||||
| 2948 | rule.drawRule(p, opt->rect); | - | ||||||||||||||||||||||||
| 2949 | } | - | ||||||||||||||||||||||||
| 2950 | - | |||||||||||||||||||||||||
| 2951 | if (opt->subControls & QStyle::SC_ComboBoxArrow) { | - | ||||||||||||||||||||||||
| 2952 | QRenderRule subRule = renderRule(w, opt, PseudoElement_ComboBoxDropDown); | - | ||||||||||||||||||||||||
| 2953 | if (subRule.hasDrawable()) { | - | ||||||||||||||||||||||||
| 2954 | QRect r = subControlRect(CC_ComboBox, opt, SC_ComboBoxArrow, w); | - | ||||||||||||||||||||||||
| 2955 | subRule.drawRule(p, r); | - | ||||||||||||||||||||||||
| 2956 | QRenderRule subRule2 = renderRule(w, opt, PseudoElement_ComboBoxArrow); | - | ||||||||||||||||||||||||
| 2957 | r = positionRect(w, subRule, subRule2, PseudoElement_ComboBoxArrow, r, opt->direction); | - | ||||||||||||||||||||||||
| 2958 | subRule2.drawRule(p, r); | - | ||||||||||||||||||||||||
| 2959 | } else { | - | ||||||||||||||||||||||||
| 2960 | cmbOpt.subControls = QStyle::SC_ComboBoxArrow; | - | ||||||||||||||||||||||||
| 2961 | QWindowsStyle::drawComplexControl(cc, &cmbOpt, p, w); | - | ||||||||||||||||||||||||
| 2962 | } | - | ||||||||||||||||||||||||
| 2963 | } | - | ||||||||||||||||||||||||
| 2964 | - | |||||||||||||||||||||||||
| 2965 | return; | - | ||||||||||||||||||||||||
| 2966 | } | - | ||||||||||||||||||||||||
| 2967 | break; | - | ||||||||||||||||||||||||
| 2968 | - | |||||||||||||||||||||||||
| 2969 | #ifndef QT_NO_SPINBOX | - | ||||||||||||||||||||||||
| 2970 | case CC_SpinBox: | - | ||||||||||||||||||||||||
| 2971 | if (const QStyleOptionSpinBox *spin = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) { | - | ||||||||||||||||||||||||
| 2972 | QStyleOptionSpinBox spinOpt(*spin); | - | ||||||||||||||||||||||||
| 2973 | rule.configurePalette(&spinOpt.palette, QPalette::ButtonText, QPalette::Button); | - | ||||||||||||||||||||||||
| 2974 | rule.configurePalette(&spinOpt.palette, QPalette::Text, QPalette::Base); | - | ||||||||||||||||||||||||
| 2975 | spinOpt.rect = rule.borderRect(opt->rect); | - | ||||||||||||||||||||||||
| 2976 | bool customUp = true, customDown = true; | - | ||||||||||||||||||||||||
| 2977 | QRenderRule upRule = renderRule(w, opt, PseudoElement_SpinBoxUpButton); | - | ||||||||||||||||||||||||
| 2978 | QRenderRule downRule = renderRule(w, opt, PseudoElement_SpinBoxDownButton); | - | ||||||||||||||||||||||||
| 2979 | bool upRuleMatch = upRule.hasGeometry() || upRule.hasPosition(); | - | ||||||||||||||||||||||||
| 2980 | bool downRuleMatch = downRule.hasGeometry() || downRule.hasPosition(); | - | ||||||||||||||||||||||||
| 2981 | if (rule.hasNativeBorder() && !upRuleMatch && !downRuleMatch) { | - | ||||||||||||||||||||||||
| 2982 | rule.drawBackgroundImage(p, spinOpt.rect); | - | ||||||||||||||||||||||||
| 2983 | customUp = (opt->subControls & QStyle::SC_SpinBoxUp) | - | ||||||||||||||||||||||||
| 2984 | && (hasStyleRule(w, PseudoElement_SpinBoxUpButton) || hasStyleRule(w, PseudoElement_UpArrow)); | - | ||||||||||||||||||||||||
| 2985 | if (customUp) | - | ||||||||||||||||||||||||
| 2986 | spinOpt.subControls &= ~QStyle::SC_SpinBoxUp; | - | ||||||||||||||||||||||||
| 2987 | customDown = (opt->subControls & QStyle::SC_SpinBoxDown) | - | ||||||||||||||||||||||||
| 2988 | && (hasStyleRule(w, PseudoElement_SpinBoxDownButton) || hasStyleRule(w, PseudoElement_DownArrow)); | - | ||||||||||||||||||||||||
| 2989 | if (customDown) | - | ||||||||||||||||||||||||
| 2990 | spinOpt.subControls &= ~QStyle::SC_SpinBoxDown; | - | ||||||||||||||||||||||||
| 2991 | if (rule.baseStyleCanDraw()) { | - | ||||||||||||||||||||||||
| 2992 | baseStyle()->drawComplexControl(cc, &spinOpt, p, w); | - | ||||||||||||||||||||||||
| 2993 | } else { | - | ||||||||||||||||||||||||
| 2994 | QWindowsStyle::drawComplexControl(cc, &spinOpt, p, w); | - | ||||||||||||||||||||||||
| 2995 | } | - | ||||||||||||||||||||||||
| 2996 | if (!customUp && !customDown) | - | ||||||||||||||||||||||||
| 2997 | return; | - | ||||||||||||||||||||||||
| 2998 | } else { | - | ||||||||||||||||||||||||
| 2999 | rule.drawRule(p, opt->rect); | - | ||||||||||||||||||||||||
| 3000 | } | - | ||||||||||||||||||||||||
| 3001 | - | |||||||||||||||||||||||||
| 3002 | if ((opt->subControls & QStyle::SC_SpinBoxUp) && customUp) { | - | ||||||||||||||||||||||||
| 3003 | QRenderRule subRule = renderRule(w, opt, PseudoElement_SpinBoxUpButton); | - | ||||||||||||||||||||||||
| 3004 | if (subRule.hasDrawable()) { | - | ||||||||||||||||||||||||
| 3005 | QRect r = subControlRect(CC_SpinBox, opt, SC_SpinBoxUp, w); | - | ||||||||||||||||||||||||
| 3006 | subRule.drawRule(p, r); | - | ||||||||||||||||||||||||
| 3007 | QRenderRule subRule2 = renderRule(w, opt, PseudoElement_SpinBoxUpArrow); | - | ||||||||||||||||||||||||
| 3008 | r = positionRect(w, subRule, subRule2, PseudoElement_SpinBoxUpArrow, r, opt->direction); | - | ||||||||||||||||||||||||
| 3009 | subRule2.drawRule(p, r); | - | ||||||||||||||||||||||||
| 3010 | } else { | - | ||||||||||||||||||||||||
| 3011 | spinOpt.subControls = QStyle::SC_SpinBoxUp; | - | ||||||||||||||||||||||||
| 3012 | QWindowsStyle::drawComplexControl(cc, &spinOpt, p, w); | - | ||||||||||||||||||||||||
| 3013 | } | - | ||||||||||||||||||||||||
| 3014 | } | - | ||||||||||||||||||||||||
| 3015 | - | |||||||||||||||||||||||||
| 3016 | if ((opt->subControls & QStyle::SC_SpinBoxDown) && customDown) { | - | ||||||||||||||||||||||||
| 3017 | QRenderRule subRule = renderRule(w, opt, PseudoElement_SpinBoxDownButton); | - | ||||||||||||||||||||||||
| 3018 | if (subRule.hasDrawable()) { | - | ||||||||||||||||||||||||
| 3019 | QRect r = subControlRect(CC_SpinBox, opt, SC_SpinBoxDown, w); | - | ||||||||||||||||||||||||
| 3020 | subRule.drawRule(p, r); | - | ||||||||||||||||||||||||
| 3021 | QRenderRule subRule2 = renderRule(w, opt, PseudoElement_SpinBoxDownArrow); | - | ||||||||||||||||||||||||
| 3022 | r = positionRect(w, subRule, subRule2, PseudoElement_SpinBoxDownArrow, r, opt->direction); | - | ||||||||||||||||||||||||
| 3023 | subRule2.drawRule(p, r); | - | ||||||||||||||||||||||||
| 3024 | } else { | - | ||||||||||||||||||||||||
| 3025 | spinOpt.subControls = QStyle::SC_SpinBoxDown; | - | ||||||||||||||||||||||||
| 3026 | QWindowsStyle::drawComplexControl(cc, &spinOpt, p, w); | - | ||||||||||||||||||||||||
| 3027 | } | - | ||||||||||||||||||||||||
| 3028 | } | - | ||||||||||||||||||||||||
| 3029 | return; | - | ||||||||||||||||||||||||
| 3030 | } | - | ||||||||||||||||||||||||
| 3031 | break; | - | ||||||||||||||||||||||||
| 3032 | #endif // QT_NO_SPINBOX | - | ||||||||||||||||||||||||
| 3033 | - | |||||||||||||||||||||||||
| 3034 | case CC_GroupBox: | - | ||||||||||||||||||||||||
| 3035 | if (const QStyleOptionGroupBox *gb = qstyleoption_cast<const QStyleOptionGroupBox *>(opt)) { | - | ||||||||||||||||||||||||
| 3036 | - | |||||||||||||||||||||||||
| 3037 | QRect labelRect, checkBoxRect, titleRect, frameRect; | - | ||||||||||||||||||||||||
| 3038 | bool hasTitle = (gb->subControls & QStyle::SC_GroupBoxCheckBox) || !gb->text.isEmpty(); | - | ||||||||||||||||||||||||
| 3039 | - | |||||||||||||||||||||||||
| 3040 | if (!rule.hasDrawable() && (!hasTitle || !hasStyleRule(w, PseudoElement_GroupBoxTitle)) | - | ||||||||||||||||||||||||
| 3041 | && !hasStyleRule(w, PseudoElement_Indicator) && !rule.hasBox() && !rule.hasFont && !rule.hasPalette()) { | - | ||||||||||||||||||||||||
| 3042 | // let the native style draw the combobox if there is no style for it. | - | ||||||||||||||||||||||||
| 3043 | break; | - | ||||||||||||||||||||||||
| 3044 | } | - | ||||||||||||||||||||||||
| 3045 | rule.drawBackground(p, opt->rect); | - | ||||||||||||||||||||||||
| 3046 | - | |||||||||||||||||||||||||
| 3047 | QRenderRule titleRule = renderRule(w, opt, PseudoElement_GroupBoxTitle); | - | ||||||||||||||||||||||||
| 3048 | bool clipSet = false; | - | ||||||||||||||||||||||||
| 3049 | - | |||||||||||||||||||||||||
| 3050 | if (hasTitle) { | - | ||||||||||||||||||||||||
| 3051 | labelRect = subControlRect(CC_GroupBox, opt, SC_GroupBoxLabel, w); | - | ||||||||||||||||||||||||
| 3052 | //Some native style (such as mac) may return a too small rectangle (because they use smaller fonts), so we may need to expand it a little bit. | - | ||||||||||||||||||||||||
| 3053 | labelRect.setSize(labelRect.size().expandedTo(ParentStyle::subControlRect(CC_GroupBox, opt, SC_GroupBoxLabel, w).size())); | - | ||||||||||||||||||||||||
| 3054 | if (gb->subControls & QStyle::SC_GroupBoxCheckBox) { | - | ||||||||||||||||||||||||
| 3055 | checkBoxRect = subControlRect(CC_GroupBox, opt, SC_GroupBoxCheckBox, w); | - | ||||||||||||||||||||||||
| 3056 | titleRect = titleRule.boxRect(checkBoxRect.united(labelRect)); | - | ||||||||||||||||||||||||
| 3057 | } else { | - | ||||||||||||||||||||||||
| 3058 | titleRect = titleRule.boxRect(labelRect); | - | ||||||||||||||||||||||||
| 3059 | } | - | ||||||||||||||||||||||||
| 3060 | if (!titleRule.hasBackground() || !titleRule.background()->isTransparent()) { | - | ||||||||||||||||||||||||
| 3061 | clipSet = true; | - | ||||||||||||||||||||||||
| 3062 | p->save(); | - | ||||||||||||||||||||||||
| 3063 | p->setClipRegion(QRegion(opt->rect) - titleRect); | - | ||||||||||||||||||||||||
| 3064 | } | - | ||||||||||||||||||||||||
| 3065 | } | - | ||||||||||||||||||||||||
| 3066 | - | |||||||||||||||||||||||||
| 3067 | frameRect = subControlRect(CC_GroupBox, opt, SC_GroupBoxFrame, w); | - | ||||||||||||||||||||||||
| 3068 | QStyleOptionFrame frame; | - | ||||||||||||||||||||||||
| 3069 | frame.QStyleOption::operator=(*gb); | - | ||||||||||||||||||||||||
| 3070 | frame.features = gb->features; | - | ||||||||||||||||||||||||
| 3071 | frame.lineWidth = gb->lineWidth; | - | ||||||||||||||||||||||||
| 3072 | frame.midLineWidth = gb->midLineWidth; | - | ||||||||||||||||||||||||
| 3073 | frame.rect = frameRect; | - | ||||||||||||||||||||||||
| 3074 | drawPrimitive(PE_FrameGroupBox, &frame, p, w); | - | ||||||||||||||||||||||||
| 3075 | - | |||||||||||||||||||||||||
| 3076 | if (clipSet) | - | ||||||||||||||||||||||||
| 3077 | p->restore(); | - | ||||||||||||||||||||||||
| 3078 | - | |||||||||||||||||||||||||
| 3079 | // draw background and frame of the title | - | ||||||||||||||||||||||||
| 3080 | if (hasTitle) | - | ||||||||||||||||||||||||
| 3081 | titleRule.drawRule(p, titleRect); | - | ||||||||||||||||||||||||
| 3082 | - | |||||||||||||||||||||||||
| 3083 | // draw the indicator | - | ||||||||||||||||||||||||
| 3084 | if (gb->subControls & QStyle::SC_GroupBoxCheckBox) { | - | ||||||||||||||||||||||||
| 3085 | QStyleOptionButton box; | - | ||||||||||||||||||||||||
| 3086 | box.QStyleOption::operator=(*gb); | - | ||||||||||||||||||||||||
| 3087 | box.rect = checkBoxRect; | - | ||||||||||||||||||||||||
| 3088 | drawPrimitive(PE_IndicatorCheckBox, &box, p, w); | - | ||||||||||||||||||||||||
| 3089 | } | - | ||||||||||||||||||||||||
| 3090 | - | |||||||||||||||||||||||||
| 3091 | // draw the text | - | ||||||||||||||||||||||||
| 3092 | if (!gb->text.isEmpty()) { | - | ||||||||||||||||||||||||
| 3093 | int alignment = int(Qt::AlignCenter | Qt::TextShowMnemonic); | - | ||||||||||||||||||||||||
| 3094 | if (!styleHint(QStyle::SH_UnderlineShortcut, opt, w)) { | - | ||||||||||||||||||||||||
| 3095 | alignment |= Qt::TextHideMnemonic; | - | ||||||||||||||||||||||||
| 3096 | } | - | ||||||||||||||||||||||||
| 3097 | - | |||||||||||||||||||||||||
| 3098 | QPalette pal = gb->palette; | - | ||||||||||||||||||||||||
| 3099 | if (gb->textColor.isValid()) | - | ||||||||||||||||||||||||
| 3100 | pal.setColor(QPalette::WindowText, gb->textColor); | - | ||||||||||||||||||||||||
| 3101 | titleRule.configurePalette(&pal, QPalette::WindowText, QPalette::Window); | - | ||||||||||||||||||||||||
| 3102 | drawItemText(p, labelRect, alignment, pal, gb->state & State_Enabled, | - | ||||||||||||||||||||||||
| 3103 | gb->text, QPalette::WindowText); | - | ||||||||||||||||||||||||
| 3104 | - | |||||||||||||||||||||||||
| 3105 | if (gb->state & State_HasFocus) { | - | ||||||||||||||||||||||||
| 3106 | QStyleOptionFocusRect fropt; | - | ||||||||||||||||||||||||
| 3107 | fropt.QStyleOption::operator=(*gb); | - | ||||||||||||||||||||||||
| 3108 | fropt.rect = labelRect; | - | ||||||||||||||||||||||||
| 3109 | drawPrimitive(PE_FrameFocusRect, &fropt, p, w); | - | ||||||||||||||||||||||||
| 3110 | } | - | ||||||||||||||||||||||||
| 3111 | } | - | ||||||||||||||||||||||||
| 3112 | - | |||||||||||||||||||||||||
| 3113 | return; | - | ||||||||||||||||||||||||
| 3114 | } | - | ||||||||||||||||||||||||
| 3115 | break; | - | ||||||||||||||||||||||||
| 3116 | - | |||||||||||||||||||||||||
| 3117 | case CC_ToolButton: | - | ||||||||||||||||||||||||
| 3118 | if (const QStyleOptionToolButton *tool = qstyleoption_cast<const QStyleOptionToolButton *>(opt)) { | - | ||||||||||||||||||||||||
| 3119 | QStyleOptionToolButton toolOpt(*tool); | - | ||||||||||||||||||||||||
| 3120 | rule.configurePalette(&toolOpt.palette, QPalette::ButtonText, QPalette::Button); | - | ||||||||||||||||||||||||
| 3121 | toolOpt.font = rule.font.resolve(toolOpt.font); | - | ||||||||||||||||||||||||
| 3122 | toolOpt.rect = rule.borderRect(opt->rect); | - | ||||||||||||||||||||||||
| 3123 | bool customArrow = (tool->features & (QStyleOptionToolButton::HasMenu | QStyleOptionToolButton::MenuButtonPopup)); | - | ||||||||||||||||||||||||
| 3124 | bool customDropDown = tool->features & QStyleOptionToolButton::MenuButtonPopup; | - | ||||||||||||||||||||||||
| 3125 | if (rule.hasNativeBorder()) { | - | ||||||||||||||||||||||||
| 3126 | if (tool->subControls & SC_ToolButton) { | - | ||||||||||||||||||||||||
| 3127 | //in some case (eg. the button is "auto raised") the style doesn't draw the background | - | ||||||||||||||||||||||||
| 3128 | //so we need to draw the background. | - | ||||||||||||||||||||||||
| 3129 | // use the same condition as in QCommonStyle | - | ||||||||||||||||||||||||
| 3130 | State bflags = tool->state & ~State_Sunken; | - | ||||||||||||||||||||||||
| 3131 | if (bflags & State_AutoRaise && (!(bflags & State_MouseOver) || !(bflags & State_Enabled))) | - | ||||||||||||||||||||||||
| 3132 | bflags &= ~State_Raised; | - | ||||||||||||||||||||||||
| 3133 | if (tool->state & State_Sunken && tool->activeSubControls & SC_ToolButton) | - | ||||||||||||||||||||||||
| 3134 | bflags |= State_Sunken; | - | ||||||||||||||||||||||||
| 3135 | if (!(bflags & (State_Sunken | State_On | State_Raised))) | - | ||||||||||||||||||||||||
| 3136 | rule.drawBackground(p, toolOpt.rect); | - | ||||||||||||||||||||||||
| 3137 | } | - | ||||||||||||||||||||||||
| 3138 | customArrow = customArrow && hasStyleRule(w, PseudoElement_ToolButtonDownArrow); | - | ||||||||||||||||||||||||
| 3139 | if (customArrow) | - | ||||||||||||||||||||||||
| 3140 | toolOpt.features &= ~QStyleOptionToolButton::HasMenu; | - | ||||||||||||||||||||||||
| 3141 | customDropDown = customDropDown && hasStyleRule(w, PseudoElement_ToolButtonMenu); | - | ||||||||||||||||||||||||
| 3142 | if (customDropDown) | - | ||||||||||||||||||||||||
| 3143 | toolOpt.subControls &= ~QStyle::SC_ToolButtonMenu; | - | ||||||||||||||||||||||||
| 3144 | - | |||||||||||||||||||||||||
| 3145 | if (rule.baseStyleCanDraw() && !(tool->features & QStyleOptionToolButton::Arrow)) { | - | ||||||||||||||||||||||||
| 3146 | baseStyle()->drawComplexControl(cc, &toolOpt, p, w); | - | ||||||||||||||||||||||||
| 3147 | } else { | - | ||||||||||||||||||||||||
| 3148 | QWindowsStyle::drawComplexControl(cc, &toolOpt, p, w); | - | ||||||||||||||||||||||||
| 3149 | } | - | ||||||||||||||||||||||||
| 3150 | - | |||||||||||||||||||||||||
| 3151 | if (!customArrow && !customDropDown) | - | ||||||||||||||||||||||||
| 3152 | return; | - | ||||||||||||||||||||||||
| 3153 | } else { | - | ||||||||||||||||||||||||
| 3154 | rule.drawRule(p, opt->rect); | - | ||||||||||||||||||||||||
| 3155 | toolOpt.rect = rule.contentsRect(opt->rect); | - | ||||||||||||||||||||||||
| 3156 | if (rule.hasFont) | - | ||||||||||||||||||||||||
| 3157 | toolOpt.font = rule.font; | - | ||||||||||||||||||||||||
| 3158 | drawControl(CE_ToolButtonLabel, &toolOpt, p, w); | - | ||||||||||||||||||||||||
| 3159 | } | - | ||||||||||||||||||||||||
| 3160 | - | |||||||||||||||||||||||||
| 3161 | QRenderRule subRule = renderRule(w, opt, PseudoElement_ToolButtonMenu); | - | ||||||||||||||||||||||||
| 3162 | QRect r = subControlRect(CC_ToolButton, opt, QStyle::SC_ToolButtonMenu, w); | - | ||||||||||||||||||||||||
| 3163 | if (customDropDown) { | - | ||||||||||||||||||||||||
| 3164 | if (opt->subControls & QStyle::SC_ToolButtonMenu) { | - | ||||||||||||||||||||||||
| 3165 | if (subRule.hasDrawable()) { | - | ||||||||||||||||||||||||
| 3166 | subRule.drawRule(p, r); | - | ||||||||||||||||||||||||
| 3167 | } else { | - | ||||||||||||||||||||||||
| 3168 | toolOpt.rect = r; | - | ||||||||||||||||||||||||
| 3169 | baseStyle()->drawPrimitive(PE_IndicatorButtonDropDown, &toolOpt, p, w); | - | ||||||||||||||||||||||||
| 3170 | } | - | ||||||||||||||||||||||||
| 3171 | } | - | ||||||||||||||||||||||||
| 3172 | } | - | ||||||||||||||||||||||||
| 3173 | - | |||||||||||||||||||||||||
| 3174 | if (customArrow) { | - | ||||||||||||||||||||||||
| 3175 | QRenderRule subRule2 = customDropDown ? renderRule(w, opt, PseudoElement_ToolButtonMenuArrow) | - | ||||||||||||||||||||||||
| 3176 | : renderRule(w, opt, PseudoElement_ToolButtonDownArrow); | - | ||||||||||||||||||||||||
| 3177 | QRect r2 = customDropDown | - | ||||||||||||||||||||||||
| 3178 | ? positionRect(w, subRule, subRule2, PseudoElement_ToolButtonMenuArrow, r, opt->direction) | - | ||||||||||||||||||||||||
| 3179 | : positionRect(w, rule, subRule2, PseudoElement_ToolButtonDownArrow, opt->rect, opt->direction); | - | ||||||||||||||||||||||||
| 3180 | if (subRule2.hasDrawable()) { | - | ||||||||||||||||||||||||
| 3181 | subRule2.drawRule(p, r2); | - | ||||||||||||||||||||||||
| 3182 | } else { | - | ||||||||||||||||||||||||
| 3183 | toolOpt.rect = r2; | - | ||||||||||||||||||||||||
| 3184 | baseStyle()->drawPrimitive(QStyle::PE_IndicatorArrowDown, &toolOpt, p, w); | - | ||||||||||||||||||||||||
| 3185 | } | - | ||||||||||||||||||||||||
| 3186 | } | - | ||||||||||||||||||||||||
| 3187 | - | |||||||||||||||||||||||||
| 3188 | return; | - | ||||||||||||||||||||||||
| 3189 | } | - | ||||||||||||||||||||||||
| 3190 | break; | - | ||||||||||||||||||||||||
| 3191 | - | |||||||||||||||||||||||||
| 3192 | #ifndef QT_NO_SCROLLBAR | - | ||||||||||||||||||||||||
| 3193 | case CC_ScrollBar: | - | ||||||||||||||||||||||||
| 3194 | if (const QStyleOptionSlider *sb = qstyleoption_cast<const QStyleOptionSlider *>(opt)) { | - | ||||||||||||||||||||||||
| 3195 | QStyleOptionSlider sbOpt(*sb); | - | ||||||||||||||||||||||||
| 3196 | if (!rule.hasDrawable()) { | - | ||||||||||||||||||||||||
| 3197 | sbOpt.rect = rule.borderRect(opt->rect); | - | ||||||||||||||||||||||||
| 3198 | rule.drawBackgroundImage(p, opt->rect); | - | ||||||||||||||||||||||||
| 3199 | baseStyle()->drawComplexControl(cc, &sbOpt, p, w); | - | ||||||||||||||||||||||||
| 3200 | } else { | - | ||||||||||||||||||||||||
| 3201 | rule.drawRule(p, opt->rect); | - | ||||||||||||||||||||||||
| 3202 | QWindowsStyle::drawComplexControl(cc, opt, p, w); | - | ||||||||||||||||||||||||
| 3203 | } | - | ||||||||||||||||||||||||
| 3204 | return; | - | ||||||||||||||||||||||||
| 3205 | } | - | ||||||||||||||||||||||||
| 3206 | break; | - | ||||||||||||||||||||||||
| 3207 | #endif // QT_NO_SCROLLBAR | - | ||||||||||||||||||||||||
| 3208 | - | |||||||||||||||||||||||||
| 3209 | #ifndef QT_NO_SLIDER | - | ||||||||||||||||||||||||
| 3210 | case CC_Slider: | - | ||||||||||||||||||||||||
| 3211 | if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) { | - | ||||||||||||||||||||||||
| 3212 | rule.drawRule(p, opt->rect); | - | ||||||||||||||||||||||||
| 3213 | - | |||||||||||||||||||||||||
| 3214 | QRenderRule grooveSubRule = renderRule(w, opt, PseudoElement_SliderGroove); | - | ||||||||||||||||||||||||
| 3215 | QRenderRule handleSubRule = renderRule(w, opt, PseudoElement_SliderHandle); | - | ||||||||||||||||||||||||
| 3216 | if (!grooveSubRule.hasDrawable()) { | - | ||||||||||||||||||||||||
| 3217 | QStyleOptionSlider slOpt(*slider); | - | ||||||||||||||||||||||||
| 3218 | bool handleHasRule = handleSubRule.hasDrawable(); | - | ||||||||||||||||||||||||
| 3219 | // If the style specifies a different handler rule, draw the groove without the handler. | - | ||||||||||||||||||||||||
| 3220 | if (handleHasRule) | - | ||||||||||||||||||||||||
| 3221 | slOpt.subControls &= ~SC_SliderHandle; | - | ||||||||||||||||||||||||
| 3222 | baseStyle()->drawComplexControl(cc, &slOpt, p, w); | - | ||||||||||||||||||||||||
| 3223 | if (!handleHasRule) | - | ||||||||||||||||||||||||
| 3224 | return; | - | ||||||||||||||||||||||||
| 3225 | } | - | ||||||||||||||||||||||||
| 3226 | - | |||||||||||||||||||||||||
| 3227 | QRect gr = subControlRect(cc, opt, SC_SliderGroove, w); | - | ||||||||||||||||||||||||
| 3228 | if (slider->subControls & SC_SliderGroove) { | - | ||||||||||||||||||||||||
| 3229 | grooveSubRule.drawRule(p, gr); | - | ||||||||||||||||||||||||
| 3230 | } | - | ||||||||||||||||||||||||
| 3231 | - | |||||||||||||||||||||||||
| 3232 | if (slider->subControls & SC_SliderHandle) { | - | ||||||||||||||||||||||||
| 3233 | QRect hr = subControlRect(cc, opt, SC_SliderHandle, w); | - | ||||||||||||||||||||||||
| 3234 | - | |||||||||||||||||||||||||
| 3235 | QRenderRule subRule1 = renderRule(w, opt, PseudoElement_SliderSubPage); | - | ||||||||||||||||||||||||
| 3236 | if (subRule1.hasDrawable()) { | - | ||||||||||||||||||||||||
| 3237 | QRect r(gr.topLeft(), | - | ||||||||||||||||||||||||
| 3238 | slider->orientation == Qt::Horizontal | - | ||||||||||||||||||||||||
| 3239 | ? QPoint(hr.x()+hr.width()/2, gr.y()+gr.height() - 1) | - | ||||||||||||||||||||||||
| 3240 | : QPoint(gr.x()+gr.width() - 1, hr.y()+hr.height()/2)); | - | ||||||||||||||||||||||||
| 3241 | subRule1.drawRule(p, r); | - | ||||||||||||||||||||||||
| 3242 | } | - | ||||||||||||||||||||||||
| 3243 | - | |||||||||||||||||||||||||
| 3244 | QRenderRule subRule2 = renderRule(w, opt, PseudoElement_SliderAddPage); | - | ||||||||||||||||||||||||
| 3245 | if (subRule2.hasDrawable()) { | - | ||||||||||||||||||||||||
| 3246 | QRect r(slider->orientation == Qt::Horizontal | - | ||||||||||||||||||||||||
| 3247 | ? QPoint(hr.x()+hr.width()/2+1, gr.y()) | - | ||||||||||||||||||||||||
| 3248 | : QPoint(gr.x(), hr.y()+hr.height()/2+1), | - | ||||||||||||||||||||||||
| 3249 | gr.bottomRight()); | - | ||||||||||||||||||||||||
| 3250 | subRule2.drawRule(p, r); | - | ||||||||||||||||||||||||
| 3251 | } | - | ||||||||||||||||||||||||
| 3252 | - | |||||||||||||||||||||||||
| 3253 | handleSubRule.drawRule(p, handleSubRule.boxRect(hr, Margin)); | - | ||||||||||||||||||||||||
| 3254 | } | - | ||||||||||||||||||||||||
| 3255 | - | |||||||||||||||||||||||||
| 3256 | if (slider->subControls & SC_SliderTickmarks) { | - | ||||||||||||||||||||||||
| 3257 | // TODO... | - | ||||||||||||||||||||||||
| 3258 | } | - | ||||||||||||||||||||||||
| 3259 | - | |||||||||||||||||||||||||
| 3260 | return; | - | ||||||||||||||||||||||||
| 3261 | } | - | ||||||||||||||||||||||||
| 3262 | break; | - | ||||||||||||||||||||||||
| 3263 | #endif // QT_NO_SLIDER | - | ||||||||||||||||||||||||
| 3264 | - | |||||||||||||||||||||||||
| 3265 | case CC_MdiControls: | - | ||||||||||||||||||||||||
| 3266 | if (hasStyleRule(w, PseudoElement_MdiCloseButton) | - | ||||||||||||||||||||||||
| 3267 | || hasStyleRule(w, PseudoElement_MdiNormalButton) | - | ||||||||||||||||||||||||
| 3268 | || hasStyleRule(w, PseudoElement_MdiMinButton)) { | - | ||||||||||||||||||||||||
| 3269 | QList<QVariant> layout = rule.styleHint(QLatin1String("button-layout")).toList(); | - | ||||||||||||||||||||||||
| 3270 | if (layout.isEmpty()) | - | ||||||||||||||||||||||||
| 3271 | layout = subControlLayout(QLatin1String("mNX")); | - | ||||||||||||||||||||||||
| 3272 | - | |||||||||||||||||||||||||
| 3273 | QStyleOptionComplex optCopy(*opt); | - | ||||||||||||||||||||||||
| 3274 | optCopy.subControls = 0; | - | ||||||||||||||||||||||||
| 3275 | for (int i = 0; i < layout.count(); i++) { | - | ||||||||||||||||||||||||
| 3276 | int layoutButton = layout[i].toInt(); | - | ||||||||||||||||||||||||
| 3277 | if (layoutButton < PseudoElement_MdiCloseButton | - | ||||||||||||||||||||||||
| 3278 | || layoutButton > PseudoElement_MdiNormalButton) | - | ||||||||||||||||||||||||
| 3279 | continue; | - | ||||||||||||||||||||||||
| 3280 | QStyle::SubControl control = knownPseudoElements[layoutButton].subControl; | - | ||||||||||||||||||||||||
| 3281 | if (!(opt->subControls & control)) | - | ||||||||||||||||||||||||
| 3282 | continue; | - | ||||||||||||||||||||||||
| 3283 | QRenderRule subRule = renderRule(w, opt, layoutButton); | - | ||||||||||||||||||||||||
| 3284 | if (subRule.hasDrawable()) { | - | ||||||||||||||||||||||||
| 3285 | QRect rect = subRule.boxRect(subControlRect(CC_MdiControls, opt, control, w), Margin); | - | ||||||||||||||||||||||||
| 3286 | subRule.drawRule(p, rect); | - | ||||||||||||||||||||||||
| 3287 | QIcon icon = standardIcon(subControlIcon(layoutButton), opt); | - | ||||||||||||||||||||||||
| 3288 | icon.paint(p, subRule.contentsRect(rect), Qt::AlignCenter); | - | ||||||||||||||||||||||||
| 3289 | } else { | - | ||||||||||||||||||||||||
| 3290 | optCopy.subControls |= control; | - | ||||||||||||||||||||||||
| 3291 | } | - | ||||||||||||||||||||||||
| 3292 | } | - | ||||||||||||||||||||||||
| 3293 | - | |||||||||||||||||||||||||
| 3294 | if (optCopy.subControls) | - | ||||||||||||||||||||||||
| 3295 | baseStyle()->drawComplexControl(CC_MdiControls, &optCopy, p, w); | - | ||||||||||||||||||||||||
| 3296 | return; | - | ||||||||||||||||||||||||
| 3297 | } | - | ||||||||||||||||||||||||
| 3298 | break; | - | ||||||||||||||||||||||||
| 3299 | - | |||||||||||||||||||||||||
| 3300 | case CC_TitleBar: | - | ||||||||||||||||||||||||
| 3301 | if (const QStyleOptionTitleBar *tb = qstyleoption_cast<const QStyleOptionTitleBar *>(opt)) { | - | ||||||||||||||||||||||||
| 3302 | QRenderRule subRule = renderRule(w, opt, PseudoElement_TitleBar); | - | ||||||||||||||||||||||||
| 3303 | if (!subRule.hasDrawable() && !subRule.hasBox() && !subRule.hasBorder()) | - | ||||||||||||||||||||||||
| 3304 | break; | - | ||||||||||||||||||||||||
| 3305 | subRule.drawRule(p, opt->rect); | - | ||||||||||||||||||||||||
| 3306 | QHash<QStyle::SubControl, QRect> layout = titleBarLayout(w, tb); | - | ||||||||||||||||||||||||
| 3307 | - | |||||||||||||||||||||||||
| 3308 | QRect ir; | - | ||||||||||||||||||||||||
| 3309 | ir = layout[SC_TitleBarLabel]; | - | ||||||||||||||||||||||||
| 3310 | if (ir.isValid()) { | - | ||||||||||||||||||||||||
| 3311 | if (subRule.hasPalette()) | - | ||||||||||||||||||||||||
| 3312 | p->setPen(subRule.palette()->foreground.color()); | - | ||||||||||||||||||||||||
| 3313 | p->fillRect(ir, Qt::white); | - | ||||||||||||||||||||||||
| 3314 | p->drawText(ir.x(), ir.y(), ir.width(), ir.height(), Qt::AlignLeft | Qt::AlignVCenter | Qt::TextSingleLine, tb->text); | - | ||||||||||||||||||||||||
| 3315 | } | - | ||||||||||||||||||||||||
| 3316 | - | |||||||||||||||||||||||||
| 3317 | QPixmap pm; | - | ||||||||||||||||||||||||
| 3318 | - | |||||||||||||||||||||||||
| 3319 | ir = layout[SC_TitleBarSysMenu]; | - | ||||||||||||||||||||||||
| 3320 | if (ir.isValid()) { | - | ||||||||||||||||||||||||
| 3321 | QRenderRule subSubRule = renderRule(w, opt, PseudoElement_TitleBarSysMenu); | - | ||||||||||||||||||||||||
| 3322 | subSubRule.drawRule(p, ir); | - | ||||||||||||||||||||||||
| 3323 | ir = subSubRule.contentsRect(ir); | - | ||||||||||||||||||||||||
| 3324 | if (!tb->icon.isNull()) { | - | ||||||||||||||||||||||||
| 3325 | tb->icon.paint(p, ir); | - | ||||||||||||||||||||||||
| 3326 | } else { | - | ||||||||||||||||||||||||
| 3327 | int iconSize = pixelMetric(PM_SmallIconSize, tb, w); | - | ||||||||||||||||||||||||
| 3328 | pm = standardIcon(SP_TitleBarMenuButton, 0, w).pixmap(iconSize, iconSize); | - | ||||||||||||||||||||||||
| 3329 | drawItemPixmap(p, ir, Qt::AlignCenter, pm); | - | ||||||||||||||||||||||||
| 3330 | } | - | ||||||||||||||||||||||||
| 3331 | } | - | ||||||||||||||||||||||||
| 3332 | - | |||||||||||||||||||||||||
| 3333 | ir = layout[SC_TitleBarCloseButton]; | - | ||||||||||||||||||||||||
| 3334 | if (ir.isValid()) { | - | ||||||||||||||||||||||||
| 3335 | QRenderRule subSubRule = renderRule(w, opt, PseudoElement_TitleBarCloseButton); | - | ||||||||||||||||||||||||
| 3336 | subSubRule.drawRule(p, ir); | - | ||||||||||||||||||||||||
| 3337 | - | |||||||||||||||||||||||||
| 3338 | QSize sz = subSubRule.contentsRect(ir).size(); | - | ||||||||||||||||||||||||
| 3339 | if ((tb->titleBarFlags & Qt::WindowType_Mask) == Qt::Tool) | - | ||||||||||||||||||||||||
| 3340 | pm = standardIcon(SP_DockWidgetCloseButton, 0, w).pixmap(sz); | - | ||||||||||||||||||||||||
| 3341 | else | - | ||||||||||||||||||||||||
| 3342 | pm = standardIcon(SP_TitleBarCloseButton, 0, w).pixmap(sz); | - | ||||||||||||||||||||||||
| 3343 | drawItemPixmap(p, ir, Qt::AlignCenter, pm); | - | ||||||||||||||||||||||||
| 3344 | } | - | ||||||||||||||||||||||||
| 3345 | - | |||||||||||||||||||||||||
| 3346 | int pes[] = { | - | ||||||||||||||||||||||||
| 3347 | PseudoElement_TitleBarMaxButton, | - | ||||||||||||||||||||||||
| 3348 | PseudoElement_TitleBarMinButton, | - | ||||||||||||||||||||||||
| 3349 | PseudoElement_TitleBarNormalButton, | - | ||||||||||||||||||||||||
| 3350 | PseudoElement_TitleBarShadeButton, | - | ||||||||||||||||||||||||
| 3351 | PseudoElement_TitleBarUnshadeButton, | - | ||||||||||||||||||||||||
| 3352 | PseudoElement_TitleBarContextHelpButton | - | ||||||||||||||||||||||||
| 3353 | }; | - | ||||||||||||||||||||||||
| 3354 | - | |||||||||||||||||||||||||
| 3355 | for (unsigned int i = 0; i < sizeof(pes)/sizeof(int); i++) { | - | ||||||||||||||||||||||||
| 3356 | int pe = pes[i]; | - | ||||||||||||||||||||||||
| 3357 | QStyle::SubControl sc = knownPseudoElements[pe].subControl; | - | ||||||||||||||||||||||||
| 3358 | ir = layout[sc]; | - | ||||||||||||||||||||||||
| 3359 | if (!ir.isValid()) | - | ||||||||||||||||||||||||
| 3360 | continue; | - | ||||||||||||||||||||||||
| 3361 | QRenderRule subSubRule = renderRule(w, opt, pe); | - | ||||||||||||||||||||||||
| 3362 | subSubRule.drawRule(p, ir); | - | ||||||||||||||||||||||||
| 3363 | pm = standardIcon(subControlIcon(pe), 0, w).pixmap(subSubRule.contentsRect(ir).size()); | - | ||||||||||||||||||||||||
| 3364 | drawItemPixmap(p, ir, Qt::AlignCenter, pm); | - | ||||||||||||||||||||||||
| 3365 | } | - | ||||||||||||||||||||||||
| 3366 | - | |||||||||||||||||||||||||
| 3367 | return; | - | ||||||||||||||||||||||||
| 3368 | } | - | ||||||||||||||||||||||||
| 3369 | break; | - | ||||||||||||||||||||||||
| 3370 | - | |||||||||||||||||||||||||
| 3371 | - | |||||||||||||||||||||||||
| 3372 | default: | - | ||||||||||||||||||||||||
| 3373 | break; | - | ||||||||||||||||||||||||
| 3374 | } | - | ||||||||||||||||||||||||
| 3375 | - | |||||||||||||||||||||||||
| 3376 | baseStyle()->drawComplexControl(cc, opt, p, w); | - | ||||||||||||||||||||||||
| 3377 | } | - | ||||||||||||||||||||||||
| 3378 | - | |||||||||||||||||||||||||
| 3379 | void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPainter *p, | - | ||||||||||||||||||||||||
| 3380 | const QWidget *w) const | - | ||||||||||||||||||||||||
| 3381 | { | - | ||||||||||||||||||||||||
| 3382 | RECURSION_GUARD(baseStyle()->drawControl(ce, opt, p, w); return) never executed: return;
| 0 | ||||||||||||||||||||||||
| 3383 | - | |||||||||||||||||||||||||
| 3384 | QRenderRule rule = renderRule(w, opt); | - | ||||||||||||||||||||||||
| 3385 | int pe1 = PseudoElement_None, pe2 = PseudoElement_None; | - | ||||||||||||||||||||||||
| 3386 | bool fallback = false; | - | ||||||||||||||||||||||||
| 3387 | - | |||||||||||||||||||||||||
| 3388 | switch (ce) { | - | ||||||||||||||||||||||||
| 3389 | case CE_ToolButtonLabel: never executed: case CE_ToolButtonLabel: | 0 | ||||||||||||||||||||||||
| 3390 | if (const QStyleOptionToolButton *btn = qstyleoption_cast<const QStyleOptionToolButton *>(opt)) {
| 0 | ||||||||||||||||||||||||
| 3391 | if (rule.hasBox() || btn->features & QStyleOptionToolButton::Arrow) {
| 0 | ||||||||||||||||||||||||
| 3392 | QCommonStyle::drawControl(ce, opt, p, w); | - | ||||||||||||||||||||||||
| 3393 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 3394 | QStyleOptionToolButton butOpt(*btn); | - | ||||||||||||||||||||||||
| 3395 | rule.configurePalette(&butOpt.palette, QPalette::ButtonText, QPalette::Button); | - | ||||||||||||||||||||||||
| 3396 | baseStyle()->drawControl(ce, &butOpt, p, w); | - | ||||||||||||||||||||||||
| 3397 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3398 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 3399 | } | - | ||||||||||||||||||||||||
| 3400 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 3401 | - | |||||||||||||||||||||||||
| 3402 | case CE_FocusFrame: never executed: case CE_FocusFrame: | 0 | ||||||||||||||||||||||||
| 3403 | if (!rule.hasNativeBorder()) {
| 0 | ||||||||||||||||||||||||
| 3404 | rule.drawBorder(p, opt->rect); | - | ||||||||||||||||||||||||
| 3405 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 3406 | } | - | ||||||||||||||||||||||||
| 3407 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 3408 | - | |||||||||||||||||||||||||
| 3409 | case CE_PushButton: never executed: case CE_PushButton: | 0 | ||||||||||||||||||||||||
| 3410 | if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
| 0 | ||||||||||||||||||||||||
| 3411 | if (rule.hasDrawable() || rule.hasBox() || rule.hasPosition() || rule.hasPalette() ||
| 0 | ||||||||||||||||||||||||
| 3412 | ((btn->features & QStyleOptionButton::HasMenu) && hasStyleRule(w, PseudoElement_PushButtonMenuIndicator))) {
| 0 | ||||||||||||||||||||||||
| 3413 | ParentStyle::drawControl(ce, opt, p, w); | - | ||||||||||||||||||||||||
| 3414 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 3415 | } | - | ||||||||||||||||||||||||
| 3416 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3417 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 3418 | case CE_PushButtonBevel: never executed: case CE_PushButtonBevel: | 0 | ||||||||||||||||||||||||
| 3419 | if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
| 0 | ||||||||||||||||||||||||
| 3420 | QStyleOptionButton btnOpt(*btn); | - | ||||||||||||||||||||||||
| 3421 | btnOpt.rect = rule.borderRect(opt->rect); | - | ||||||||||||||||||||||||
| 3422 | if (rule.hasNativeBorder()) {
| 0 | ||||||||||||||||||||||||
| 3423 | rule.drawBackgroundImage(p, btnOpt.rect); | - | ||||||||||||||||||||||||
| 3424 | rule.configurePalette(&btnOpt.palette, QPalette::ButtonText, QPalette::Button); | - | ||||||||||||||||||||||||
| 3425 | bool customMenu = (btn->features & QStyleOptionButton::HasMenu
| 0 | ||||||||||||||||||||||||
| 3426 | && hasStyleRule(w, PseudoElement_PushButtonMenuIndicator));
| 0 | ||||||||||||||||||||||||
| 3427 | if (customMenu)
| 0 | ||||||||||||||||||||||||
| 3428 | btnOpt.features &= ~QStyleOptionButton::HasMenu; never executed: btnOpt.features &= ~QStyleOptionButton::HasMenu; | 0 | ||||||||||||||||||||||||
| 3429 | if (rule.baseStyleCanDraw()) {
| 0 | ||||||||||||||||||||||||
| 3430 | baseStyle()->drawControl(ce, &btnOpt, p, w); | - | ||||||||||||||||||||||||
| 3431 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 3432 | QWindowsStyle::drawControl(ce, &btnOpt, p, w); | - | ||||||||||||||||||||||||
| 3433 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3434 | if (!customMenu)
| 0 | ||||||||||||||||||||||||
| 3435 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 3436 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 3437 | rule.drawRule(p, opt->rect); | - | ||||||||||||||||||||||||
| 3438 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3439 | - | |||||||||||||||||||||||||
| 3440 | if (btn->features & QStyleOptionButton::HasMenu) {
| 0 | ||||||||||||||||||||||||
| 3441 | QRenderRule subRule = renderRule(w, opt, PseudoElement_PushButtonMenuIndicator); | - | ||||||||||||||||||||||||
| 3442 | QRect ir = positionRect(w, rule, subRule, PseudoElement_PushButtonMenuIndicator, opt->rect, opt->direction); | - | ||||||||||||||||||||||||
| 3443 | if (subRule.hasDrawable()) {
| 0 | ||||||||||||||||||||||||
| 3444 | subRule.drawRule(p, ir); | - | ||||||||||||||||||||||||
| 3445 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 3446 | btnOpt.rect = ir; | - | ||||||||||||||||||||||||
| 3447 | baseStyle()->drawPrimitive(PE_IndicatorArrowDown, &btnOpt, p, w); | - | ||||||||||||||||||||||||
| 3448 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3449 | } | - | ||||||||||||||||||||||||
| 3450 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3451 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 3452 | - | |||||||||||||||||||||||||
| 3453 | case CE_PushButtonLabel: never executed: case CE_PushButtonLabel: | 0 | ||||||||||||||||||||||||
| 3454 | if (const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
| 0 | ||||||||||||||||||||||||
| 3455 | QStyleOptionButton butOpt(*button); | - | ||||||||||||||||||||||||
| 3456 | rule.configurePalette(&butOpt.palette, QPalette::ButtonText, QPalette::Button); | - | ||||||||||||||||||||||||
| 3457 | - | |||||||||||||||||||||||||
| 3458 | const QFont oldFont = p->font(); | - | ||||||||||||||||||||||||
| 3459 | if (rule.hasFont)
| 0 | ||||||||||||||||||||||||
| 3460 | p->setFont(rule.font); never executed: p->setFont(rule.font); | 0 | ||||||||||||||||||||||||
| 3461 | - | |||||||||||||||||||||||||
| 3462 | if (rule.hasPosition() && rule.position()->textAlignment != 0) {
| 0 | ||||||||||||||||||||||||
| 3463 | Qt::Alignment textAlignment = rule.position()->textAlignment; | - | ||||||||||||||||||||||||
| 3464 | QRect textRect = button->rect; | - | ||||||||||||||||||||||||
| 3465 | uint tf = Qt::TextShowMnemonic; | - | ||||||||||||||||||||||||
| 3466 | const uint verticalAlignMask = Qt::AlignVCenter | Qt::AlignTop | Qt::AlignLeft; | - | ||||||||||||||||||||||||
| 3467 | tf |= (textAlignment & verticalAlignMask) ? (textAlignment & verticalAlignMask) : Qt::AlignVCenter;
| 0 | ||||||||||||||||||||||||
| 3468 | if (!styleHint(SH_UnderlineShortcut, button, w))
| 0 | ||||||||||||||||||||||||
| 3469 | tf |= Qt::TextHideMnemonic; never executed: tf |= Qt::TextHideMnemonic; | 0 | ||||||||||||||||||||||||
| 3470 | if (!button->icon.isNull()) {
| 0 | ||||||||||||||||||||||||
| 3471 | //Group both icon and text | - | ||||||||||||||||||||||||
| 3472 | QRect iconRect; | - | ||||||||||||||||||||||||
| 3473 | QIcon::Mode mode = button->state & State_Enabled ? QIcon::Normal : QIcon::Disabled;
| 0 | ||||||||||||||||||||||||
| 3474 | if (mode == QIcon::Normal && button->state & State_HasFocus)
| 0 | ||||||||||||||||||||||||
| 3475 | mode = QIcon::Active; never executed: mode = QIcon::Active; | 0 | ||||||||||||||||||||||||
| 3476 | QIcon::State state = QIcon::Off; | - | ||||||||||||||||||||||||
| 3477 | if (button->state & State_On)
| 0 | ||||||||||||||||||||||||
| 3478 | state = QIcon::On; never executed: state = QIcon::On; | 0 | ||||||||||||||||||||||||
| 3479 | - | |||||||||||||||||||||||||
| 3480 | QPixmap pixmap = button->icon.pixmap(button->iconSize, mode, state); | - | ||||||||||||||||||||||||
| 3481 | int pixmapWidth = pixmap.width() / pixmap.devicePixelRatio(); | - | ||||||||||||||||||||||||
| 3482 | int pixmapHeight = pixmap.height() / pixmap.devicePixelRatio(); | - | ||||||||||||||||||||||||
| 3483 | int labelWidth = pixmapWidth; | - | ||||||||||||||||||||||||
| 3484 | int labelHeight = pixmapHeight; | - | ||||||||||||||||||||||||
| 3485 | int iconSpacing = 4;//### 4 is currently hardcoded in QPushButton::sizeHint() | - | ||||||||||||||||||||||||
| 3486 | int textWidth = button->fontMetrics.boundingRect(opt->rect, tf, button->text).width(); | - | ||||||||||||||||||||||||
| 3487 | if (!button->text.isEmpty())
| 0 | ||||||||||||||||||||||||
| 3488 | labelWidth += (textWidth + iconSpacing); never executed: labelWidth += (textWidth + iconSpacing); | 0 | ||||||||||||||||||||||||
| 3489 | - | |||||||||||||||||||||||||
| 3490 | //Determine label alignment: | - | ||||||||||||||||||||||||
| 3491 | if (textAlignment & Qt::AlignLeft) { /*left*/
| 0 | ||||||||||||||||||||||||
| 3492 | iconRect = QRect(textRect.x(), textRect.y() + (textRect.height() - labelHeight) / 2, | - | ||||||||||||||||||||||||
| 3493 | pixmapWidth, pixmapHeight); | - | ||||||||||||||||||||||||
| 3494 | } else if (textAlignment & Qt::AlignHCenter) { /* center */ never executed: end of block
| 0 | ||||||||||||||||||||||||
| 3495 | iconRect = QRect(textRect.x() + (textRect.width() - labelWidth) / 2, | - | ||||||||||||||||||||||||
| 3496 | textRect.y() + (textRect.height() - labelHeight) / 2, | - | ||||||||||||||||||||||||
| 3497 | pixmapWidth, pixmapHeight); | - | ||||||||||||||||||||||||
| 3498 | } else { /*right*/ never executed: end of block | 0 | ||||||||||||||||||||||||
| 3499 | iconRect = QRect(textRect.x() + textRect.width() - labelWidth, | - | ||||||||||||||||||||||||
| 3500 | textRect.y() + (textRect.height() - labelHeight) / 2, | - | ||||||||||||||||||||||||
| 3501 | pixmapWidth, pixmapHeight); | - | ||||||||||||||||||||||||
| 3502 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3503 | - | |||||||||||||||||||||||||
| 3504 | iconRect = visualRect(button->direction, textRect, iconRect); | - | ||||||||||||||||||||||||
| 3505 | - | |||||||||||||||||||||||||
| 3506 | tf |= Qt::AlignLeft; //left align, we adjust the text-rect instead | - | ||||||||||||||||||||||||
| 3507 | - | |||||||||||||||||||||||||
| 3508 | if (button->direction == Qt::RightToLeft)
| 0 | ||||||||||||||||||||||||
| 3509 | textRect.setRight(iconRect.left() - iconSpacing); never executed: textRect.setRight(iconRect.left() - iconSpacing); | 0 | ||||||||||||||||||||||||
| 3510 | else | - | ||||||||||||||||||||||||
| 3511 | textRect.setLeft(iconRect.left() + iconRect.width() + iconSpacing); never executed: textRect.setLeft(iconRect.left() + iconRect.width() + iconSpacing); | 0 | ||||||||||||||||||||||||
| 3512 | - | |||||||||||||||||||||||||
| 3513 | if (button->state & (State_On | State_Sunken))
| 0 | ||||||||||||||||||||||||
| 3514 | iconRect.translate(pixelMetric(PM_ButtonShiftHorizontal, opt, w), never executed: iconRect.translate(pixelMetric(PM_ButtonShiftHorizontal, opt, w), pixelMetric(PM_ButtonShiftVertical, opt, w)); | 0 | ||||||||||||||||||||||||
| 3515 | pixelMetric(PM_ButtonShiftVertical, opt, w)); never executed: iconRect.translate(pixelMetric(PM_ButtonShiftHorizontal, opt, w), pixelMetric(PM_ButtonShiftVertical, opt, w)); | 0 | ||||||||||||||||||||||||
| 3516 | p->drawPixmap(iconRect, pixmap); | - | ||||||||||||||||||||||||
| 3517 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 3518 | tf |= textAlignment; | - | ||||||||||||||||||||||||
| 3519 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3520 | if (button->state & (State_On | State_Sunken))
| 0 | ||||||||||||||||||||||||
| 3521 | textRect.translate(pixelMetric(PM_ButtonShiftHorizontal, opt, w), never executed: textRect.translate(pixelMetric(PM_ButtonShiftHorizontal, opt, w), pixelMetric(PM_ButtonShiftVertical, opt, w)); | 0 | ||||||||||||||||||||||||
| 3522 | pixelMetric(PM_ButtonShiftVertical, opt, w)); never executed: textRect.translate(pixelMetric(PM_ButtonShiftHorizontal, opt, w), pixelMetric(PM_ButtonShiftVertical, opt, w)); | 0 | ||||||||||||||||||||||||
| 3523 | - | |||||||||||||||||||||||||
| 3524 | if (button->features & QStyleOptionButton::HasMenu) {
| 0 | ||||||||||||||||||||||||
| 3525 | int indicatorSize = pixelMetric(PM_MenuButtonIndicator, button, w); | - | ||||||||||||||||||||||||
| 3526 | if (button->direction == Qt::LeftToRight)
| 0 | ||||||||||||||||||||||||
| 3527 | textRect = textRect.adjusted(0, 0, -indicatorSize, 0); never executed: textRect = textRect.adjusted(0, 0, -indicatorSize, 0); | 0 | ||||||||||||||||||||||||
| 3528 | else | - | ||||||||||||||||||||||||
| 3529 | textRect = textRect.adjusted(indicatorSize, 0, 0, 0); never executed: textRect = textRect.adjusted(indicatorSize, 0, 0, 0); | 0 | ||||||||||||||||||||||||
| 3530 | } | - | ||||||||||||||||||||||||
| 3531 | drawItemText(p, textRect, tf, butOpt.palette, (button->state & State_Enabled), | - | ||||||||||||||||||||||||
| 3532 | button->text, QPalette::ButtonText); | - | ||||||||||||||||||||||||
| 3533 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 3534 | ParentStyle::drawControl(ce, &butOpt, p, w); | - | ||||||||||||||||||||||||
| 3535 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3536 | - | |||||||||||||||||||||||||
| 3537 | if (rule.hasFont)
| 0 | ||||||||||||||||||||||||
| 3538 | p->setFont(oldFont); never executed: p->setFont(oldFont); | 0 | ||||||||||||||||||||||||
| 3539 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3540 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 3541 | - | |||||||||||||||||||||||||
| 3542 | case CE_RadioButton: never executed: case CE_RadioButton: | 0 | ||||||||||||||||||||||||
| 3543 | case CE_CheckBox: never executed: case CE_CheckBox: | 0 | ||||||||||||||||||||||||
| 3544 | if (rule.hasBox() || !rule.hasNativeBorder() || rule.hasDrawable() || hasStyleRule(w, PseudoElement_Indicator)) {
| 0 | ||||||||||||||||||||||||
| 3545 | rule.drawRule(p, opt->rect); | - | ||||||||||||||||||||||||
| 3546 | ParentStyle::drawControl(ce, opt, p, w); | - | ||||||||||||||||||||||||
| 3547 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 3548 | } else if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
| 0 | ||||||||||||||||||||||||
| 3549 | QStyleOptionButton butOpt(*btn); | - | ||||||||||||||||||||||||
| 3550 | rule.configurePalette(&butOpt.palette, QPalette::ButtonText, QPalette::Button); | - | ||||||||||||||||||||||||
| 3551 | baseStyle()->drawControl(ce, &butOpt, p, w); | - | ||||||||||||||||||||||||
| 3552 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 3553 | } | - | ||||||||||||||||||||||||
| 3554 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 3555 | case CE_RadioButtonLabel: never executed: case CE_RadioButtonLabel: | 0 | ||||||||||||||||||||||||
| 3556 | case CE_CheckBoxLabel: never executed: case CE_CheckBoxLabel: | 0 | ||||||||||||||||||||||||
| 3557 | if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
| 0 | ||||||||||||||||||||||||
| 3558 | QStyleOptionButton butOpt(*btn); | - | ||||||||||||||||||||||||
| 3559 | rule.configurePalette(&butOpt.palette, QPalette::ButtonText, QPalette::Button); | - | ||||||||||||||||||||||||
| 3560 | ParentStyle::drawControl(ce, &butOpt, p, w); | - | ||||||||||||||||||||||||
| 3561 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3562 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 3563 | - | |||||||||||||||||||||||||
| 3564 | case CE_Splitter: never executed: case CE_Splitter: | 0 | ||||||||||||||||||||||||
| 3565 | pe1 = PseudoElement_SplitterHandle; | - | ||||||||||||||||||||||||
| 3566 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 3567 | - | |||||||||||||||||||||||||
| 3568 | case CE_ToolBar: never executed: case CE_ToolBar: | 0 | ||||||||||||||||||||||||
| 3569 | if (rule.hasBackground()) {
| 0 | ||||||||||||||||||||||||
| 3570 | rule.drawBackground(p, opt->rect); | - | ||||||||||||||||||||||||
| 3571 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3572 | if (rule.hasBorder()) {
| 0 | ||||||||||||||||||||||||
| 3573 | rule.drawBorder(p, rule.borderRect(opt->rect)); | - | ||||||||||||||||||||||||
| 3574 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 3575 | #ifndef QT_NO_TOOLBAR | - | ||||||||||||||||||||||||
| 3576 | if (const QStyleOptionToolBar *tb = qstyleoption_cast<const QStyleOptionToolBar *>(opt)) {
| 0 | ||||||||||||||||||||||||
| 3577 | QStyleOptionToolBar newTb(*tb); | - | ||||||||||||||||||||||||
| 3578 | newTb.rect = rule.borderRect(opt->rect); | - | ||||||||||||||||||||||||
| 3579 | baseStyle()->drawControl(ce, &newTb, p, w); | - | ||||||||||||||||||||||||
| 3580 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3581 | #endif // QT_NO_TOOLBAR | - | ||||||||||||||||||||||||
| 3582 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3583 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 3584 | - | |||||||||||||||||||||||||
| 3585 | case CE_MenuEmptyArea: never executed: case CE_MenuEmptyArea: | 0 | ||||||||||||||||||||||||
| 3586 | case CE_MenuBarEmptyArea: never executed: case CE_MenuBarEmptyArea: | 0 | ||||||||||||||||||||||||
| 3587 | if (rule.hasDrawable()) {
| 0 | ||||||||||||||||||||||||
| 3588 | // Drawn by PE_Widget | - | ||||||||||||||||||||||||
| 3589 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 3590 | } | - | ||||||||||||||||||||||||
| 3591 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 3592 | - | |||||||||||||||||||||||||
| 3593 | case CE_MenuTearoff: never executed: case CE_MenuTearoff: | 0 | ||||||||||||||||||||||||
| 3594 | case CE_MenuScroller: never executed: case CE_MenuScroller: | 0 | ||||||||||||||||||||||||
| 3595 | if (const QStyleOptionMenuItem *m = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) {
| 0 | ||||||||||||||||||||||||
| 3596 | QStyleOptionMenuItem mi(*m); | - | ||||||||||||||||||||||||
| 3597 | int pe = ce == CE_MenuTearoff ? PseudoElement_MenuTearoff : PseudoElement_MenuScroller;
| 0 | ||||||||||||||||||||||||
| 3598 | QRenderRule subRule = renderRule(w, opt, pe); | - | ||||||||||||||||||||||||
| 3599 | mi.rect = subRule.contentsRect(opt->rect); | - | ||||||||||||||||||||||||
| 3600 | rule.configurePalette(&mi.palette, QPalette::ButtonText, QPalette::Button); | - | ||||||||||||||||||||||||
| 3601 | subRule.configurePalette(&mi.palette, QPalette::ButtonText, QPalette::Button); | - | ||||||||||||||||||||||||
| 3602 | - | |||||||||||||||||||||||||
| 3603 | if (subRule.hasDrawable()) {
| 0 | ||||||||||||||||||||||||
| 3604 | subRule.drawRule(p, opt->rect); | - | ||||||||||||||||||||||||
| 3605 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 3606 | baseStyle()->drawControl(ce, &mi, p, w); | - | ||||||||||||||||||||||||
| 3607 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3608 | } | - | ||||||||||||||||||||||||
| 3609 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 3610 | - | |||||||||||||||||||||||||
| 3611 | case CE_MenuItem: never executed: case CE_MenuItem: | 0 | ||||||||||||||||||||||||
| 3612 | if (const QStyleOptionMenuItem *m = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) {
| 0 | ||||||||||||||||||||||||
| 3613 | QStyleOptionMenuItem mi(*m); | - | ||||||||||||||||||||||||
| 3614 | - | |||||||||||||||||||||||||
| 3615 | int pseudo = (mi.menuItemType == QStyleOptionMenuItem::Separator) ? PseudoElement_MenuSeparator : PseudoElement_Item;
| 0 | ||||||||||||||||||||||||
| 3616 | QRenderRule subRule = renderRule(w, opt, pseudo); | - | ||||||||||||||||||||||||
| 3617 | mi.rect = subRule.contentsRect(opt->rect); | - | ||||||||||||||||||||||||
| 3618 | rule.configurePalette(&mi.palette, QPalette::ButtonText, QPalette::Button); | - | ||||||||||||||||||||||||
| 3619 | rule.configurePalette(&mi.palette, QPalette::HighlightedText, QPalette::Highlight); | - | ||||||||||||||||||||||||
| 3620 | subRule.configurePalette(&mi.palette, QPalette::ButtonText, QPalette::Button); | - | ||||||||||||||||||||||||
| 3621 | subRule.configurePalette(&mi.palette, QPalette::HighlightedText, QPalette::Highlight); | - | ||||||||||||||||||||||||
| 3622 | QFont oldFont = p->font(); | - | ||||||||||||||||||||||||
| 3623 | if (subRule.hasFont)
| 0 | ||||||||||||||||||||||||
| 3624 | p->setFont(subRule.font.resolve(p->font())); never executed: p->setFont(subRule.font.resolve(p->font())); | 0 | ||||||||||||||||||||||||
| 3625 | - | |||||||||||||||||||||||||
| 3626 | // We fall back to drawing with the style sheet code whenever at least one of the | - | ||||||||||||||||||||||||
| 3627 | // items are styled in an incompatible way, such as having a background image. | - | ||||||||||||||||||||||||
| 3628 | QRenderRule allRules = renderRule(w, PseudoElement_Item, PseudoClass_Any); | - | ||||||||||||||||||||||||
| 3629 | - | |||||||||||||||||||||||||
| 3630 | if ((pseudo == PseudoElement_MenuSeparator) && subRule.hasDrawable()) {
| 0 | ||||||||||||||||||||||||
| 3631 | subRule.drawRule(p, opt->rect); | - | ||||||||||||||||||||||||
| 3632 | } else if ((pseudo == PseudoElement_Item) never executed: end of block
| 0 | ||||||||||||||||||||||||
| 3633 | && (allRules.hasBox() || allRules.hasBorder()
| 0 | ||||||||||||||||||||||||
| 3634 | || (allRules.background() && !allRules.background()->pixmap.isNull()))) {
| 0 | ||||||||||||||||||||||||
| 3635 | subRule.drawRule(p, opt->rect); | - | ||||||||||||||||||||||||
| 3636 | if (subRule.hasBackground()) {
| 0 | ||||||||||||||||||||||||
| 3637 | mi.palette.setBrush(QPalette::Highlight, Qt::NoBrush); | - | ||||||||||||||||||||||||
| 3638 | mi.palette.setBrush(QPalette::Button, Qt::NoBrush); | - | ||||||||||||||||||||||||
| 3639 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 3640 | mi.palette.setBrush(QPalette::Highlight, mi.palette.brush(QPalette::Button)); | - | ||||||||||||||||||||||||
| 3641 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3642 | mi.palette.setBrush(QPalette::HighlightedText, mi.palette.brush(QPalette::ButtonText)); | - | ||||||||||||||||||||||||
| 3643 | - | |||||||||||||||||||||||||
| 3644 | bool checkable = mi.checkType != QStyleOptionMenuItem::NotCheckable; | - | ||||||||||||||||||||||||
| 3645 | bool checked = checkable ? mi.checked : false;
| 0 | ||||||||||||||||||||||||
| 3646 | - | |||||||||||||||||||||||||
| 3647 | bool dis = !(opt->state & QStyle::State_Enabled), | - | ||||||||||||||||||||||||
| 3648 | act = opt->state & QStyle::State_Selected; | - | ||||||||||||||||||||||||
| 3649 | - | |||||||||||||||||||||||||
| 3650 | if (!mi.icon.isNull()) {
| 0 | ||||||||||||||||||||||||
| 3651 | QIcon::Mode mode = dis ? QIcon::Disabled : QIcon::Normal;
| 0 | ||||||||||||||||||||||||
| 3652 | if (act && !dis)
| 0 | ||||||||||||||||||||||||
| 3653 | mode = QIcon::Active; never executed: mode = QIcon::Active; | 0 | ||||||||||||||||||||||||
| 3654 | QPixmap pixmap; | - | ||||||||||||||||||||||||
| 3655 | if (checked)
| 0 | ||||||||||||||||||||||||
| 3656 | pixmap = mi.icon.pixmap(pixelMetric(PM_SmallIconSize), mode, QIcon::On); never executed: pixmap = mi.icon.pixmap(pixelMetric(PM_SmallIconSize), mode, QIcon::On); | 0 | ||||||||||||||||||||||||
| 3657 | else | - | ||||||||||||||||||||||||
| 3658 | pixmap = mi.icon.pixmap(pixelMetric(PM_SmallIconSize), mode); never executed: pixmap = mi.icon.pixmap(pixelMetric(PM_SmallIconSize), mode); | 0 | ||||||||||||||||||||||||
| 3659 | const int pixw = pixmap.width() / pixmap.devicePixelRatio(); | - | ||||||||||||||||||||||||
| 3660 | const int pixh = pixmap.height() / pixmap.devicePixelRatio(); | - | ||||||||||||||||||||||||
| 3661 | QRenderRule iconRule = renderRule(w, opt, PseudoElement_MenuIcon); | - | ||||||||||||||||||||||||
| 3662 | if (!iconRule.hasGeometry()) {
| 0 | ||||||||||||||||||||||||
| 3663 | iconRule.geo = new QStyleSheetGeometryData(pixw, pixh, pixw, pixh, -1, -1); | - | ||||||||||||||||||||||||
| 3664 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 3665 | iconRule.geo->width = pixw; | - | ||||||||||||||||||||||||
| 3666 | iconRule.geo->height = pixh; | - | ||||||||||||||||||||||||
| 3667 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3668 | QRect iconRect = positionRect(w, subRule, iconRule, PseudoElement_MenuIcon, opt->rect, opt->direction); | - | ||||||||||||||||||||||||
| 3669 | iconRule.drawRule(p, iconRect); | - | ||||||||||||||||||||||||
| 3670 | QRect pmr(0, 0, pixw, pixh); | - | ||||||||||||||||||||||||
| 3671 | pmr.moveCenter(iconRect.center()); | - | ||||||||||||||||||||||||
| 3672 | p->drawPixmap(pmr.topLeft(), pixmap); | - | ||||||||||||||||||||||||
| 3673 | } else if (checkable) { never executed: end of block
| 0 | ||||||||||||||||||||||||
| 3674 | QRenderRule subSubRule = renderRule(w, opt, PseudoElement_MenuCheckMark); | - | ||||||||||||||||||||||||
| 3675 | if (subSubRule.hasDrawable() || checked) {
| 0 | ||||||||||||||||||||||||
| 3676 | QStyleOptionMenuItem newMi = mi; | - | ||||||||||||||||||||||||
| 3677 | newMi.rect = positionRect(w, subRule, subSubRule, PseudoElement_MenuCheckMark, opt->rect, opt->direction); | - | ||||||||||||||||||||||||
| 3678 | drawPrimitive(PE_IndicatorMenuCheckMark, &newMi, p, w); | - | ||||||||||||||||||||||||
| 3679 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3680 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3681 | - | |||||||||||||||||||||||||
| 3682 | QRect textRect = subRule.contentsRect(opt->rect); | - | ||||||||||||||||||||||||
| 3683 | textRect.setWidth(textRect.width() - mi.tabWidth); | - | ||||||||||||||||||||||||
| 3684 | QStringQStringRef s= mi(&mi.text;); | - | ||||||||||||||||||||||||
| 3685 | p->setPen(mi.palette.buttonText().color()); | - | ||||||||||||||||||||||||
| 3686 | if (!s.isEmpty()) {
| 0 | ||||||||||||||||||||||||
| 3687 | int text_flags = Qt::AlignLeft | Qt::AlignVCenter | Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine; | - | ||||||||||||||||||||||||
| 3688 | if (!styleHint(SH_UnderlineShortcut, &mi, w))
| 0 | ||||||||||||||||||||||||
| 3689 | text_flags |= Qt::TextHideMnemonic; never executed: text_flags |= Qt::TextHideMnemonic; | 0 | ||||||||||||||||||||||||
| 3690 | int t = s.indexOf(QLatin1Char('\t')); | - | ||||||||||||||||||||||||
| 3691 | if (t >= 0) {
| 0 | ||||||||||||||||||||||||
| 3692 | QRect vShortcutRect = visualRect(opt->direction, mi.rect, | - | ||||||||||||||||||||||||
| 3693 | QRect(textRect.topRight(), QPoint(mi.rect.right(), textRect.bottom()))); | - | ||||||||||||||||||||||||
| 3694 | p->drawText(vShortcutRect, text_flags, s.mid(t + 1));).toString()); | - | ||||||||||||||||||||||||
| 3695 | s = s.left(t); | - | ||||||||||||||||||||||||
| 3696 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3697 | p->drawText(textRect, text_flags, s.left(t));).toString()); | - | ||||||||||||||||||||||||
| 3698 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3699 | - | |||||||||||||||||||||||||
| 3700 | if (mi.menuItemType == QStyleOptionMenuItem::SubMenu) {// draw sub menu arrow
| 0 | ||||||||||||||||||||||||
| 3701 | PrimitiveElement arrow = (opt->direction == Qt::RightToLeft) ? PE_IndicatorArrowLeft : PE_IndicatorArrowRight;
| 0 | ||||||||||||||||||||||||
| 3702 | QRenderRule subRule2 = renderRule(w, opt, PseudoElement_MenuRightArrow); | - | ||||||||||||||||||||||||
| 3703 | mi.rect = positionRect(w, subRule, subRule2, PseudoElement_MenuRightArrow, opt->rect, mi.direction); | - | ||||||||||||||||||||||||
| 3704 | drawPrimitive(arrow, &mi, p, w); | - | ||||||||||||||||||||||||
| 3705 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3706 | } else if (hasStyleRule(w, PseudoElement_MenuCheckMark) || hasStyleRule(w, PseudoElement_MenuRightArrow)) { never executed: end of block
| 0 | ||||||||||||||||||||||||
| 3707 | QWindowsStyle::drawControl(ce, &mi, p, w); | - | ||||||||||||||||||||||||
| 3708 | if (mi.checkType != QStyleOptionMenuItem::NotCheckable && !mi.checked) {
| 0 | ||||||||||||||||||||||||
| 3709 | // We have a style defined, but QWindowsStyle won't draw anything if not checked. | - | ||||||||||||||||||||||||
| 3710 | // So we mimick what QWindowsStyle would do. | - | ||||||||||||||||||||||||
| 3711 | int checkcol = qMax<int>(mi.maxIconWidth, QWindowsStylePrivate::windowsCheckMarkWidth); | - | ||||||||||||||||||||||||
| 3712 | QRect vCheckRect = visualRect(opt->direction, mi.rect, QRect(mi.rect.x(), mi.rect.y(), checkcol, mi.rect.height())); | - | ||||||||||||||||||||||||
| 3713 | if (mi.state.testFlag(State_Enabled) && mi.state.testFlag(State_Selected)) {
| 0 | ||||||||||||||||||||||||
| 3714 | qDrawShadePanel(p, vCheckRect, mi.palette, true, 1, &mi.palette.brush(QPalette::Button)); | - | ||||||||||||||||||||||||
| 3715 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 3716 | QBrush fill(mi.palette.light().color(), Qt::Dense4Pattern); | - | ||||||||||||||||||||||||
| 3717 | qDrawShadePanel(p, vCheckRect, mi.palette, true, 1, &fill); | - | ||||||||||||||||||||||||
| 3718 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3719 | QRenderRule subSubRule = renderRule(w, opt, PseudoElement_MenuCheckMark); | - | ||||||||||||||||||||||||
| 3720 | if (subSubRule.hasDrawable()) {
| 0 | ||||||||||||||||||||||||
| 3721 | QStyleOptionMenuItem newMi(mi); | - | ||||||||||||||||||||||||
| 3722 | newMi.rect = visualRect(opt->direction, mi.rect, QRect(mi.rect.x() + QWindowsStylePrivate::windowsItemFrame, | - | ||||||||||||||||||||||||
| 3723 | mi.rect.y() + QWindowsStylePrivate::windowsItemFrame, | - | ||||||||||||||||||||||||
| 3724 | checkcol - 2 * QWindowsStylePrivate::windowsItemFrame, | - | ||||||||||||||||||||||||
| 3725 | mi.rect.height() - 2 * QWindowsStylePrivate::windowsItemFrame)); | - | ||||||||||||||||||||||||
| 3726 | drawPrimitive(PE_IndicatorMenuCheckMark, &newMi, p, w); | - | ||||||||||||||||||||||||
| 3727 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3728 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3729 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 3730 | if (rule.hasDrawable() && !subRule.hasDrawable() && !(opt->state & QStyle::State_Selected)) {
| 0 | ||||||||||||||||||||||||
| 3731 | mi.palette.setColor(QPalette::Window, Qt::transparent); | - | ||||||||||||||||||||||||
| 3732 | mi.palette.setColor(QPalette::Button, Qt::transparent); | - | ||||||||||||||||||||||||
| 3733 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3734 | if (rule.baseStyleCanDraw() && subRule.baseStyleCanDraw()) {
| 0 | ||||||||||||||||||||||||
| 3735 | baseStyle()->drawControl(ce, &mi, p, w); | - | ||||||||||||||||||||||||
| 3736 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 3737 | ParentStyle::drawControl(ce, &mi, p, w); | - | ||||||||||||||||||||||||
| 3738 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3739 | } | - | ||||||||||||||||||||||||
| 3740 | - | |||||||||||||||||||||||||
| 3741 | if (subRule.hasFont)
| 0 | ||||||||||||||||||||||||
| 3742 | p->setFont(oldFont); never executed: p->setFont(oldFont); | 0 | ||||||||||||||||||||||||
| 3743 | - | |||||||||||||||||||||||||
| 3744 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 3745 | } | - | ||||||||||||||||||||||||
| 3746 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 3747 | - | |||||||||||||||||||||||||
| 3748 | case CE_MenuBarItem: never executed: case CE_MenuBarItem: | 0 | ||||||||||||||||||||||||
| 3749 | if (const QStyleOptionMenuItem *m = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) {
| 0 | ||||||||||||||||||||||||
| 3750 | QStyleOptionMenuItem mi(*m); | - | ||||||||||||||||||||||||
| 3751 | QRenderRule subRule = renderRule(w, opt, PseudoElement_Item); | - | ||||||||||||||||||||||||
| 3752 | mi.rect = subRule.contentsRect(opt->rect); | - | ||||||||||||||||||||||||
| 3753 | rule.configurePalette(&mi.palette, QPalette::ButtonText, QPalette::Button); | - | ||||||||||||||||||||||||
| 3754 | subRule.configurePalette(&mi.palette, QPalette::ButtonText, QPalette::Button); | - | ||||||||||||||||||||||||
| 3755 | - | |||||||||||||||||||||||||
| 3756 | if (subRule.hasDrawable()) {
| 0 | ||||||||||||||||||||||||
| 3757 | subRule.drawRule(p, opt->rect); | - | ||||||||||||||||||||||||
| 3758 | QCommonStyle::drawControl(ce, &mi, p, w); | - | ||||||||||||||||||||||||
| 3759 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 3760 | if (rule.hasDrawable() && !(opt->state & QStyle::State_Selected)) {
| 0 | ||||||||||||||||||||||||
| 3761 | // So that the menu bar background is not hidden by the items | - | ||||||||||||||||||||||||
| 3762 | mi.palette.setColor(QPalette::Window, Qt::transparent); | - | ||||||||||||||||||||||||
| 3763 | mi.palette.setColor(QPalette::Button, Qt::transparent); | - | ||||||||||||||||||||||||
| 3764 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3765 | baseStyle()->drawControl(ce, &mi, p, w); | - | ||||||||||||||||||||||||
| 3766 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3767 | } | - | ||||||||||||||||||||||||
| 3768 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 3769 | - | |||||||||||||||||||||||||
| 3770 | #ifndef QT_NO_COMBOBOX | - | ||||||||||||||||||||||||
| 3771 | case CE_ComboBoxLabel: never executed: case CE_ComboBoxLabel: | 0 | ||||||||||||||||||||||||
| 3772 | if (!rule.hasBox())
| 0 | ||||||||||||||||||||||||
| 3773 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 3774 | if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) {
| 0 | ||||||||||||||||||||||||
| 3775 | QRect editRect = subControlRect(CC_ComboBox, cb, SC_ComboBoxEditField, w); | - | ||||||||||||||||||||||||
| 3776 | p->save(); | - | ||||||||||||||||||||||||
| 3777 | p->setClipRect(editRect); | - | ||||||||||||||||||||||||
| 3778 | if (!cb->currentIcon.isNull()) {
| 0 | ||||||||||||||||||||||||
| 3779 | int spacing = rule.hasBox() ? rule.box()->spacing : -1;
| 0 | ||||||||||||||||||||||||
| 3780 | if (spacing == -1)
| 0 | ||||||||||||||||||||||||
| 3781 | spacing = 6; never executed: spacing = 6; | 0 | ||||||||||||||||||||||||
| 3782 | QIcon::Mode mode = cb->state & State_Enabled ? QIcon::Normal : QIcon::Disabled;
| 0 | ||||||||||||||||||||||||
| 3783 | QPixmap pixmap = cb->currentIcon.pixmap(cb->iconSize, mode); | - | ||||||||||||||||||||||||
| 3784 | QRect iconRect(editRect); | - | ||||||||||||||||||||||||
| 3785 | iconRect.setWidth(cb->iconSize.width()); | - | ||||||||||||||||||||||||
| 3786 | iconRect = alignedRect(cb->direction, | - | ||||||||||||||||||||||||
| 3787 | Qt::AlignLeft | Qt::AlignVCenter, | - | ||||||||||||||||||||||||
| 3788 | iconRect.size(), editRect); | - | ||||||||||||||||||||||||
| 3789 | drawItemPixmap(p, iconRect, Qt::AlignCenter, pixmap); | - | ||||||||||||||||||||||||
| 3790 | - | |||||||||||||||||||||||||
| 3791 | if (cb->direction == Qt::RightToLeft)
| 0 | ||||||||||||||||||||||||
| 3792 | editRect.translate(-spacing - cb->iconSize.width(), 0); never executed: editRect.translate(-spacing - cb->iconSize.width(), 0); | 0 | ||||||||||||||||||||||||
| 3793 | else | - | ||||||||||||||||||||||||
| 3794 | editRect.translate(cb->iconSize.width() + spacing, 0); never executed: editRect.translate(cb->iconSize.width() + spacing, 0); | 0 | ||||||||||||||||||||||||
| 3795 | } | - | ||||||||||||||||||||||||
| 3796 | if (!cb->currentText.isEmpty() && !cb->editable) {
| 0 | ||||||||||||||||||||||||
| 3797 | QPalette styledPalette(cb->palette); | - | ||||||||||||||||||||||||
| 3798 | rule.configurePalette(&styledPalette, QPalette::Text, QPalette::Base); | - | ||||||||||||||||||||||||
| 3799 | drawItemText(p, editRect.adjusted(0, 0, 0, 0), Qt::AlignLeft | Qt::AlignVCenter, styledPalette, | - | ||||||||||||||||||||||||
| 3800 | cb->state & State_Enabled, cb->currentText, QPalette::Text); | - | ||||||||||||||||||||||||
| 3801 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3802 | p->restore(); | - | ||||||||||||||||||||||||
| 3803 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 3804 | } | - | ||||||||||||||||||||||||
| 3805 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 3806 | #endif // QT_NO_COMBOBOX | - | ||||||||||||||||||||||||
| 3807 | - | |||||||||||||||||||||||||
| 3808 | case CE_Header: never executed: case CE_Header: | 0 | ||||||||||||||||||||||||
| 3809 | if (hasStyleRule(w, PseudoElement_HeaderViewUpArrow)
| 0 | ||||||||||||||||||||||||
| 3810 | || hasStyleRule(w, PseudoElement_HeaderViewDownArrow)) {
| 0 | ||||||||||||||||||||||||
| 3811 | ParentStyle::drawControl(ce, opt, p, w); | - | ||||||||||||||||||||||||
| 3812 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 3813 | } | - | ||||||||||||||||||||||||
| 3814 | if(hasStyleRule(w, PseudoElement_HeaderViewSection)) {
| 0 | ||||||||||||||||||||||||
| 3815 | QRenderRule subRule = renderRule(w, opt, PseudoElement_HeaderViewSection); | - | ||||||||||||||||||||||||
| 3816 | if (!subRule.hasNativeBorder() || !subRule.baseStyleCanDraw()
| 0 | ||||||||||||||||||||||||
| 3817 | || subRule.hasBackground() || subRule.hasPalette()) {
| 0 | ||||||||||||||||||||||||
| 3818 | ParentStyle::drawControl(ce, opt, p, w); | - | ||||||||||||||||||||||||
| 3819 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 3820 | } | - | ||||||||||||||||||||||||
| 3821 | if (subRule.hasFont) {
| 0 | ||||||||||||||||||||||||
| 3822 | const QFont oldFont = p->font(); | - | ||||||||||||||||||||||||
| 3823 | p->setFont(subRule.font.resolve(p->font())); | - | ||||||||||||||||||||||||
| 3824 | baseStyle()->drawControl(ce, opt, p, w); | - | ||||||||||||||||||||||||
| 3825 | p->setFont(oldFont); | - | ||||||||||||||||||||||||
| 3826 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 3827 | } | - | ||||||||||||||||||||||||
| 3828 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3829 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 3830 | case CE_HeaderSection: never executed: case CE_HeaderSection: | 0 | ||||||||||||||||||||||||
| 3831 | if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(opt)) {
| 0 | ||||||||||||||||||||||||
| 3832 | QRenderRule subRule = renderRule(w, opt, PseudoElement_HeaderViewSection); | - | ||||||||||||||||||||||||
| 3833 | if (subRule.hasNativeBorder()) {
| 0 | ||||||||||||||||||||||||
| 3834 | QStyleOptionHeader hdr(*header); | - | ||||||||||||||||||||||||
| 3835 | subRule.configurePalette(&hdr.palette, QPalette::ButtonText, QPalette::Button); | - | ||||||||||||||||||||||||
| 3836 | - | |||||||||||||||||||||||||
| 3837 | if (subRule.baseStyleCanDraw()) {
| 0 | ||||||||||||||||||||||||
| 3838 | baseStyle()->drawControl(CE_HeaderSection, &hdr, p, w); | - | ||||||||||||||||||||||||
| 3839 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 3840 | QWindowsStyle::drawControl(CE_HeaderSection, &hdr, p, w); | - | ||||||||||||||||||||||||
| 3841 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3842 | } else { | - | ||||||||||||||||||||||||
| 3843 | subRule.drawRule(p, opt->rect); | - | ||||||||||||||||||||||||
| 3844 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3845 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 3846 | } | - | ||||||||||||||||||||||||
| 3847 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 3848 | - | |||||||||||||||||||||||||
| 3849 | case CE_HeaderLabel: never executed: case CE_HeaderLabel: | 0 | ||||||||||||||||||||||||
| 3850 | if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(opt)) {
| 0 | ||||||||||||||||||||||||
| 3851 | QStyleOptionHeader hdr(*header); | - | ||||||||||||||||||||||||
| 3852 | QRenderRule subRule = renderRule(w, opt, PseudoElement_HeaderViewSection); | - | ||||||||||||||||||||||||
| 3853 | subRule.configurePalette(&hdr.palette, QPalette::ButtonText, QPalette::Button); | - | ||||||||||||||||||||||||
| 3854 | QFont oldFont = p->font(); | - | ||||||||||||||||||||||||
| 3855 | if (subRule.hasFont)
| 0 | ||||||||||||||||||||||||
| 3856 | p->setFont(subRule.font.resolve(p->font())); never executed: p->setFont(subRule.font.resolve(p->font())); | 0 | ||||||||||||||||||||||||
| 3857 | baseStyle()->drawControl(ce, &hdr, p, w); | - | ||||||||||||||||||||||||
| 3858 | if (subRule.hasFont)
| 0 | ||||||||||||||||||||||||
| 3859 | p->setFont(oldFont); never executed: p->setFont(oldFont); | 0 | ||||||||||||||||||||||||
| 3860 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 3861 | } | - | ||||||||||||||||||||||||
| 3862 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 3863 | - | |||||||||||||||||||||||||
| 3864 | case CE_HeaderEmptyArea: never executed: case CE_HeaderEmptyArea: | 0 | ||||||||||||||||||||||||
| 3865 | if (rule.hasDrawable()) {
| 0 | ||||||||||||||||||||||||
| 3866 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 3867 | } | - | ||||||||||||||||||||||||
| 3868 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 3869 | - | |||||||||||||||||||||||||
| 3870 | case CE_ProgressBar: never executed: case CE_ProgressBar: | 0 | ||||||||||||||||||||||||
| 3871 | QWindowsStyle::drawControl(ce, opt, p, w); | - | ||||||||||||||||||||||||
| 3872 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 3873 | - | |||||||||||||||||||||||||
| 3874 | case CE_ProgressBarGroove: never executed: case CE_ProgressBarGroove: | 0 | ||||||||||||||||||||||||
| 3875 | if (!rule.hasNativeBorder()) {
| 0 | ||||||||||||||||||||||||
| 3876 | rule.drawRule(p, rule.boxRect(opt->rect, Margin)); | - | ||||||||||||||||||||||||
| 3877 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 3878 | } | - | ||||||||||||||||||||||||
| 3879 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 3880 | - | |||||||||||||||||||||||||
| 3881 | case CE_ProgressBarContents: { never executed: case CE_ProgressBarContents: | 0 | ||||||||||||||||||||||||
| 3882 | QRenderRule subRule = renderRule(w, opt, PseudoElement_ProgressBarChunk); | - | ||||||||||||||||||||||||
| 3883 | if (subRule.hasDrawable()) {
| 0 | ||||||||||||||||||||||||
| 3884 | if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(opt)) {
| 0 | ||||||||||||||||||||||||
| 3885 | p->save(); | - | ||||||||||||||||||||||||
| 3886 | p->setClipRect(pb->rect); | - | ||||||||||||||||||||||||
| 3887 | - | |||||||||||||||||||||||||
| 3888 | qint64 minimum = qint64(pb->minimum); | - | ||||||||||||||||||||||||
| 3889 | qint64 maximum = qint64(pb->maximum); | - | ||||||||||||||||||||||||
| 3890 | qint64 progress = qint64(pb->progress); | - | ||||||||||||||||||||||||
| 3891 | bool vertical = (pb->orientation == Qt::Vertical); | - | ||||||||||||||||||||||||
| 3892 | bool inverted = pb->invertedAppearance; | - | ||||||||||||||||||||||||
| 3893 | - | |||||||||||||||||||||||||
| 3894 | QTransform m; | - | ||||||||||||||||||||||||
| 3895 | QRect rect = pb->rect; | - | ||||||||||||||||||||||||
| 3896 | if (vertical) {
| 0 | ||||||||||||||||||||||||
| 3897 | rect = QRect(rect.y(), rect.x(), rect.height(), rect.width()); | - | ||||||||||||||||||||||||
| 3898 | m.rotate(90); | - | ||||||||||||||||||||||||
| 3899 | m.translate(0, -(rect.height() + rect.y()*2)); | - | ||||||||||||||||||||||||
| 3900 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3901 | - | |||||||||||||||||||||||||
| 3902 | bool reverse = ((!vertical && (pb->direction == Qt::RightToLeft)) || vertical);
| 0 | ||||||||||||||||||||||||
| 3903 | if (inverted)
| 0 | ||||||||||||||||||||||||
| 3904 | reverse = !reverse; never executed: reverse = !reverse; | 0 | ||||||||||||||||||||||||
| 3905 | const bool indeterminate = pb->minimum == pb->maximum; | - | ||||||||||||||||||||||||
| 3906 | qreal fillRatio = indeterminate ? 0.50 : qreal(progress - minimum)/(maximum - minimum);
| 0 | ||||||||||||||||||||||||
| 3907 | int fillWidth = int(rect.width() * fillRatio); | - | ||||||||||||||||||||||||
| 3908 | int chunkWidth = fillWidth; | - | ||||||||||||||||||||||||
| 3909 | if (subRule.hasContentsSize()) {
| 0 | ||||||||||||||||||||||||
| 3910 | QSize sz = subRule.size(); | - | ||||||||||||||||||||||||
| 3911 | chunkWidth = (opt->state & QStyle::State_Horizontal) ? sz.width() : sz.height();
| 0 | ||||||||||||||||||||||||
| 3912 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3913 | - | |||||||||||||||||||||||||
| 3914 | QRect r = rect; | - | ||||||||||||||||||||||||
| 3915 | Q_D(const QWindowsStyle); | - | ||||||||||||||||||||||||
| 3916 | if (pb->minimum == 0 && pb->maximum == 0) {
| 0 | ||||||||||||||||||||||||
| 3917 | int chunkCount = fillWidth/chunkWidth; | - | ||||||||||||||||||||||||
| 3918 | int offset = 0; | - | ||||||||||||||||||||||||
| 3919 | if (QProgressStyleAnimation *animation = qobject_cast<QProgressStyleAnimation*>(d->animation(opt->styleObject)))
| 0 | ||||||||||||||||||||||||
| 3920 | offset = animation->animationStep() * 8 % rect.width(); never executed: offset = animation->animationStep() * 8 % rect.width(); | 0 | ||||||||||||||||||||||||
| 3921 | else | - | ||||||||||||||||||||||||
| 3922 | d->startAnimation(new QProgressStyleAnimation(d->animationFps, opt->styleObject)); never executed: d->startAnimation(new QProgressStyleAnimation(d->animationFps, opt->styleObject)); | 0 | ||||||||||||||||||||||||
| 3923 | int x = reverse ? r.left() + r.width() - offset - chunkWidth : r.x() + offset;
| 0 | ||||||||||||||||||||||||
| 3924 | while (chunkCount > 0) {
| 0 | ||||||||||||||||||||||||
| 3925 | r.setRect(x, rect.y(), chunkWidth, rect.height()); | - | ||||||||||||||||||||||||
| 3926 | r = m.mapRect(QRectF(r)).toRect(); | - | ||||||||||||||||||||||||
| 3927 | subRule.drawRule(p, r); | - | ||||||||||||||||||||||||
| 3928 | x += reverse ? -chunkWidth : chunkWidth;
| 0 | ||||||||||||||||||||||||
| 3929 | if (reverse ? x < rect.left() : x > rect.right())
| 0 | ||||||||||||||||||||||||
| 3930 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 3931 | --chunkCount; | - | ||||||||||||||||||||||||
| 3932 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3933 | - | |||||||||||||||||||||||||
| 3934 | r = rect; | - | ||||||||||||||||||||||||
| 3935 | x = reverse ? r.right() - (r.left() - x - chunkWidth)
| 0 | ||||||||||||||||||||||||
| 3936 | : r.left() + (x - r.right() - chunkWidth); | - | ||||||||||||||||||||||||
| 3937 | while (chunkCount > 0) {
| 0 | ||||||||||||||||||||||||
| 3938 | r.setRect(x, rect.y(), chunkWidth, rect.height()); | - | ||||||||||||||||||||||||
| 3939 | r = m.mapRect(QRectF(r)).toRect(); | - | ||||||||||||||||||||||||
| 3940 | subRule.drawRule(p, r); | - | ||||||||||||||||||||||||
| 3941 | x += reverse ? -chunkWidth : chunkWidth;
| 0 | ||||||||||||||||||||||||
| 3942 | --chunkCount; | - | ||||||||||||||||||||||||
| 3943 | }; never executed: end of block | 0 | ||||||||||||||||||||||||
| 3944 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 3945 | int x = reverse ? r.left() + r.width() - chunkWidth : r.x();
| 0 | ||||||||||||||||||||||||
| 3946 | - | |||||||||||||||||||||||||
| 3947 | for (int i = 0; i < ceil(qreal(fillWidth)/chunkWidth); ++i) {
| 0 | ||||||||||||||||||||||||
| 3948 | r.setRect(x, rect.y(), chunkWidth, rect.height()); | - | ||||||||||||||||||||||||
| 3949 | r = m.mapRect(QRectF(r)).toRect(); | - | ||||||||||||||||||||||||
| 3950 | subRule.drawRule(p, r); | - | ||||||||||||||||||||||||
| 3951 | x += reverse ? -chunkWidth : chunkWidth;
| 0 | ||||||||||||||||||||||||
| 3952 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3953 | - | |||||||||||||||||||||||||
| 3954 | d->stopAnimation(opt->styleObject); | - | ||||||||||||||||||||||||
| 3955 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3956 | - | |||||||||||||||||||||||||
| 3957 | p->restore(); | - | ||||||||||||||||||||||||
| 3958 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 3959 | } | - | ||||||||||||||||||||||||
| 3960 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3961 | } | - | ||||||||||||||||||||||||
| 3962 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 3963 | - | |||||||||||||||||||||||||
| 3964 | case CE_ProgressBarLabel: never executed: case CE_ProgressBarLabel: | 0 | ||||||||||||||||||||||||
| 3965 | if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(opt)) {
| 0 | ||||||||||||||||||||||||
| 3966 | if (rule.hasBox() || rule.hasBorder() || hasStyleRule(w, PseudoElement_ProgressBarChunk)) {
| 0 | ||||||||||||||||||||||||
| 3967 | drawItemText(p, pb->rect, pb->textAlignment | Qt::TextSingleLine, pb->palette, | - | ||||||||||||||||||||||||
| 3968 | pb->state & State_Enabled, pb->text, QPalette::Text); | - | ||||||||||||||||||||||||
| 3969 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 3970 | QStyleOptionProgressBar pbCopy(*pb); | - | ||||||||||||||||||||||||
| 3971 | rule.configurePalette(&pbCopy.palette, QPalette::HighlightedText, QPalette::Highlight); | - | ||||||||||||||||||||||||
| 3972 | baseStyle()->drawControl(ce, &pbCopy, p, w); | - | ||||||||||||||||||||||||
| 3973 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3974 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 3975 | } | - | ||||||||||||||||||||||||
| 3976 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 3977 | - | |||||||||||||||||||||||||
| 3978 | case CE_SizeGrip: never executed: case CE_SizeGrip: | 0 | ||||||||||||||||||||||||
| 3979 | if (const QStyleOptionSizeGrip *sgOpt = qstyleoption_cast<const QStyleOptionSizeGrip *>(opt)) {
| 0 | ||||||||||||||||||||||||
| 3980 | if (rule.hasDrawable()) {
| 0 | ||||||||||||||||||||||||
| 3981 | rule.drawFrame(p, opt->rect); | - | ||||||||||||||||||||||||
| 3982 | p->save(); | - | ||||||||||||||||||||||||
| 3983 | switch (sgOpt->corner) { | - | ||||||||||||||||||||||||
| 3984 | case Qt::BottomRightCorner: break; never executed: break;never executed: case Qt::BottomRightCorner: | 0 | ||||||||||||||||||||||||
| 3985 | case Qt::BottomLeftCorner: p->rotate(90); break; never executed: break;never executed: case Qt::BottomLeftCorner: | 0 | ||||||||||||||||||||||||
| 3986 | case Qt::TopLeftCorner: p->rotate(180); break; never executed: break;never executed: case Qt::TopLeftCorner: | 0 | ||||||||||||||||||||||||
| 3987 | case Qt::TopRightCorner: p->rotate(270); break; never executed: break;never executed: case Qt::TopRightCorner: | 0 | ||||||||||||||||||||||||
| 3988 | default: break; never executed: break;never executed: default: | 0 | ||||||||||||||||||||||||
| 3989 | } | - | ||||||||||||||||||||||||
| 3990 | rule.drawImage(p, opt->rect); | - | ||||||||||||||||||||||||
| 3991 | p->restore(); | - | ||||||||||||||||||||||||
| 3992 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 3993 | QStyleOptionSizeGrip sg(*sgOpt); | - | ||||||||||||||||||||||||
| 3994 | sg.rect = rule.contentsRect(opt->rect); | - | ||||||||||||||||||||||||
| 3995 | baseStyle()->drawControl(CE_SizeGrip, &sg, p, w); | - | ||||||||||||||||||||||||
| 3996 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 3997 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 3998 | } | - | ||||||||||||||||||||||||
| 3999 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 4000 | - | |||||||||||||||||||||||||
| 4001 | case CE_ToolBoxTab: never executed: case CE_ToolBoxTab: | 0 | ||||||||||||||||||||||||
| 4002 | QWindowsStyle::drawControl(ce, opt, p, w); | - | ||||||||||||||||||||||||
| 4003 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 4004 | - | |||||||||||||||||||||||||
| 4005 | case CE_ToolBoxTabShape: { never executed: case CE_ToolBoxTabShape: | 0 | ||||||||||||||||||||||||
| 4006 | QRenderRule subRule = renderRule(w, opt, PseudoElement_ToolBoxTab); | - | ||||||||||||||||||||||||
| 4007 | if (subRule.hasDrawable()) {
| 0 | ||||||||||||||||||||||||
| 4008 | subRule.drawRule(p, opt->rect); | - | ||||||||||||||||||||||||
| 4009 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 4010 | } | - | ||||||||||||||||||||||||
| 4011 | } | - | ||||||||||||||||||||||||
| 4012 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 4013 | - | |||||||||||||||||||||||||
| 4014 | case CE_ToolBoxTabLabel: never executed: case CE_ToolBoxTabLabel: | 0 | ||||||||||||||||||||||||
| 4015 | if (const QStyleOptionToolBox *box = qstyleoption_cast<const QStyleOptionToolBox *>(opt)) {
| 0 | ||||||||||||||||||||||||
| 4016 | QStyleOptionToolBox boxCopy(*box); | - | ||||||||||||||||||||||||
| 4017 | QRenderRule subRule = renderRule(w, opt, PseudoElement_ToolBoxTab); | - | ||||||||||||||||||||||||
| 4018 | subRule.configurePalette(&boxCopy.palette, QPalette::ButtonText, QPalette::Button); | - | ||||||||||||||||||||||||
| 4019 | QFont oldFont = p->font(); | - | ||||||||||||||||||||||||
| 4020 | if (subRule.hasFont)
| 0 | ||||||||||||||||||||||||
| 4021 | p->setFont(subRule.font); never executed: p->setFont(subRule.font); | 0 | ||||||||||||||||||||||||
| 4022 | boxCopy.rect = subRule.contentsRect(opt->rect); | - | ||||||||||||||||||||||||
| 4023 | QWindowsStyle::drawControl(ce, &boxCopy, p , w); | - | ||||||||||||||||||||||||
| 4024 | if (subRule.hasFont)
| 0 | ||||||||||||||||||||||||
| 4025 | p->setFont(oldFont); never executed: p->setFont(oldFont); | 0 | ||||||||||||||||||||||||
| 4026 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 4027 | } | - | ||||||||||||||||||||||||
| 4028 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 4029 | - | |||||||||||||||||||||||||
| 4030 | case CE_ScrollBarAddPage: never executed: case CE_ScrollBarAddPage: | 0 | ||||||||||||||||||||||||
| 4031 | pe1 = PseudoElement_ScrollBarAddPage; | - | ||||||||||||||||||||||||
| 4032 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 4033 | - | |||||||||||||||||||||||||
| 4034 | case CE_ScrollBarSubPage: never executed: case CE_ScrollBarSubPage: | 0 | ||||||||||||||||||||||||
| 4035 | pe1 = PseudoElement_ScrollBarSubPage; | - | ||||||||||||||||||||||||
| 4036 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 4037 | - | |||||||||||||||||||||||||
| 4038 | case CE_ScrollBarAddLine: never executed: case CE_ScrollBarAddLine: | 0 | ||||||||||||||||||||||||
| 4039 | pe1 = PseudoElement_ScrollBarAddLine; | - | ||||||||||||||||||||||||
| 4040 | pe2 = (opt->state & QStyle::State_Horizontal) ? PseudoElement_ScrollBarRightArrow : PseudoElement_ScrollBarDownArrow;
| 0 | ||||||||||||||||||||||||
| 4041 | fallback = true; | - | ||||||||||||||||||||||||
| 4042 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 4043 | - | |||||||||||||||||||||||||
| 4044 | case CE_ScrollBarSubLine: never executed: case CE_ScrollBarSubLine: | 0 | ||||||||||||||||||||||||
| 4045 | pe1 = PseudoElement_ScrollBarSubLine; | - | ||||||||||||||||||||||||
| 4046 | pe2 = (opt->state & QStyle::State_Horizontal) ? PseudoElement_ScrollBarLeftArrow : PseudoElement_ScrollBarUpArrow;
| 0 | ||||||||||||||||||||||||
| 4047 | fallback = true; | - | ||||||||||||||||||||||||
| 4048 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 4049 | - | |||||||||||||||||||||||||
| 4050 | case CE_ScrollBarFirst: never executed: case CE_ScrollBarFirst: | 0 | ||||||||||||||||||||||||
| 4051 | pe1 = PseudoElement_ScrollBarFirst; | - | ||||||||||||||||||||||||
| 4052 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 4053 | - | |||||||||||||||||||||||||
| 4054 | case CE_ScrollBarLast: never executed: case CE_ScrollBarLast: | 0 | ||||||||||||||||||||||||
| 4055 | pe1 = PseudoElement_ScrollBarLast; | - | ||||||||||||||||||||||||
| 4056 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 4057 | - | |||||||||||||||||||||||||
| 4058 | case CE_ScrollBarSlider: never executed: case CE_ScrollBarSlider: | 0 | ||||||||||||||||||||||||
| 4059 | pe1 = PseudoElement_ScrollBarSlider; | - | ||||||||||||||||||||||||
| 4060 | fallback = true; | - | ||||||||||||||||||||||||
| 4061 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 4062 | - | |||||||||||||||||||||||||
| 4063 | #ifndef QT_NO_ITEMVIEWS | - | ||||||||||||||||||||||||
| 4064 | case CE_ItemViewItem: never executed: case CE_ItemViewItem: | 0 | ||||||||||||||||||||||||
| 4065 | if (const QStyleOptionViewItem *vopt = qstyleoption_cast<const QStyleOptionViewItem *>(opt)) {
| 0 | ||||||||||||||||||||||||
| 4066 | QRenderRule subRule = renderRule(w, opt, PseudoElement_ViewItem); | - | ||||||||||||||||||||||||
| 4067 | if (subRule.hasDrawable() || hasStyleRule(w, PseudoElement_Indicator)) {
| 0 | ||||||||||||||||||||||||
| 4068 | QStyleOptionViewItem optCopy(*vopt); | - | ||||||||||||||||||||||||
| 4069 | subRule.configurePalette(&optCopy.palette, vopt->state & QStyle::State_Selected ? QPalette::HighlightedText : QPalette::Text, | - | ||||||||||||||||||||||||
| 4070 | vopt->state & QStyle::State_Selected ? QPalette::Highlight : QPalette::Base); | - | ||||||||||||||||||||||||
| 4071 | QWindowsStyle::drawControl(ce, &optCopy, p, w); | - | ||||||||||||||||||||||||
| 4072 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 4073 | QStyleOptionViewItem voptCopy(*vopt); | - | ||||||||||||||||||||||||
| 4074 | subRule.configurePalette(&voptCopy.palette, QPalette::Text, QPalette::NoRole); | - | ||||||||||||||||||||||||
| 4075 | baseStyle()->drawControl(ce, &voptCopy, p, w); | - | ||||||||||||||||||||||||
| 4076 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4077 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 4078 | } | - | ||||||||||||||||||||||||
| 4079 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 4080 | #endif // QT_NO_ITEMVIEWS | - | ||||||||||||||||||||||||
| 4081 | - | |||||||||||||||||||||||||
| 4082 | #ifndef QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 4083 | case CE_TabBarTab: never executed: case CE_TabBarTab: | 0 | ||||||||||||||||||||||||
| 4084 | if (hasStyleRule(w, PseudoElement_TabBarTab)) {
| 0 | ||||||||||||||||||||||||
| 4085 | QWindowsStyle::drawControl(ce, opt, p, w); | - | ||||||||||||||||||||||||
| 4086 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 4087 | } | - | ||||||||||||||||||||||||
| 4088 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 4089 | - | |||||||||||||||||||||||||
| 4090 | case CE_TabBarTabLabel: never executed: case CE_TabBarTabLabel: | 0 | ||||||||||||||||||||||||
| 4091 | case CE_TabBarTabShape: never executed: case CE_TabBarTabShape: | 0 | ||||||||||||||||||||||||
| 4092 | if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) {
| 0 | ||||||||||||||||||||||||
| 4093 | QRenderRule subRule = renderRule(w, opt, PseudoElement_TabBarTab); | - | ||||||||||||||||||||||||
| 4094 | QRect r = positionRect(w, subRule, PseudoElement_TabBarTab, opt->rect, opt->direction); | - | ||||||||||||||||||||||||
| 4095 | if (ce == CE_TabBarTabShape && subRule.hasDrawable()) {
| 0 | ||||||||||||||||||||||||
| 4096 | subRule.drawRule(p, r); | - | ||||||||||||||||||||||||
| 4097 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 4098 | } | - | ||||||||||||||||||||||||
| 4099 | QStyleOptionTab tabCopy(*tab); | - | ||||||||||||||||||||||||
| 4100 | subRule.configurePalette(&tabCopy.palette, QPalette::WindowText, QPalette::Window); | - | ||||||||||||||||||||||||
| 4101 | QFont oldFont = p->font(); | - | ||||||||||||||||||||||||
| 4102 | if (subRule.hasFont)
| 0 | ||||||||||||||||||||||||
| 4103 | p->setFont(subRule.font); never executed: p->setFont(subRule.font); | 0 | ||||||||||||||||||||||||
| 4104 | if (subRule.hasBox() || !subRule.hasNativeBorder()) {
| 0 | ||||||||||||||||||||||||
| 4105 | tabCopy.rect = ce == CE_TabBarTabShape ? subRule.borderRect(r)
| 0 | ||||||||||||||||||||||||
| 4106 | : subRule.contentsRect(r); | - | ||||||||||||||||||||||||
| 4107 | QWindowsStyle::drawControl(ce, &tabCopy, p, w); | - | ||||||||||||||||||||||||
| 4108 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 4109 | baseStyle()->drawControl(ce, &tabCopy, p, w); | - | ||||||||||||||||||||||||
| 4110 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4111 | if (subRule.hasFont)
| 0 | ||||||||||||||||||||||||
| 4112 | p->setFont(oldFont); never executed: p->setFont(oldFont); | 0 | ||||||||||||||||||||||||
| 4113 | - | |||||||||||||||||||||||||
| 4114 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 4115 | } | - | ||||||||||||||||||||||||
| 4116 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 4117 | #endif // QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 4118 | - | |||||||||||||||||||||||||
| 4119 | case CE_ColumnViewGrip: never executed: case CE_ColumnViewGrip: | 0 | ||||||||||||||||||||||||
| 4120 | if (rule.hasDrawable()) {
| 0 | ||||||||||||||||||||||||
| 4121 | rule.drawRule(p, opt->rect); | - | ||||||||||||||||||||||||
| 4122 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 4123 | } | - | ||||||||||||||||||||||||
| 4124 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 4125 | - | |||||||||||||||||||||||||
| 4126 | case CE_DockWidgetTitle: never executed: case CE_DockWidgetTitle: | 0 | ||||||||||||||||||||||||
| 4127 | if (const QStyleOptionDockWidget *dwOpt = qstyleoption_cast<const QStyleOptionDockWidget *>(opt)) {
| 0 | ||||||||||||||||||||||||
| 4128 | QRenderRule subRule = renderRule(w, opt, PseudoElement_DockWidgetTitle); | - | ||||||||||||||||||||||||
| 4129 | if (!subRule.hasDrawable() && !subRule.hasPosition())
| 0 | ||||||||||||||||||||||||
| 4130 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 4131 | if (subRule.hasDrawable()) {
| 0 | ||||||||||||||||||||||||
| 4132 | subRule.drawRule(p, opt->rect); | - | ||||||||||||||||||||||||
| 4133 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 4134 | QStyleOptionDockWidget dwCopy(*dwOpt); | - | ||||||||||||||||||||||||
| 4135 | dwCopy.title = QString(); | - | ||||||||||||||||||||||||
| 4136 | baseStyle()->drawControl(ce, &dwCopy, p, w); | - | ||||||||||||||||||||||||
| 4137 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4138 | - | |||||||||||||||||||||||||
| 4139 | if (!dwOpt->title.isEmpty()) {
| 0 | ||||||||||||||||||||||||
| 4140 | QRect r = subElementRect(SE_DockWidgetTitleBarText, opt, w); | - | ||||||||||||||||||||||||
| 4141 | if (dwOpt->verticalTitleBar) {
| 0 | ||||||||||||||||||||||||
| 4142 | r .setSize(= r.size().transposed());(); | - | ||||||||||||||||||||||||
| 4143 | p->save(); | - | ||||||||||||||||||||||||
| 4144 | p->translate(r.left(), r.top() + r.width()); | - | ||||||||||||||||||||||||
| 4145 | p->rotate(-90); | - | ||||||||||||||||||||||||
| 4146 | p->translate(-r.left(), -r.top()); | - | ||||||||||||||||||||||||
| 4147 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4148 | r = subRule.contentsRect(r); | - | ||||||||||||||||||||||||
| 4149 | - | |||||||||||||||||||||||||
| 4150 | Qt::Alignment alignment = 0; | - | ||||||||||||||||||||||||
| 4151 | if (subRule.hasPosition())
| 0 | ||||||||||||||||||||||||
| 4152 | alignment = subRule.position()->textAlignment; never executed: alignment = subRule.position()->textAlignment; | 0 | ||||||||||||||||||||||||
| 4153 | if (alignment == 0)
| 0 | ||||||||||||||||||||||||
| 4154 | alignment = Qt::AlignLeft; never executed: alignment = Qt::AlignLeft; | 0 | ||||||||||||||||||||||||
| 4155 | - | |||||||||||||||||||||||||
| 4156 | QString titleText = p->fontMetrics().elidedText(dwOpt->title, Qt::ElideRight, r.width()); | - | ||||||||||||||||||||||||
| 4157 | drawItemText(p, r, | - | ||||||||||||||||||||||||
| 4158 | alignment | Qt::TextShowMnemonic, dwOpt->palette, | - | ||||||||||||||||||||||||
| 4159 | dwOpt->state & State_Enabled, titleText, | - | ||||||||||||||||||||||||
| 4160 | QPalette::WindowText); | - | ||||||||||||||||||||||||
| 4161 | - | |||||||||||||||||||||||||
| 4162 | if (dwOpt->verticalTitleBar)
| 0 | ||||||||||||||||||||||||
| 4163 | p->restore(); never executed: p->restore(); | 0 | ||||||||||||||||||||||||
| 4164 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4165 | - | |||||||||||||||||||||||||
| 4166 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 4167 | } | - | ||||||||||||||||||||||||
| 4168 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 4169 | case CE_ShapedFrame: never executed: case CE_ShapedFrame: | 0 | ||||||||||||||||||||||||
| 4170 | if (const QStyleOptionFrame *frm = qstyleoption_cast<const QStyleOptionFrame *>(opt)) {
| 0 | ||||||||||||||||||||||||
| 4171 | if (rule.hasNativeBorder()) {
| 0 | ||||||||||||||||||||||||
| 4172 | QStyleOptionFrame frmOpt(*frm); | - | ||||||||||||||||||||||||
| 4173 | rule.configurePalette(&frmOpt.palette, QPalette::Text, QPalette::Base); | - | ||||||||||||||||||||||||
| 4174 | frmOpt.rect = rule.borderRect(frmOpt.rect); | - | ||||||||||||||||||||||||
| 4175 | baseStyle()->drawControl(ce, &frmOpt, p, w); | - | ||||||||||||||||||||||||
| 4176 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4177 | // else, borders are already drawn in PE_Widget | - | ||||||||||||||||||||||||
| 4178 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4179 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 4180 | - | |||||||||||||||||||||||||
| 4181 | - | |||||||||||||||||||||||||
| 4182 | default: never executed: default: | 0 | ||||||||||||||||||||||||
| 4183 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 4184 | } | - | ||||||||||||||||||||||||
| 4185 | - | |||||||||||||||||||||||||
| 4186 | if (pe1 != PseudoElement_None) {
| 0 | ||||||||||||||||||||||||
| 4187 | QRenderRule subRule = renderRule(w, opt, pe1); | - | ||||||||||||||||||||||||
| 4188 | if (subRule.bg != 0 || subRule.hasDrawable()) {
| 0 | ||||||||||||||||||||||||
| 4189 | //We test subRule.bg directly because hasBackground() would return false for background:none. | - | ||||||||||||||||||||||||
| 4190 | //But we still don't want the default drawning in that case (example for QScrollBar::add-page) (task 198926) | - | ||||||||||||||||||||||||
| 4191 | subRule.drawRule(p, opt->rect); | - | ||||||||||||||||||||||||
| 4192 | } else if (fallback) { never executed: end of block
| 0 | ||||||||||||||||||||||||
| 4193 | QWindowsStyle::drawControl(ce, opt, p, w); | - | ||||||||||||||||||||||||
| 4194 | pe2 = PseudoElement_None; | - | ||||||||||||||||||||||||
| 4195 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 4196 | baseStyle()->drawControl(ce, opt, p, w); | - | ||||||||||||||||||||||||
| 4197 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4198 | if (pe2 != PseudoElement_None) {
| 0 | ||||||||||||||||||||||||
| 4199 | QRenderRule subSubRule = renderRule(w, opt, pe2); | - | ||||||||||||||||||||||||
| 4200 | QRect r = positionRect(w, subRule, subSubRule, pe2, opt->rect, opt->direction); | - | ||||||||||||||||||||||||
| 4201 | subSubRule.drawRule(p, r); | - | ||||||||||||||||||||||||
| 4202 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4203 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 4204 | } | - | ||||||||||||||||||||||||
| 4205 | - | |||||||||||||||||||||||||
| 4206 | baseStyle()->drawControl(ce, opt, p, w); | - | ||||||||||||||||||||||||
| 4207 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 4208 | - | |||||||||||||||||||||||||
| 4209 | void QStyleSheetStyle::drawItemPixmap(QPainter *p, const QRect &rect, int alignment, const | - | ||||||||||||||||||||||||
| 4210 | QPixmap &pixmap) const | - | ||||||||||||||||||||||||
| 4211 | { | - | ||||||||||||||||||||||||
| 4212 | baseStyle()->drawItemPixmap(p, rect, alignment, pixmap); | - | ||||||||||||||||||||||||
| 4213 | } | - | ||||||||||||||||||||||||
| 4214 | - | |||||||||||||||||||||||||
| 4215 | void QStyleSheetStyle::drawItemText(QPainter *painter, const QRect& rect, int alignment, const QPalette &pal, | - | ||||||||||||||||||||||||
| 4216 | bool enabled, const QString& text, QPalette::ColorRole textRole) const | - | ||||||||||||||||||||||||
| 4217 | { | - | ||||||||||||||||||||||||
| 4218 | baseStyle()->drawItemText(painter, rect, alignment, pal, enabled, text, textRole); | - | ||||||||||||||||||||||||
| 4219 | } | - | ||||||||||||||||||||||||
| 4220 | - | |||||||||||||||||||||||||
| 4221 | void QStyleSheetStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, | - | ||||||||||||||||||||||||
| 4222 | const QWidget *w) const | - | ||||||||||||||||||||||||
| 4223 | { | - | ||||||||||||||||||||||||
| 4224 | RECURSION_GUARD(baseStyle()->drawPrimitive(pe, opt, p, w); return) | - | ||||||||||||||||||||||||
| 4225 | - | |||||||||||||||||||||||||
| 4226 | int pseudoElement = PseudoElement_None; | - | ||||||||||||||||||||||||
| 4227 | QRenderRule rule = renderRule(w, opt); | - | ||||||||||||||||||||||||
| 4228 | QRect rect = opt->rect; | - | ||||||||||||||||||||||||
| 4229 | - | |||||||||||||||||||||||||
| 4230 | switch (pe) { | - | ||||||||||||||||||||||||
| 4231 | - | |||||||||||||||||||||||||
| 4232 | case PE_FrameStatusBar: { | - | ||||||||||||||||||||||||
| 4233 | QRenderRule subRule = renderRule(w ? w->parentWidget() : Q_NULLPTR, opt, PseudoElement_Item); | - | ||||||||||||||||||||||||
| 4234 | if (subRule.hasDrawable()) { | - | ||||||||||||||||||||||||
| 4235 | subRule.drawRule(p, opt->rect); | - | ||||||||||||||||||||||||
| 4236 | return; | - | ||||||||||||||||||||||||
| 4237 | } | - | ||||||||||||||||||||||||
| 4238 | break; | - | ||||||||||||||||||||||||
| 4239 | } | - | ||||||||||||||||||||||||
| 4240 | - | |||||||||||||||||||||||||
| 4241 | case PE_IndicatorArrowDown: | - | ||||||||||||||||||||||||
| 4242 | pseudoElement = PseudoElement_DownArrow; | - | ||||||||||||||||||||||||
| 4243 | break; | - | ||||||||||||||||||||||||
| 4244 | - | |||||||||||||||||||||||||
| 4245 | case PE_IndicatorArrowUp: | - | ||||||||||||||||||||||||
| 4246 | pseudoElement = PseudoElement_UpArrow; | - | ||||||||||||||||||||||||
| 4247 | break; | - | ||||||||||||||||||||||||
| 4248 | - | |||||||||||||||||||||||||
| 4249 | case PE_IndicatorRadioButton: | - | ||||||||||||||||||||||||
| 4250 | pseudoElement = PseudoElement_ExclusiveIndicator; | - | ||||||||||||||||||||||||
| 4251 | break; | - | ||||||||||||||||||||||||
| 4252 | - | |||||||||||||||||||||||||
| 4253 | case PE_IndicatorViewItemCheck: | - | ||||||||||||||||||||||||
| 4254 | pseudoElement = PseudoElement_ViewItemIndicator; | - | ||||||||||||||||||||||||
| 4255 | break; | - | ||||||||||||||||||||||||
| 4256 | - | |||||||||||||||||||||||||
| 4257 | case PE_IndicatorCheckBox: | - | ||||||||||||||||||||||||
| 4258 | pseudoElement = PseudoElement_Indicator; | - | ||||||||||||||||||||||||
| 4259 | break; | - | ||||||||||||||||||||||||
| 4260 | - | |||||||||||||||||||||||||
| 4261 | case PE_IndicatorHeaderArrow: | - | ||||||||||||||||||||||||
| 4262 | if (const QStyleOptionHeader *hdr = qstyleoption_cast<const QStyleOptionHeader *>(opt)) { | - | ||||||||||||||||||||||||
| 4263 | pseudoElement = hdr->sortIndicator == QStyleOptionHeader::SortUp | - | ||||||||||||||||||||||||
| 4264 | ? PseudoElement_HeaderViewUpArrow | - | ||||||||||||||||||||||||
| 4265 | : PseudoElement_HeaderViewDownArrow; | - | ||||||||||||||||||||||||
| 4266 | } | - | ||||||||||||||||||||||||
| 4267 | break; | - | ||||||||||||||||||||||||
| 4268 | - | |||||||||||||||||||||||||
| 4269 | case PE_PanelButtonTool: | - | ||||||||||||||||||||||||
| 4270 | case PE_PanelButtonCommand: | - | ||||||||||||||||||||||||
| 4271 | if (qobject_cast<const QAbstractButton *>(w) && rule.hasBackground() && rule.hasNativeBorder()) { | - | ||||||||||||||||||||||||
| 4272 | //the window style will draw the borders | - | ||||||||||||||||||||||||
| 4273 | ParentStyle::drawPrimitive(pe, opt, p, w); | - | ||||||||||||||||||||||||
| 4274 | if (!rule.background()->pixmap.isNull() || rule.hasImage()) { | - | ||||||||||||||||||||||||
| 4275 | rule.drawRule(p, rule.boxRect(opt->rect, QRenderRule::Margin).adjusted(1,1,-1,-1)); | - | ||||||||||||||||||||||||
| 4276 | } | - | ||||||||||||||||||||||||
| 4277 | return; | - | ||||||||||||||||||||||||
| 4278 | } | - | ||||||||||||||||||||||||
| 4279 | if (!rule.hasNativeBorder()) { | - | ||||||||||||||||||||||||
| 4280 | rule.drawRule(p, rule.boxRect(opt->rect, QRenderRule::Margin)); | - | ||||||||||||||||||||||||
| 4281 | return; | - | ||||||||||||||||||||||||
| 4282 | } | - | ||||||||||||||||||||||||
| 4283 | break; | - | ||||||||||||||||||||||||
| 4284 | - | |||||||||||||||||||||||||
| 4285 | case PE_IndicatorButtonDropDown: { | - | ||||||||||||||||||||||||
| 4286 | QRenderRule subRule = renderRule(w, opt, PseudoElement_ToolButtonMenu); | - | ||||||||||||||||||||||||
| 4287 | if (!subRule.hasNativeBorder()) { | - | ||||||||||||||||||||||||
| 4288 | rule.drawBorder(p, opt->rect); | - | ||||||||||||||||||||||||
| 4289 | return; | - | ||||||||||||||||||||||||
| 4290 | } | - | ||||||||||||||||||||||||
| 4291 | break; | - | ||||||||||||||||||||||||
| 4292 | } | - | ||||||||||||||||||||||||
| 4293 | - | |||||||||||||||||||||||||
| 4294 | case PE_FrameDefaultButton: | - | ||||||||||||||||||||||||
| 4295 | if (rule.hasNativeBorder()) { | - | ||||||||||||||||||||||||
| 4296 | if (rule.baseStyleCanDraw()) | - | ||||||||||||||||||||||||
| 4297 | break; | - | ||||||||||||||||||||||||
| 4298 | QWindowsStyle::drawPrimitive(pe, opt, p, w); | - | ||||||||||||||||||||||||
| 4299 | } | - | ||||||||||||||||||||||||
| 4300 | return; | - | ||||||||||||||||||||||||
| 4301 | - | |||||||||||||||||||||||||
| 4302 | case PE_FrameWindow: | - | ||||||||||||||||||||||||
| 4303 | case PE_FrameDockWidget: | - | ||||||||||||||||||||||||
| 4304 | case PE_Frame: | - | ||||||||||||||||||||||||
| 4305 | if (const QStyleOptionFrame *frm = qstyleoption_cast<const QStyleOptionFrame *>(opt)) { | - | ||||||||||||||||||||||||
| 4306 | if (rule.hasNativeBorder()) { | - | ||||||||||||||||||||||||
| 4307 | QStyleOptionFrame frmOpt(*frm); | - | ||||||||||||||||||||||||
| 4308 | rule.configurePalette(&frmOpt.palette, QPalette::Text, QPalette::Base); | - | ||||||||||||||||||||||||
| 4309 | baseStyle()->drawPrimitive(pe, &frmOpt, p, w); | - | ||||||||||||||||||||||||
| 4310 | } else { | - | ||||||||||||||||||||||||
| 4311 | rule.drawBorder(p, rule.borderRect(opt->rect)); | - | ||||||||||||||||||||||||
| 4312 | } | - | ||||||||||||||||||||||||
| 4313 | } | - | ||||||||||||||||||||||||
| 4314 | return; | - | ||||||||||||||||||||||||
| 4315 | - | |||||||||||||||||||||||||
| 4316 | case PE_PanelLineEdit: | - | ||||||||||||||||||||||||
| 4317 | if (const QStyleOptionFrame *frm = qstyleoption_cast<const QStyleOptionFrame *>(opt)) { | - | ||||||||||||||||||||||||
| 4318 | #ifndef QT_NO_SPINBOX | - | ||||||||||||||||||||||||
| 4319 | if (w && qobject_cast<const QAbstractSpinBox *>(w->parentWidget())) { | - | ||||||||||||||||||||||||
| 4320 | QRenderRule spinboxRule = renderRule(w->parentWidget(), opt); | - | ||||||||||||||||||||||||
| 4321 | if (!spinboxRule.hasNativeBorder() || !spinboxRule.baseStyleCanDraw()) | - | ||||||||||||||||||||||||
| 4322 | return; | - | ||||||||||||||||||||||||
| 4323 | rule = spinboxRule; | - | ||||||||||||||||||||||||
| 4324 | } | - | ||||||||||||||||||||||||
| 4325 | #endif | - | ||||||||||||||||||||||||
| 4326 | if (rule.hasNativeBorder()) { | - | ||||||||||||||||||||||||
| 4327 | QStyleOptionFrame frmOpt(*frm); | - | ||||||||||||||||||||||||
| 4328 | rule.configurePalette(&frmOpt.palette, QPalette::Text, QPalette::Base); | - | ||||||||||||||||||||||||
| 4329 | frmOpt.rect = rule.borderRect(frmOpt.rect); | - | ||||||||||||||||||||||||
| 4330 | if (rule.baseStyleCanDraw()) { | - | ||||||||||||||||||||||||
| 4331 | rule.drawBackgroundImage(p, opt->rect); | - | ||||||||||||||||||||||||
| 4332 | baseStyle()->drawPrimitive(pe, &frmOpt, p, w); | - | ||||||||||||||||||||||||
| 4333 | } else { | - | ||||||||||||||||||||||||
| 4334 | rule.drawBackground(p, opt->rect); | - | ||||||||||||||||||||||||
| 4335 | if (frmOpt.lineWidth > 0) | - | ||||||||||||||||||||||||
| 4336 | baseStyle()->drawPrimitive(PE_FrameLineEdit, &frmOpt, p, w); | - | ||||||||||||||||||||||||
| 4337 | } | - | ||||||||||||||||||||||||
| 4338 | } else { | - | ||||||||||||||||||||||||
| 4339 | rule.drawRule(p, opt->rect); | - | ||||||||||||||||||||||||
| 4340 | } | - | ||||||||||||||||||||||||
| 4341 | } | - | ||||||||||||||||||||||||
| 4342 | return; | - | ||||||||||||||||||||||||
| 4343 | - | |||||||||||||||||||||||||
| 4344 | case PE_Widget: | - | ||||||||||||||||||||||||
| 4345 | if (w && !rule.hasDrawable()) { | - | ||||||||||||||||||||||||
| 4346 | QWidget *container = containerWidget(w); | - | ||||||||||||||||||||||||
| 4347 | if (styleSheetCaches->autoFillDisabledWidgets.contains(container) | - | ||||||||||||||||||||||||
| 4348 | && (container == w || !renderRule(container, opt).hasBackground())) { | - | ||||||||||||||||||||||||
| 4349 | //we do not have a background, but we disabled the autofillbackground anyway. so fill the background now. | - | ||||||||||||||||||||||||
| 4350 | // (this may happen if we have rules like :focus) | - | ||||||||||||||||||||||||
| 4351 | p->fillRect(opt->rect, opt->palette.brush(w->backgroundRole())); | - | ||||||||||||||||||||||||
| 4352 | } | - | ||||||||||||||||||||||||
| 4353 | break; | - | ||||||||||||||||||||||||
| 4354 | } | - | ||||||||||||||||||||||||
| 4355 | #ifndef QT_NO_SCROLLAREA | - | ||||||||||||||||||||||||
| 4356 | if (const QAbstractScrollArea *sa = qobject_cast<const QAbstractScrollArea *>(w)) { | - | ||||||||||||||||||||||||
| 4357 | const QAbstractScrollAreaPrivate *sap = sa->d_func(); | - | ||||||||||||||||||||||||
| 4358 | rule.drawBackground(p, opt->rect, sap->contentsOffset()); | - | ||||||||||||||||||||||||
| 4359 | if (rule.hasBorder()) { | - | ||||||||||||||||||||||||
| 4360 | QRect brect = rule.borderRect(opt->rect); | - | ||||||||||||||||||||||||
| 4361 | if (styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents, opt, w)) { | - | ||||||||||||||||||||||||
| 4362 | QRect r = brect.adjusted(0, 0, sa->verticalScrollBar()->isVisible() ? -sa->verticalScrollBar()->width() : 0, | - | ||||||||||||||||||||||||
| 4363 | sa->horizontalScrollBar()->isVisible() ? -sa->horizontalScrollBar()->height() : 0); | - | ||||||||||||||||||||||||
| 4364 | brect = QStyle::visualRect(opt->direction, brect, r); | - | ||||||||||||||||||||||||
| 4365 | } | - | ||||||||||||||||||||||||
| 4366 | rule.drawBorder(p, brect); | - | ||||||||||||||||||||||||
| 4367 | } | - | ||||||||||||||||||||||||
| 4368 | break; | - | ||||||||||||||||||||||||
| 4369 | } | - | ||||||||||||||||||||||||
| 4370 | #endif | - | ||||||||||||||||||||||||
| 4371 | //fall tghought | - | ||||||||||||||||||||||||
| 4372 | case PE_PanelMenu: | - | ||||||||||||||||||||||||
| 4373 | case PE_PanelStatusBar: | - | ||||||||||||||||||||||||
| 4374 | if(rule.hasDrawable()) { | - | ||||||||||||||||||||||||
| 4375 | rule.drawRule(p, opt->rect); | - | ||||||||||||||||||||||||
| 4376 | return; | - | ||||||||||||||||||||||||
| 4377 | } | - | ||||||||||||||||||||||||
| 4378 | break; | - | ||||||||||||||||||||||||
| 4379 | - | |||||||||||||||||||||||||
| 4380 | case PE_FrameMenu: | - | ||||||||||||||||||||||||
| 4381 | if (rule.hasDrawable()) { | - | ||||||||||||||||||||||||
| 4382 | // Drawn by PE_PanelMenu | - | ||||||||||||||||||||||||
| 4383 | return; | - | ||||||||||||||||||||||||
| 4384 | } | - | ||||||||||||||||||||||||
| 4385 | break; | - | ||||||||||||||||||||||||
| 4386 | - | |||||||||||||||||||||||||
| 4387 | case PE_PanelMenuBar: | - | ||||||||||||||||||||||||
| 4388 | if (rule.hasDrawable()) { | - | ||||||||||||||||||||||||
| 4389 | // Drawn by PE_Widget | - | ||||||||||||||||||||||||
| 4390 | return; | - | ||||||||||||||||||||||||
| 4391 | } | - | ||||||||||||||||||||||||
| 4392 | break; | - | ||||||||||||||||||||||||
| 4393 | - | |||||||||||||||||||||||||
| 4394 | case PE_IndicatorToolBarSeparator: | - | ||||||||||||||||||||||||
| 4395 | case PE_IndicatorToolBarHandle: { | - | ||||||||||||||||||||||||
| 4396 | PseudoElement ps = pe == PE_IndicatorToolBarHandle ? PseudoElement_ToolBarHandle : PseudoElement_ToolBarSeparator; | - | ||||||||||||||||||||||||
| 4397 | QRenderRule subRule = renderRule(w, opt, ps); | - | ||||||||||||||||||||||||
| 4398 | if (subRule.hasDrawable()) { | - | ||||||||||||||||||||||||
| 4399 | subRule.drawRule(p, opt->rect); | - | ||||||||||||||||||||||||
| 4400 | return; | - | ||||||||||||||||||||||||
| 4401 | } | - | ||||||||||||||||||||||||
| 4402 | } | - | ||||||||||||||||||||||||
| 4403 | break; | - | ||||||||||||||||||||||||
| 4404 | - | |||||||||||||||||||||||||
| 4405 | case PE_IndicatorMenuCheckMark: | - | ||||||||||||||||||||||||
| 4406 | pseudoElement = PseudoElement_MenuCheckMark; | - | ||||||||||||||||||||||||
| 4407 | break; | - | ||||||||||||||||||||||||
| 4408 | - | |||||||||||||||||||||||||
| 4409 | case PE_IndicatorArrowLeft: | - | ||||||||||||||||||||||||
| 4410 | pseudoElement = PseudoElement_LeftArrow; | - | ||||||||||||||||||||||||
| 4411 | break; | - | ||||||||||||||||||||||||
| 4412 | - | |||||||||||||||||||||||||
| 4413 | case PE_IndicatorArrowRight: | - | ||||||||||||||||||||||||
| 4414 | pseudoElement = PseudoElement_RightArrow; | - | ||||||||||||||||||||||||
| 4415 | break; | - | ||||||||||||||||||||||||
| 4416 | - | |||||||||||||||||||||||||
| 4417 | case PE_IndicatorColumnViewArrow: | - | ||||||||||||||||||||||||
| 4418 | if (const QStyleOptionViewItem *viewOpt = qstyleoption_cast<const QStyleOptionViewItem *>(opt)) { | - | ||||||||||||||||||||||||
| 4419 | bool reverse = (viewOpt->direction == Qt::RightToLeft); | - | ||||||||||||||||||||||||
| 4420 | pseudoElement = reverse ? PseudoElement_LeftArrow : PseudoElement_RightArrow; | - | ||||||||||||||||||||||||
| 4421 | } else { | - | ||||||||||||||||||||||||
| 4422 | pseudoElement = PseudoElement_RightArrow; | - | ||||||||||||||||||||||||
| 4423 | } | - | ||||||||||||||||||||||||
| 4424 | break; | - | ||||||||||||||||||||||||
| 4425 | - | |||||||||||||||||||||||||
| 4426 | case PE_IndicatorBranch: | - | ||||||||||||||||||||||||
| 4427 | if (const QStyleOptionViewItem *vopt = qstyleoption_cast<const QStyleOptionViewItem *>(opt)) { | - | ||||||||||||||||||||||||
| 4428 | QRenderRule subRule = renderRule(w, opt, PseudoElement_TreeViewBranch); | - | ||||||||||||||||||||||||
| 4429 | if (subRule.hasDrawable()) { | - | ||||||||||||||||||||||||
| 4430 | if ((vopt->state & QStyle::State_Selected) && vopt->showDecorationSelected) | - | ||||||||||||||||||||||||
| 4431 | p->fillRect(vopt->rect, vopt->palette.highlight()); | - | ||||||||||||||||||||||||
| 4432 | else if (vopt->features & QStyleOptionViewItem::Alternate) | - | ||||||||||||||||||||||||
| 4433 | p->fillRect(vopt->rect, vopt->palette.alternateBase()); | - | ||||||||||||||||||||||||
| 4434 | subRule.drawRule(p, opt->rect); | - | ||||||||||||||||||||||||
| 4435 | } else { | - | ||||||||||||||||||||||||
| 4436 | baseStyle()->drawPrimitive(pe, vopt, p, w); | - | ||||||||||||||||||||||||
| 4437 | } | - | ||||||||||||||||||||||||
| 4438 | } | - | ||||||||||||||||||||||||
| 4439 | return; | - | ||||||||||||||||||||||||
| 4440 | - | |||||||||||||||||||||||||
| 4441 | case PE_PanelTipLabel: | - | ||||||||||||||||||||||||
| 4442 | if (!rule.hasDrawable()) | - | ||||||||||||||||||||||||
| 4443 | break; | - | ||||||||||||||||||||||||
| 4444 | - | |||||||||||||||||||||||||
| 4445 | if (const QStyleOptionFrame *frmOpt = qstyleoption_cast<const QStyleOptionFrame *>(opt)) { | - | ||||||||||||||||||||||||
| 4446 | if (rule.hasNativeBorder()) { | - | ||||||||||||||||||||||||
| 4447 | rule.drawBackground(p, opt->rect); | - | ||||||||||||||||||||||||
| 4448 | QStyleOptionFrame optCopy(*frmOpt); | - | ||||||||||||||||||||||||
| 4449 | optCopy.rect = rule.borderRect(opt->rect); | - | ||||||||||||||||||||||||
| 4450 | optCopy.palette.setBrush(QPalette::Window, Qt::NoBrush); // oh dear | - | ||||||||||||||||||||||||
| 4451 | baseStyle()->drawPrimitive(pe, &optCopy, p, w); | - | ||||||||||||||||||||||||
| 4452 | } else { | - | ||||||||||||||||||||||||
| 4453 | rule.drawRule(p, opt->rect); | - | ||||||||||||||||||||||||
| 4454 | } | - | ||||||||||||||||||||||||
| 4455 | } | - | ||||||||||||||||||||||||
| 4456 | return; | - | ||||||||||||||||||||||||
| 4457 | - | |||||||||||||||||||||||||
| 4458 | case PE_FrameGroupBox: | - | ||||||||||||||||||||||||
| 4459 | if (rule.hasNativeBorder()) | - | ||||||||||||||||||||||||
| 4460 | break; | - | ||||||||||||||||||||||||
| 4461 | rule.drawBorder(p, opt->rect); | - | ||||||||||||||||||||||||
| 4462 | return; | - | ||||||||||||||||||||||||
| 4463 | - | |||||||||||||||||||||||||
| 4464 | #ifndef QT_NO_TABWIDGET | - | ||||||||||||||||||||||||
| 4465 | case PE_FrameTabWidget: | - | ||||||||||||||||||||||||
| 4466 | if (const QStyleOptionTabWidgetFrame *frm = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(opt)) { | - | ||||||||||||||||||||||||
| 4467 | QRenderRule subRule = renderRule(w, opt, PseudoElement_TabWidgetPane); | - | ||||||||||||||||||||||||
| 4468 | if (subRule.hasNativeBorder()) { | - | ||||||||||||||||||||||||
| 4469 | subRule.drawBackground(p, opt->rect); | - | ||||||||||||||||||||||||
| 4470 | QStyleOptionTabWidgetFrame frmCopy(*frm); | - | ||||||||||||||||||||||||
| 4471 | subRule.configurePalette(&frmCopy.palette, QPalette::WindowText, QPalette::Window); | - | ||||||||||||||||||||||||
| 4472 | baseStyle()->drawPrimitive(pe, &frmCopy, p, w); | - | ||||||||||||||||||||||||
| 4473 | } else { | - | ||||||||||||||||||||||||
| 4474 | subRule.drawRule(p, opt->rect); | - | ||||||||||||||||||||||||
| 4475 | } | - | ||||||||||||||||||||||||
| 4476 | return; | - | ||||||||||||||||||||||||
| 4477 | } | - | ||||||||||||||||||||||||
| 4478 | break; | - | ||||||||||||||||||||||||
| 4479 | #endif // QT_NO_TABWIDGET | - | ||||||||||||||||||||||||
| 4480 | - | |||||||||||||||||||||||||
| 4481 | case PE_IndicatorProgressChunk: | - | ||||||||||||||||||||||||
| 4482 | pseudoElement = PseudoElement_ProgressBarChunk; | - | ||||||||||||||||||||||||
| 4483 | break; | - | ||||||||||||||||||||||||
| 4484 | - | |||||||||||||||||||||||||
| 4485 | case PE_IndicatorTabTear: | - | ||||||||||||||||||||||||
| 4486 | pseudoElement = PseudoElement_TabBarTear; | - | ||||||||||||||||||||||||
| 4487 | break; | - | ||||||||||||||||||||||||
| 4488 | - | |||||||||||||||||||||||||
| 4489 | case PE_FrameFocusRect: | - | ||||||||||||||||||||||||
| 4490 | if (!rule.hasNativeOutline()) { | - | ||||||||||||||||||||||||
| 4491 | rule.drawOutline(p, opt->rect); | - | ||||||||||||||||||||||||
| 4492 | return; | - | ||||||||||||||||||||||||
| 4493 | } | - | ||||||||||||||||||||||||
| 4494 | break; | - | ||||||||||||||||||||||||
| 4495 | - | |||||||||||||||||||||||||
| 4496 | case PE_IndicatorDockWidgetResizeHandle: | - | ||||||||||||||||||||||||
| 4497 | pseudoElement = PseudoElement_DockWidgetSeparator; | - | ||||||||||||||||||||||||
| 4498 | break; | - | ||||||||||||||||||||||||
| 4499 | - | |||||||||||||||||||||||||
| 4500 | case PE_PanelItemViewItem: | - | ||||||||||||||||||||||||
| 4501 | pseudoElement = PseudoElement_ViewItem; | - | ||||||||||||||||||||||||
| 4502 | break; | - | ||||||||||||||||||||||||
| 4503 | - | |||||||||||||||||||||||||
| 4504 | case PE_PanelScrollAreaCorner: | - | ||||||||||||||||||||||||
| 4505 | pseudoElement = PseudoElement_ScrollAreaCorner; | - | ||||||||||||||||||||||||
| 4506 | break; | - | ||||||||||||||||||||||||
| 4507 | - | |||||||||||||||||||||||||
| 4508 | case PE_IndicatorSpinDown: | - | ||||||||||||||||||||||||
| 4509 | case PE_IndicatorSpinMinus: | - | ||||||||||||||||||||||||
| 4510 | pseudoElement = PseudoElement_SpinBoxDownArrow; | - | ||||||||||||||||||||||||
| 4511 | break; | - | ||||||||||||||||||||||||
| 4512 | - | |||||||||||||||||||||||||
| 4513 | case PE_IndicatorSpinUp: | - | ||||||||||||||||||||||||
| 4514 | case PE_IndicatorSpinPlus: | - | ||||||||||||||||||||||||
| 4515 | pseudoElement = PseudoElement_SpinBoxUpArrow; | - | ||||||||||||||||||||||||
| 4516 | break; | - | ||||||||||||||||||||||||
| 4517 | #ifndef QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 4518 | case PE_IndicatorTabClose: | - | ||||||||||||||||||||||||
| 4519 | if (w) | - | ||||||||||||||||||||||||
| 4520 | w = w->parentWidget(); //match on the QTabBar instead of the CloseButton | - | ||||||||||||||||||||||||
| 4521 | pseudoElement = PseudoElement_TabBarTabCloseButton; | - | ||||||||||||||||||||||||
| 4522 | #endif | - | ||||||||||||||||||||||||
| 4523 | - | |||||||||||||||||||||||||
| 4524 | default: | - | ||||||||||||||||||||||||
| 4525 | break; | - | ||||||||||||||||||||||||
| 4526 | } | - | ||||||||||||||||||||||||
| 4527 | - | |||||||||||||||||||||||||
| 4528 | if (pseudoElement != PseudoElement_None) { | - | ||||||||||||||||||||||||
| 4529 | QRenderRule subRule = renderRule(w, opt, pseudoElement); | - | ||||||||||||||||||||||||
| 4530 | if (subRule.hasDrawable()) { | - | ||||||||||||||||||||||||
| 4531 | subRule.drawRule(p, rect); | - | ||||||||||||||||||||||||
| 4532 | } else { | - | ||||||||||||||||||||||||
| 4533 | baseStyle()->drawPrimitive(pe, opt, p, w); | - | ||||||||||||||||||||||||
| 4534 | } | - | ||||||||||||||||||||||||
| 4535 | } else { | - | ||||||||||||||||||||||||
| 4536 | baseStyle()->drawPrimitive(pe, opt, p, w); | - | ||||||||||||||||||||||||
| 4537 | } | - | ||||||||||||||||||||||||
| 4538 | } | - | ||||||||||||||||||||||||
| 4539 | - | |||||||||||||||||||||||||
| 4540 | QPixmap QStyleSheetStyle::generatedIconPixmap(QIcon::Mode iconMode, const QPixmap& pixmap, | - | ||||||||||||||||||||||||
| 4541 | const QStyleOption *option) const | - | ||||||||||||||||||||||||
| 4542 | { | - | ||||||||||||||||||||||||
| 4543 | return baseStyle()->generatedIconPixmap(iconMode, pixmap, option); | - | ||||||||||||||||||||||||
| 4544 | } | - | ||||||||||||||||||||||||
| 4545 | - | |||||||||||||||||||||||||
| 4546 | QStyle::SubControl QStyleSheetStyle::hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, | - | ||||||||||||||||||||||||
| 4547 | const QPoint &pt, const QWidget *w) const | - | ||||||||||||||||||||||||
| 4548 | { | - | ||||||||||||||||||||||||
| 4549 | RECURSION_GUARD(return baseStyle()->hitTestComplexControl(cc, opt, pt, w)) | - | ||||||||||||||||||||||||
| 4550 | switch (cc) { | - | ||||||||||||||||||||||||
| 4551 | case CC_TitleBar: | - | ||||||||||||||||||||||||
| 4552 | if (const QStyleOptionTitleBar *tb = qstyleoption_cast<const QStyleOptionTitleBar *>(opt)) { | - | ||||||||||||||||||||||||
| 4553 | QRenderRule rule = renderRule(w, opt, PseudoElement_TitleBar); | - | ||||||||||||||||||||||||
| 4554 | if (rule.hasDrawable() || rule.hasBox() || rule.hasBorder()) { | - | ||||||||||||||||||||||||
| 4555 | QHash<QStyle::SubControl, QRect> layout = titleBarLayout(w, tb); | - | ||||||||||||||||||||||||
| 4556 | QRect r; | - | ||||||||||||||||||||||||
| 4557 | QStyle::SubControl sc = QStyle::SC_None; | - | ||||||||||||||||||||||||
| 4558 | uint ctrl = SC_TitleBarSysMenu; | - | ||||||||||||||||||||||||
| 4559 | while (ctrl <= SC_TitleBarLabel) { | - | ||||||||||||||||||||||||
| 4560 | r = layout[QStyle::SubControl(ctrl)]; | - | ||||||||||||||||||||||||
| 4561 | if (r.isValid() && r.contains(pt)) { | - | ||||||||||||||||||||||||
| 4562 | sc = QStyle::SubControl(ctrl); | - | ||||||||||||||||||||||||
| 4563 | break; | - | ||||||||||||||||||||||||
| 4564 | } | - | ||||||||||||||||||||||||
| 4565 | ctrl <<= 1; | - | ||||||||||||||||||||||||
| 4566 | } | - | ||||||||||||||||||||||||
| 4567 | return sc; | - | ||||||||||||||||||||||||
| 4568 | } | - | ||||||||||||||||||||||||
| 4569 | } | - | ||||||||||||||||||||||||
| 4570 | break; | - | ||||||||||||||||||||||||
| 4571 | - | |||||||||||||||||||||||||
| 4572 | case CC_MdiControls: | - | ||||||||||||||||||||||||
| 4573 | if (hasStyleRule(w, PseudoElement_MdiCloseButton) | - | ||||||||||||||||||||||||
| 4574 | || hasStyleRule(w, PseudoElement_MdiNormalButton) | - | ||||||||||||||||||||||||
| 4575 | || hasStyleRule(w, PseudoElement_MdiMinButton)) | - | ||||||||||||||||||||||||
| 4576 | return QWindowsStyle::hitTestComplexControl(cc, opt, pt, w); | - | ||||||||||||||||||||||||
| 4577 | break; | - | ||||||||||||||||||||||||
| 4578 | - | |||||||||||||||||||||||||
| 4579 | case CC_ScrollBar: { | - | ||||||||||||||||||||||||
| 4580 | QRenderRule rule = renderRule(w, opt); | - | ||||||||||||||||||||||||
| 4581 | if (!rule.hasDrawable() && !rule.hasBox()) | - | ||||||||||||||||||||||||
| 4582 | break; | - | ||||||||||||||||||||||||
| 4583 | } | - | ||||||||||||||||||||||||
| 4584 | // intentionally falls through | - | ||||||||||||||||||||||||
| 4585 | case CC_SpinBox: | - | ||||||||||||||||||||||||
| 4586 | case CC_GroupBox: | - | ||||||||||||||||||||||||
| 4587 | case CC_ComboBox: | - | ||||||||||||||||||||||||
| 4588 | case CC_Slider: | - | ||||||||||||||||||||||||
| 4589 | case CC_ToolButton: | - | ||||||||||||||||||||||||
| 4590 | return QWindowsStyle::hitTestComplexControl(cc, opt, pt, w); | - | ||||||||||||||||||||||||
| 4591 | default: | - | ||||||||||||||||||||||||
| 4592 | break; | - | ||||||||||||||||||||||||
| 4593 | } | - | ||||||||||||||||||||||||
| 4594 | - | |||||||||||||||||||||||||
| 4595 | return baseStyle()->hitTestComplexControl(cc, opt, pt, w); | - | ||||||||||||||||||||||||
| 4596 | } | - | ||||||||||||||||||||||||
| 4597 | - | |||||||||||||||||||||||||
| 4598 | QRect QStyleSheetStyle::itemPixmapRect(const QRect &rect, int alignment, const QPixmap &pixmap) const | - | ||||||||||||||||||||||||
| 4599 | { | - | ||||||||||||||||||||||||
| 4600 | return baseStyle()->itemPixmapRect(rect, alignment, pixmap); | - | ||||||||||||||||||||||||
| 4601 | } | - | ||||||||||||||||||||||||
| 4602 | - | |||||||||||||||||||||||||
| 4603 | QRect QStyleSheetStyle::itemTextRect(const QFontMetrics &metrics, const QRect& rect, int alignment, | - | ||||||||||||||||||||||||
| 4604 | bool enabled, const QString& text) const | - | ||||||||||||||||||||||||
| 4605 | { | - | ||||||||||||||||||||||||
| 4606 | return baseStyle()->itemTextRect(metrics, rect, alignment, enabled, text); | - | ||||||||||||||||||||||||
| 4607 | } | - | ||||||||||||||||||||||||
| 4608 | - | |||||||||||||||||||||||||
| 4609 | int QStyleSheetStyle::pixelMetric(PixelMetric m, const QStyleOption *opt, const QWidget *w) const | - | ||||||||||||||||||||||||
| 4610 | { | - | ||||||||||||||||||||||||
| 4611 | RECURSION_GUARD(return baseStyle()->pixelMetric(m, opt, w)) | - | ||||||||||||||||||||||||
| 4612 | - | |||||||||||||||||||||||||
| 4613 | QRenderRule rule = renderRule(w, opt); | - | ||||||||||||||||||||||||
| 4614 | QRenderRule subRule; | - | ||||||||||||||||||||||||
| 4615 | - | |||||||||||||||||||||||||
| 4616 | switch (m) { | - | ||||||||||||||||||||||||
| 4617 | case PM_MenuButtonIndicator: | - | ||||||||||||||||||||||||
| 4618 | #ifndef QT_NO_TOOLBUTTON | - | ||||||||||||||||||||||||
| 4619 | // QToolButton adds this directly to the width | - | ||||||||||||||||||||||||
| 4620 | if (qobject_cast<const QToolButton *>(w) && (rule.hasBox() || !rule.hasNativeBorder())) | - | ||||||||||||||||||||||||
| 4621 | return 0; | - | ||||||||||||||||||||||||
| 4622 | #endif | - | ||||||||||||||||||||||||
| 4623 | subRule = renderRule(w, opt, PseudoElement_PushButtonMenuIndicator); | - | ||||||||||||||||||||||||
| 4624 | if (subRule.hasContentsSize()) | - | ||||||||||||||||||||||||
| 4625 | return subRule.size().width(); | - | ||||||||||||||||||||||||
| 4626 | break; | - | ||||||||||||||||||||||||
| 4627 | - | |||||||||||||||||||||||||
| 4628 | case PM_ButtonShiftHorizontal: | - | ||||||||||||||||||||||||
| 4629 | case PM_ButtonShiftVertical: | - | ||||||||||||||||||||||||
| 4630 | case PM_ButtonMargin: | - | ||||||||||||||||||||||||
| 4631 | case PM_ButtonDefaultIndicator: | - | ||||||||||||||||||||||||
| 4632 | if (rule.hasBox()) | - | ||||||||||||||||||||||||
| 4633 | return 0; | - | ||||||||||||||||||||||||
| 4634 | break; | - | ||||||||||||||||||||||||
| 4635 | - | |||||||||||||||||||||||||
| 4636 | case PM_DefaultFrameWidth: | - | ||||||||||||||||||||||||
| 4637 | if (!rule.hasNativeBorder()) | - | ||||||||||||||||||||||||
| 4638 | return rule.border()->borders[LeftEdge]; | - | ||||||||||||||||||||||||
| 4639 | break; | - | ||||||||||||||||||||||||
| 4640 | - | |||||||||||||||||||||||||
| 4641 | case PM_ExclusiveIndicatorWidth: | - | ||||||||||||||||||||||||
| 4642 | case PM_IndicatorWidth: | - | ||||||||||||||||||||||||
| 4643 | case PM_ExclusiveIndicatorHeight: | - | ||||||||||||||||||||||||
| 4644 | case PM_IndicatorHeight: | - | ||||||||||||||||||||||||
| 4645 | subRule = renderRule(w, opt, PseudoElement_Indicator); | - | ||||||||||||||||||||||||
| 4646 | if (subRule.hasContentsSize()) { | - | ||||||||||||||||||||||||
| 4647 | return (m == PM_ExclusiveIndicatorWidth) || (m == PM_IndicatorWidth) | - | ||||||||||||||||||||||||
| 4648 | ? subRule.size().width() : subRule.size().height(); | - | ||||||||||||||||||||||||
| 4649 | } | - | ||||||||||||||||||||||||
| 4650 | break; | - | ||||||||||||||||||||||||
| 4651 | - | |||||||||||||||||||||||||
| 4652 | case PM_DockWidgetFrameWidth: | - | ||||||||||||||||||||||||
| 4653 | case PM_ToolTipLabelFrameWidth: // border + margin + padding (support only one width) | - | ||||||||||||||||||||||||
| 4654 | if (!rule.hasDrawable()) | - | ||||||||||||||||||||||||
| 4655 | break; | - | ||||||||||||||||||||||||
| 4656 | - | |||||||||||||||||||||||||
| 4657 | return (rule.border() ? rule.border()->borders[LeftEdge] : 0) | - | ||||||||||||||||||||||||
| 4658 | + (rule.hasBox() ? rule.box()->margins[LeftEdge] + rule.box()->paddings[LeftEdge]: 0); | - | ||||||||||||||||||||||||
| 4659 | - | |||||||||||||||||||||||||
| 4660 | case PM_ToolBarFrameWidth: | - | ||||||||||||||||||||||||
| 4661 | if (rule.hasBorder() || rule.hasBox()) | - | ||||||||||||||||||||||||
| 4662 | return (rule.border() ? rule.border()->borders[LeftEdge] : 0) | - | ||||||||||||||||||||||||
| 4663 | + (rule.hasBox() ? rule.box()->paddings[LeftEdge]: 0); | - | ||||||||||||||||||||||||
| 4664 | break; | - | ||||||||||||||||||||||||
| 4665 | - | |||||||||||||||||||||||||
| 4666 | case PM_MenuPanelWidth: | - | ||||||||||||||||||||||||
| 4667 | case PM_MenuBarPanelWidth: | - | ||||||||||||||||||||||||
| 4668 | if (rule.hasBorder() || rule.hasBox()) | - | ||||||||||||||||||||||||
| 4669 | return (rule.border() ? rule.border()->borders[LeftEdge] : 0) | - | ||||||||||||||||||||||||
| 4670 | + (rule.hasBox() ? rule.box()->margins[LeftEdge]: 0); | - | ||||||||||||||||||||||||
| 4671 | break; | - | ||||||||||||||||||||||||
| 4672 | - | |||||||||||||||||||||||||
| 4673 | - | |||||||||||||||||||||||||
| 4674 | case PM_MenuHMargin: | - | ||||||||||||||||||||||||
| 4675 | case PM_MenuBarHMargin: | - | ||||||||||||||||||||||||
| 4676 | if (rule.hasBox()) | - | ||||||||||||||||||||||||
| 4677 | return rule.box()->paddings[LeftEdge]; | - | ||||||||||||||||||||||||
| 4678 | break; | - | ||||||||||||||||||||||||
| 4679 | - | |||||||||||||||||||||||||
| 4680 | case PM_MenuVMargin: | - | ||||||||||||||||||||||||
| 4681 | case PM_MenuBarVMargin: | - | ||||||||||||||||||||||||
| 4682 | if (rule.hasBox()) | - | ||||||||||||||||||||||||
| 4683 | return rule.box()->paddings[TopEdge]; | - | ||||||||||||||||||||||||
| 4684 | break; | - | ||||||||||||||||||||||||
| 4685 | - | |||||||||||||||||||||||||
| 4686 | case PM_DockWidgetTitleBarButtonMargin: | - | ||||||||||||||||||||||||
| 4687 | case PM_ToolBarItemMargin: | - | ||||||||||||||||||||||||
| 4688 | if (rule.hasBox()) | - | ||||||||||||||||||||||||
| 4689 | return rule.box()->margins[TopEdge]; | - | ||||||||||||||||||||||||
| 4690 | break; | - | ||||||||||||||||||||||||
| 4691 | - | |||||||||||||||||||||||||
| 4692 | case PM_ToolBarItemSpacing: | - | ||||||||||||||||||||||||
| 4693 | case PM_MenuBarItemSpacing: | - | ||||||||||||||||||||||||
| 4694 | if (rule.hasBox() && rule.box()->spacing != -1) | - | ||||||||||||||||||||||||
| 4695 | return rule.box()->spacing; | - | ||||||||||||||||||||||||
| 4696 | break; | - | ||||||||||||||||||||||||
| 4697 | - | |||||||||||||||||||||||||
| 4698 | case PM_MenuTearoffHeight: | - | ||||||||||||||||||||||||
| 4699 | case PM_MenuScrollerHeight: { | - | ||||||||||||||||||||||||
| 4700 | PseudoElement ps = m == PM_MenuTearoffHeight ? PseudoElement_MenuTearoff : PseudoElement_MenuScroller; | - | ||||||||||||||||||||||||
| 4701 | subRule = renderRule(w, opt, ps); | - | ||||||||||||||||||||||||
| 4702 | if (subRule.hasContentsSize()) | - | ||||||||||||||||||||||||
| 4703 | return subRule.size().height(); | - | ||||||||||||||||||||||||
| 4704 | break; | - | ||||||||||||||||||||||||
| 4705 | } | - | ||||||||||||||||||||||||
| 4706 | - | |||||||||||||||||||||||||
| 4707 | case PM_ToolBarExtensionExtent: | - | ||||||||||||||||||||||||
| 4708 | break; | - | ||||||||||||||||||||||||
| 4709 | - | |||||||||||||||||||||||||
| 4710 | case PM_SplitterWidth: | - | ||||||||||||||||||||||||
| 4711 | case PM_ToolBarSeparatorExtent: | - | ||||||||||||||||||||||||
| 4712 | case PM_ToolBarHandleExtent: { | - | ||||||||||||||||||||||||
| 4713 | PseudoElement ps; | - | ||||||||||||||||||||||||
| 4714 | if (m == PM_ToolBarHandleExtent) ps = PseudoElement_ToolBarHandle; | - | ||||||||||||||||||||||||
| 4715 | else if (m == PM_SplitterWidth) ps = PseudoElement_SplitterHandle; | - | ||||||||||||||||||||||||
| 4716 | else ps = PseudoElement_ToolBarSeparator; | - | ||||||||||||||||||||||||
| 4717 | subRule = renderRule(w, opt, ps); | - | ||||||||||||||||||||||||
| 4718 | if (subRule.hasContentsSize()) { | - | ||||||||||||||||||||||||
| 4719 | QSize sz = subRule.size(); | - | ||||||||||||||||||||||||
| 4720 | return (opt && opt->state & QStyle::State_Horizontal) ? sz.width() : sz.height(); | - | ||||||||||||||||||||||||
| 4721 | } | - | ||||||||||||||||||||||||
| 4722 | break; | - | ||||||||||||||||||||||||
| 4723 | } | - | ||||||||||||||||||||||||
| 4724 | - | |||||||||||||||||||||||||
| 4725 | case PM_RadioButtonLabelSpacing: | - | ||||||||||||||||||||||||
| 4726 | if (rule.hasBox() && rule.box()->spacing != -1) | - | ||||||||||||||||||||||||
| 4727 | return rule.box()->spacing; | - | ||||||||||||||||||||||||
| 4728 | break; | - | ||||||||||||||||||||||||
| 4729 | case PM_CheckBoxLabelSpacing: | - | ||||||||||||||||||||||||
| 4730 | if (qobject_cast<const QCheckBox *>(w)) { | - | ||||||||||||||||||||||||
| 4731 | if (rule.hasBox() && rule.box()->spacing != -1) | - | ||||||||||||||||||||||||
| 4732 | return rule.box()->spacing; | - | ||||||||||||||||||||||||
| 4733 | } | - | ||||||||||||||||||||||||
| 4734 | // assume group box | - | ||||||||||||||||||||||||
| 4735 | subRule = renderRule(w, opt, PseudoElement_GroupBoxTitle); | - | ||||||||||||||||||||||||
| 4736 | if (subRule.hasBox() && subRule.box()->spacing != -1) | - | ||||||||||||||||||||||||
| 4737 | return subRule.box()->spacing; | - | ||||||||||||||||||||||||
| 4738 | break; | - | ||||||||||||||||||||||||
| 4739 | - | |||||||||||||||||||||||||
| 4740 | #ifndef QT_NO_SCROLLBAR | - | ||||||||||||||||||||||||
| 4741 | case PM_ScrollBarExtent: | - | ||||||||||||||||||||||||
| 4742 | if (rule.hasContentsSize()) { | - | ||||||||||||||||||||||||
| 4743 | QSize sz = rule.size(); | - | ||||||||||||||||||||||||
| 4744 | if (const QStyleOptionSlider *sb = qstyleoption_cast<const QStyleOptionSlider *>(opt)) | - | ||||||||||||||||||||||||
| 4745 | return sb->orientation == Qt::Horizontal ? sz.height() : sz.width(); | - | ||||||||||||||||||||||||
| 4746 | return sz.width() == -1 ? sz.height() : sz.width(); | - | ||||||||||||||||||||||||
| 4747 | } | - | ||||||||||||||||||||||||
| 4748 | break; | - | ||||||||||||||||||||||||
| 4749 | - | |||||||||||||||||||||||||
| 4750 | case PM_ScrollBarSliderMin: | - | ||||||||||||||||||||||||
| 4751 | if (hasStyleRule(w, PseudoElement_ScrollBarSlider)) { | - | ||||||||||||||||||||||||
| 4752 | subRule = renderRule(w, opt, PseudoElement_ScrollBarSlider); | - | ||||||||||||||||||||||||
| 4753 | QSize msz = subRule.minimumSize(); | - | ||||||||||||||||||||||||
| 4754 | if (const QStyleOptionSlider *sb = qstyleoption_cast<const QStyleOptionSlider *>(opt)) | - | ||||||||||||||||||||||||
| 4755 | return sb->orientation == Qt::Horizontal ? msz.width() : msz.height(); | - | ||||||||||||||||||||||||
| 4756 | return msz.width() == -1 ? msz.height() : msz.width(); | - | ||||||||||||||||||||||||
| 4757 | } | - | ||||||||||||||||||||||||
| 4758 | break; | - | ||||||||||||||||||||||||
| 4759 | - | |||||||||||||||||||||||||
| 4760 | case PM_ScrollView_ScrollBarSpacing: | - | ||||||||||||||||||||||||
| 4761 | if(!rule.hasNativeBorder() || rule.hasBox()) | - | ||||||||||||||||||||||||
| 4762 | return 0; | - | ||||||||||||||||||||||||
| 4763 | break; | - | ||||||||||||||||||||||||
| 4764 | #endif // QT_NO_SCROLLBAR | - | ||||||||||||||||||||||||
| 4765 | - | |||||||||||||||||||||||||
| 4766 | case PM_ProgressBarChunkWidth: | - | ||||||||||||||||||||||||
| 4767 | subRule = renderRule(w, opt, PseudoElement_ProgressBarChunk); | - | ||||||||||||||||||||||||
| 4768 | if (subRule.hasContentsSize()) { | - | ||||||||||||||||||||||||
| 4769 | QSize sz = subRule.size(); | - | ||||||||||||||||||||||||
| 4770 | return (opt->state & QStyle::State_Horizontal) | - | ||||||||||||||||||||||||
| 4771 | ? sz.width() : sz.height(); | - | ||||||||||||||||||||||||
| 4772 | } | - | ||||||||||||||||||||||||
| 4773 | break; | - | ||||||||||||||||||||||||
| 4774 | - | |||||||||||||||||||||||||
| 4775 | #ifndef QT_NO_TABWIDGET | - | ||||||||||||||||||||||||
| 4776 | case PM_TabBarTabHSpace: | - | ||||||||||||||||||||||||
| 4777 | case PM_TabBarTabVSpace: | - | ||||||||||||||||||||||||
| 4778 | subRule = renderRule(w, opt, PseudoElement_TabBarTab); | - | ||||||||||||||||||||||||
| 4779 | if (subRule.hasBox() || subRule.hasBorder()) | - | ||||||||||||||||||||||||
| 4780 | return 0; | - | ||||||||||||||||||||||||
| 4781 | break; | - | ||||||||||||||||||||||||
| 4782 | - | |||||||||||||||||||||||||
| 4783 | case PM_TabBarScrollButtonWidth: { | - | ||||||||||||||||||||||||
| 4784 | subRule = renderRule(w, opt, PseudoElement_TabBarScroller); | - | ||||||||||||||||||||||||
| 4785 | if (subRule.hasContentsSize()) { | - | ||||||||||||||||||||||||
| 4786 | QSize sz = subRule.size(); | - | ||||||||||||||||||||||||
| 4787 | return sz.width() != -1 ? sz.width() : sz.height(); | - | ||||||||||||||||||||||||
| 4788 | } | - | ||||||||||||||||||||||||
| 4789 | } | - | ||||||||||||||||||||||||
| 4790 | break; | - | ||||||||||||||||||||||||
| 4791 | - | |||||||||||||||||||||||||
| 4792 | case PM_TabBarTabShiftHorizontal: | - | ||||||||||||||||||||||||
| 4793 | case PM_TabBarTabShiftVertical: | - | ||||||||||||||||||||||||
| 4794 | subRule = renderRule(w, opt, PseudoElement_TabBarTab); | - | ||||||||||||||||||||||||
| 4795 | if (subRule.hasBox()) | - | ||||||||||||||||||||||||
| 4796 | return 0; | - | ||||||||||||||||||||||||
| 4797 | break; | - | ||||||||||||||||||||||||
| 4798 | - | |||||||||||||||||||||||||
| 4799 | case PM_TabBarBaseOverlap: { | - | ||||||||||||||||||||||||
| 4800 | const QWidget *tabWidget = qobject_cast<const QTabWidget *>(w); | - | ||||||||||||||||||||||||
| 4801 | if (!tabWidget && w) | - | ||||||||||||||||||||||||
| 4802 | tabWidget = w->parentWidget(); | - | ||||||||||||||||||||||||
| 4803 | if (hasStyleRule(tabWidget, PseudoElement_TabWidgetPane)) { | - | ||||||||||||||||||||||||
| 4804 | return 0; | - | ||||||||||||||||||||||||
| 4805 | } | - | ||||||||||||||||||||||||
| 4806 | break; | - | ||||||||||||||||||||||||
| 4807 | } | - | ||||||||||||||||||||||||
| 4808 | #endif // QT_NO_TABWIDGET | - | ||||||||||||||||||||||||
| 4809 | - | |||||||||||||||||||||||||
| 4810 | case PM_SliderThickness: // horizontal slider's height (sizeHint) | - | ||||||||||||||||||||||||
| 4811 | case PM_SliderLength: // minimum length of slider | - | ||||||||||||||||||||||||
| 4812 | if (rule.hasContentsSize()) { | - | ||||||||||||||||||||||||
| 4813 | bool horizontal = opt->state & QStyle::State_Horizontal; | - | ||||||||||||||||||||||||
| 4814 | if (m == PM_SliderThickness) { | - | ||||||||||||||||||||||||
| 4815 | QSize sz = rule.size(); | - | ||||||||||||||||||||||||
| 4816 | return horizontal ? sz.height() : sz.width(); | - | ||||||||||||||||||||||||
| 4817 | } else { | - | ||||||||||||||||||||||||
| 4818 | QSize msz = rule.minimumContentsSize(); | - | ||||||||||||||||||||||||
| 4819 | return horizontal ? msz.width() : msz.height(); | - | ||||||||||||||||||||||||
| 4820 | } | - | ||||||||||||||||||||||||
| 4821 | } | - | ||||||||||||||||||||||||
| 4822 | break; | - | ||||||||||||||||||||||||
| 4823 | - | |||||||||||||||||||||||||
| 4824 | case PM_SliderControlThickness: { | - | ||||||||||||||||||||||||
| 4825 | QRenderRule subRule = renderRule(w, opt, PseudoElement_SliderHandle); | - | ||||||||||||||||||||||||
| 4826 | if (!subRule.hasContentsSize()) | - | ||||||||||||||||||||||||
| 4827 | break; | - | ||||||||||||||||||||||||
| 4828 | QSize size = subRule.size(); | - | ||||||||||||||||||||||||
| 4829 | return (opt->state & QStyle::State_Horizontal) ? size.height() : size.width(); | - | ||||||||||||||||||||||||
| 4830 | } | - | ||||||||||||||||||||||||
| 4831 | - | |||||||||||||||||||||||||
| 4832 | case PM_ToolBarIconSize: | - | ||||||||||||||||||||||||
| 4833 | case PM_ListViewIconSize: | - | ||||||||||||||||||||||||
| 4834 | case PM_IconViewIconSize: | - | ||||||||||||||||||||||||
| 4835 | case PM_TabBarIconSize: | - | ||||||||||||||||||||||||
| 4836 | case PM_MessageBoxIconSize: | - | ||||||||||||||||||||||||
| 4837 | case PM_ButtonIconSize: | - | ||||||||||||||||||||||||
| 4838 | case PM_SmallIconSize: | - | ||||||||||||||||||||||||
| 4839 | if (rule.hasStyleHint(QLatin1String("icon-size"))) { | - | ||||||||||||||||||||||||
| 4840 | return rule.styleHint(QLatin1String("icon-size")).toSize().width(); | - | ||||||||||||||||||||||||
| 4841 | } | - | ||||||||||||||||||||||||
| 4842 | break; | - | ||||||||||||||||||||||||
| 4843 | - | |||||||||||||||||||||||||
| 4844 | case PM_DockWidgetTitleMargin: { | - | ||||||||||||||||||||||||
| 4845 | QRenderRule subRule = renderRule(w, opt, PseudoElement_DockWidgetTitle); | - | ||||||||||||||||||||||||
| 4846 | if (!subRule.hasBox()) | - | ||||||||||||||||||||||||
| 4847 | break; | - | ||||||||||||||||||||||||
| 4848 | return (subRule.border() ? subRule.border()->borders[TopEdge] : 0) | - | ||||||||||||||||||||||||
| 4849 | + (subRule.hasBox() ? subRule.box()->margins[TopEdge] + subRule.box()->paddings[TopEdge]: 0); | - | ||||||||||||||||||||||||
| 4850 | } | - | ||||||||||||||||||||||||
| 4851 | - | |||||||||||||||||||||||||
| 4852 | case PM_DockWidgetSeparatorExtent: { | - | ||||||||||||||||||||||||
| 4853 | QRenderRule subRule = renderRule(w, opt, PseudoElement_DockWidgetSeparator); | - | ||||||||||||||||||||||||
| 4854 | if (!subRule.hasContentsSize()) | - | ||||||||||||||||||||||||
| 4855 | break; | - | ||||||||||||||||||||||||
| 4856 | QSize sz = subRule.size(); | - | ||||||||||||||||||||||||
| 4857 | return qMax(sz.width(), sz.height()); | - | ||||||||||||||||||||||||
| 4858 | } | - | ||||||||||||||||||||||||
| 4859 | - | |||||||||||||||||||||||||
| 4860 | case PM_TitleBarHeight: { | - | ||||||||||||||||||||||||
| 4861 | QRenderRule subRule = renderRule(w, opt, PseudoElement_TitleBar); | - | ||||||||||||||||||||||||
| 4862 | if (subRule.hasContentsSize()) | - | ||||||||||||||||||||||||
| 4863 | return subRule.size().height(); | - | ||||||||||||||||||||||||
| 4864 | else if (subRule.hasBox() || subRule.hasBorder()) { | - | ||||||||||||||||||||||||
| 4865 | QFontMetrics fm = opt ? opt->fontMetrics : w->fontMetrics(); | - | ||||||||||||||||||||||||
| 4866 | return subRule.size(QSize(0, fm.height())).height(); | - | ||||||||||||||||||||||||
| 4867 | } | - | ||||||||||||||||||||||||
| 4868 | break; | - | ||||||||||||||||||||||||
| 4869 | } | - | ||||||||||||||||||||||||
| 4870 | - | |||||||||||||||||||||||||
| 4871 | case PM_MdiSubWindowFrameWidth: | - | ||||||||||||||||||||||||
| 4872 | if (rule.hasBox() || rule.hasBorder()) { | - | ||||||||||||||||||||||||
| 4873 | return (rule.border() ? rule.border()->borders[LeftEdge] : 0) | - | ||||||||||||||||||||||||
| 4874 | + (rule.hasBox() ? rule.box()->paddings[LeftEdge]+rule.box()->margins[LeftEdge]: 0); | - | ||||||||||||||||||||||||
| 4875 | } | - | ||||||||||||||||||||||||
| 4876 | break; | - | ||||||||||||||||||||||||
| 4877 | - | |||||||||||||||||||||||||
| 4878 | case PM_MdiSubWindowMinimizedWidth: { | - | ||||||||||||||||||||||||
| 4879 | QRenderRule subRule = renderRule(w, PseudoElement_None, PseudoClass_Minimized); | - | ||||||||||||||||||||||||
| 4880 | int width = subRule.size().width(); | - | ||||||||||||||||||||||||
| 4881 | if (width != -1) | - | ||||||||||||||||||||||||
| 4882 | return width; | - | ||||||||||||||||||||||||
| 4883 | break; | - | ||||||||||||||||||||||||
| 4884 | } | - | ||||||||||||||||||||||||
| 4885 | default: | - | ||||||||||||||||||||||||
| 4886 | break; | - | ||||||||||||||||||||||||
| 4887 | } | - | ||||||||||||||||||||||||
| 4888 | - | |||||||||||||||||||||||||
| 4889 | return baseStyle()->pixelMetric(m, opt, w); | - | ||||||||||||||||||||||||
| 4890 | } | - | ||||||||||||||||||||||||
| 4891 | - | |||||||||||||||||||||||||
| 4892 | QSize QStyleSheetStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt, | - | ||||||||||||||||||||||||
| 4893 | const QSize &csz, const QWidget *w) const | - | ||||||||||||||||||||||||
| 4894 | { | - | ||||||||||||||||||||||||
| 4895 | RECURSION_GUARD(return baseStyle()->sizeFromContents(ct, opt, csz, w)) | - | ||||||||||||||||||||||||
| 4896 | - | |||||||||||||||||||||||||
| 4897 | QRenderRule rule = renderRule(w, opt); | - | ||||||||||||||||||||||||
| 4898 | QSize sz = rule.adjustSize(csz); | - | ||||||||||||||||||||||||
| 4899 | - | |||||||||||||||||||||||||
| 4900 | switch (ct) { | - | ||||||||||||||||||||||||
| 4901 | case CT_SpinBox: // ### hopelessly broken QAbstractSpinBox (part 1) | - | ||||||||||||||||||||||||
| 4902 | if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) { | - | ||||||||||||||||||||||||
| 4903 | // Add some space for the up/down buttons | - | ||||||||||||||||||||||||
| 4904 | QRenderRule subRule = renderRule(w, opt, PseudoElement_SpinBoxUpButton); | - | ||||||||||||||||||||||||
| 4905 | if (subRule.hasDrawable()) { | - | ||||||||||||||||||||||||
| 4906 | QRect r = positionRect(w, rule, subRule, PseudoElement_SpinBoxUpButton, | - | ||||||||||||||||||||||||
| 4907 | opt->rect, opt->direction); | - | ||||||||||||||||||||||||
| 4908 | sz += QSize(r.width(), 0); | - | ||||||||||||||||||||||||
| 4909 | } else { | - | ||||||||||||||||||||||||
| 4910 | QSize defaultUpSize = defaultSize(w, subRule.size(), spinbox->rect, PseudoElement_SpinBoxUpButton); | - | ||||||||||||||||||||||||
| 4911 | sz += QSize(defaultUpSize.width(), 0); | - | ||||||||||||||||||||||||
| 4912 | } | - | ||||||||||||||||||||||||
| 4913 | if (rule.hasBox() || rule.hasBorder() || !rule.hasNativeBorder()) | - | ||||||||||||||||||||||||
| 4914 | sz = rule.boxSize(sz); | - | ||||||||||||||||||||||||
| 4915 | return sz; | - | ||||||||||||||||||||||||
| 4916 | } | - | ||||||||||||||||||||||||
| 4917 | break; | - | ||||||||||||||||||||||||
| 4918 | case CT_ToolButton: | - | ||||||||||||||||||||||||
| 4919 | if (rule.hasBox() || !rule.hasNativeBorder() || !rule.baseStyleCanDraw()) | - | ||||||||||||||||||||||||
| 4920 | sz += QSize(3, 3); // ### broken QToolButton | - | ||||||||||||||||||||||||
| 4921 | //fall thought | - | ||||||||||||||||||||||||
| 4922 | case CT_ComboBox: | - | ||||||||||||||||||||||||
| 4923 | case CT_PushButton: | - | ||||||||||||||||||||||||
| 4924 | if (rule.hasBox() || !rule.hasNativeBorder()) { | - | ||||||||||||||||||||||||
| 4925 | if(ct == CT_ComboBox) { | - | ||||||||||||||||||||||||
| 4926 | //add some space for the drop down. | - | ||||||||||||||||||||||||
| 4927 | QRenderRule subRule = renderRule(w, opt, PseudoElement_ComboBoxDropDown); | - | ||||||||||||||||||||||||
| 4928 | QRect comboRect = positionRect(w, rule, subRule, PseudoElement_ComboBoxDropDown, opt->rect, opt->direction); | - | ||||||||||||||||||||||||
| 4929 | //+2 because there is hardcoded margins in QCommonStyle::drawControl(CE_ComboBoxLabel) | - | ||||||||||||||||||||||||
| 4930 | sz += QSize(comboRect.width() + 2, 0); | - | ||||||||||||||||||||||||
| 4931 | } | - | ||||||||||||||||||||||||
| 4932 | return rule.boxSize(sz); | - | ||||||||||||||||||||||||
| 4933 | } | - | ||||||||||||||||||||||||
| 4934 | sz = rule.baseStyleCanDraw() ? baseStyle()->sizeFromContents(ct, opt, sz, w) | - | ||||||||||||||||||||||||
| 4935 | : QWindowsStyle::sizeFromContents(ct, opt, sz, w); | - | ||||||||||||||||||||||||
| 4936 | return rule.boxSize(sz, Margin); | - | ||||||||||||||||||||||||
| 4937 | - | |||||||||||||||||||||||||
| 4938 | case CT_HeaderSection: { | - | ||||||||||||||||||||||||
| 4939 | if (const QStyleOptionHeader *hdr = qstyleoption_cast<const QStyleOptionHeader *>(opt)) { | - | ||||||||||||||||||||||||
| 4940 | QRenderRule subRule = renderRule(w, opt, PseudoElement_HeaderViewSection); | - | ||||||||||||||||||||||||
| 4941 | if (subRule.hasGeometry() || subRule.hasBox() || !subRule.hasNativeBorder() || subRule.hasFont) { | - | ||||||||||||||||||||||||
| 4942 | sz = subRule.adjustSize(csz); | - | ||||||||||||||||||||||||
| 4943 | if (!subRule.hasGeometry()) { | - | ||||||||||||||||||||||||
| 4944 | QSize nativeContentsSize; | - | ||||||||||||||||||||||||
| 4945 | bool nullIcon = hdr->icon.isNull(); | - | ||||||||||||||||||||||||
| 4946 | int iconSize = nullIcon ? 0 : pixelMetric(QStyle::PM_SmallIconSize, hdr, w); | - | ||||||||||||||||||||||||
| 4947 | const QSize txt = subRule.hasFont ? QFontMetrics(subRule.font).size(0, hdr->text) | - | ||||||||||||||||||||||||
| 4948 | : hdr->fontMetrics.size(0, hdr->text); | - | ||||||||||||||||||||||||
| 4949 | nativeContentsSize.setHeight(qMax(iconSize, txt.height())); | - | ||||||||||||||||||||||||
| 4950 | nativeContentsSize.setWidth(iconSize + txt.width()); | - | ||||||||||||||||||||||||
| 4951 | sz = sz.expandedTo(nativeContentsSize); | - | ||||||||||||||||||||||||
| 4952 | } | - | ||||||||||||||||||||||||
| 4953 | return subRule.size(sz); | - | ||||||||||||||||||||||||
| 4954 | } | - | ||||||||||||||||||||||||
| 4955 | return subRule.baseStyleCanDraw() ? baseStyle()->sizeFromContents(ct, opt, sz, w) | - | ||||||||||||||||||||||||
| 4956 | : QWindowsStyle::sizeFromContents(ct, opt, sz, w); | - | ||||||||||||||||||||||||
| 4957 | } | - | ||||||||||||||||||||||||
| 4958 | } | - | ||||||||||||||||||||||||
| 4959 | break; | - | ||||||||||||||||||||||||
| 4960 | case CT_GroupBox: | - | ||||||||||||||||||||||||
| 4961 | case CT_LineEdit: | - | ||||||||||||||||||||||||
| 4962 | #ifndef QT_NO_SPINBOX | - | ||||||||||||||||||||||||
| 4963 | if (qobject_cast<QAbstractSpinBox *>(w ? w->parentWidget() : 0)) | - | ||||||||||||||||||||||||
| 4964 | return csz; // we only care about the size hint of the line edit | - | ||||||||||||||||||||||||
| 4965 | #endif | - | ||||||||||||||||||||||||
| 4966 | if (rule.hasBox() || !rule.hasNativeBorder()) { | - | ||||||||||||||||||||||||
| 4967 | return rule.boxSize(sz); | - | ||||||||||||||||||||||||
| 4968 | } | - | ||||||||||||||||||||||||
| 4969 | break; | - | ||||||||||||||||||||||||
| 4970 | - | |||||||||||||||||||||||||
| 4971 | case CT_CheckBox: | - | ||||||||||||||||||||||||
| 4972 | case CT_RadioButton: | - | ||||||||||||||||||||||||
| 4973 | if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) { | - | ||||||||||||||||||||||||
| 4974 | if (rule.hasBox() || rule.hasBorder() || hasStyleRule(w, PseudoElement_Indicator)) { | - | ||||||||||||||||||||||||
| 4975 | bool isRadio = (ct == CT_RadioButton); | - | ||||||||||||||||||||||||
| 4976 | int iw = pixelMetric(isRadio ? PM_ExclusiveIndicatorWidth | - | ||||||||||||||||||||||||
| 4977 | : PM_IndicatorWidth, btn, w); | - | ||||||||||||||||||||||||
| 4978 | int ih = pixelMetric(isRadio ? PM_ExclusiveIndicatorHeight | - | ||||||||||||||||||||||||
| 4979 | : PM_IndicatorHeight, btn, w); | - | ||||||||||||||||||||||||
| 4980 | - | |||||||||||||||||||||||||
| 4981 | int spacing = pixelMetric(isRadio ? PM_RadioButtonLabelSpacing | - | ||||||||||||||||||||||||
| 4982 | : PM_CheckBoxLabelSpacing, btn, w); | - | ||||||||||||||||||||||||
| 4983 | sz.setWidth(sz.width() + iw + spacing); | - | ||||||||||||||||||||||||
| 4984 | sz.setHeight(qMax(sz.height(), ih)); | - | ||||||||||||||||||||||||
| 4985 | return rule.boxSize(sz); | - | ||||||||||||||||||||||||
| 4986 | } | - | ||||||||||||||||||||||||
| 4987 | } | - | ||||||||||||||||||||||||
| 4988 | break; | - | ||||||||||||||||||||||||
| 4989 | - | |||||||||||||||||||||||||
| 4990 | case CT_Menu: | - | ||||||||||||||||||||||||
| 4991 | case CT_MenuBar: // already has everything! | - | ||||||||||||||||||||||||
| 4992 | case CT_ScrollBar: | - | ||||||||||||||||||||||||
| 4993 | if (rule.hasBox() || rule.hasBorder()) | - | ||||||||||||||||||||||||
| 4994 | return sz; | - | ||||||||||||||||||||||||
| 4995 | break; | - | ||||||||||||||||||||||||
| 4996 | - | |||||||||||||||||||||||||
| 4997 | case CT_MenuItem: | - | ||||||||||||||||||||||||
| 4998 | if (const QStyleOptionMenuItem *mi = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) { | - | ||||||||||||||||||||||||
| 4999 | PseudoElement pe = (mi->menuItemType == QStyleOptionMenuItem::Separator) | - | ||||||||||||||||||||||||
| 5000 | ? PseudoElement_MenuSeparator : PseudoElement_Item; | - | ||||||||||||||||||||||||
| 5001 | QRenderRule subRule = renderRule(w, opt, pe); | - | ||||||||||||||||||||||||
| 5002 | if ((pe == PseudoElement_MenuSeparator) && subRule.hasContentsSize()) { | - | ||||||||||||||||||||||||
| 5003 | return QSize(sz.width(), subRule.size().height()); | - | ||||||||||||||||||||||||
| 5004 | } else if ((pe == PseudoElement_Item) && (subRule.hasBox() || subRule.hasBorder())) { | - | ||||||||||||||||||||||||
| 5005 | int width = csz.width(); | - | ||||||||||||||||||||||||
| 5006 | if (mi->text.contains(QLatin1Char('\t'))) | - | ||||||||||||||||||||||||
| 5007 | width += 12; //as in QCommonStyle | - | ||||||||||||||||||||||||
| 5008 | return subRule.boxSize(subRule.adjustSize(QSize(width, csz.height()))); | - | ||||||||||||||||||||||||
| 5009 | } | - | ||||||||||||||||||||||||
| 5010 | } | - | ||||||||||||||||||||||||
| 5011 | break; | - | ||||||||||||||||||||||||
| 5012 | - | |||||||||||||||||||||||||
| 5013 | case CT_Splitter: | - | ||||||||||||||||||||||||
| 5014 | case CT_MenuBarItem: { | - | ||||||||||||||||||||||||
| 5015 | PseudoElement pe = (ct == CT_Splitter) ? PseudoElement_SplitterHandle : PseudoElement_Item; | - | ||||||||||||||||||||||||
| 5016 | QRenderRule subRule = renderRule(w, opt, pe); | - | ||||||||||||||||||||||||
| 5017 | if (subRule.hasBox() || subRule.hasBorder()) | - | ||||||||||||||||||||||||
| 5018 | return subRule.boxSize(sz); | - | ||||||||||||||||||||||||
| 5019 | break; | - | ||||||||||||||||||||||||
| 5020 | } | - | ||||||||||||||||||||||||
| 5021 | - | |||||||||||||||||||||||||
| 5022 | case CT_ProgressBar: | - | ||||||||||||||||||||||||
| 5023 | case CT_SizeGrip: | - | ||||||||||||||||||||||||
| 5024 | return (rule.hasContentsSize()) | - | ||||||||||||||||||||||||
| 5025 | ? rule.size(sz) | - | ||||||||||||||||||||||||
| 5026 | : rule.boxSize(baseStyle()->sizeFromContents(ct, opt, sz, w)); | - | ||||||||||||||||||||||||
| 5027 | break; dead code: break; | - | ||||||||||||||||||||||||
| 5028 | - | |||||||||||||||||||||||||
| 5029 | case CT_Slider: | - | ||||||||||||||||||||||||
| 5030 | if (rule.hasBorder() || rule.hasBox() || rule.hasGeometry()) | - | ||||||||||||||||||||||||
| 5031 | return rule.boxSize(sz); | - | ||||||||||||||||||||||||
| 5032 | break; | - | ||||||||||||||||||||||||
| 5033 | - | |||||||||||||||||||||||||
| 5034 | #ifndef QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 5035 | case CT_TabBarTab: { | - | ||||||||||||||||||||||||
| 5036 | QRenderRule subRule = renderRule(w, opt, PseudoElement_TabBarTab); | - | ||||||||||||||||||||||||
| 5037 | if (subRule.hasBox() || !subRule.hasNativeBorder()) { | - | ||||||||||||||||||||||||
| 5038 | int spaceForIcon = 0; | - | ||||||||||||||||||||||||
| 5039 | bool vertical = false; | - | ||||||||||||||||||||||||
| 5040 | if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) { | - | ||||||||||||||||||||||||
| 5041 | if (!tab->icon.isNull()) | - | ||||||||||||||||||||||||
| 5042 | spaceForIcon = 6 /* icon offset */ + 4 /* spacing */ + 2 /* magic */; // ###: hardcoded to match with common style | - | ||||||||||||||||||||||||
| 5043 | vertical = verticalTabs(tab->shape); | - | ||||||||||||||||||||||||
| 5044 | } | - | ||||||||||||||||||||||||
| 5045 | sz = csz + QSize(vertical ? 0 : spaceForIcon, vertical ? spaceForIcon : 0); | - | ||||||||||||||||||||||||
| 5046 | return subRule.boxSize(subRule.adjustSize(sz)); | - | ||||||||||||||||||||||||
| 5047 | } | - | ||||||||||||||||||||||||
| 5048 | #ifdef Q_DEAD_CODE_FROM_QT4_MAC | - | ||||||||||||||||||||||||
| 5049 | if (baseStyle()->inherits("QMacStyle")) { | - | ||||||||||||||||||||||||
| 5050 | //adjust the size after the call to the style because the mac style ignore the size arguments anyway. | - | ||||||||||||||||||||||||
| 5051 | //this might cause the (max-){width,height} property to include the native style border while they should not. | - | ||||||||||||||||||||||||
| 5052 | return subRule.adjustSize(baseStyle()->sizeFromContents(ct, opt, csz, w)); | - | ||||||||||||||||||||||||
| 5053 | } | - | ||||||||||||||||||||||||
| 5054 | #endif | - | ||||||||||||||||||||||||
| 5055 | sz = subRule.adjustSize(csz); | - | ||||||||||||||||||||||||
| 5056 | break; | - | ||||||||||||||||||||||||
| 5057 | } | - | ||||||||||||||||||||||||
| 5058 | #endif // QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 5059 | - | |||||||||||||||||||||||||
| 5060 | case CT_MdiControls: | - | ||||||||||||||||||||||||
| 5061 | if (const QStyleOptionComplex *ccOpt = qstyleoption_cast<const QStyleOptionComplex *>(opt)) { | - | ||||||||||||||||||||||||
| 5062 | if (!hasStyleRule(w, PseudoElement_MdiCloseButton) | - | ||||||||||||||||||||||||
| 5063 | && !hasStyleRule(w, PseudoElement_MdiNormalButton) | - | ||||||||||||||||||||||||
| 5064 | && !hasStyleRule(w, PseudoElement_MdiMinButton)) | - | ||||||||||||||||||||||||
| 5065 | break; | - | ||||||||||||||||||||||||
| 5066 | - | |||||||||||||||||||||||||
| 5067 | QList<QVariant> layout = rule.styleHint(QLatin1String("button-layout")).toList(); | - | ||||||||||||||||||||||||
| 5068 | if (layout.isEmpty()) | - | ||||||||||||||||||||||||
| 5069 | layout = subControlLayout(QLatin1String("mNX")); | - | ||||||||||||||||||||||||
| 5070 | - | |||||||||||||||||||||||||
| 5071 | int width = 0, height = 0; | - | ||||||||||||||||||||||||
| 5072 | for (int i = 0; i < layout.count(); i++) { | - | ||||||||||||||||||||||||
| 5073 | int layoutButton = layout[i].toInt(); | - | ||||||||||||||||||||||||
| 5074 | if (layoutButton < PseudoElement_MdiCloseButton | - | ||||||||||||||||||||||||
| 5075 | || layoutButton > PseudoElement_MdiNormalButton) | - | ||||||||||||||||||||||||
| 5076 | continue; | - | ||||||||||||||||||||||||
| 5077 | QStyle::SubControl sc = knownPseudoElements[layoutButton].subControl; | - | ||||||||||||||||||||||||
| 5078 | if (!(ccOpt->subControls & sc)) | - | ||||||||||||||||||||||||
| 5079 | continue; | - | ||||||||||||||||||||||||
| 5080 | QRenderRule subRule = renderRule(w, opt, layoutButton); | - | ||||||||||||||||||||||||
| 5081 | QSize sz = subRule.size(); | - | ||||||||||||||||||||||||
| 5082 | width += sz.width(); | - | ||||||||||||||||||||||||
| 5083 | height = qMax(height, sz.height()); | - | ||||||||||||||||||||||||
| 5084 | } | - | ||||||||||||||||||||||||
| 5085 | - | |||||||||||||||||||||||||
| 5086 | return QSize(width, height); | - | ||||||||||||||||||||||||
| 5087 | } | - | ||||||||||||||||||||||||
| 5088 | break; | - | ||||||||||||||||||||||||
| 5089 | - | |||||||||||||||||||||||||
| 5090 | #ifndef QT_NO_ITEMVIEWS | - | ||||||||||||||||||||||||
| 5091 | case CT_ItemViewItem: { | - | ||||||||||||||||||||||||
| 5092 | QRenderRule subRule = renderRule(w, opt, PseudoElement_ViewItem); | - | ||||||||||||||||||||||||
| 5093 | sz = baseStyle()->sizeFromContents(ct, opt, csz, w); | - | ||||||||||||||||||||||||
| 5094 | sz = subRule.adjustSize(sz); | - | ||||||||||||||||||||||||
| 5095 | if (subRule.hasBox() || subRule.hasBorder()) | - | ||||||||||||||||||||||||
| 5096 | sz = subRule.boxSize(sz); | - | ||||||||||||||||||||||||
| 5097 | return sz; | - | ||||||||||||||||||||||||
| 5098 | } | - | ||||||||||||||||||||||||
| 5099 | #endif // QT_NO_ITEMVIEWS | - | ||||||||||||||||||||||||
| 5100 | - | |||||||||||||||||||||||||
| 5101 | default: | - | ||||||||||||||||||||||||
| 5102 | break; | - | ||||||||||||||||||||||||
| 5103 | } | - | ||||||||||||||||||||||||
| 5104 | - | |||||||||||||||||||||||||
| 5105 | return baseStyle()->sizeFromContents(ct, opt, sz, w); | - | ||||||||||||||||||||||||
| 5106 | } | - | ||||||||||||||||||||||||
| 5107 | - | |||||||||||||||||||||||||
| 5108 | /*! | - | ||||||||||||||||||||||||
| 5109 | \internal | - | ||||||||||||||||||||||||
| 5110 | */ | - | ||||||||||||||||||||||||
| 5111 | static QLatin1String propertyNameForStandardPixmap(QStyle::StandardPixmap sp) | - | ||||||||||||||||||||||||
| 5112 | { | - | ||||||||||||||||||||||||
| 5113 | switch (sp) { | - | ||||||||||||||||||||||||
| 5114 | case QStyle::SP_TitleBarMenuButton: return QLatin1String("titlebar-menu-icon"); | - | ||||||||||||||||||||||||
| 5115 | case QStyle::SP_TitleBarMinButton: return QLatin1String("titlebar-minimize-icon"); | - | ||||||||||||||||||||||||
| 5116 | case QStyle::SP_TitleBarMaxButton: return QLatin1String("titlebar-maximize-icon"); | - | ||||||||||||||||||||||||
| 5117 | case QStyle::SP_TitleBarCloseButton: return QLatin1String("titlebar-close-icon"); | - | ||||||||||||||||||||||||
| 5118 | case QStyle::SP_TitleBarNormalButton: return QLatin1String("titlebar-normal-icon"); | - | ||||||||||||||||||||||||
| 5119 | case QStyle::SP_TitleBarShadeButton: return QLatin1String("titlebar-shade-icon"); | - | ||||||||||||||||||||||||
| 5120 | case QStyle::SP_TitleBarUnshadeButton: return QLatin1String("titlebar-unshade-icon"); | - | ||||||||||||||||||||||||
| 5121 | case QStyle::SP_TitleBarContextHelpButton: return QLatin1String("titlebar-contexthelp-icon"); | - | ||||||||||||||||||||||||
| 5122 | case QStyle::SP_DockWidgetCloseButton: return QLatin1String("dockwidget-close-icon"); | - | ||||||||||||||||||||||||
| 5123 | case QStyle::SP_MessageBoxInformation: return QLatin1String("messagebox-information-icon"); | - | ||||||||||||||||||||||||
| 5124 | case QStyle::SP_MessageBoxWarning: return QLatin1String("messagebox-warning-icon"); | - | ||||||||||||||||||||||||
| 5125 | case QStyle::SP_MessageBoxCritical: return QLatin1String("messagebox-critical-icon"); | - | ||||||||||||||||||||||||
| 5126 | case QStyle::SP_MessageBoxQuestion: return QLatin1String("messagebox-question-icon"); | - | ||||||||||||||||||||||||
| 5127 | case QStyle::SP_DesktopIcon: return QLatin1String("desktop-icon"); | - | ||||||||||||||||||||||||
| 5128 | case QStyle::SP_TrashIcon: return QLatin1String("trash-icon"); | - | ||||||||||||||||||||||||
| 5129 | case QStyle::SP_ComputerIcon: return QLatin1String("computer-icon"); | - | ||||||||||||||||||||||||
| 5130 | case QStyle::SP_DriveFDIcon: return QLatin1String("floppy-icon"); | - | ||||||||||||||||||||||||
| 5131 | case QStyle::SP_DriveHDIcon: return QLatin1String("harddisk-icon"); | - | ||||||||||||||||||||||||
| 5132 | case QStyle::SP_DriveCDIcon: return QLatin1String("cd-icon"); | - | ||||||||||||||||||||||||
| 5133 | case QStyle::SP_DriveDVDIcon: return QLatin1String("dvd-icon"); | - | ||||||||||||||||||||||||
| 5134 | case QStyle::SP_DriveNetIcon: return QLatin1String("network-icon"); | - | ||||||||||||||||||||||||
| 5135 | case QStyle::SP_DirOpenIcon: return QLatin1String("directory-open-icon"); | - | ||||||||||||||||||||||||
| 5136 | case QStyle::SP_DirClosedIcon: return QLatin1String("directory-closed-icon"); | - | ||||||||||||||||||||||||
| 5137 | case QStyle::SP_DirLinkIcon: return QLatin1String("directory-link-icon"); | - | ||||||||||||||||||||||||
| 5138 | case QStyle::SP_FileIcon: return QLatin1String("file-icon"); | - | ||||||||||||||||||||||||
| 5139 | case QStyle::SP_FileLinkIcon: return QLatin1String("file-link-icon"); | - | ||||||||||||||||||||||||
| 5140 | case QStyle::SP_FileDialogStart: return QLatin1String("filedialog-start-icon"); | - | ||||||||||||||||||||||||
| 5141 | case QStyle::SP_FileDialogEnd: return QLatin1String("filedialog-end-icon"); | - | ||||||||||||||||||||||||
| 5142 | case QStyle::SP_FileDialogToParent: return QLatin1String("filedialog-parent-directory-icon"); | - | ||||||||||||||||||||||||
| 5143 | case QStyle::SP_FileDialogNewFolder: return QLatin1String("filedialog-new-directory-icon"); | - | ||||||||||||||||||||||||
| 5144 | case QStyle::SP_FileDialogDetailedView: return QLatin1String("filedialog-detailedview-icon"); | - | ||||||||||||||||||||||||
| 5145 | case QStyle::SP_FileDialogInfoView: return QLatin1String("filedialog-infoview-icon"); | - | ||||||||||||||||||||||||
| 5146 | case QStyle::SP_FileDialogContentsView: return QLatin1String("filedialog-contentsview-icon"); | - | ||||||||||||||||||||||||
| 5147 | case QStyle::SP_FileDialogListView: return QLatin1String("filedialog-listview-icon"); | - | ||||||||||||||||||||||||
| 5148 | case QStyle::SP_FileDialogBack: return QLatin1String("filedialog-backward-icon"); | - | ||||||||||||||||||||||||
| 5149 | case QStyle::SP_DirIcon: return QLatin1String("directory-icon"); | - | ||||||||||||||||||||||||
| 5150 | case QStyle::SP_DialogOkButton: return QLatin1String("dialog-ok-icon"); | - | ||||||||||||||||||||||||
| 5151 | case QStyle::SP_DialogCancelButton: return QLatin1String("dialog-cancel-icon"); | - | ||||||||||||||||||||||||
| 5152 | case QStyle::SP_DialogHelpButton: return QLatin1String("dialog-help-icon"); | - | ||||||||||||||||||||||||
| 5153 | case QStyle::SP_DialogOpenButton: return QLatin1String("dialog-open-icon"); | - | ||||||||||||||||||||||||
| 5154 | case QStyle::SP_DialogSaveButton: return QLatin1String("dialog-save-icon"); | - | ||||||||||||||||||||||||
| 5155 | case QStyle::SP_DialogCloseButton: return QLatin1String("dialog-close-icon"); | - | ||||||||||||||||||||||||
| 5156 | case QStyle::SP_DialogApplyButton: return QLatin1String("dialog-apply-icon"); | - | ||||||||||||||||||||||||
| 5157 | case QStyle::SP_DialogResetButton: return QLatin1String("dialog-reset-icon"); | - | ||||||||||||||||||||||||
| 5158 | case QStyle::SP_DialogDiscardButton: return QLatin1String("discard-icon"); | - | ||||||||||||||||||||||||
| 5159 | case QStyle::SP_DialogYesButton: return QLatin1String("dialog-yes-icon"); | - | ||||||||||||||||||||||||
| 5160 | case QStyle::SP_DialogNoButton: return QLatin1String("dialog-no-icon"); | - | ||||||||||||||||||||||||
| 5161 | case QStyle::SP_ArrowUp: return QLatin1String("uparrow-icon"); | - | ||||||||||||||||||||||||
| 5162 | case QStyle::SP_ArrowDown: return QLatin1String("downarrow-icon"); | - | ||||||||||||||||||||||||
| 5163 | case QStyle::SP_ArrowLeft: return QLatin1String("leftarrow-icon"); | - | ||||||||||||||||||||||||
| 5164 | case QStyle::SP_ArrowRight: return QLatin1String("rightarrow-icon"); | - | ||||||||||||||||||||||||
| 5165 | case QStyle::SP_ArrowBack: return QLatin1String("backward-icon"); | - | ||||||||||||||||||||||||
| 5166 | case QStyle::SP_ArrowForward: return QLatin1String("forward-icon"); | - | ||||||||||||||||||||||||
| 5167 | case QStyle::SP_DirHomeIcon: return QLatin1String("home-icon"); | - | ||||||||||||||||||||||||
| 5168 | default: return QLatin1String(""); | - | ||||||||||||||||||||||||
| 5169 | } | - | ||||||||||||||||||||||||
| 5170 | } | - | ||||||||||||||||||||||||
| 5171 | - | |||||||||||||||||||||||||
| 5172 | QIcon QStyleSheetStyle::standardIcon(StandardPixmap standardIcon, const QStyleOption *opt, | - | ||||||||||||||||||||||||
| 5173 | const QWidget *w) const | - | ||||||||||||||||||||||||
| 5174 | { | - | ||||||||||||||||||||||||
| 5175 | RECURSION_GUARD(return baseStyle()->standardIcon(standardIcon, opt, w)) | - | ||||||||||||||||||||||||
| 5176 | QString s = propertyNameForStandardPixmap(standardIcon); | - | ||||||||||||||||||||||||
| 5177 | if (!s.isEmpty()) { | - | ||||||||||||||||||||||||
| 5178 | QRenderRule rule = renderRule(w, opt); | - | ||||||||||||||||||||||||
| 5179 | if (rule.hasStyleHint(s)) | - | ||||||||||||||||||||||||
| 5180 | return qvariant_cast<QIcon>(rule.styleHint(s)); | - | ||||||||||||||||||||||||
| 5181 | } | - | ||||||||||||||||||||||||
| 5182 | return baseStyle()->standardIcon(standardIcon, opt, w); | - | ||||||||||||||||||||||||
| 5183 | } | - | ||||||||||||||||||||||||
| 5184 | - | |||||||||||||||||||||||||
| 5185 | QPalette QStyleSheetStyle::standardPalette() const | - | ||||||||||||||||||||||||
| 5186 | { | - | ||||||||||||||||||||||||
| 5187 | return baseStyle()->standardPalette(); | - | ||||||||||||||||||||||||
| 5188 | } | - | ||||||||||||||||||||||||
| 5189 | - | |||||||||||||||||||||||||
| 5190 | QPixmap QStyleSheetStyle::standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, | - | ||||||||||||||||||||||||
| 5191 | const QWidget *w) const | - | ||||||||||||||||||||||||
| 5192 | { | - | ||||||||||||||||||||||||
| 5193 | RECURSION_GUARD(return baseStyle()->standardPixmap(standardPixmap, opt, w)) | - | ||||||||||||||||||||||||
| 5194 | QString s = propertyNameForStandardPixmap(standardPixmap); | - | ||||||||||||||||||||||||
| 5195 | if (!s.isEmpty()) { | - | ||||||||||||||||||||||||
| 5196 | QRenderRule rule = renderRule(w, opt); | - | ||||||||||||||||||||||||
| 5197 | if (rule.hasStyleHint(s)) { | - | ||||||||||||||||||||||||
| 5198 | QIcon icon = qvariant_cast<QIcon>(rule.styleHint(s)); | - | ||||||||||||||||||||||||
| 5199 | return icon.pixmap(16, 16); // ###: unhard-code this if someone complains | - | ||||||||||||||||||||||||
| 5200 | } | - | ||||||||||||||||||||||||
| 5201 | } | - | ||||||||||||||||||||||||
| 5202 | return baseStyle()->standardPixmap(standardPixmap, opt, w); | - | ||||||||||||||||||||||||
| 5203 | } | - | ||||||||||||||||||||||||
| 5204 | - | |||||||||||||||||||||||||
| 5205 | int QStyleSheetStyle::layoutSpacing(QSizePolicy::ControlType control1, QSizePolicy::ControlType control2, | - | ||||||||||||||||||||||||
| 5206 | Qt::Orientation orientation, const QStyleOption *option, | - | ||||||||||||||||||||||||
| 5207 | const QWidget *widget) const | - | ||||||||||||||||||||||||
| 5208 | { | - | ||||||||||||||||||||||||
| 5209 | return baseStyle()->layoutSpacing(control1, control2, orientation, option, widget); | - | ||||||||||||||||||||||||
| 5210 | } | - | ||||||||||||||||||||||||
| 5211 | - | |||||||||||||||||||||||||
| 5212 | int QStyleSheetStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w, | - | ||||||||||||||||||||||||
| 5213 | QStyleHintReturn *shret) const | - | ||||||||||||||||||||||||
| 5214 | { | - | ||||||||||||||||||||||||
| 5215 | RECURSION_GUARD(return baseStyle()->styleHint(sh, opt, w, shret)) | - | ||||||||||||||||||||||||
| 5216 | // Prevent endless loop if somebody use isActiveWindow property as selector. | - | ||||||||||||||||||||||||
| 5217 | // QWidget::isActiveWindow uses this styleHint to determine if the window is active or not | - | ||||||||||||||||||||||||
| 5218 | if (sh == SH_Widget_ShareActivation) | - | ||||||||||||||||||||||||
| 5219 | return baseStyle()->styleHint(sh, opt, w, shret); | - | ||||||||||||||||||||||||
| 5220 | - | |||||||||||||||||||||||||
| 5221 | QRenderRule rule = renderRule(w, opt); | - | ||||||||||||||||||||||||
| 5222 | QString s; | - | ||||||||||||||||||||||||
| 5223 | switch (sh) { | - | ||||||||||||||||||||||||
| 5224 | case SH_LineEdit_PasswordCharacter: s = QLatin1String("lineedit-password-character"); break; | - | ||||||||||||||||||||||||
| 5225 | case SH_LineEdit_PasswordMaskDelay: s = QLatin1String("lineedit-password-mask-delay"); break; | - | ||||||||||||||||||||||||
| 5226 | case SH_DitherDisabledText: s = QLatin1String("dither-disabled-text"); break; | - | ||||||||||||||||||||||||
| 5227 | case SH_EtchDisabledText: s = QLatin1String("etch-disabled-text"); break; | - | ||||||||||||||||||||||||
| 5228 | case SH_ItemView_ActivateItemOnSingleClick: s = QLatin1String("activate-on-singleclick"); break; | - | ||||||||||||||||||||||||
| 5229 | case SH_ItemView_ShowDecorationSelected: s = QLatin1String("show-decoration-selected"); break; | - | ||||||||||||||||||||||||
| 5230 | case SH_Table_GridLineColor: s = QLatin1String("gridline-color"); break; | - | ||||||||||||||||||||||||
| 5231 | case SH_DialogButtonLayout: s = QLatin1String("button-layout"); break; | - | ||||||||||||||||||||||||
| 5232 | case SH_ToolTipLabel_Opacity: s = QLatin1String("opacity"); break; | - | ||||||||||||||||||||||||
| 5233 | case SH_ComboBox_Popup: s = QLatin1String("combobox-popup"); break; | - | ||||||||||||||||||||||||
| 5234 | case SH_ComboBox_ListMouseTracking: s = QLatin1String("combobox-list-mousetracking"); break; | - | ||||||||||||||||||||||||
| 5235 | case SH_MenuBar_AltKeyNavigation: s = QLatin1String("menubar-altkey-navigation"); break; | - | ||||||||||||||||||||||||
| 5236 | case SH_Menu_Scrollable: s = QLatin1String("menu-scrollable"); break; | - | ||||||||||||||||||||||||
| 5237 | case SH_DrawMenuBarSeparator: s = QLatin1String("menubar-separator"); break; | - | ||||||||||||||||||||||||
| 5238 | case SH_MenuBar_MouseTracking: s = QLatin1String("mouse-tracking"); break; | - | ||||||||||||||||||||||||
| 5239 | case SH_SpinBox_ClickAutoRepeatRate: s = QLatin1String("spinbox-click-autorepeat-rate"); break; | - | ||||||||||||||||||||||||
| 5240 | case SH_SpinControls_DisableOnBounds: s = QLatin1String("spincontrol-disable-on-bounds"); break; | - | ||||||||||||||||||||||||
| 5241 | case SH_MessageBox_TextInteractionFlags: s = QLatin1String("messagebox-text-interaction-flags"); break; | - | ||||||||||||||||||||||||
| 5242 | case SH_ToolButton_PopupDelay: s = QLatin1String("toolbutton-popup-delay"); break; | - | ||||||||||||||||||||||||
| 5243 | case SH_ToolBox_SelectedPageTitleBold: | - | ||||||||||||||||||||||||
| 5244 | if (renderRule(w, opt, PseudoElement_ToolBoxTab).hasFont) | - | ||||||||||||||||||||||||
| 5245 | return 0; | - | ||||||||||||||||||||||||
| 5246 | break; | - | ||||||||||||||||||||||||
| 5247 | case SH_GroupBox_TextLabelColor: | - | ||||||||||||||||||||||||
| 5248 | if (rule.hasPalette() && rule.palette()->foreground.style() != Qt::NoBrush) | - | ||||||||||||||||||||||||
| 5249 | return rule.palette()->foreground.color().rgba(); | - | ||||||||||||||||||||||||
| 5250 | break; | - | ||||||||||||||||||||||||
| 5251 | case SH_ScrollView_FrameOnlyAroundContents: s = QLatin1String("scrollview-frame-around-contents"); break; | - | ||||||||||||||||||||||||
| 5252 | case SH_ScrollBar_ContextMenu: s = QLatin1String("scrollbar-contextmenu"); break; | - | ||||||||||||||||||||||||
| 5253 | case SH_ScrollBar_LeftClickAbsolutePosition: s = QLatin1String("scrollbar-leftclick-absolute-position"); break; | - | ||||||||||||||||||||||||
| 5254 | case SH_ScrollBar_MiddleClickAbsolutePosition: s = QLatin1String("scrollbar-middleclick-absolute-position"); break; | - | ||||||||||||||||||||||||
| 5255 | case SH_ScrollBar_RollBetweenButtons: s = QLatin1String("scrollbar-roll-between-buttons"); break; | - | ||||||||||||||||||||||||
| 5256 | case SH_ScrollBar_ScrollWhenPointerLeavesControl: s = QLatin1String("scrollbar-scroll-when-pointer-leaves-control"); break; | - | ||||||||||||||||||||||||
| 5257 | case SH_TabBar_Alignment: | - | ||||||||||||||||||||||||
| 5258 | #ifndef QT_NO_TABWIDGET | - | ||||||||||||||||||||||||
| 5259 | if (qobject_cast<const QTabWidget *>(w)) { | - | ||||||||||||||||||||||||
| 5260 | rule = renderRule(w, opt, PseudoElement_TabWidgetTabBar); | - | ||||||||||||||||||||||||
| 5261 | if (rule.hasPosition()) | - | ||||||||||||||||||||||||
| 5262 | return rule.position()->position; | - | ||||||||||||||||||||||||
| 5263 | } | - | ||||||||||||||||||||||||
| 5264 | #endif // QT_NO_TABWIDGET | - | ||||||||||||||||||||||||
| 5265 | s = QLatin1String("alignment"); | - | ||||||||||||||||||||||||
| 5266 | break; | - | ||||||||||||||||||||||||
| 5267 | #ifndef QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 5268 | case SH_TabBar_CloseButtonPosition: | - | ||||||||||||||||||||||||
| 5269 | rule = renderRule(w, opt, PseudoElement_TabBarTabCloseButton); | - | ||||||||||||||||||||||||
| 5270 | if (rule.hasPosition()) { | - | ||||||||||||||||||||||||
| 5271 | Qt::Alignment align = rule.position()->position; | - | ||||||||||||||||||||||||
| 5272 | if (align & Qt::AlignLeft || align & Qt::AlignTop) | - | ||||||||||||||||||||||||
| 5273 | return QTabBar::LeftSide; | - | ||||||||||||||||||||||||
| 5274 | if (align & Qt::AlignRight || align & Qt::AlignBottom) | - | ||||||||||||||||||||||||
| 5275 | return QTabBar::RightSide; | - | ||||||||||||||||||||||||
| 5276 | } | - | ||||||||||||||||||||||||
| 5277 | break; | - | ||||||||||||||||||||||||
| 5278 | #endif | - | ||||||||||||||||||||||||
| 5279 | case SH_TabBar_ElideMode: s = QLatin1String("tabbar-elide-mode"); break; | - | ||||||||||||||||||||||||
| 5280 | case SH_TabBar_PreferNoArrows: s = QLatin1String("tabbar-prefer-no-arrows"); break; | - | ||||||||||||||||||||||||
| 5281 | case SH_ComboBox_PopupFrameStyle: | - | ||||||||||||||||||||||||
| 5282 | #ifndef QT_NO_COMBOBOX | - | ||||||||||||||||||||||||
| 5283 | if (qobject_cast<const QComboBox *>(w)) { | - | ||||||||||||||||||||||||
| 5284 | QAbstractItemView *view = w->findChild<QAbstractItemView *>(); | - | ||||||||||||||||||||||||
| 5285 | if (view) { | - | ||||||||||||||||||||||||
| 5286 | view->ensurePolished(); | - | ||||||||||||||||||||||||
| 5287 | QRenderRule subRule = renderRule(view, PseudoElement_None); | - | ||||||||||||||||||||||||
| 5288 | if (subRule.hasBox() || !subRule.hasNativeBorder()) | - | ||||||||||||||||||||||||
| 5289 | return QFrame::NoFrame; | - | ||||||||||||||||||||||||
| 5290 | } | - | ||||||||||||||||||||||||
| 5291 | } | - | ||||||||||||||||||||||||
| 5292 | #endif // QT_NO_COMBOBOX | - | ||||||||||||||||||||||||
| 5293 | break; | - | ||||||||||||||||||||||||
| 5294 | case SH_DialogButtonBox_ButtonsHaveIcons: s = QLatin1String("dialogbuttonbox-buttons-have-icons"); break; | - | ||||||||||||||||||||||||
| 5295 | case SH_Workspace_FillSpaceOnMaximize: s = QLatin1String("mdi-fill-space-on-maximize"); break; | - | ||||||||||||||||||||||||
| 5296 | case SH_TitleBar_NoBorder: | - | ||||||||||||||||||||||||
| 5297 | if (rule.hasBorder()) | - | ||||||||||||||||||||||||
| 5298 | return !rule.border()->borders[LeftEdge]; | - | ||||||||||||||||||||||||
| 5299 | break; | - | ||||||||||||||||||||||||
| 5300 | case SH_TitleBar_AutoRaise: { // plain absurd | - | ||||||||||||||||||||||||
| 5301 | QRenderRule subRule = renderRule(w, opt, PseudoElement_TitleBar); | - | ||||||||||||||||||||||||
| 5302 | if (subRule.hasDrawable()) | - | ||||||||||||||||||||||||
| 5303 | return 1; | - | ||||||||||||||||||||||||
| 5304 | break; | - | ||||||||||||||||||||||||
| 5305 | } | - | ||||||||||||||||||||||||
| 5306 | case SH_ItemView_ArrowKeysNavigateIntoChildren: s = QLatin1String("arrow-keys-navigate-into-children"); break; | - | ||||||||||||||||||||||||
| 5307 | case SH_ItemView_PaintAlternatingRowColorsForEmptyArea: s = QLatin1String("paint-alternating-row-colors-for-empty-area"); break; | - | ||||||||||||||||||||||||
| 5308 | default: break; | - | ||||||||||||||||||||||||
| 5309 | } | - | ||||||||||||||||||||||||
| 5310 | if (!s.isEmpty() && rule.hasStyleHint(s)) { | - | ||||||||||||||||||||||||
| 5311 | return rule.styleHint(s).toInt(); | - | ||||||||||||||||||||||||
| 5312 | } | - | ||||||||||||||||||||||||
| 5313 | - | |||||||||||||||||||||||||
| 5314 | return baseStyle()->styleHint(sh, opt, w, shret); | - | ||||||||||||||||||||||||
| 5315 | } | - | ||||||||||||||||||||||||
| 5316 | - | |||||||||||||||||||||||||
| 5317 | QRect QStyleSheetStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, | - | ||||||||||||||||||||||||
| 5318 | const QWidget *w) const | - | ||||||||||||||||||||||||
| 5319 | { | - | ||||||||||||||||||||||||
| 5320 | RECURSION_GUARD(return baseStyle()->subControlRect(cc, opt, sc, w)) never executed: return baseStyle()->subControlRect(cc, opt, sc, w);
| 0 | ||||||||||||||||||||||||
| 5321 | - | |||||||||||||||||||||||||
| 5322 | QRenderRule rule = renderRule(w, opt); | - | ||||||||||||||||||||||||
| 5323 | switch (cc) { | - | ||||||||||||||||||||||||
| 5324 | case CC_ComboBox: never executed: case CC_ComboBox: | 0 | ||||||||||||||||||||||||
| 5325 | if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) {
| 0 | ||||||||||||||||||||||||
| 5326 | if (rule.hasBox() || !rule.hasNativeBorder()) {
| 0 | ||||||||||||||||||||||||
| 5327 | switch (sc) { | - | ||||||||||||||||||||||||
| 5328 | case SC_ComboBoxFrame: return rule.borderRect(opt->rect); never executed: return rule.borderRect(opt->rect);never executed: case SC_ComboBoxFrame: | 0 | ||||||||||||||||||||||||
| 5329 | case SC_ComboBoxEditField: never executed: case SC_ComboBoxEditField: | 0 | ||||||||||||||||||||||||
| 5330 | { | - | ||||||||||||||||||||||||
| 5331 | QRenderRule subRule = renderRule(w, opt, PseudoElement_ComboBoxDropDown); | - | ||||||||||||||||||||||||
| 5332 | QRect r = rule.contentsRect(opt->rect); | - | ||||||||||||||||||||||||
| 5333 | QRect r2 = positionRect(w, rule, subRule, PseudoElement_ComboBoxDropDown, | - | ||||||||||||||||||||||||
| 5334 | opt->rect, opt->direction); | - | ||||||||||||||||||||||||
| 5335 | if (subRule.hasPosition() && subRule.position()->position & Qt::AlignLeft) {
| 0 | ||||||||||||||||||||||||
| 5336 | return visualRect(opt->direction, r, r.adjusted(r2.width(),0,0,0)); never executed: return visualRect(opt->direction, r, r.adjusted(r2.width(),0,0,0)); | 0 | ||||||||||||||||||||||||
| 5337 | } else { | - | ||||||||||||||||||||||||
| 5338 | return visualRect(opt->direction, r, r.adjusted(0,0,-r2.width(),0)); never executed: return visualRect(opt->direction, r, r.adjusted(0,0,-r2.width(),0)); | 0 | ||||||||||||||||||||||||
| 5339 | } | - | ||||||||||||||||||||||||
| 5340 | } | - | ||||||||||||||||||||||||
| 5341 | case SC_ComboBoxArrow: { never executed: case SC_ComboBoxArrow: | 0 | ||||||||||||||||||||||||
| 5342 | QRenderRule subRule = renderRule(w, opt, PseudoElement_ComboBoxDropDown); | - | ||||||||||||||||||||||||
| 5343 | return positionRect(w, rule, subRule, PseudoElement_ComboBoxDropDown, opt->rect, opt->direction); never executed: return positionRect(w, rule, subRule, PseudoElement_ComboBoxDropDown, opt->rect, opt->direction); | 0 | ||||||||||||||||||||||||
| 5344 | } | - | ||||||||||||||||||||||||
| 5345 | case SC_ComboBoxListBoxPopup: never executed: case SC_ComboBoxListBoxPopup: | 0 | ||||||||||||||||||||||||
| 5346 | default: never executed: default: | 0 | ||||||||||||||||||||||||
| 5347 | return baseStyle()->subControlRect(cc, opt, sc, w); never executed: return baseStyle()->subControlRect(cc, opt, sc, w); | 0 | ||||||||||||||||||||||||
| 5348 | } | - | ||||||||||||||||||||||||
| 5349 | } | - | ||||||||||||||||||||||||
| 5350 | - | |||||||||||||||||||||||||
| 5351 | QStyleOptionComboBox comboBox(*cb); | - | ||||||||||||||||||||||||
| 5352 | comboBox.rect = rule.borderRect(opt->rect); | - | ||||||||||||||||||||||||
| 5353 | return rule.baseStyleCanDraw() ? baseStyle()->subControlRect(cc, &comboBox, sc, w) never executed: return rule.baseStyleCanDraw() ? baseStyle()->subControlRect(cc, &comboBox, sc, w) : QWindowsStyle::subControlRect(cc, &comboBox, sc, w); | 0 | ||||||||||||||||||||||||
| 5354 | : QWindowsStyle::subControlRect(cc, &comboBox, sc, w); never executed: return rule.baseStyleCanDraw() ? baseStyle()->subControlRect(cc, &comboBox, sc, w) : QWindowsStyle::subControlRect(cc, &comboBox, sc, w); | 0 | ||||||||||||||||||||||||
| 5355 | } | - | ||||||||||||||||||||||||
| 5356 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 5357 | - | |||||||||||||||||||||||||
| 5358 | #ifndef QT_NO_SPINBOX | - | ||||||||||||||||||||||||
| 5359 | case CC_SpinBox: never executed: case CC_SpinBox: | 0 | ||||||||||||||||||||||||
| 5360 | if (const QStyleOptionSpinBox *spin = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) {
| 0 | ||||||||||||||||||||||||
| 5361 | QRenderRule upRule = renderRule(w, opt, PseudoElement_SpinBoxUpButton); | - | ||||||||||||||||||||||||
| 5362 | QRenderRule downRule = renderRule(w, opt, PseudoElement_SpinBoxDownButton); | - | ||||||||||||||||||||||||
| 5363 | bool ruleMatch = rule.hasBox() || !rule.hasNativeBorder();
| 0 | ||||||||||||||||||||||||
| 5364 | bool upRuleMatch = upRule.hasGeometry() || upRule.hasPosition();
| 0 | ||||||||||||||||||||||||
| 5365 | bool downRuleMatch = downRule.hasGeometry() || downRule.hasPosition();
| 0 | ||||||||||||||||||||||||
| 5366 | if (ruleMatch || upRuleMatch || downRuleMatch) {
| 0 | ||||||||||||||||||||||||
| 5367 | switch (sc) { | - | ||||||||||||||||||||||||
| 5368 | case SC_SpinBoxFrame: never executed: case SC_SpinBoxFrame: | 0 | ||||||||||||||||||||||||
| 5369 | return rule.borderRect(opt->rect); never executed: return rule.borderRect(opt->rect); | 0 | ||||||||||||||||||||||||
| 5370 | case SC_SpinBoxEditField: never executed: case SC_SpinBoxEditField: | 0 | ||||||||||||||||||||||||
| 5371 | { | - | ||||||||||||||||||||||||
| 5372 | QRect r = rule.contentsRect(opt->rect); | - | ||||||||||||||||||||||||
| 5373 | // Use the widest button on each side to determine edit field size. | - | ||||||||||||||||||||||||
| 5374 | Qt::Alignment upAlign, downAlign; | - | ||||||||||||||||||||||||
| 5375 | - | |||||||||||||||||||||||||
| 5376 | upAlign = upRule.hasPosition() ? upRule.position()->position
| 0 | ||||||||||||||||||||||||
| 5377 | : Qt::Alignment(Qt::AlignRight); | - | ||||||||||||||||||||||||
| 5378 | upAlign = resolveAlignment(opt->direction, upAlign); | - | ||||||||||||||||||||||||
| 5379 | - | |||||||||||||||||||||||||
| 5380 | downAlign = downRule.hasPosition() ? downRule.position()->position
| 0 | ||||||||||||||||||||||||
| 5381 | : Qt::Alignment(Qt::AlignRight); | - | ||||||||||||||||||||||||
| 5382 | downAlign = resolveAlignment(opt->direction, downAlign); | - | ||||||||||||||||||||||||
| 5383 | - | |||||||||||||||||||||||||
| 5384 | int upSize = subControlRect(CC_SpinBox, opt, SC_SpinBoxUp, w).width(); | - | ||||||||||||||||||||||||
| 5385 | int downSize = subControlRect(CC_SpinBox, opt, SC_SpinBoxDown, w).width(); | - | ||||||||||||||||||||||||
| 5386 | int widestL = qMax((upAlign & Qt::AlignLeft) ? upSize : 0, | - | ||||||||||||||||||||||||
| 5387 | (downAlign & Qt::AlignLeft) ? downSize : 0); | - | ||||||||||||||||||||||||
| 5388 | int widestR = qMax((upAlign & Qt::AlignRight) ? upSize : 0, | - | ||||||||||||||||||||||||
| 5389 | (downAlign & Qt::AlignRight) ? downSize : 0); | - | ||||||||||||||||||||||||
| 5390 | r.setRight(r.right() - widestR); | - | ||||||||||||||||||||||||
| 5391 | r.setLeft(r.left() + widestL); | - | ||||||||||||||||||||||||
| 5392 | return r; never executed: return r; | 0 | ||||||||||||||||||||||||
| 5393 | } | - | ||||||||||||||||||||||||
| 5394 | case SC_SpinBoxDown: never executed: case SC_SpinBoxDown: | 0 | ||||||||||||||||||||||||
| 5395 | if (downRuleMatch)
| 0 | ||||||||||||||||||||||||
| 5396 | return positionRect(w, rule, downRule, PseudoElement_SpinBoxDownButton, never executed: return positionRect(w, rule, downRule, PseudoElement_SpinBoxDownButton, opt->rect, opt->direction); | 0 | ||||||||||||||||||||||||
| 5397 | opt->rect, opt->direction); never executed: return positionRect(w, rule, downRule, PseudoElement_SpinBoxDownButton, opt->rect, opt->direction); | 0 | ||||||||||||||||||||||||
| 5398 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 5399 | case SC_SpinBoxUp: never executed: case SC_SpinBoxUp: | 0 | ||||||||||||||||||||||||
| 5400 | if (upRuleMatch)
| 0 | ||||||||||||||||||||||||
| 5401 | return positionRect(w, rule, upRule, PseudoElement_SpinBoxUpButton, never executed: return positionRect(w, rule, upRule, PseudoElement_SpinBoxUpButton, opt->rect, opt->direction); | 0 | ||||||||||||||||||||||||
| 5402 | opt->rect, opt->direction); never executed: return positionRect(w, rule, upRule, PseudoElement_SpinBoxUpButton, opt->rect, opt->direction); | 0 | ||||||||||||||||||||||||
| 5403 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 5404 | default: never executed: default: | 0 | ||||||||||||||||||||||||
| 5405 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 5406 | } | - | ||||||||||||||||||||||||
| 5407 | - | |||||||||||||||||||||||||
| 5408 | return baseStyle()->subControlRect(cc, opt, sc, w); never executed: return baseStyle()->subControlRect(cc, opt, sc, w); | 0 | ||||||||||||||||||||||||
| 5409 | } | - | ||||||||||||||||||||||||
| 5410 | - | |||||||||||||||||||||||||
| 5411 | QStyleOptionSpinBox spinBox(*spin); | - | ||||||||||||||||||||||||
| 5412 | spinBox.rect = rule.borderRect(opt->rect); | - | ||||||||||||||||||||||||
| 5413 | return rule.baseStyleCanDraw() ? baseStyle()->subControlRect(cc, &spinBox, sc, w) never executed: return rule.baseStyleCanDraw() ? baseStyle()->subControlRect(cc, &spinBox, sc, w) : QWindowsStyle::subControlRect(cc, &spinBox, sc, w); | 0 | ||||||||||||||||||||||||
| 5414 | : QWindowsStyle::subControlRect(cc, &spinBox, sc, w); never executed: return rule.baseStyleCanDraw() ? baseStyle()->subControlRect(cc, &spinBox, sc, w) : QWindowsStyle::subControlRect(cc, &spinBox, sc, w); | 0 | ||||||||||||||||||||||||
| 5415 | } | - | ||||||||||||||||||||||||
| 5416 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 5417 | #endif // QT_NO_SPINBOX | - | ||||||||||||||||||||||||
| 5418 | - | |||||||||||||||||||||||||
| 5419 | case CC_GroupBox: never executed: case CC_GroupBox: | 0 | ||||||||||||||||||||||||
| 5420 | if (const QStyleOptionGroupBox *gb = qstyleoption_cast<const QStyleOptionGroupBox *>(opt)) {
| 0 | ||||||||||||||||||||||||
| 5421 | switch (sc) { | - | ||||||||||||||||||||||||
| 5422 | case SC_GroupBoxFrame: never executed: case SC_GroupBoxFrame: | 0 | ||||||||||||||||||||||||
| 5423 | case SC_GroupBoxContents: { never executed: case SC_GroupBoxContents: | 0 | ||||||||||||||||||||||||
| 5424 | if (rule.hasBox() || !rule.hasNativeBorder()) {
| 0 | ||||||||||||||||||||||||
| 5425 | return sc == SC_GroupBoxFrame ? rule.borderRect(opt->rect) never executed: return sc == SC_GroupBoxFrame ? rule.borderRect(opt->rect) : rule.contentsRect(opt->rect); | 0 | ||||||||||||||||||||||||
| 5426 | : rule.contentsRect(opt->rect); never executed: return sc == SC_GroupBoxFrame ? rule.borderRect(opt->rect) : rule.contentsRect(opt->rect); | 0 | ||||||||||||||||||||||||
| 5427 | } | - | ||||||||||||||||||||||||
| 5428 | QStyleOptionGroupBox groupBox(*gb); | - | ||||||||||||||||||||||||
| 5429 | groupBox.rect = rule.borderRect(opt->rect); | - | ||||||||||||||||||||||||
| 5430 | return baseStyle()->subControlRect(cc, &groupBox, sc, w); never executed: return baseStyle()->subControlRect(cc, &groupBox, sc, w); | 0 | ||||||||||||||||||||||||
| 5431 | } | - | ||||||||||||||||||||||||
| 5432 | default: never executed: default: | 0 | ||||||||||||||||||||||||
| 5433 | case SC_GroupBoxLabel: never executed: case SC_GroupBoxLabel: | 0 | ||||||||||||||||||||||||
| 5434 | case SC_GroupBoxCheckBox: { never executed: case SC_GroupBoxCheckBox: | 0 | ||||||||||||||||||||||||
| 5435 | QRenderRule indRule = renderRule(w, opt, PseudoElement_GroupBoxIndicator); | - | ||||||||||||||||||||||||
| 5436 | QRenderRule labelRule = renderRule(w, opt, PseudoElement_GroupBoxTitle); | - | ||||||||||||||||||||||||
| 5437 | if (!labelRule.hasPosition() && !labelRule.hasGeometry() && !labelRule.hasBox()
| 0 | ||||||||||||||||||||||||
| 5438 | && !labelRule.hasBorder() && !indRule.hasContentsSize()) {
| 0 | ||||||||||||||||||||||||
| 5439 | QStyleOptionGroupBox groupBox(*gb); | - | ||||||||||||||||||||||||
| 5440 | groupBox.rect = rule.borderRect(opt->rect); | - | ||||||||||||||||||||||||
| 5441 | return baseStyle()->subControlRect(cc, &groupBox, sc, w); never executed: return baseStyle()->subControlRect(cc, &groupBox, sc, w); | 0 | ||||||||||||||||||||||||
| 5442 | } | - | ||||||||||||||||||||||||
| 5443 | int tw = opt->fontMetrics.width(gb->text); | - | ||||||||||||||||||||||||
| 5444 | int th = opt->fontMetrics.height(); | - | ||||||||||||||||||||||||
| 5445 | int spacing = pixelMetric(QStyle::PM_CheckBoxLabelSpacing, opt, w); | - | ||||||||||||||||||||||||
| 5446 | int iw = pixelMetric(QStyle::PM_IndicatorWidth, opt, w); | - | ||||||||||||||||||||||||
| 5447 | int ih = pixelMetric(QStyle::PM_IndicatorHeight, opt, w); | - | ||||||||||||||||||||||||
| 5448 | - | |||||||||||||||||||||||||
| 5449 | if (gb->subControls & QStyle::SC_GroupBoxCheckBox) {
| 0 | ||||||||||||||||||||||||
| 5450 | tw = tw + iw + spacing; | - | ||||||||||||||||||||||||
| 5451 | th = qMax(th, ih); | - | ||||||||||||||||||||||||
| 5452 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 5453 | if (!labelRule.hasGeometry()) {
| 0 | ||||||||||||||||||||||||
| 5454 | labelRule.geo = new QStyleSheetGeometryData(tw, th, tw, th, -1, -1); | - | ||||||||||||||||||||||||
| 5455 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 5456 | labelRule.geo->width = tw; | - | ||||||||||||||||||||||||
| 5457 | labelRule.geo->height = th; | - | ||||||||||||||||||||||||
| 5458 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 5459 | if (!labelRule.hasPosition()) {
| 0 | ||||||||||||||||||||||||
| 5460 | labelRule.p = new QStyleSheetPositionData(0, 0, 0, 0, defaultOrigin(PseudoElement_GroupBoxTitle), | - | ||||||||||||||||||||||||
| 5461 | gb->textAlignment, PositionMode_Static); | - | ||||||||||||||||||||||||
| 5462 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 5463 | QRect r = positionRect(w, rule, labelRule, PseudoElement_GroupBoxTitle, | - | ||||||||||||||||||||||||
| 5464 | opt->rect, opt->direction); | - | ||||||||||||||||||||||||
| 5465 | if (gb->subControls & SC_GroupBoxCheckBox) {
| 0 | ||||||||||||||||||||||||
| 5466 | r = labelRule.contentsRect(r); | - | ||||||||||||||||||||||||
| 5467 | if (sc == SC_GroupBoxLabel) {
| 0 | ||||||||||||||||||||||||
| 5468 | r.setLeft(r.left() + iw + spacing); | - | ||||||||||||||||||||||||
| 5469 | r.setTop(r.center().y() - th/2); | - | ||||||||||||||||||||||||
| 5470 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 5471 | r = QRect(r.left(), r.center().y() - ih/2, iw, ih); | - | ||||||||||||||||||||||||
| 5472 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 5473 | return r; never executed: return r; | 0 | ||||||||||||||||||||||||
| 5474 | } else { | - | ||||||||||||||||||||||||
| 5475 | return labelRule.contentsRect(r); never executed: return labelRule.contentsRect(r); | 0 | ||||||||||||||||||||||||
| 5476 | } | - | ||||||||||||||||||||||||
| 5477 | } | - | ||||||||||||||||||||||||
| 5478 | } // switch | - | ||||||||||||||||||||||||
| 5479 | } | - | ||||||||||||||||||||||||
| 5480 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 5481 | - | |||||||||||||||||||||||||
| 5482 | case CC_ToolButton: never executed: case CC_ToolButton: | 0 | ||||||||||||||||||||||||
| 5483 | if (const QStyleOptionToolButton *tb = qstyleoption_cast<const QStyleOptionToolButton *>(opt)) {
| 0 | ||||||||||||||||||||||||
| 5484 | if (rule.hasBox() || !rule.hasNativeBorder()) {
| 0 | ||||||||||||||||||||||||
| 5485 | switch (sc) { | - | ||||||||||||||||||||||||
| 5486 | case SC_ToolButton: return rule.borderRect(opt->rect); never executed: return rule.borderRect(opt->rect);never executed: case SC_ToolButton: | 0 | ||||||||||||||||||||||||
| 5487 | case SC_ToolButtonMenu: { never executed: case SC_ToolButtonMenu: | 0 | ||||||||||||||||||||||||
| 5488 | QRenderRule subRule = renderRule(w, opt, PseudoElement_ToolButtonMenu); | - | ||||||||||||||||||||||||
| 5489 | return positionRect(w, rule, subRule, PseudoElement_ToolButtonMenu, opt->rect, opt->direction); never executed: return positionRect(w, rule, subRule, PseudoElement_ToolButtonMenu, opt->rect, opt->direction); | 0 | ||||||||||||||||||||||||
| 5490 | } | - | ||||||||||||||||||||||||
| 5491 | default: never executed: default: | 0 | ||||||||||||||||||||||||
| 5492 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 5493 | } | - | ||||||||||||||||||||||||
| 5494 | } | - | ||||||||||||||||||||||||
| 5495 | - | |||||||||||||||||||||||||
| 5496 | QStyleOptionToolButton tool(*tb); | - | ||||||||||||||||||||||||
| 5497 | tool.rect = rule.borderRect(opt->rect); | - | ||||||||||||||||||||||||
| 5498 | return rule.baseStyleCanDraw() ? baseStyle()->subControlRect(cc, &tool, sc, w) never executed: return rule.baseStyleCanDraw() ? baseStyle()->subControlRect(cc, &tool, sc, w) : QWindowsStyle::subControlRect(cc, &tool, sc, w); | 0 | ||||||||||||||||||||||||
| 5499 | : QWindowsStyle::subControlRect(cc, &tool, sc, w); never executed: return rule.baseStyleCanDraw() ? baseStyle()->subControlRect(cc, &tool, sc, w) : QWindowsStyle::subControlRect(cc, &tool, sc, w); | 0 | ||||||||||||||||||||||||
| 5500 | } | - | ||||||||||||||||||||||||
| 5501 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 5502 | - | |||||||||||||||||||||||||
| 5503 | #ifndef QT_NO_SCROLLBAR | - | ||||||||||||||||||||||||
| 5504 | case CC_ScrollBar: never executed: case CC_ScrollBar: | 0 | ||||||||||||||||||||||||
| 5505 | if (const QStyleOptionSlider *sb = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
| 0 | ||||||||||||||||||||||||
| 5506 | QStyleOptionSlider styleOptionSlider(*sb); | - | ||||||||||||||||||||||||
| 5507 | styleOptionSlider.rect = rule.borderRect(opt->rect); | - | ||||||||||||||||||||||||
| 5508 | if (rule.hasDrawable() || rule.hasBox()) {
| 0 | ||||||||||||||||||||||||
| 5509 | QRect grooveRect; | - | ||||||||||||||||||||||||
| 5510 | if (!rule.hasBox()) {
| 0 | ||||||||||||||||||||||||
| 5511 | grooveRect = rule.baseStyleCanDraw() ? baseStyle()->subControlRect(cc, sb, SC_ScrollBarGroove, w)
| 0 | ||||||||||||||||||||||||
| 5512 | : QWindowsStyle::subControlRect(cc, sb, SC_ScrollBarGroove, w); | - | ||||||||||||||||||||||||
| 5513 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 5514 | grooveRect = rule.contentsRect(opt->rect); | - | ||||||||||||||||||||||||
| 5515 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 5516 | - | |||||||||||||||||||||||||
| 5517 | PseudoElement pe = PseudoElement_None; | - | ||||||||||||||||||||||||
| 5518 | - | |||||||||||||||||||||||||
| 5519 | switch (sc) { | - | ||||||||||||||||||||||||
| 5520 | case SC_ScrollBarGroove: never executed: case SC_ScrollBarGroove: | 0 | ||||||||||||||||||||||||
| 5521 | return grooveRect; never executed: return grooveRect; | 0 | ||||||||||||||||||||||||
| 5522 | case SC_ScrollBarAddPage: never executed: case SC_ScrollBarAddPage: | 0 | ||||||||||||||||||||||||
| 5523 | case SC_ScrollBarSubPage: never executed: case SC_ScrollBarSubPage: | 0 | ||||||||||||||||||||||||
| 5524 | case SC_ScrollBarSlider: { never executed: case SC_ScrollBarSlider: | 0 | ||||||||||||||||||||||||
| 5525 | QRect contentRect = grooveRect; | - | ||||||||||||||||||||||||
| 5526 | if (hasStyleRule(w, PseudoElement_ScrollBarSlider)) {
| 0 | ||||||||||||||||||||||||
| 5527 | QRenderRule sliderRule = renderRule(w, opt, PseudoElement_ScrollBarSlider); | - | ||||||||||||||||||||||||
| 5528 | Origin origin = sliderRule.hasPosition() ? sliderRule.position()->origin : defaultOrigin(PseudoElement_ScrollBarSlider);
| 0 | ||||||||||||||||||||||||
| 5529 | contentRect = rule.originRect(opt->rect, origin); | - | ||||||||||||||||||||||||
| 5530 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 5531 | int maxlen = (styleOptionSlider.orientation == Qt::Horizontal) ? contentRect.width() : contentRect.height();
| 0 | ||||||||||||||||||||||||
| 5532 | int sliderlen; | - | ||||||||||||||||||||||||
| 5533 | if (sb->maximum != sb->minimum) {
| 0 | ||||||||||||||||||||||||
| 5534 | uint range = sb->maximum - sb->minimum; | - | ||||||||||||||||||||||||
| 5535 | sliderlen = (qint64(sb->pageStep) * maxlen) / (range + sb->pageStep); | - | ||||||||||||||||||||||||
| 5536 | - | |||||||||||||||||||||||||
| 5537 | int slidermin = pixelMetric(PM_ScrollBarSliderMin, sb, w); | - | ||||||||||||||||||||||||
| 5538 | if (sliderlen < slidermin || range > INT_MAX / 2)
| 0 | ||||||||||||||||||||||||
| 5539 | sliderlen = slidermin; never executed: sliderlen = slidermin; | 0 | ||||||||||||||||||||||||
| 5540 | if (sliderlen > maxlen)
| 0 | ||||||||||||||||||||||||
| 5541 | sliderlen = maxlen; never executed: sliderlen = maxlen; | 0 | ||||||||||||||||||||||||
| 5542 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 5543 | sliderlen = maxlen; | - | ||||||||||||||||||||||||
| 5544 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 5545 | - | |||||||||||||||||||||||||
| 5546 | const int sliderPosition = sb->orientation == Qt::Horizontal && sb->direction == Qt::RightToLeft ? sb->maximum - sb->sliderPosition + sb->minimum : sb->sliderPosition;int sliderstart = (styleOptionSlider.orientation == Qt::Horizontal ? contentRect.left() : contentRect.top())
| 0 | ||||||||||||||||||||||||
| 5547 | + sliderPositionFromValue(sb->minimum, sb->maximum, sb->sliderPosition, | - | ||||||||||||||||||||||||
| 5548 | maxlen - sliderlen, sb->upsideDown); | - | ||||||||||||||||||||||||
| 5549 | - | |||||||||||||||||||||||||
| 5550 | QRect sr = (sb->orientation == Qt::Horizontal)
| 0 | ||||||||||||||||||||||||
| 5551 | ? QRect(sliderstart, contentRect.top(), sliderlen, contentRect.height()) | - | ||||||||||||||||||||||||
| 5552 | : QRect(contentRect.left(), sliderstart, contentRect.width(), sliderlen); | - | ||||||||||||||||||||||||
| 5553 | if (sc == SC_ScrollBarSlider) {
| 0 | ||||||||||||||||||||||||
| 5554 | return sr; never executed: return sr; | 0 | ||||||||||||||||||||||||
| 5555 | } else if (sc == SC_ScrollBarSubPage) {
| 0 | ||||||||||||||||||||||||
| 5556 | return QRect(contentRect.topLeft(), sb->orientation == Qt::Horizontal ? sr.bottomLeft() : sr.topRight()); never executed: return QRect(contentRect.topLeft(), sb->orientation == Qt::Horizontal ? sr.bottomLeft() : sr.topRight()); | 0 | ||||||||||||||||||||||||
| 5557 | } else { // SC_ScrollBarAddPage | - | ||||||||||||||||||||||||
| 5558 | return QRect(sb->orientation == Qt::Horizontal ? sr.topRight() : sr.bottomLeft(), contentRect.bottomRight()); never executed: return QRect(sb->orientation == Qt::Horizontal ? sr.topRight() : sr.bottomLeft(), contentRect.bottomRight()); | 0 | ||||||||||||||||||||||||
| 5559 | } | - | ||||||||||||||||||||||||
| 5560 | break; dead code: break; | - | ||||||||||||||||||||||||
| 5561 | } | - | ||||||||||||||||||||||||
| 5562 | case SC_ScrollBarAddLine: pe = PseudoElement_ScrollBarAddLine; break; never executed: break;never executed: case SC_ScrollBarAddLine: | 0 | ||||||||||||||||||||||||
| 5563 | case SC_ScrollBarSubLine: pe = PseudoElement_ScrollBarSubLine; break; never executed: break;never executed: case SC_ScrollBarSubLine: | 0 | ||||||||||||||||||||||||
| 5564 | case SC_ScrollBarFirst: pe = PseudoElement_ScrollBarFirst; break; never executed: break;never executed: case SC_ScrollBarFirst: | 0 | ||||||||||||||||||||||||
| 5565 | case SC_ScrollBarLast: pe = PseudoElement_ScrollBarLast; break; never executed: break;never executed: case SC_ScrollBarLast: | 0 | ||||||||||||||||||||||||
| 5566 | default: break; never executed: break;never executed: default: | 0 | ||||||||||||||||||||||||
| 5567 | } | - | ||||||||||||||||||||||||
| 5568 | if (hasStyleRule(w,pe)) {
| 0 | ||||||||||||||||||||||||
| 5569 | QRenderRule subRule = renderRule(w, opt, pe); | - | ||||||||||||||||||||||||
| 5570 | if (subRule.hasPosition() || subRule.hasGeometry() || subRule.hasBox()) {
| 0 | ||||||||||||||||||||||||
| 5571 | const QStyleSheetPositionData *pos = subRule.position(); | - | ||||||||||||||||||||||||
| 5572 | QRect originRect = grooveRect; | - | ||||||||||||||||||||||||
| 5573 | if (rule.hasBox()) {
| 0 | ||||||||||||||||||||||||
| 5574 | Origin origin = (pos && pos->origin != Origin_Unknown) ? pos->origin : defaultOrigin(pe);
| 0 | ||||||||||||||||||||||||
| 5575 | originRect = rule.originRect(opt->rect, origin); | - | ||||||||||||||||||||||||
| 5576 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 5577 | return positionRect(w, subRule, pe, originRect, styleOptionSlider.direction); never executed: return positionRect(w, subRule, pe, originRect, styleOptionSlider.direction); | 0 | ||||||||||||||||||||||||
| 5578 | } | - | ||||||||||||||||||||||||
| 5579 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 5580 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 5581 | return rule.baseStyleCanDraw() ? baseStyle()->subControlRect(cc, &styleOptionSlider, sc, w) never executed: return rule.baseStyleCanDraw() ? baseStyle()->subControlRect(cc, &styleOptionSlider, sc, w) : QWindowsStyle::subControlRect(cc, &styleOptionSlider, sc, w); | 0 | ||||||||||||||||||||||||
| 5582 | : QWindowsStyle::subControlRect(cc, &styleOptionSlider, sc, w); never executed: return rule.baseStyleCanDraw() ? baseStyle()->subControlRect(cc, &styleOptionSlider, sc, w) : QWindowsStyle::subControlRect(cc, &styleOptionSlider, sc, w); | 0 | ||||||||||||||||||||||||
| 5583 | } | - | ||||||||||||||||||||||||
| 5584 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 5585 | #endif // QT_NO_SCROLLBAR | - | ||||||||||||||||||||||||
| 5586 | - | |||||||||||||||||||||||||
| 5587 | #ifndef QT_NO_SLIDER | - | ||||||||||||||||||||||||
| 5588 | case CC_Slider: never executed: case CC_Slider: | 0 | ||||||||||||||||||||||||
| 5589 | if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
| 0 | ||||||||||||||||||||||||
| 5590 | QRenderRule subRule = renderRule(w, opt, PseudoElement_SliderGroove); | - | ||||||||||||||||||||||||
| 5591 | if (!subRule.hasDrawable())
| 0 | ||||||||||||||||||||||||
| 5592 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 5593 | subRule.img = 0; | - | ||||||||||||||||||||||||
| 5594 | QRect gr = positionRect(w, rule, subRule, PseudoElement_SliderGroove, opt->rect, opt->direction); | - | ||||||||||||||||||||||||
| 5595 | switch (sc) { | - | ||||||||||||||||||||||||
| 5596 | case SC_SliderGroove: never executed: case SC_SliderGroove: | 0 | ||||||||||||||||||||||||
| 5597 | return gr; never executed: return gr; | 0 | ||||||||||||||||||||||||
| 5598 | case SC_SliderHandle: { never executed: case SC_SliderHandle: | 0 | ||||||||||||||||||||||||
| 5599 | bool horizontal = slider->orientation & Qt::Horizontal; | - | ||||||||||||||||||||||||
| 5600 | QRect cr = subRule.contentsRect(gr); | - | ||||||||||||||||||||||||
| 5601 | QRenderRule subRule2 = renderRule(w, opt, PseudoElement_SliderHandle); | - | ||||||||||||||||||||||||
| 5602 | int len = horizontal ? subRule2.size().width() : subRule2.size().height();
| 0 | ||||||||||||||||||||||||
| 5603 | subRule2.img = 0; | - | ||||||||||||||||||||||||
| 5604 | subRule2.geo = 0; | - | ||||||||||||||||||||||||
| 5605 | cr = positionRect(w, subRule2, PseudoElement_SliderHandle, cr, opt->direction); | - | ||||||||||||||||||||||||
| 5606 | int thickness = horizontal ? cr.height() : cr.width();
| 0 | ||||||||||||||||||||||||
| 5607 | int sliderPos = sliderPositionFromValue(slider->minimum, slider->maximum, slider->sliderPosition, | - | ||||||||||||||||||||||||
| 5608 | (horizontal ? cr.width() : cr.height()) - len, slider->upsideDown); | - | ||||||||||||||||||||||||
| 5609 | cr = horizontal ? QRect(cr.x() + sliderPos, cr.y(), len, thickness)
| 0 | ||||||||||||||||||||||||
| 5610 | : QRect(cr.x(), cr.y() + sliderPos, thickness, len); | - | ||||||||||||||||||||||||
| 5611 | return subRule2.borderRect(cr); never executed: return subRule2.borderRect(cr); | 0 | ||||||||||||||||||||||||
| 5612 | break; } dead code: break; | - | ||||||||||||||||||||||||
| 5613 | case SC_SliderTickmarks: never executed: case SC_SliderTickmarks: | 0 | ||||||||||||||||||||||||
| 5614 | // TODO... | - | ||||||||||||||||||||||||
| 5615 | default: never executed: default: | 0 | ||||||||||||||||||||||||
| 5616 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 5617 | } | - | ||||||||||||||||||||||||
| 5618 | } | - | ||||||||||||||||||||||||
| 5619 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 5620 | #endif // QT_NO_SLIDER | - | ||||||||||||||||||||||||
| 5621 | - | |||||||||||||||||||||||||
| 5622 | case CC_MdiControls: never executed: case CC_MdiControls: | 0 | ||||||||||||||||||||||||
| 5623 | if (hasStyleRule(w, PseudoElement_MdiCloseButton)
| 0 | ||||||||||||||||||||||||
| 5624 | || hasStyleRule(w, PseudoElement_MdiNormalButton)
| 0 | ||||||||||||||||||||||||
| 5625 | || hasStyleRule(w, PseudoElement_MdiMinButton)) {
| 0 | ||||||||||||||||||||||||
| 5626 | QList<QVariant> layout = rule.styleHint(QLatin1String("button-layout")).toList(); | - | ||||||||||||||||||||||||
| 5627 | if (layout.isEmpty())
| 0 | ||||||||||||||||||||||||
| 5628 | layout = subControlLayout(QLatin1String("mNX")); never executed: layout = subControlLayout(QLatin1String("mNX")); | 0 | ||||||||||||||||||||||||
| 5629 | - | |||||||||||||||||||||||||
| 5630 | int x = 0, width = 0; | - | ||||||||||||||||||||||||
| 5631 | QRenderRule subRule; | - | ||||||||||||||||||||||||
| 5632 | for (int i = 0; i < layout.count(); i++) {
| 0 | ||||||||||||||||||||||||
| 5633 | int layoutButton = layout[i].toInt(); | - | ||||||||||||||||||||||||
| 5634 | if (layoutButton < PseudoElement_MdiCloseButton
| 0 | ||||||||||||||||||||||||
| 5635 | || layoutButton > PseudoElement_MdiNormalButton)
| 0 | ||||||||||||||||||||||||
| 5636 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 5637 | QStyle::SubControl control = knownPseudoElements[layoutButton].subControl; | - | ||||||||||||||||||||||||
| 5638 | if (!(opt->subControls & control))
| 0 | ||||||||||||||||||||||||
| 5639 | continue; never executed: continue; | 0 | ||||||||||||||||||||||||
| 5640 | subRule = renderRule(w, opt, layoutButton); | - | ||||||||||||||||||||||||
| 5641 | width = subRule.size().width(); | - | ||||||||||||||||||||||||
| 5642 | if (sc == control)
| 0 | ||||||||||||||||||||||||
| 5643 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 5644 | x += width; | - | ||||||||||||||||||||||||
| 5645 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 5646 | - | |||||||||||||||||||||||||
| 5647 | return subRule.borderRect(QRect(x, opt->rect.top(), width, opt->rect.height())); never executed: return subRule.borderRect(QRect(x, opt->rect.top(), width, opt->rect.height())); | 0 | ||||||||||||||||||||||||
| 5648 | } | - | ||||||||||||||||||||||||
| 5649 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 5650 | - | |||||||||||||||||||||||||
| 5651 | case CC_TitleBar: never executed: case CC_TitleBar: | 0 | ||||||||||||||||||||||||
| 5652 | if (const QStyleOptionTitleBar *tb = qstyleoption_cast<const QStyleOptionTitleBar *>(opt)) {
| 0 | ||||||||||||||||||||||||
| 5653 | QRenderRule subRule = renderRule(w, opt, PseudoElement_TitleBar); | - | ||||||||||||||||||||||||
| 5654 | if (!subRule.hasDrawable() && !subRule.hasBox() && !subRule.hasBorder())
| 0 | ||||||||||||||||||||||||
| 5655 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 5656 | QHash<QStyle::SubControl, QRect> layoutRects = titleBarLayout(w, tb); | - | ||||||||||||||||||||||||
| 5657 | return layoutRects.value(sc); never executed: return layoutRects.value(sc); | 0 | ||||||||||||||||||||||||
| 5658 | } | - | ||||||||||||||||||||||||
| 5659 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 5660 | - | |||||||||||||||||||||||||
| 5661 | default: never executed: default: | 0 | ||||||||||||||||||||||||
| 5662 | break; never executed: break; | 0 | ||||||||||||||||||||||||
| 5663 | } | - | ||||||||||||||||||||||||
| 5664 | - | |||||||||||||||||||||||||
| 5665 | return baseStyle()->subControlRect(cc, opt, sc, w); never executed: return baseStyle()->subControlRect(cc, opt, sc, w); | 0 | ||||||||||||||||||||||||
| 5666 | } | - | ||||||||||||||||||||||||
| 5667 | - | |||||||||||||||||||||||||
| 5668 | QRect QStyleSheetStyle::subElementRect(SubElement se, const QStyleOption *opt, const QWidget *w) const | - | ||||||||||||||||||||||||
| 5669 | { | - | ||||||||||||||||||||||||
| 5670 | RECURSION_GUARD(return baseStyle()->subElementRect(se, opt, w)) | - | ||||||||||||||||||||||||
| 5671 | - | |||||||||||||||||||||||||
| 5672 | QRenderRule rule = renderRule(w, opt); | - | ||||||||||||||||||||||||
| 5673 | #ifndef QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 5674 | int pe = PseudoElement_None; | - | ||||||||||||||||||||||||
| 5675 | #endif | - | ||||||||||||||||||||||||
| 5676 | - | |||||||||||||||||||||||||
| 5677 | switch (se) { | - | ||||||||||||||||||||||||
| 5678 | case SE_PushButtonContents: | - | ||||||||||||||||||||||||
| 5679 | case SE_PushButtonFocusRect: | - | ||||||||||||||||||||||||
| 5680 | if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) { | - | ||||||||||||||||||||||||
| 5681 | QStyleOptionButton btnOpt(*btn); | - | ||||||||||||||||||||||||
| 5682 | if (rule.hasBox() || !rule.hasNativeBorder()) | - | ||||||||||||||||||||||||
| 5683 | return visualRect(opt->direction, opt->rect, rule.contentsRect(opt->rect)); | - | ||||||||||||||||||||||||
| 5684 | return rule.baseStyleCanDraw() ? baseStyle()->subElementRect(se, &btnOpt, w) | - | ||||||||||||||||||||||||
| 5685 | : QWindowsStyle::subElementRect(se, &btnOpt, w); | - | ||||||||||||||||||||||||
| 5686 | } | - | ||||||||||||||||||||||||
| 5687 | break; | - | ||||||||||||||||||||||||
| 5688 | - | |||||||||||||||||||||||||
| 5689 | case SE_LineEditContents: | - | ||||||||||||||||||||||||
| 5690 | case SE_FrameContents: | - | ||||||||||||||||||||||||
| 5691 | case SE_ShapedFrameContents: | - | ||||||||||||||||||||||||
| 5692 | if (rule.hasBox() || !rule.hasNativeBorder()) { | - | ||||||||||||||||||||||||
| 5693 | return visualRect(opt->direction, opt->rect, rule.contentsRect(opt->rect)); | - | ||||||||||||||||||||||||
| 5694 | } | - | ||||||||||||||||||||||||
| 5695 | break; | - | ||||||||||||||||||||||||
| 5696 | - | |||||||||||||||||||||||||
| 5697 | case SE_CheckBoxIndicator: | - | ||||||||||||||||||||||||
| 5698 | case SE_RadioButtonIndicator: | - | ||||||||||||||||||||||||
| 5699 | if (rule.hasBox() || rule.hasBorder() || hasStyleRule(w, PseudoElement_Indicator)) { | - | ||||||||||||||||||||||||
| 5700 | PseudoElement pe = se == SE_CheckBoxIndicator ? PseudoElement_Indicator : PseudoElement_ExclusiveIndicator; | - | ||||||||||||||||||||||||
| 5701 | QRenderRule subRule = renderRule(w, opt, pe); | - | ||||||||||||||||||||||||
| 5702 | return positionRect(w, rule, subRule, pe, opt->rect, opt->direction); | - | ||||||||||||||||||||||||
| 5703 | } | - | ||||||||||||||||||||||||
| 5704 | break; | - | ||||||||||||||||||||||||
| 5705 | - | |||||||||||||||||||||||||
| 5706 | case SE_CheckBoxContents: | - | ||||||||||||||||||||||||
| 5707 | case SE_RadioButtonContents: | - | ||||||||||||||||||||||||
| 5708 | if (rule.hasBox() || rule.hasBorder() || hasStyleRule(w, PseudoElement_Indicator)) { | - | ||||||||||||||||||||||||
| 5709 | bool isRadio = se == SE_RadioButtonContents; | - | ||||||||||||||||||||||||
| 5710 | QRect ir = subElementRect(isRadio ? SE_RadioButtonIndicator : SE_CheckBoxIndicator, | - | ||||||||||||||||||||||||
| 5711 | opt, w); | - | ||||||||||||||||||||||||
| 5712 | ir = visualRect(opt->direction, opt->rect, ir); | - | ||||||||||||||||||||||||
| 5713 | int spacing = pixelMetric(isRadio ? PM_RadioButtonLabelSpacing : PM_CheckBoxLabelSpacing, 0, w); | - | ||||||||||||||||||||||||
| 5714 | QRect cr = rule.contentsRect(opt->rect); | - | ||||||||||||||||||||||||
| 5715 | ir.setRect(ir.left() + ir.width() + spacing, cr.y(), | - | ||||||||||||||||||||||||
| 5716 | cr.width() - ir.width() - spacing, cr.height()); | - | ||||||||||||||||||||||||
| 5717 | return visualRect(opt->direction, opt->rect, ir); | - | ||||||||||||||||||||||||
| 5718 | } | - | ||||||||||||||||||||||||
| 5719 | break; | - | ||||||||||||||||||||||||
| 5720 | - | |||||||||||||||||||||||||
| 5721 | case SE_ToolBoxTabContents: | - | ||||||||||||||||||||||||
| 5722 | if (w && hasStyleRule(w->parentWidget(), PseudoElement_ToolBoxTab)) { | - | ||||||||||||||||||||||||
| 5723 | QRenderRule subRule = renderRule(w->parentWidget(), opt, PseudoElement_ToolBoxTab); | - | ||||||||||||||||||||||||
| 5724 | return visualRect(opt->direction, opt->rect, subRule.contentsRect(opt->rect)); | - | ||||||||||||||||||||||||
| 5725 | } | - | ||||||||||||||||||||||||
| 5726 | break; | - | ||||||||||||||||||||||||
| 5727 | - | |||||||||||||||||||||||||
| 5728 | case SE_RadioButtonFocusRect: | - | ||||||||||||||||||||||||
| 5729 | case SE_RadioButtonClickRect: // focusrect | indicator | - | ||||||||||||||||||||||||
| 5730 | if (rule.hasBox() || rule.hasBorder() || hasStyleRule(w, PseudoElement_Indicator)) { | - | ||||||||||||||||||||||||
| 5731 | return opt->rect; | - | ||||||||||||||||||||||||
| 5732 | } | - | ||||||||||||||||||||||||
| 5733 | break; | - | ||||||||||||||||||||||||
| 5734 | - | |||||||||||||||||||||||||
| 5735 | case SE_CheckBoxFocusRect: | - | ||||||||||||||||||||||||
| 5736 | case SE_CheckBoxClickRect: // relies on indicator and contents | - | ||||||||||||||||||||||||
| 5737 | return ParentStyle::subElementRect(se, opt, w); | - | ||||||||||||||||||||||||
| 5738 | - | |||||||||||||||||||||||||
| 5739 | #ifndef QT_NO_ITEMVIEWS | - | ||||||||||||||||||||||||
| 5740 | case SE_ViewItemCheckIndicator: | - | ||||||||||||||||||||||||
| 5741 | if (!qstyleoption_cast<const QStyleOptionViewItem *>(opt)) { | - | ||||||||||||||||||||||||
| 5742 | return subElementRect(SE_CheckBoxIndicator, opt, w); | - | ||||||||||||||||||||||||
| 5743 | } | - | ||||||||||||||||||||||||
| 5744 | // intentionally falls through | - | ||||||||||||||||||||||||
| 5745 | case SE_ItemViewItemText: | - | ||||||||||||||||||||||||
| 5746 | case SE_ItemViewItemDecoration: | - | ||||||||||||||||||||||||
| 5747 | case SE_ItemViewItemFocusRect: | - | ||||||||||||||||||||||||
| 5748 | if (const QStyleOptionViewItem *vopt = qstyleoption_cast<const QStyleOptionViewItem *>(opt)) { | - | ||||||||||||||||||||||||
| 5749 | QRenderRule subRule = renderRule(w, opt, PseudoElement_ViewItem); | - | ||||||||||||||||||||||||
| 5750 | PseudoElement pe = PseudoElement_None; | - | ||||||||||||||||||||||||
| 5751 | if (se == SE_ItemViewItemText || se == SE_ItemViewItemFocusRect) | - | ||||||||||||||||||||||||
| 5752 | pe = PseudoElement_ViewItemText; | - | ||||||||||||||||||||||||
| 5753 | else if (se == SE_ItemViewItemDecoration && vopt->features & QStyleOptionViewItem::HasDecoration) | - | ||||||||||||||||||||||||
| 5754 | pe = PseudoElement_ViewItemIcon; | - | ||||||||||||||||||||||||
| 5755 | else if (se == SE_ItemViewItemCheckIndicator && vopt->features & QStyleOptionViewItem::HasCheckIndicator) | - | ||||||||||||||||||||||||
| 5756 | pe = PseudoElement_ViewItemIndicator; | - | ||||||||||||||||||||||||
| 5757 | else | - | ||||||||||||||||||||||||
| 5758 | break; | - | ||||||||||||||||||||||||
| 5759 | if (subRule.hasGeometry() || subRule.hasBox() || !subRule.hasNativeBorder() || hasStyleRule(w, pe)) { | - | ||||||||||||||||||||||||
| 5760 | QRenderRule subRule2 = renderRule(w, opt, pe); | - | ||||||||||||||||||||||||
| 5761 | QStyleOptionViewItem optCopy(*vopt); | - | ||||||||||||||||||||||||
| 5762 | optCopy.rect = subRule.contentsRect(vopt->rect); | - | ||||||||||||||||||||||||
| 5763 | QRect rect = ParentStyle::subElementRect(se, &optCopy, w); | - | ||||||||||||||||||||||||
| 5764 | return positionRect(w, subRule2, pe, rect, opt->direction); | - | ||||||||||||||||||||||||
| 5765 | } | - | ||||||||||||||||||||||||
| 5766 | } | - | ||||||||||||||||||||||||
| 5767 | break; | - | ||||||||||||||||||||||||
| 5768 | #endif // QT_NO_ITEMVIEWS | - | ||||||||||||||||||||||||
| 5769 | - | |||||||||||||||||||||||||
| 5770 | case SE_HeaderArrow: { | - | ||||||||||||||||||||||||
| 5771 | QRenderRule subRule = renderRule(w, opt, PseudoElement_HeaderViewUpArrow); | - | ||||||||||||||||||||||||
| 5772 | if (subRule.hasPosition() || subRule.hasGeometry()) | - | ||||||||||||||||||||||||
| 5773 | return positionRect(w, rule, subRule, PseudoElement_HeaderViewUpArrow, opt->rect, opt->direction); | - | ||||||||||||||||||||||||
| 5774 | } | - | ||||||||||||||||||||||||
| 5775 | break; | - | ||||||||||||||||||||||||
| 5776 | - | |||||||||||||||||||||||||
| 5777 | case SE_HeaderLabel: { | - | ||||||||||||||||||||||||
| 5778 | QRenderRule subRule = renderRule(w, opt, PseudoElement_HeaderViewSection); | - | ||||||||||||||||||||||||
| 5779 | if (subRule.hasBox() || !subRule.hasNativeBorder()) | - | ||||||||||||||||||||||||
| 5780 | return subRule.contentsRect(opt->rect); | - | ||||||||||||||||||||||||
| 5781 | } | - | ||||||||||||||||||||||||
| 5782 | break; | - | ||||||||||||||||||||||||
| 5783 | - | |||||||||||||||||||||||||
| 5784 | case SE_ProgressBarGroove: | - | ||||||||||||||||||||||||
| 5785 | case SE_ProgressBarContents: | - | ||||||||||||||||||||||||
| 5786 | case SE_ProgressBarLabel: | - | ||||||||||||||||||||||||
| 5787 | if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(opt)) { | - | ||||||||||||||||||||||||
| 5788 | if (rule.hasBox() || !rule.hasNativeBorder() || rule.hasPosition() || hasStyleRule(w, PseudoElement_ProgressBarChunk)) { | - | ||||||||||||||||||||||||
| 5789 | if (se == SE_ProgressBarGroove) | - | ||||||||||||||||||||||||
| 5790 | return rule.borderRect(pb->rect); | - | ||||||||||||||||||||||||
| 5791 | else if (se == SE_ProgressBarContents) | - | ||||||||||||||||||||||||
| 5792 | return rule.contentsRect(pb->rect); | - | ||||||||||||||||||||||||
| 5793 | - | |||||||||||||||||||||||||
| 5794 | QSize sz = pb->fontMetrics.size(0, pb->text); | - | ||||||||||||||||||||||||
| 5795 | return QStyle::alignedRect(Qt::LeftToRight, rule.hasPosition() ? rule.position()->textAlignment : pb->textAlignment, | - | ||||||||||||||||||||||||
| 5796 | sz, pb->rect); | - | ||||||||||||||||||||||||
| 5797 | } | - | ||||||||||||||||||||||||
| 5798 | } | - | ||||||||||||||||||||||||
| 5799 | break; | - | ||||||||||||||||||||||||
| 5800 | - | |||||||||||||||||||||||||
| 5801 | #ifndef QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 5802 | case SE_TabWidgetLeftCorner: | - | ||||||||||||||||||||||||
| 5803 | pe = PseudoElement_TabWidgetLeftCorner; | - | ||||||||||||||||||||||||
| 5804 | // intentionally falls through | - | ||||||||||||||||||||||||
| 5805 | case SE_TabWidgetRightCorner: | - | ||||||||||||||||||||||||
| 5806 | if (pe == PseudoElement_None) | - | ||||||||||||||||||||||||
| 5807 | pe = PseudoElement_TabWidgetRightCorner; | - | ||||||||||||||||||||||||
| 5808 | // intentionally falls through | - | ||||||||||||||||||||||||
| 5809 | case SE_TabWidgetTabBar: | - | ||||||||||||||||||||||||
| 5810 | if (pe == PseudoElement_None) | - | ||||||||||||||||||||||||
| 5811 | pe = PseudoElement_TabWidgetTabBar; | - | ||||||||||||||||||||||||
| 5812 | // intentionally falls through | - | ||||||||||||||||||||||||
| 5813 | case SE_TabWidgetTabPane: | - | ||||||||||||||||||||||||
| 5814 | case SE_TabWidgetTabContents: | - | ||||||||||||||||||||||||
| 5815 | if (pe == PseudoElement_None) | - | ||||||||||||||||||||||||
| 5816 | pe = PseudoElement_TabWidgetPane; | - | ||||||||||||||||||||||||
| 5817 | - | |||||||||||||||||||||||||
| 5818 | if (hasStyleRule(w, pe)) { | - | ||||||||||||||||||||||||
| 5819 | QRect r = QWindowsStyle::subElementRect(pe == PseudoElement_TabWidgetPane ? SE_TabWidgetTabPane : se, opt, w); | - | ||||||||||||||||||||||||
| 5820 | QRenderRule subRule = renderRule(w, opt, pe); | - | ||||||||||||||||||||||||
| 5821 | r = positionRect(w, subRule, pe, r, opt->direction); | - | ||||||||||||||||||||||||
| 5822 | if (pe == PseudoElement_TabWidgetTabBar) { | - | ||||||||||||||||||||||||
| 5823 | Q_ASSERT(opt); | - | ||||||||||||||||||||||||
| 5824 | r = opt->rect.intersected(r); | - | ||||||||||||||||||||||||
| 5825 | } | - | ||||||||||||||||||||||||
| 5826 | if (se == SE_TabWidgetTabContents) | - | ||||||||||||||||||||||||
| 5827 | r = subRule.contentsRect(r); | - | ||||||||||||||||||||||||
| 5828 | return r; | - | ||||||||||||||||||||||||
| 5829 | } | - | ||||||||||||||||||||||||
| 5830 | break; | - | ||||||||||||||||||||||||
| 5831 | - | |||||||||||||||||||||||||
| 5832 | case SE_TabBarTearIndicator: { | - | ||||||||||||||||||||||||
| 5833 | QRenderRule subRule = renderRule(w, opt, PseudoElement_TabBarTear); | - | ||||||||||||||||||||||||
| 5834 | if (subRule.hasContentsSize()) { | - | ||||||||||||||||||||||||
| 5835 | QRect r; | - | ||||||||||||||||||||||||
| 5836 | if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) { | - | ||||||||||||||||||||||||
| 5837 | switch (tab->shape) { | - | ||||||||||||||||||||||||
| 5838 | case QTabBar::RoundedNorth: | - | ||||||||||||||||||||||||
| 5839 | case QTabBar::TriangularNorth: | - | ||||||||||||||||||||||||
| 5840 | case QTabBar::RoundedSouth: | - | ||||||||||||||||||||||||
| 5841 | case QTabBar::TriangularSouth: | - | ||||||||||||||||||||||||
| 5842 | r.setRect(tab->rect.left(), tab->rect.top(), subRule.size().width(), opt->rect.height()); | - | ||||||||||||||||||||||||
| 5843 | break; | - | ||||||||||||||||||||||||
| 5844 | case QTabBar::RoundedWest: | - | ||||||||||||||||||||||||
| 5845 | case QTabBar::TriangularWest: | - | ||||||||||||||||||||||||
| 5846 | case QTabBar::RoundedEast: | - | ||||||||||||||||||||||||
| 5847 | case QTabBar::TriangularEast: | - | ||||||||||||||||||||||||
| 5848 | r.setRect(tab->rect.left(), tab->rect.top(), opt->rect.width(), subRule.size().height()); | - | ||||||||||||||||||||||||
| 5849 | break; | - | ||||||||||||||||||||||||
| 5850 | default: | - | ||||||||||||||||||||||||
| 5851 | break; | - | ||||||||||||||||||||||||
| 5852 | } | - | ||||||||||||||||||||||||
| 5853 | r = visualRect(opt->direction, opt->rect, r); | - | ||||||||||||||||||||||||
| 5854 | } | - | ||||||||||||||||||||||||
| 5855 | return r; | - | ||||||||||||||||||||||||
| 5856 | } | - | ||||||||||||||||||||||||
| 5857 | break; | - | ||||||||||||||||||||||||
| 5858 | } | - | ||||||||||||||||||||||||
| 5859 | case SE_TabBarTabText: | - | ||||||||||||||||||||||||
| 5860 | case SE_TabBarTabLeftButton: | - | ||||||||||||||||||||||||
| 5861 | case SE_TabBarTabRightButton: { | - | ||||||||||||||||||||||||
| 5862 | QRenderRule subRule = renderRule(w, opt, PseudoElement_TabBarTab); | - | ||||||||||||||||||||||||
| 5863 | if (subRule.hasBox() || !subRule.hasNativeBorder()) { | - | ||||||||||||||||||||||||
| 5864 | return ParentStyle::subElementRect(se, opt, w); | - | ||||||||||||||||||||||||
| 5865 | } | - | ||||||||||||||||||||||||
| 5866 | break; | - | ||||||||||||||||||||||||
| 5867 | } | - | ||||||||||||||||||||||||
| 5868 | #endif // QT_NO_TABBAR | - | ||||||||||||||||||||||||
| 5869 | - | |||||||||||||||||||||||||
| 5870 | case SE_DockWidgetCloseButton: | - | ||||||||||||||||||||||||
| 5871 | case SE_DockWidgetFloatButton: { | - | ||||||||||||||||||||||||
| 5872 | PseudoElement pe = (se == SE_DockWidgetCloseButton) ? PseudoElement_DockWidgetCloseButton : PseudoElement_DockWidgetFloatButton; | - | ||||||||||||||||||||||||
| 5873 | QRenderRule subRule2 = renderRule(w, opt, pe); | - | ||||||||||||||||||||||||
| 5874 | if (!subRule2.hasPosition()) | - | ||||||||||||||||||||||||
| 5875 | break; | - | ||||||||||||||||||||||||
| 5876 | QRenderRule subRule = renderRule(w, opt, PseudoElement_DockWidgetTitle); | - | ||||||||||||||||||||||||
| 5877 | return positionRect(w, subRule, subRule2, pe, opt->rect, opt->direction); | - | ||||||||||||||||||||||||
| 5878 | } | - | ||||||||||||||||||||||||
| 5879 | - | |||||||||||||||||||||||||
| 5880 | #ifndef QT_NO_TOOLBAR | - | ||||||||||||||||||||||||
| 5881 | case SE_ToolBarHandle: | - | ||||||||||||||||||||||||
| 5882 | if (hasStyleRule(w, PseudoElement_ToolBarHandle)) | - | ||||||||||||||||||||||||
| 5883 | return ParentStyle::subElementRect(se, opt, w); | - | ||||||||||||||||||||||||
| 5884 | break; | - | ||||||||||||||||||||||||
| 5885 | #endif //QT_NO_TOOLBAR | - | ||||||||||||||||||||||||
| 5886 | - | |||||||||||||||||||||||||
| 5887 | // On mac we make pixel adjustments to layouts which are not | - | ||||||||||||||||||||||||
| 5888 | // desireable when you have custom style sheets on them | - | ||||||||||||||||||||||||
| 5889 | case SE_CheckBoxLayoutItem: | - | ||||||||||||||||||||||||
| 5890 | case SE_ComboBoxLayoutItem: | - | ||||||||||||||||||||||||
| 5891 | case SE_DateTimeEditLayoutItem: | - | ||||||||||||||||||||||||
| 5892 | case SE_LabelLayoutItem: | - | ||||||||||||||||||||||||
| 5893 | case SE_ProgressBarLayoutItem: | - | ||||||||||||||||||||||||
| 5894 | case SE_PushButtonLayoutItem: | - | ||||||||||||||||||||||||
| 5895 | case SE_RadioButtonLayoutItem: | - | ||||||||||||||||||||||||
| 5896 | case SE_SliderLayoutItem: | - | ||||||||||||||||||||||||
| 5897 | case SE_SpinBoxLayoutItem: | - | ||||||||||||||||||||||||
| 5898 | case SE_ToolButtonLayoutItem: | - | ||||||||||||||||||||||||
| 5899 | case SE_FrameLayoutItem: | - | ||||||||||||||||||||||||
| 5900 | case SE_GroupBoxLayoutItem: | - | ||||||||||||||||||||||||
| 5901 | case SE_TabWidgetLayoutItem: | - | ||||||||||||||||||||||||
| 5902 | if (!rule.hasNativeBorder()) | - | ||||||||||||||||||||||||
| 5903 | return opt->rect; | - | ||||||||||||||||||||||||
| 5904 | break; | - | ||||||||||||||||||||||||
| 5905 | - | |||||||||||||||||||||||||
| 5906 | default: | - | ||||||||||||||||||||||||
| 5907 | break; | - | ||||||||||||||||||||||||
| 5908 | } | - | ||||||||||||||||||||||||
| 5909 | - | |||||||||||||||||||||||||
| 5910 | return baseStyle()->subElementRect(se, opt, w); | - | ||||||||||||||||||||||||
| 5911 | } | - | ||||||||||||||||||||||||
| 5912 | - | |||||||||||||||||||||||||
| 5913 | bool QStyleSheetStyle::event(QEvent *e) | - | ||||||||||||||||||||||||
| 5914 | { | - | ||||||||||||||||||||||||
| 5915 | return (baseStyle()->event(e) && e->isAccepted()) || ParentStyle::event(e); | - | ||||||||||||||||||||||||
| 5916 | } | - | ||||||||||||||||||||||||
| 5917 | - | |||||||||||||||||||||||||
| 5918 | void QStyleSheetStyle::updateStyleSheetFont(QWidget* w) const | - | ||||||||||||||||||||||||
| 5919 | { | - | ||||||||||||||||||||||||
| 5920 | // Qt's fontDialog relies on the font of the sample edit for its selection, | - | ||||||||||||||||||||||||
| 5921 | // we should never override it. | - | ||||||||||||||||||||||||
| 5922 | if (w->objectName() == QLatin1String("qt_fontDialog_sampleEdit"))
| 0 | ||||||||||||||||||||||||
| 5923 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 5924 | - | |||||||||||||||||||||||||
| 5925 | QWidget *container = containerWidget(w); | - | ||||||||||||||||||||||||
| 5926 | QRenderRule rule = renderRule(container, PseudoElement_None, | - | ||||||||||||||||||||||||
| 5927 | PseudoClass_Active | PseudoClass_Enabled | extendedPseudoClass(container)); | - | ||||||||||||||||||||||||
| 5928 | - | |||||||||||||||||||||||||
| 5929 | const bool useStyleSheetPropagationInWidgetStyles = | - | ||||||||||||||||||||||||
| 5930 | QCoreApplication::testAttribute(Qt::AA_UseStyleSheetPropagationInWidgetStyles); | - | ||||||||||||||||||||||||
| 5931 | - | |||||||||||||||||||||||||
| 5932 | if (useStyleSheetPropagationInWidgetStyles) {
| 0 | ||||||||||||||||||||||||
| 5933 | unsetStyleSheetFont(w); | - | ||||||||||||||||||||||||
| 5934 | - | |||||||||||||||||||||||||
| 5935 | if (rule.font.resolve()) {
| 0 | ||||||||||||||||||||||||
| 5936 | QFont wf = w->font(); | - | ||||||||||||||||||||||||
| 5937 | styleSheetCaches->customFontWidgets.insert(w, qMakePair(wf, rule.font.resolve())); | - | ||||||||||||||||||||||||
| 5938 | - | |||||||||||||||||||||||||
| 5939 | QFont font = rule.font.resolve(wf); | - | ||||||||||||||||||||||||
| 5940 | font.resolve(wf.resolve() | rule.font.resolve()); | - | ||||||||||||||||||||||||
| 5941 | w->setFont(font); | - | ||||||||||||||||||||||||
| 5942 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 5943 | } else { never executed: end of block | 0 | ||||||||||||||||||||||||
| 5944 | QFont font = rule.font.resolve(w->font()); | - | ||||||||||||||||||||||||
| 5945 | - | |||||||||||||||||||||||||
| 5946 | if ((!w->isWindow() || w->testAttribute(Qt::WA_WindowPropagation))
| 0 | ||||||||||||||||||||||||
| 5947 | && isNaturalChild(w) && qobject_cast<QWidget *>(w->parent())) {
| 0 | ||||||||||||||||||||||||
| 5948 | - | |||||||||||||||||||||||||
| 5949 | font = font.resolve(static_cast<QWidget *>(w->parent())->font()); | - | ||||||||||||||||||||||||
| 5950 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 5951 | - | |||||||||||||||||||||||||
| 5952 | if (w->data->fnt == font)
| 0 | ||||||||||||||||||||||||
| 5953 | return; never executed: return; | 0 | ||||||||||||||||||||||||
| 5954 | - | |||||||||||||||||||||||||
| 5955 | w->data->fnt = font; | - | ||||||||||||||||||||||||
| 5956 | - | |||||||||||||||||||||||||
| 5957 | QEvent e(QEvent::FontChange); | - | ||||||||||||||||||||||||
| 5958 | QApplication::sendEvent(w, &e); | - | ||||||||||||||||||||||||
| 5959 | } never executed: end of block | 0 | ||||||||||||||||||||||||
| 5960 | } | - | ||||||||||||||||||||||||
| 5961 | - | |||||||||||||||||||||||||
| 5962 | void QStyleSheetStyle::saveWidgetFont(QWidget* w, const QFont& font) const | - | ||||||||||||||||||||||||
| 5963 | { | - | ||||||||||||||||||||||||
| 5964 | w->setProperty("_q_styleSheetWidgetFont", font); | - | ||||||||||||||||||||||||
| 5965 | } | - | ||||||||||||||||||||||||
| 5966 | - | |||||||||||||||||||||||||
| 5967 | void QStyleSheetStyle::clearWidgetFont(QWidget* w) const | - | ||||||||||||||||||||||||
| 5968 | { | - | ||||||||||||||||||||||||
| 5969 | w->setProperty("_q_styleSheetWidgetFont", QVariant(QVariant::Invalid)); | - | ||||||||||||||||||||||||
| 5970 | } | - | ||||||||||||||||||||||||
| 5971 | - | |||||||||||||||||||||||||
| 5972 | // Polish palette that should be used for a particular widget, with particular states | - | ||||||||||||||||||||||||
| 5973 | // (eg. :focus, :hover, ...) | - | ||||||||||||||||||||||||
| 5974 | // this is called by widgets that paint themself in their paint event | - | ||||||||||||||||||||||||
| 5975 | // Returns \c true if there is a new palette in pal. | - | ||||||||||||||||||||||||
| 5976 | bool QStyleSheetStyle::styleSheetPalette(const QWidget* w, const QStyleOption* opt, QPalette* pal) | - | ||||||||||||||||||||||||
| 5977 | { | - | ||||||||||||||||||||||||
| 5978 | if (!w || !opt || !pal) | - | ||||||||||||||||||||||||
| 5979 | return false; | - | ||||||||||||||||||||||||
| 5980 | - | |||||||||||||||||||||||||
| 5981 | RECURSION_GUARD(return false) | - | ||||||||||||||||||||||||
| 5982 | - | |||||||||||||||||||||||||
| 5983 | w = containerWidget(w); | - | ||||||||||||||||||||||||
| 5984 | - | |||||||||||||||||||||||||
| 5985 | QRenderRule rule = renderRule(w, PseudoElement_None, pseudoClass(opt->state) | extendedPseudoClass(w)); | - | ||||||||||||||||||||||||
| 5986 | if (!rule.hasPalette()) | - | ||||||||||||||||||||||||
| 5987 | return false; | - | ||||||||||||||||||||||||
| 5988 | - | |||||||||||||||||||||||||
| 5989 | rule.configurePalette(pal, QPalette::NoRole, QPalette::NoRole); | - | ||||||||||||||||||||||||
| 5990 | return true; | - | ||||||||||||||||||||||||
| 5991 | } | - | ||||||||||||||||||||||||
| 5992 | - | |||||||||||||||||||||||||
| 5993 | Qt::Alignment QStyleSheetStyle::resolveAlignment(Qt::LayoutDirection layDir, Qt::Alignment src) | - | ||||||||||||||||||||||||
| 5994 | { | - | ||||||||||||||||||||||||
| 5995 | if (layDir == Qt::LeftToRight || src & Qt::AlignAbsolute) | - | ||||||||||||||||||||||||
| 5996 | return src; | - | ||||||||||||||||||||||||
| 5997 | - | |||||||||||||||||||||||||
| 5998 | if (src & Qt::AlignLeft) { | - | ||||||||||||||||||||||||
| 5999 | src &= ~Qt::AlignLeft; | - | ||||||||||||||||||||||||
| 6000 | src |= Qt::AlignRight; | - | ||||||||||||||||||||||||
| 6001 | } else if (src & Qt::AlignRight) { | - | ||||||||||||||||||||||||
| 6002 | src &= ~Qt::AlignRight; | - | ||||||||||||||||||||||||
| 6003 | src |= Qt::AlignLeft; | - | ||||||||||||||||||||||||
| 6004 | } | - | ||||||||||||||||||||||||
| 6005 | src |= Qt::AlignAbsolute; | - | ||||||||||||||||||||||||
| 6006 | return src; | - | ||||||||||||||||||||||||
| 6007 | } | - | ||||||||||||||||||||||||
| 6008 | - | |||||||||||||||||||||||||
| 6009 | // Returns whether the given QWidget has a "natural" parent, meaning that | - | ||||||||||||||||||||||||
| 6010 | // the parent contains this child as part of its normal operation. | - | ||||||||||||||||||||||||
| 6011 | // An example is the QTabBar inside a QTabWidget. | - | ||||||||||||||||||||||||
| 6012 | // This does not mean that any QTabBar which is a child of QTabWidget will | - | ||||||||||||||||||||||||
| 6013 | // match, only the one that was created by the QTabWidget initialization | - | ||||||||||||||||||||||||
| 6014 | // (and hence has the correct object name). | - | ||||||||||||||||||||||||
| 6015 | bool QStyleSheetStyle::isNaturalChild(const QObject *obj) | - | ||||||||||||||||||||||||
| 6016 | { | - | ||||||||||||||||||||||||
| 6017 | if (obj->objectName().startsWith(QLatin1String("qt_"))) | - | ||||||||||||||||||||||||
| 6018 | return true; | - | ||||||||||||||||||||||||
| 6019 | - | |||||||||||||||||||||||||
| 6020 | return false; | - | ||||||||||||||||||||||||
| 6021 | } | - | ||||||||||||||||||||||||
| 6022 | - | |||||||||||||||||||||||||
| 6023 | QT_END_NAMESPACE | - | ||||||||||||||||||||||||
| 6024 | - | |||||||||||||||||||||||||
| 6025 | #include "moc_qstylesheetstyle_p.cpp" | - | ||||||||||||||||||||||||
| 6026 | - | |||||||||||||||||||||||||
| 6027 | #endif // QT_NO_STYLE_STYLESHEET | - | ||||||||||||||||||||||||
| Source code | Switch to Preprocessed file |