| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/widgets/styles/qpixmapstyle.cpp |
| Source code | Switch to Preprocessed file |
| Line | Source | Count | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | /*************************************************************************** | - | ||||||||||||||||||
| 2 | ** | - | ||||||||||||||||||
| 3 | ** Copyright (C) 2014 BlackBerry Limited. All rights reserved. | - | ||||||||||||||||||
| 4 | ** Copyright (C) 2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com | - | ||||||||||||||||||
| 5 | ** Copyright (C) 2016 The Qt Company Ltd. | - | ||||||||||||||||||
| 6 | ** Contact: https://www.qt.io/licensing/ | - | ||||||||||||||||||
| 7 | ** | - | ||||||||||||||||||
| 8 | ** This file is part of the QtWidgets module of the Qt Toolkit. | - | ||||||||||||||||||
| 9 | ** | - | ||||||||||||||||||
| 10 | ** $QT_BEGIN_LICENSE:LGPL$ | - | ||||||||||||||||||
| 11 | ** Commercial License Usage | - | ||||||||||||||||||
| 12 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||||||||
| 13 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||||||||
| 14 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||||||||
| 15 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||||||||
| 16 | ** and conditions see https://www.qt.io/terms-conditions. For further | - | ||||||||||||||||||
| 17 | ** information use the contact form at https://www.qt.io/contact-us. | - | ||||||||||||||||||
| 18 | ** | - | ||||||||||||||||||
| 19 | ** GNU Lesser General Public License Usage | - | ||||||||||||||||||
| 20 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||||||||
| 21 | ** General Public License version 3 as published by the Free Software | - | ||||||||||||||||||
| 22 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | - | ||||||||||||||||||
| 23 | ** packaging of this file. Please review the following information to | - | ||||||||||||||||||
| 24 | ** ensure the GNU Lesser General Public License version 3 requirements | - | ||||||||||||||||||
| 25 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | - | ||||||||||||||||||
| 26 | ** | - | ||||||||||||||||||
| 27 | ** GNU General Public License Usage | - | ||||||||||||||||||
| 28 | ** Alternatively, this file may be used under the terms of the GNU | - | ||||||||||||||||||
| 29 | ** General Public License version 2.0 or (at your option) the GNU General | - | ||||||||||||||||||
| 30 | ** Public license version 3 or any later version approved by the KDE Free | - | ||||||||||||||||||
| 31 | ** Qt Foundation. The licenses are as published by the Free Software | - | ||||||||||||||||||
| 32 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | - | ||||||||||||||||||
| 33 | ** included in the packaging of this file. Please review the following | - | ||||||||||||||||||
| 34 | ** information to ensure the GNU General Public License requirements will | - | ||||||||||||||||||
| 35 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | - | ||||||||||||||||||
| 36 | ** https://www.gnu.org/licenses/gpl-3.0.html. | - | ||||||||||||||||||
| 37 | ** | - | ||||||||||||||||||
| 38 | ** $QT_END_LICENSE$ | - | ||||||||||||||||||
| 39 | ** | - | ||||||||||||||||||
| 40 | ****************************************************************************/ | - | ||||||||||||||||||
| 41 | - | |||||||||||||||||||
| 42 | #include "qpixmapstyle_p.h" | - | ||||||||||||||||||
| 43 | #include "qpixmapstyle_p_p.h" | - | ||||||||||||||||||
| 44 | - | |||||||||||||||||||
| 45 | #include <QDebug> | - | ||||||||||||||||||
| 46 | #include <QTextEdit> | - | ||||||||||||||||||
| 47 | #include <QStringBuilder> | - | ||||||||||||||||||
| 48 | #include <QPainter> | - | ||||||||||||||||||
| 49 | #include <QPixmapCache> | - | ||||||||||||||||||
| 50 | #include <QStyleOption> | - | ||||||||||||||||||
| 51 | #include <QString> | - | ||||||||||||||||||
| 52 | #include <QProgressBar> | - | ||||||||||||||||||
| 53 | #include <QSlider> | - | ||||||||||||||||||
| 54 | #include <QEvent> | - | ||||||||||||||||||
| 55 | #include <QComboBox> | - | ||||||||||||||||||
| 56 | #include <QAbstractItemView> | - | ||||||||||||||||||
| 57 | #include <QListView> | - | ||||||||||||||||||
| 58 | #include <QTreeView> | - | ||||||||||||||||||
| 59 | #include <QStyledItemDelegate> | - | ||||||||||||||||||
| 60 | #include <QAbstractScrollArea> | - | ||||||||||||||||||
| 61 | #include <QScrollBar> | - | ||||||||||||||||||
| 62 | - | |||||||||||||||||||
| 63 | #include <qscroller.h> | - | ||||||||||||||||||
| 64 | - | |||||||||||||||||||
| 65 | QT_BEGIN_NAMESPACE | - | ||||||||||||||||||
| 66 | - | |||||||||||||||||||
| 67 | /*! | - | ||||||||||||||||||
| 68 | \class QPixmapStyle | - | ||||||||||||||||||
| 69 | \brief The QPixmapStyle class provides mechanism for writing pixmap based styles. | - | ||||||||||||||||||
| 70 | - | |||||||||||||||||||
| 71 | \since 5.7 | - | ||||||||||||||||||
| 72 | \ingroup appearance | - | ||||||||||||||||||
| 73 | \inmodule QtWidgets | - | ||||||||||||||||||
| 74 | \internal | - | ||||||||||||||||||
| 75 | - | |||||||||||||||||||
| 76 | This is a convenience class that enables the implementation of a widget style using | - | ||||||||||||||||||
| 77 | pixmaps, on the same fashion used by the \l{BorderImage} QML type. | - | ||||||||||||||||||
| 78 | - | |||||||||||||||||||
| 79 | In order to style a QWidget, one simply needs to call QPixmapStyle::addDescriptor() | - | ||||||||||||||||||
| 80 | or QPixmapStyle::addPixmap() with the id of the component to be styled, the path of | - | ||||||||||||||||||
| 81 | the image to be used, the margins and the tiling rules: | - | ||||||||||||||||||
| 82 | - | |||||||||||||||||||
| 83 | \snippet styles/qcustompixmapstyle.cpp 0 | - | ||||||||||||||||||
| 84 | - | |||||||||||||||||||
| 85 | \sa QStyle, QCommonStyle | - | ||||||||||||||||||
| 86 | */ | - | ||||||||||||||||||
| 87 | - | |||||||||||||||||||
| 88 | /*! | - | ||||||||||||||||||
| 89 | \internal | - | ||||||||||||||||||
| 90 | - | |||||||||||||||||||
| 91 | Constructs a QPixmapStyle object. | - | ||||||||||||||||||
| 92 | */ | - | ||||||||||||||||||
| 93 | QPixmapStyle::QPixmapStyle() | - | ||||||||||||||||||
| 94 | : QCommonStyle(*new QPixmapStylePrivate) | - | ||||||||||||||||||
| 95 | { | - | ||||||||||||||||||
| 96 | } never executed: end of block | 0 | ||||||||||||||||||
| 97 | - | |||||||||||||||||||
| 98 | /*! | - | ||||||||||||||||||
| 99 | Destroys the QPixmapStyle object. | - | ||||||||||||||||||
| 100 | */ | - | ||||||||||||||||||
| 101 | QPixmapStyle::~QPixmapStyle() | - | ||||||||||||||||||
| 102 | { | - | ||||||||||||||||||
| 103 | } | - | ||||||||||||||||||
| 104 | - | |||||||||||||||||||
| 105 | /*! | - | ||||||||||||||||||
| 106 | \reimp | - | ||||||||||||||||||
| 107 | */ | - | ||||||||||||||||||
| 108 | void QPixmapStyle::polish(QApplication *application) | - | ||||||||||||||||||
| 109 | { | - | ||||||||||||||||||
| 110 | QCommonStyle::polish(application); | - | ||||||||||||||||||
| 111 | #if defined(Q_DEAD_CODE_FROM_QT4_WIN) | - | ||||||||||||||||||
| 112 | QApplication::setEffectEnabled(Qt::UI_AnimateCombo, false); | - | ||||||||||||||||||
| 113 | #endif | - | ||||||||||||||||||
| 114 | } never executed: end of block | 0 | ||||||||||||||||||
| 115 | - | |||||||||||||||||||
| 116 | /*! | - | ||||||||||||||||||
| 117 | \reimp | - | ||||||||||||||||||
| 118 | */ | - | ||||||||||||||||||
| 119 | void QPixmapStyle::polish(QPalette &palette) | - | ||||||||||||||||||
| 120 | { | - | ||||||||||||||||||
| 121 | palette = proxy()->standardPalette(); | - | ||||||||||||||||||
| 122 | } never executed: end of block | 0 | ||||||||||||||||||
| 123 | - | |||||||||||||||||||
| 124 | /*! | - | ||||||||||||||||||
| 125 | \reimp | - | ||||||||||||||||||
| 126 | */ | - | ||||||||||||||||||
| 127 | void QPixmapStyle::polish(QWidget *widget) | - | ||||||||||||||||||
| 128 | { | - | ||||||||||||||||||
| 129 | Q_D(QPixmapStyle); | - | ||||||||||||||||||
| 130 | - | |||||||||||||||||||
| 131 | // Don't fill the interior of the QTextEdit | - | ||||||||||||||||||
| 132 | if (qobject_cast<QTextEdit*>(widget)) {
| 0 | ||||||||||||||||||
| 133 | QPalette p = widget->palette(); | - | ||||||||||||||||||
| 134 | p.setBrush(QPalette::Base, Qt::NoBrush); | - | ||||||||||||||||||
| 135 | widget->setPalette(p); | - | ||||||||||||||||||
| 136 | } never executed: end of block | 0 | ||||||||||||||||||
| 137 | - | |||||||||||||||||||
| 138 | if (QProgressBar *pb = qobject_cast<QProgressBar*>(widget)) {
| 0 | ||||||||||||||||||
| 139 | // Center the text in the progress bar | - | ||||||||||||||||||
| 140 | pb->setAlignment(Qt::AlignCenter); | - | ||||||||||||||||||
| 141 | // Change the font size if needed, as it's used to compute the minimum size | - | ||||||||||||||||||
| 142 | QFont font = pb->font(); | - | ||||||||||||||||||
| 143 | font.setPixelSize(d->descriptors.value(PB_HBackground).size.height()/2); | - | ||||||||||||||||||
| 144 | pb->setFont(font); | - | ||||||||||||||||||
| 145 | } never executed: end of block | 0 | ||||||||||||||||||
| 146 | - | |||||||||||||||||||
| 147 | if (qobject_cast<QSlider*>(widget))
| 0 | ||||||||||||||||||
| 148 | widget->installEventFilter(this); never executed: widget->installEventFilter(this); | 0 | ||||||||||||||||||
| 149 | - | |||||||||||||||||||
| 150 | if (QComboBox *cb = qobject_cast<QComboBox*>(widget)) {
| 0 | ||||||||||||||||||
| 151 | widget->installEventFilter(this); | - | ||||||||||||||||||
| 152 | // NOTE: This will break if the private API of QComboBox changes drastically | - | ||||||||||||||||||
| 153 | // Make sure the popup is created so we can change the frame style | - | ||||||||||||||||||
| 154 | QAbstractItemView *list = cb->view(); | - | ||||||||||||||||||
| 155 | list->setProperty("_pixmap_combobox_list", true); | - | ||||||||||||||||||
| 156 | list->setItemDelegate(new QStyledItemDelegate(list)); | - | ||||||||||||||||||
| 157 | QPalette p = list->palette(); | - | ||||||||||||||||||
| 158 | p.setBrush(QPalette::Active, QPalette::Base, QBrush(Qt::transparent) ); | - | ||||||||||||||||||
| 159 | p.setBrush(QPalette::Active, QPalette::AlternateBase, QBrush(Qt::transparent) ); | - | ||||||||||||||||||
| 160 | p.setBrush(QPalette::Inactive, QPalette::Base, QBrush(Qt::transparent) ); | - | ||||||||||||||||||
| 161 | p.setBrush(QPalette::Inactive, QPalette::AlternateBase, QBrush(Qt::transparent) ); | - | ||||||||||||||||||
| 162 | p.setBrush(QPalette::Disabled, QPalette::Base, QBrush(Qt::transparent) ); | - | ||||||||||||||||||
| 163 | p.setBrush(QPalette::Disabled, QPalette::AlternateBase, QBrush(Qt::transparent) ); | - | ||||||||||||||||||
| 164 | list->setPalette(p); | - | ||||||||||||||||||
| 165 | - | |||||||||||||||||||
| 166 | QFrame *frame = qobject_cast<QFrame*>(list->parent()); | - | ||||||||||||||||||
| 167 | if (frame) {
| 0 | ||||||||||||||||||
| 168 | const QPixmapStyleDescriptor &desc = d->descriptors.value(DD_PopupDown); | - | ||||||||||||||||||
| 169 | const QPixmapStylePixmap &pix = d->pixmaps.value(DD_ItemSeparator); | - | ||||||||||||||||||
| 170 | frame->setContentsMargins(pix.margins.left(), desc.margins.top(), | - | ||||||||||||||||||
| 171 | pix.margins.right(), desc.margins.bottom()); | - | ||||||||||||||||||
| 172 | frame->setAttribute(Qt::WA_TranslucentBackground); | - | ||||||||||||||||||
| 173 | #ifdef Q_DEAD_CODE_FROM_QT4_WIN | - | ||||||||||||||||||
| 174 | // FramelessWindowHint is needed on windows to make | - | ||||||||||||||||||
| 175 | // WA_TranslucentBackground work properly | - | ||||||||||||||||||
| 176 | frame->setWindowFlags(widget->windowFlags() | Qt::FramelessWindowHint); | - | ||||||||||||||||||
| 177 | #endif | - | ||||||||||||||||||
| 178 | } never executed: end of block | 0 | ||||||||||||||||||
| 179 | } never executed: end of block | 0 | ||||||||||||||||||
| 180 | - | |||||||||||||||||||
| 181 | if (qstrcmp(widget->metaObject()->className(),"QComboBoxPrivateContainer") == 0)
| 0 | ||||||||||||||||||
| 182 | widget->installEventFilter(this); never executed: widget->installEventFilter(this); | 0 | ||||||||||||||||||
| 183 | - | |||||||||||||||||||
| 184 | if (QAbstractScrollArea *scrollArea = qobject_cast<QAbstractScrollArea*>(widget)) {
| 0 | ||||||||||||||||||
| 185 | scrollArea->viewport()->setAutoFillBackground(false); | - | ||||||||||||||||||
| 186 | if (QAbstractItemView *view = qobject_cast<QAbstractItemView*>(scrollArea)) {
| 0 | ||||||||||||||||||
| 187 | view->setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel); | - | ||||||||||||||||||
| 188 | view->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); | - | ||||||||||||||||||
| 189 | } never executed: end of block | 0 | ||||||||||||||||||
| 190 | QScroller::grabGesture(scrollArea->viewport(), QScroller::LeftMouseButtonGesture); | - | ||||||||||||||||||
| 191 | } never executed: end of block | 0 | ||||||||||||||||||
| 192 | - | |||||||||||||||||||
| 193 | if (qobject_cast<QScrollBar*>(widget))
| 0 | ||||||||||||||||||
| 194 | widget->setAttribute(Qt::WA_OpaquePaintEvent, false); never executed: widget->setAttribute(Qt::WA_OpaquePaintEvent, false); | 0 | ||||||||||||||||||
| 195 | - | |||||||||||||||||||
| 196 | QCommonStyle::polish(widget); | - | ||||||||||||||||||
| 197 | } never executed: end of block | 0 | ||||||||||||||||||
| 198 | - | |||||||||||||||||||
| 199 | /*! | - | ||||||||||||||||||
| 200 | \reimp | - | ||||||||||||||||||
| 201 | */ | - | ||||||||||||||||||
| 202 | void QPixmapStyle::unpolish(QApplication *application) | - | ||||||||||||||||||
| 203 | { | - | ||||||||||||||||||
| 204 | QCommonStyle::unpolish(application); | - | ||||||||||||||||||
| 205 | } never executed: end of block | 0 | ||||||||||||||||||
| 206 | - | |||||||||||||||||||
| 207 | /*! | - | ||||||||||||||||||
| 208 | \reimp | - | ||||||||||||||||||
| 209 | */ | - | ||||||||||||||||||
| 210 | void QPixmapStyle::unpolish(QWidget *widget) | - | ||||||||||||||||||
| 211 | { | - | ||||||||||||||||||
| 212 | if (qobject_cast<QSlider*>(widget) ||
| 0 | ||||||||||||||||||
| 213 | qobject_cast<QComboBox*>(widget)) {
| 0 | ||||||||||||||||||
| 214 | widget->removeEventFilter(this); | - | ||||||||||||||||||
| 215 | } never executed: end of block | 0 | ||||||||||||||||||
| 216 | - | |||||||||||||||||||
| 217 | if (qstrcmp(widget->metaObject()->className(),"QComboBoxPrivateContainer") == 0)
| 0 | ||||||||||||||||||
| 218 | widget->removeEventFilter(this); never executed: widget->removeEventFilter(this); | 0 | ||||||||||||||||||
| 219 | - | |||||||||||||||||||
| 220 | if (QAbstractScrollArea *scrollArea = qobject_cast<QAbstractScrollArea*>(widget))
| 0 | ||||||||||||||||||
| 221 | QScroller::ungrabGesture(scrollArea->viewport()); never executed: QScroller::ungrabGesture(scrollArea->viewport()); | 0 | ||||||||||||||||||
| 222 | - | |||||||||||||||||||
| 223 | QCommonStyle::unpolish(widget); | - | ||||||||||||||||||
| 224 | } never executed: end of block | 0 | ||||||||||||||||||
| 225 | - | |||||||||||||||||||
| 226 | /*! | - | ||||||||||||||||||
| 227 | \reimp | - | ||||||||||||||||||
| 228 | */ | - | ||||||||||||||||||
| 229 | void QPixmapStyle::drawPrimitive(PrimitiveElement element, const QStyleOption *option, | - | ||||||||||||||||||
| 230 | QPainter *painter, const QWidget *widget) const | - | ||||||||||||||||||
| 231 | { | - | ||||||||||||||||||
| 232 | switch (element) { | - | ||||||||||||||||||
| 233 | case PE_FrameFocusRect: //disable focus rectangle never executed: case PE_FrameFocusRect: | 0 | ||||||||||||||||||
| 234 | break; never executed: break; | 0 | ||||||||||||||||||
| 235 | case PE_PanelButtonBevel: never executed: case PE_PanelButtonBevel: | 0 | ||||||||||||||||||
| 236 | case PE_PanelButtonCommand: never executed: case PE_PanelButtonCommand: | 0 | ||||||||||||||||||
| 237 | drawPushButton(option, painter, widget); | - | ||||||||||||||||||
| 238 | break; never executed: break; | 0 | ||||||||||||||||||
| 239 | case PE_PanelLineEdit: never executed: case PE_PanelLineEdit: | 0 | ||||||||||||||||||
| 240 | case PE_FrameLineEdit: never executed: case PE_FrameLineEdit: | 0 | ||||||||||||||||||
| 241 | drawLineEdit(option, painter, widget); | - | ||||||||||||||||||
| 242 | break; never executed: break; | 0 | ||||||||||||||||||
| 243 | case PE_Frame: never executed: case PE_Frame: | 0 | ||||||||||||||||||
| 244 | case PE_FrameDefaultButton: never executed: case PE_FrameDefaultButton: | 0 | ||||||||||||||||||
| 245 | if (qobject_cast<const QTextEdit*>(widget))
| 0 | ||||||||||||||||||
| 246 | drawTextEdit(option, painter, widget); never executed: drawTextEdit(option, painter, widget); | 0 | ||||||||||||||||||
| 247 | break; never executed: break; | 0 | ||||||||||||||||||
| 248 | case PE_IndicatorCheckBox: never executed: case PE_IndicatorCheckBox: | 0 | ||||||||||||||||||
| 249 | drawCheckBox(option, painter, widget); | - | ||||||||||||||||||
| 250 | break; never executed: break; | 0 | ||||||||||||||||||
| 251 | case PE_IndicatorRadioButton: never executed: case PE_IndicatorRadioButton: | 0 | ||||||||||||||||||
| 252 | drawRadioButton(option, painter, widget); | - | ||||||||||||||||||
| 253 | break; never executed: break; | 0 | ||||||||||||||||||
| 254 | case PE_PanelItemViewItem: never executed: case PE_PanelItemViewItem: | 0 | ||||||||||||||||||
| 255 | if (qobject_cast<const QListView*>(widget))
| 0 | ||||||||||||||||||
| 256 | drawPanelItemViewItem(option, painter, widget); never executed: drawPanelItemViewItem(option, painter, widget); | 0 | ||||||||||||||||||
| 257 | else | - | ||||||||||||||||||
| 258 | QCommonStyle::drawPrimitive(element, option, painter, widget); never executed: QCommonStyle::drawPrimitive(element, option, painter, widget); | 0 | ||||||||||||||||||
| 259 | break; never executed: break; | 0 | ||||||||||||||||||
| 260 | default: never executed: default: | 0 | ||||||||||||||||||
| 261 | QCommonStyle::drawPrimitive(element, option, painter, widget); | - | ||||||||||||||||||
| 262 | } never executed: end of block | 0 | ||||||||||||||||||
| 263 | } | - | ||||||||||||||||||
| 264 | - | |||||||||||||||||||
| 265 | /*! | - | ||||||||||||||||||
| 266 | \reimp | - | ||||||||||||||||||
| 267 | */ | - | ||||||||||||||||||
| 268 | void QPixmapStyle::drawControl(ControlElement element, const QStyleOption *option, | - | ||||||||||||||||||
| 269 | QPainter *painter, const QWidget *widget) const | - | ||||||||||||||||||
| 270 | { | - | ||||||||||||||||||
| 271 | Q_D(const QPixmapStyle); | - | ||||||||||||||||||
| 272 | - | |||||||||||||||||||
| 273 | switch (element) { | - | ||||||||||||||||||
| 274 | case CE_ProgressBarGroove: never executed: case CE_ProgressBarGroove: | 0 | ||||||||||||||||||
| 275 | drawProgressBarBackground(option, painter, widget); | - | ||||||||||||||||||
| 276 | break; never executed: break; | 0 | ||||||||||||||||||
| 277 | case CE_ProgressBarLabel: never executed: case CE_ProgressBarLabel: | 0 | ||||||||||||||||||
| 278 | drawProgressBarLabel(option, painter, widget); | - | ||||||||||||||||||
| 279 | break; never executed: break; | 0 | ||||||||||||||||||
| 280 | case CE_ProgressBarContents: never executed: case CE_ProgressBarContents: | 0 | ||||||||||||||||||
| 281 | drawProgressBarFill(option, painter, widget); | - | ||||||||||||||||||
| 282 | break; never executed: break; | 0 | ||||||||||||||||||
| 283 | case CE_ShapedFrame: never executed: case CE_ShapedFrame: | 0 | ||||||||||||||||||
| 284 | // NOTE: This will break if the private API of QComboBox changes drastically | - | ||||||||||||||||||
| 285 | if (qstrcmp(widget->metaObject()->className(),"QComboBoxPrivateContainer") == 0) {
| 0 | ||||||||||||||||||
| 286 | const QPixmapStyleDescriptor &desc = d->descriptors.value(DD_PopupDown); | - | ||||||||||||||||||
| 287 | const QPixmapStylePixmap &pix = d->pixmaps.value(DD_ItemSeparator); | - | ||||||||||||||||||
| 288 | QRect rect = option->rect; | - | ||||||||||||||||||
| 289 | rect.adjust(-pix.margins.left(), -desc.margins.top(), | - | ||||||||||||||||||
| 290 | pix.margins.right(), desc.margins.bottom()); | - | ||||||||||||||||||
| 291 | bool up = widget->property("_pixmapstyle_combobox_up").toBool(); | - | ||||||||||||||||||
| 292 | drawCachedPixmap(up ? DD_PopupUp : DD_PopupDown, rect, painter); | - | ||||||||||||||||||
| 293 | } never executed: end of block | 0 | ||||||||||||||||||
| 294 | else { | - | ||||||||||||||||||
| 295 | QCommonStyle::drawControl(element, option, painter, widget); | - | ||||||||||||||||||
| 296 | } never executed: end of block | 0 | ||||||||||||||||||
| 297 | break; never executed: break; | 0 | ||||||||||||||||||
| 298 | default: never executed: default: | 0 | ||||||||||||||||||
| 299 | QCommonStyle::drawControl(element, option, painter, widget); | - | ||||||||||||||||||
| 300 | } never executed: end of block | 0 | ||||||||||||||||||
| 301 | } | - | ||||||||||||||||||
| 302 | - | |||||||||||||||||||
| 303 | /*! | - | ||||||||||||||||||
| 304 | \reimp | - | ||||||||||||||||||
| 305 | */ | - | ||||||||||||||||||
| 306 | void QPixmapStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex *option, | - | ||||||||||||||||||
| 307 | QPainter *painter, const QWidget *widget) const | - | ||||||||||||||||||
| 308 | { | - | ||||||||||||||||||
| 309 | switch (cc) { | - | ||||||||||||||||||
| 310 | case CC_Slider: never executed: case CC_Slider: | 0 | ||||||||||||||||||
| 311 | drawSlider(option, painter, widget); | - | ||||||||||||||||||
| 312 | break; never executed: break; | 0 | ||||||||||||||||||
| 313 | case CC_ComboBox: never executed: case CC_ComboBox: | 0 | ||||||||||||||||||
| 314 | drawComboBox(option, painter, widget); | - | ||||||||||||||||||
| 315 | break; never executed: break; | 0 | ||||||||||||||||||
| 316 | case CC_ScrollBar: never executed: case CC_ScrollBar: | 0 | ||||||||||||||||||
| 317 | drawScrollBar(option, painter, widget); | - | ||||||||||||||||||
| 318 | break; never executed: break; | 0 | ||||||||||||||||||
| 319 | default: never executed: default: | 0 | ||||||||||||||||||
| 320 | QCommonStyle::drawComplexControl(cc, option, painter, widget); | - | ||||||||||||||||||
| 321 | } never executed: end of block | 0 | ||||||||||||||||||
| 322 | } | - | ||||||||||||||||||
| 323 | - | |||||||||||||||||||
| 324 | /*! | - | ||||||||||||||||||
| 325 | \reimp | - | ||||||||||||||||||
| 326 | */ | - | ||||||||||||||||||
| 327 | QSize QPixmapStyle::sizeFromContents(ContentsType type, const QStyleOption *option, | - | ||||||||||||||||||
| 328 | const QSize &contentsSize, const QWidget *widget) const | - | ||||||||||||||||||
| 329 | { | - | ||||||||||||||||||
| 330 | switch (type) { | - | ||||||||||||||||||
| 331 | case CT_PushButton: never executed: case CT_PushButton: | 0 | ||||||||||||||||||
| 332 | return pushButtonSizeFromContents(option, contentsSize, widget); never executed: return pushButtonSizeFromContents(option, contentsSize, widget); | 0 | ||||||||||||||||||
| 333 | case CT_LineEdit: never executed: case CT_LineEdit: | 0 | ||||||||||||||||||
| 334 | return lineEditSizeFromContents(option, contentsSize, widget); never executed: return lineEditSizeFromContents(option, contentsSize, widget); | 0 | ||||||||||||||||||
| 335 | case CT_ProgressBar: never executed: case CT_ProgressBar: | 0 | ||||||||||||||||||
| 336 | return progressBarSizeFromContents(option, contentsSize, widget); never executed: return progressBarSizeFromContents(option, contentsSize, widget); | 0 | ||||||||||||||||||
| 337 | case CT_Slider: never executed: case CT_Slider: | 0 | ||||||||||||||||||
| 338 | return sliderSizeFromContents(option, contentsSize, widget); never executed: return sliderSizeFromContents(option, contentsSize, widget); | 0 | ||||||||||||||||||
| 339 | case CT_ComboBox: never executed: case CT_ComboBox: | 0 | ||||||||||||||||||
| 340 | return comboBoxSizeFromContents(option, contentsSize, widget); never executed: return comboBoxSizeFromContents(option, contentsSize, widget); | 0 | ||||||||||||||||||
| 341 | case CT_ItemViewItem: never executed: case CT_ItemViewItem: | 0 | ||||||||||||||||||
| 342 | return itemViewSizeFromContents(option, contentsSize, widget); never executed: return itemViewSizeFromContents(option, contentsSize, widget); | 0 | ||||||||||||||||||
| 343 | default: ; never executed: default: | 0 | ||||||||||||||||||
| 344 | } never executed: end of block | 0 | ||||||||||||||||||
| 345 | - | |||||||||||||||||||
| 346 | return QCommonStyle::sizeFromContents(type, option, contentsSize, widget); never executed: return QCommonStyle::sizeFromContents(type, option, contentsSize, widget); | 0 | ||||||||||||||||||
| 347 | } | - | ||||||||||||||||||
| 348 | - | |||||||||||||||||||
| 349 | /*! | - | ||||||||||||||||||
| 350 | \reimp | - | ||||||||||||||||||
| 351 | */ | - | ||||||||||||||||||
| 352 | QRect QPixmapStyle::subElementRect(SubElement element, const QStyleOption *option, | - | ||||||||||||||||||
| 353 | const QWidget *widget) const | - | ||||||||||||||||||
| 354 | { | - | ||||||||||||||||||
| 355 | Q_D(const QPixmapStyle); | - | ||||||||||||||||||
| 356 | - | |||||||||||||||||||
| 357 | switch (element) { | - | ||||||||||||||||||
| 358 | case SE_LineEditContents: never executed: case SE_LineEditContents: | 0 | ||||||||||||||||||
| 359 | { | - | ||||||||||||||||||
| 360 | QRect rect = QCommonStyle::subElementRect(element, option, widget); | - | ||||||||||||||||||
| 361 | const QPixmapStyleDescriptor &desc = d->descriptors.value(LE_Enabled); | - | ||||||||||||||||||
| 362 | rect.adjust(desc.margins.left(), desc.margins.top(), | - | ||||||||||||||||||
| 363 | -desc.margins.right(), -desc.margins.bottom()); | - | ||||||||||||||||||
| 364 | rect = visualRect(option->direction, option->rect, rect); | - | ||||||||||||||||||
| 365 | return rect; never executed: return rect; | 0 | ||||||||||||||||||
| 366 | } | - | ||||||||||||||||||
| 367 | default: ; never executed: default: | 0 | ||||||||||||||||||
| 368 | } never executed: end of block | 0 | ||||||||||||||||||
| 369 | - | |||||||||||||||||||
| 370 | return QCommonStyle::subElementRect(element, option, widget); never executed: return QCommonStyle::subElementRect(element, option, widget); | 0 | ||||||||||||||||||
| 371 | } | - | ||||||||||||||||||
| 372 | - | |||||||||||||||||||
| 373 | /*! | - | ||||||||||||||||||
| 374 | \reimp | - | ||||||||||||||||||
| 375 | */ | - | ||||||||||||||||||
| 376 | QRect QPixmapStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *option, | - | ||||||||||||||||||
| 377 | SubControl sc, const QWidget *widget) const | - | ||||||||||||||||||
| 378 | { | - | ||||||||||||||||||
| 379 | switch (cc) { | - | ||||||||||||||||||
| 380 | case CC_ComboBox: never executed: case CC_ComboBox: | 0 | ||||||||||||||||||
| 381 | return comboBoxSubControlRect(option, sc, widget); never executed: return comboBoxSubControlRect(option, sc, widget); | 0 | ||||||||||||||||||
| 382 | case CC_ScrollBar: never executed: case CC_ScrollBar: | 0 | ||||||||||||||||||
| 383 | return scrollBarSubControlRect(option, sc, widget); never executed: return scrollBarSubControlRect(option, sc, widget); | 0 | ||||||||||||||||||
| 384 | default: ; never executed: default: | 0 | ||||||||||||||||||
| 385 | } never executed: end of block | 0 | ||||||||||||||||||
| 386 | - | |||||||||||||||||||
| 387 | return QCommonStyle::subControlRect(cc, option, sc, widget); never executed: return QCommonStyle::subControlRect(cc, option, sc, widget); | 0 | ||||||||||||||||||
| 388 | } | - | ||||||||||||||||||
| 389 | - | |||||||||||||||||||
| 390 | /*! | - | ||||||||||||||||||
| 391 | \reimp | - | ||||||||||||||||||
| 392 | */ | - | ||||||||||||||||||
| 393 | int QPixmapStyle::pixelMetric(PixelMetric metric, const QStyleOption *option, | - | ||||||||||||||||||
| 394 | const QWidget *widget) const | - | ||||||||||||||||||
| 395 | { | - | ||||||||||||||||||
| 396 | Q_D(const QPixmapStyle); | - | ||||||||||||||||||
| 397 | - | |||||||||||||||||||
| 398 | switch (metric) { | - | ||||||||||||||||||
| 399 | case PM_ButtonShiftHorizontal: never executed: case PM_ButtonShiftHorizontal: | 0 | ||||||||||||||||||
| 400 | case PM_ButtonShiftVertical: never executed: case PM_ButtonShiftVertical: | 0 | ||||||||||||||||||
| 401 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
| 402 | case PM_DefaultFrameWidth: never executed: case PM_DefaultFrameWidth: | 0 | ||||||||||||||||||
| 403 | if (qobject_cast<const QTextEdit*>(widget)) {
| 0 | ||||||||||||||||||
| 404 | const QPixmapStyleDescriptor &desc = d->descriptors.value(LE_Enabled); | - | ||||||||||||||||||
| 405 | return qMax(qMax(desc.margins.left(), desc.margins.right()), never executed: return qMax(qMax(desc.margins.left(), desc.margins.right()), qMax(desc.margins.top(), desc.margins.bottom())); | 0 | ||||||||||||||||||
| 406 | qMax(desc.margins.top(), desc.margins.bottom())); never executed: return qMax(qMax(desc.margins.left(), desc.margins.right()), qMax(desc.margins.top(), desc.margins.bottom())); | 0 | ||||||||||||||||||
| 407 | } | - | ||||||||||||||||||
| 408 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
| 409 | case PM_IndicatorWidth: never executed: case PM_IndicatorWidth: | 0 | ||||||||||||||||||
| 410 | return d->pixmaps.value(CB_Enabled).pixmap.width(); never executed: return d->pixmaps.value(CB_Enabled).pixmap.width(); | 0 | ||||||||||||||||||
| 411 | case PM_IndicatorHeight: never executed: case PM_IndicatorHeight: | 0 | ||||||||||||||||||
| 412 | return d->pixmaps.value(CB_Enabled).pixmap.height(); never executed: return d->pixmaps.value(CB_Enabled).pixmap.height(); | 0 | ||||||||||||||||||
| 413 | case PM_CheckBoxLabelSpacing: never executed: case PM_CheckBoxLabelSpacing: | 0 | ||||||||||||||||||
| 414 | { | - | ||||||||||||||||||
| 415 | const QPixmapStylePixmap &pix = d->pixmaps.value(CB_Enabled); | - | ||||||||||||||||||
| 416 | return qMax(qMax(pix.margins.left(), pix.margins.right()), never executed: return qMax(qMax(pix.margins.left(), pix.margins.right()), qMax(pix.margins.top(), pix.margins.bottom())); | 0 | ||||||||||||||||||
| 417 | qMax(pix.margins.top(), pix.margins.bottom())); never executed: return qMax(qMax(pix.margins.left(), pix.margins.right()), qMax(pix.margins.top(), pix.margins.bottom())); | 0 | ||||||||||||||||||
| 418 | } | - | ||||||||||||||||||
| 419 | case PM_ExclusiveIndicatorWidth: never executed: case PM_ExclusiveIndicatorWidth: | 0 | ||||||||||||||||||
| 420 | return d->pixmaps.value(RB_Enabled).pixmap.width(); never executed: return d->pixmaps.value(RB_Enabled).pixmap.width(); | 0 | ||||||||||||||||||
| 421 | case PM_ExclusiveIndicatorHeight: never executed: case PM_ExclusiveIndicatorHeight: | 0 | ||||||||||||||||||
| 422 | return d->pixmaps.value(RB_Enabled).pixmap.height(); never executed: return d->pixmaps.value(RB_Enabled).pixmap.height(); | 0 | ||||||||||||||||||
| 423 | case PM_RadioButtonLabelSpacing: never executed: case PM_RadioButtonLabelSpacing: | 0 | ||||||||||||||||||
| 424 | { | - | ||||||||||||||||||
| 425 | const QPixmapStylePixmap &pix = d->pixmaps.value(RB_Enabled); | - | ||||||||||||||||||
| 426 | return qMax(qMax(pix.margins.left(), pix.margins.right()), never executed: return qMax(qMax(pix.margins.left(), pix.margins.right()), qMax(pix.margins.top(), pix.margins.bottom())); | 0 | ||||||||||||||||||
| 427 | qMax(pix.margins.top(), pix.margins.bottom())); never executed: return qMax(qMax(pix.margins.left(), pix.margins.right()), qMax(pix.margins.top(), pix.margins.bottom())); | 0 | ||||||||||||||||||
| 428 | } | - | ||||||||||||||||||
| 429 | case PM_SliderThickness: never executed: case PM_SliderThickness: | 0 | ||||||||||||||||||
| 430 | if (const QStyleOptionSlider *slider =
| 0 | ||||||||||||||||||
| 431 | qstyleoption_cast<const QStyleOptionSlider*>(option)) {
| 0 | ||||||||||||||||||
| 432 | const QPixmapStyleDescriptor desc = | - | ||||||||||||||||||
| 433 | d->descriptors.value(slider->orientation == Qt::Horizontal | - | ||||||||||||||||||
| 434 | ? SG_HEnabled : SG_VEnabled); | - | ||||||||||||||||||
| 435 | return slider->orientation == Qt::Horizontal never executed: return slider->orientation == Qt::Horizontal ? desc.size.height() : desc.size.width(); | 0 | ||||||||||||||||||
| 436 | ? desc.size.height() : desc.size.width(); never executed: return slider->orientation == Qt::Horizontal ? desc.size.height() : desc.size.width(); | 0 | ||||||||||||||||||
| 437 | } | - | ||||||||||||||||||
| 438 | break; never executed: break; | 0 | ||||||||||||||||||
| 439 | case PM_SliderControlThickness: never executed: case PM_SliderControlThickness: | 0 | ||||||||||||||||||
| 440 | if (const QStyleOptionSlider *slider =
| 0 | ||||||||||||||||||
| 441 | qstyleoption_cast<const QStyleOptionSlider*>(option)) {
| 0 | ||||||||||||||||||
| 442 | const QPixmapStylePixmap pix = | - | ||||||||||||||||||
| 443 | d->pixmaps.value(slider->orientation == Qt::Horizontal | - | ||||||||||||||||||
| 444 | ? SH_HEnabled : SH_VEnabled); | - | ||||||||||||||||||
| 445 | return slider->orientation == Qt::Horizontal never executed: return slider->orientation == Qt::Horizontal ? pix.pixmap.height() : pix.pixmap.width(); | 0 | ||||||||||||||||||
| 446 | ? pix.pixmap.height() : pix.pixmap.width(); never executed: return slider->orientation == Qt::Horizontal ? pix.pixmap.height() : pix.pixmap.width(); | 0 | ||||||||||||||||||
| 447 | } | - | ||||||||||||||||||
| 448 | break; never executed: break; | 0 | ||||||||||||||||||
| 449 | case PM_SliderLength: never executed: case PM_SliderLength: | 0 | ||||||||||||||||||
| 450 | if (const QStyleOptionSlider *slider =
| 0 | ||||||||||||||||||
| 451 | qstyleoption_cast<const QStyleOptionSlider*>(option)) {
| 0 | ||||||||||||||||||
| 452 | const QPixmapStylePixmap pix = | - | ||||||||||||||||||
| 453 | d->pixmaps.value(slider->orientation == Qt::Horizontal | - | ||||||||||||||||||
| 454 | ? SH_HEnabled : SH_VEnabled); | - | ||||||||||||||||||
| 455 | return slider->orientation == Qt::Horizontal never executed: return slider->orientation == Qt::Horizontal ? pix.pixmap.width() : pix.pixmap.height(); | 0 | ||||||||||||||||||
| 456 | ? pix.pixmap.width() : pix.pixmap.height(); never executed: return slider->orientation == Qt::Horizontal ? pix.pixmap.width() : pix.pixmap.height(); | 0 | ||||||||||||||||||
| 457 | } | - | ||||||||||||||||||
| 458 | break; never executed: break; | 0 | ||||||||||||||||||
| 459 | case PM_ScrollBarExtent: never executed: case PM_ScrollBarExtent: | 0 | ||||||||||||||||||
| 460 | if (const QStyleOptionSlider *slider =
| 0 | ||||||||||||||||||
| 461 | qstyleoption_cast<const QStyleOptionSlider*>(option)) {
| 0 | ||||||||||||||||||
| 462 | const QPixmapStyleDescriptor desc = | - | ||||||||||||||||||
| 463 | d->descriptors.value(slider->orientation == Qt::Horizontal | - | ||||||||||||||||||
| 464 | ? SB_Horizontal : SB_Vertical); | - | ||||||||||||||||||
| 465 | return slider->orientation == Qt::Horizontal never executed: return slider->orientation == Qt::Horizontal ? desc.size.height() : desc.size.width(); | 0 | ||||||||||||||||||
| 466 | ? desc.size.height() : desc.size.width(); never executed: return slider->orientation == Qt::Horizontal ? desc.size.height() : desc.size.width(); | 0 | ||||||||||||||||||
| 467 | } | - | ||||||||||||||||||
| 468 | break; never executed: break; | 0 | ||||||||||||||||||
| 469 | case PM_ScrollBarSliderMin: never executed: case PM_ScrollBarSliderMin: | 0 | ||||||||||||||||||
| 470 | return 0; never executed: return 0; | 0 | ||||||||||||||||||
| 471 | default: ; never executed: default: | 0 | ||||||||||||||||||
| 472 | } never executed: end of block | 0 | ||||||||||||||||||
| 473 | - | |||||||||||||||||||
| 474 | return QCommonStyle::pixelMetric(metric, option, widget); never executed: return QCommonStyle::pixelMetric(metric, option, widget); | 0 | ||||||||||||||||||
| 475 | } | - | ||||||||||||||||||
| 476 | - | |||||||||||||||||||
| 477 | /*! | - | ||||||||||||||||||
| 478 | \reimp | - | ||||||||||||||||||
| 479 | */ | - | ||||||||||||||||||
| 480 | int QPixmapStyle::styleHint(StyleHint hint, const QStyleOption *option, | - | ||||||||||||||||||
| 481 | const QWidget *widget, QStyleHintReturn *returnData) const | - | ||||||||||||||||||
| 482 | { | - | ||||||||||||||||||
| 483 | switch (hint) { | - | ||||||||||||||||||
| 484 | case SH_EtchDisabledText: never executed: case SH_EtchDisabledText: | 0 | ||||||||||||||||||
| 485 | return false; never executed: return false; | 0 | ||||||||||||||||||
| 486 | case SH_ComboBox_Popup: never executed: case SH_ComboBox_Popup: | 0 | ||||||||||||||||||
| 487 | return false; never executed: return false; | 0 | ||||||||||||||||||
| 488 | default: ; never executed: default: | 0 | ||||||||||||||||||
| 489 | } never executed: end of block | 0 | ||||||||||||||||||
| 490 | - | |||||||||||||||||||
| 491 | return QCommonStyle::styleHint(hint, option, widget, returnData); never executed: return QCommonStyle::styleHint(hint, option, widget, returnData); | 0 | ||||||||||||||||||
| 492 | } | - | ||||||||||||||||||
| 493 | - | |||||||||||||||||||
| 494 | /*! | - | ||||||||||||||||||
| 495 | \reimp | - | ||||||||||||||||||
| 496 | */ | - | ||||||||||||||||||
| 497 | QStyle::SubControl QPixmapStyle::hitTestComplexControl(QStyle::ComplexControl control, | - | ||||||||||||||||||
| 498 | const QStyleOptionComplex *option, | - | ||||||||||||||||||
| 499 | const QPoint &pos, | - | ||||||||||||||||||
| 500 | const QWidget *widget) const | - | ||||||||||||||||||
| 501 | { | - | ||||||||||||||||||
| 502 | const SubControl sc = QCommonStyle::hitTestComplexControl(control, option, pos, widget); | - | ||||||||||||||||||
| 503 | if (control == CC_ScrollBar) {
| 0 | ||||||||||||||||||
| 504 | if (sc == SC_ScrollBarAddLine)
| 0 | ||||||||||||||||||
| 505 | return SC_ScrollBarAddPage; never executed: return SC_ScrollBarAddPage; | 0 | ||||||||||||||||||
| 506 | else if (sc == SC_ScrollBarSubLine)
| 0 | ||||||||||||||||||
| 507 | return SC_ScrollBarSubPage; never executed: return SC_ScrollBarSubPage; | 0 | ||||||||||||||||||
| 508 | } never executed: end of block | 0 | ||||||||||||||||||
| 509 | - | |||||||||||||||||||
| 510 | return sc; never executed: return sc; | 0 | ||||||||||||||||||
| 511 | } | - | ||||||||||||||||||
| 512 | - | |||||||||||||||||||
| 513 | /*! | - | ||||||||||||||||||
| 514 | \reimp | - | ||||||||||||||||||
| 515 | */ | - | ||||||||||||||||||
| 516 | bool QPixmapStyle::eventFilter(QObject *watched, QEvent *event) | - | ||||||||||||||||||
| 517 | { | - | ||||||||||||||||||
| 518 | Q_D(QPixmapStyle); | - | ||||||||||||||||||
| 519 | - | |||||||||||||||||||
| 520 | if (QSlider *slider = qobject_cast<QSlider*>(watched)) {
| 0 | ||||||||||||||||||
| 521 | switch (event->type()) { | - | ||||||||||||||||||
| 522 | case QEvent::MouseButtonPress: never executed: case QEvent::MouseButtonPress: | 0 | ||||||||||||||||||
| 523 | case QEvent::MouseButtonRelease: never executed: case QEvent::MouseButtonRelease: | 0 | ||||||||||||||||||
| 524 | case QEvent::MouseMove: never executed: case QEvent::MouseMove: | 0 | ||||||||||||||||||
| 525 | slider->update(); | - | ||||||||||||||||||
| 526 | break; never executed: break; | 0 | ||||||||||||||||||
| 527 | default: ; never executed: default: | 0 | ||||||||||||||||||
| 528 | } never executed: end of block | 0 | ||||||||||||||||||
| 529 | } | - | ||||||||||||||||||
| 530 | - | |||||||||||||||||||
| 531 | if (QComboBox *comboBox = qobject_cast<QComboBox*>(watched)) {
| 0 | ||||||||||||||||||
| 532 | switch (event->type()) { | - | ||||||||||||||||||
| 533 | case QEvent::MouseButtonPress: never executed: case QEvent::MouseButtonPress: | 0 | ||||||||||||||||||
| 534 | event->ignore(); | - | ||||||||||||||||||
| 535 | comboBox->setProperty("_pixmapstyle_combobox_pressed", true); | - | ||||||||||||||||||
| 536 | comboBox->repaint(); | - | ||||||||||||||||||
| 537 | return true; never executed: return true; | 0 | ||||||||||||||||||
| 538 | case QEvent::MouseButtonRelease: never executed: case QEvent::MouseButtonRelease: | 0 | ||||||||||||||||||
| 539 | comboBox->setProperty("_pixmapstyle_combobox_pressed", false); | - | ||||||||||||||||||
| 540 | comboBox->repaint(); | - | ||||||||||||||||||
| 541 | if ( comboBox->view() ) {
| 0 | ||||||||||||||||||
| 542 | if ( comboBox->view()->isVisible() || (!comboBox->isEnabled()))
| 0 | ||||||||||||||||||
| 543 | comboBox->hidePopup(); never executed: comboBox->hidePopup(); | 0 | ||||||||||||||||||
| 544 | else | - | ||||||||||||||||||
| 545 | comboBox->showPopup(); never executed: comboBox->showPopup(); | 0 | ||||||||||||||||||
| 546 | } | - | ||||||||||||||||||
| 547 | break; never executed: break; | 0 | ||||||||||||||||||
| 548 | default: ; never executed: default: | 0 | ||||||||||||||||||
| 549 | } never executed: end of block | 0 | ||||||||||||||||||
| 550 | } | - | ||||||||||||||||||
| 551 | - | |||||||||||||||||||
| 552 | if (qstrcmp(watched->metaObject()->className(),"QComboBoxPrivateContainer") == 0) {
| 0 | ||||||||||||||||||
| 553 | if (event->type() == QEvent::Show) {
| 0 | ||||||||||||||||||
| 554 | QWidget *widget = qobject_cast<QWidget*>(watched); | - | ||||||||||||||||||
| 555 | int yPopup = widget->geometry().top(); | - | ||||||||||||||||||
| 556 | int yCombo = widget->parentWidget()->mapToGlobal(QPoint(0, 0)).y(); | - | ||||||||||||||||||
| 557 | QRect geom = widget->geometry(); | - | ||||||||||||||||||
| 558 | const QPixmapStyleDescriptor &desc = d->descriptors.value(DD_ButtonEnabled); | - | ||||||||||||||||||
| 559 | const bool up = yPopup < yCombo; | - | ||||||||||||||||||
| 560 | geom.moveTop(geom.top() + (up ? desc.margins.top() : -desc.margins.bottom())); | - | ||||||||||||||||||
| 561 | widget->setGeometry(geom); | - | ||||||||||||||||||
| 562 | widget->setProperty("_pixmapstyle_combobox_up", up); | - | ||||||||||||||||||
| 563 | widget->parentWidget()->setProperty("_pixmapstyle_combobox_up", up); | - | ||||||||||||||||||
| 564 | } never executed: end of block | 0 | ||||||||||||||||||
| 565 | } never executed: end of block | 0 | ||||||||||||||||||
| 566 | - | |||||||||||||||||||
| 567 | return QCommonStyle::eventFilter(watched, event); never executed: return QCommonStyle::eventFilter(watched, event); | 0 | ||||||||||||||||||
| 568 | } | - | ||||||||||||||||||
| 569 | - | |||||||||||||||||||
| 570 | /*! | - | ||||||||||||||||||
| 571 | \fn void QPixmapStyle::addDescriptor(QPixmapStyle::ControlDescriptor control, const QString &fileName, QMargins margins, QTileRules tileRules) | - | ||||||||||||||||||
| 572 | - | |||||||||||||||||||
| 573 | Associates the pixmap having the given \a fileName with the given \a control. The \a margins parameter describe the boundaries | - | ||||||||||||||||||
| 574 | of the pixmap's top-left, top-right, bottom-left and bottom-right corners, as well as the left, right, top and bottorm segments | - | ||||||||||||||||||
| 575 | and the middle. The \a tileRules parameter describes how QPixmapStyle is supposed to handle the scaling of the center of the pixmap. | - | ||||||||||||||||||
| 576 | - | |||||||||||||||||||
| 577 | Use QPixmapStyle::addPixmap() for controls that are not resizable. | - | ||||||||||||||||||
| 578 | - | |||||||||||||||||||
| 579 | \snippet styles/qcustompixmapstyle.cpp 1 | - | ||||||||||||||||||
| 580 | - | |||||||||||||||||||
| 581 | \sa addPixmap, copyDescriptor | - | ||||||||||||||||||
| 582 | - | |||||||||||||||||||
| 583 | */ | - | ||||||||||||||||||
| 584 | void QPixmapStyle::addDescriptor(QPixmapStyle::ControlDescriptor control, const QString &fileName, | - | ||||||||||||||||||
| 585 | QMargins margins, QTileRules tileRules) | - | ||||||||||||||||||
| 586 | { | - | ||||||||||||||||||
| 587 | Q_D(QPixmapStyle); | - | ||||||||||||||||||
| 588 | - | |||||||||||||||||||
| 589 | QPixmapStyleDescriptor desc; | - | ||||||||||||||||||
| 590 | QImage image(fileName); | - | ||||||||||||||||||
| 591 | - | |||||||||||||||||||
| 592 | if (image.isNull())
| 0 | ||||||||||||||||||
| 593 | return; never executed: return; | 0 | ||||||||||||||||||
| 594 | - | |||||||||||||||||||
| 595 | desc.fileName = fileName; | - | ||||||||||||||||||
| 596 | desc.margins = margins; | - | ||||||||||||||||||
| 597 | desc.tileRules = tileRules; | - | ||||||||||||||||||
| 598 | desc.size = image.size(); | - | ||||||||||||||||||
| 599 | - | |||||||||||||||||||
| 600 | d->descriptors[control] = desc; | - | ||||||||||||||||||
| 601 | } never executed: end of block | 0 | ||||||||||||||||||
| 602 | - | |||||||||||||||||||
| 603 | /*! | - | ||||||||||||||||||
| 604 | \fn void QPixmapStyle::copyDescriptor(QPixmapStyle::ControlDescriptor source, QPixmapStyle::ControlDescriptor dest) | - | ||||||||||||||||||
| 605 | - | |||||||||||||||||||
| 606 | Copies the data associated with the \a source descriptor to the \a dest descriptor. | - | ||||||||||||||||||
| 607 | - | |||||||||||||||||||
| 608 | \snippet styles/qcustompixmapstyle.cpp 2 | - | ||||||||||||||||||
| 609 | */ | - | ||||||||||||||||||
| 610 | - | |||||||||||||||||||
| 611 | void QPixmapStyle::copyDescriptor(QPixmapStyle::ControlDescriptor source, | - | ||||||||||||||||||
| 612 | QPixmapStyle::ControlDescriptor dest) | - | ||||||||||||||||||
| 613 | { | - | ||||||||||||||||||
| 614 | Q_D(QPixmapStyle); | - | ||||||||||||||||||
| 615 | d->descriptors[dest] = d->descriptors.value(source); | - | ||||||||||||||||||
| 616 | } never executed: end of block | 0 | ||||||||||||||||||
| 617 | - | |||||||||||||||||||
| 618 | /*! | - | ||||||||||||||||||
| 619 | \fn void QPixmapStyle::drawCachedPixmap(QPixmapStyle::ControlDescriptor control, const QRect &rect, QPainter *painter) const | - | ||||||||||||||||||
| 620 | - | |||||||||||||||||||
| 621 | Draws the image associated with the current \a control on the given \a rect using the given \a painter. | - | ||||||||||||||||||
| 622 | */ | - | ||||||||||||||||||
| 623 | void QPixmapStyle::drawCachedPixmap(QPixmapStyle::ControlDescriptor control, const QRect &rect, | - | ||||||||||||||||||
| 624 | QPainter *p) const | - | ||||||||||||||||||
| 625 | { | - | ||||||||||||||||||
| 626 | Q_D(const QPixmapStyle); | - | ||||||||||||||||||
| 627 | if (!d->descriptors.contains(control))
| 0 | ||||||||||||||||||
| 628 | return; never executed: return; | 0 | ||||||||||||||||||
| 629 | const QPixmapStyleDescriptor &desc = d->descriptors.value(control); | - | ||||||||||||||||||
| 630 | const QPixmap pix = d->getCachedPixmap(control, desc, rect.size()); | - | ||||||||||||||||||
| 631 | Q_ASSERT(!pix.isNull()); | - | ||||||||||||||||||
| 632 | p->drawPixmap(rect, pix); | - | ||||||||||||||||||
| 633 | } never executed: end of block | 0 | ||||||||||||||||||
| 634 | - | |||||||||||||||||||
| 635 | /*! | - | ||||||||||||||||||
| 636 | \fn void QPixmapStyle::addPixmap(ControlPixmap control, const QString &fileName, QMargins margins) | - | ||||||||||||||||||
| 637 | - | |||||||||||||||||||
| 638 | Use this function to style statically sized controls such as check boxes. | - | ||||||||||||||||||
| 639 | - | |||||||||||||||||||
| 640 | \sa addDescriptor, copyPixmap | - | ||||||||||||||||||
| 641 | */ | - | ||||||||||||||||||
| 642 | void QPixmapStyle::addPixmap(ControlPixmap control, const QString &fileName, | - | ||||||||||||||||||
| 643 | QMargins margins) | - | ||||||||||||||||||
| 644 | { | - | ||||||||||||||||||
| 645 | Q_D(QPixmapStyle); | - | ||||||||||||||||||
| 646 | - | |||||||||||||||||||
| 647 | QPixmapStylePixmap pix; | - | ||||||||||||||||||
| 648 | QPixmap image(fileName); | - | ||||||||||||||||||
| 649 | - | |||||||||||||||||||
| 650 | if (image.isNull())
| 0 | ||||||||||||||||||
| 651 | return; never executed: return; | 0 | ||||||||||||||||||
| 652 | - | |||||||||||||||||||
| 653 | pix.pixmap = image; | - | ||||||||||||||||||
| 654 | pix.margins = margins; | - | ||||||||||||||||||
| 655 | - | |||||||||||||||||||
| 656 | d->pixmaps[control] = pix; | - | ||||||||||||||||||
| 657 | } never executed: end of block | 0 | ||||||||||||||||||
| 658 | - | |||||||||||||||||||
| 659 | /* | - | ||||||||||||||||||
| 660 | \fn void QPixmapStyle::copyPixmap(QPixmapStyle::ControlPixmap source, QPixmapStyle::ControlPixmap dest) | - | ||||||||||||||||||
| 661 | - | |||||||||||||||||||
| 662 | Copies the data associated with the \a source pixmap to the \a dest pixmap. | - | ||||||||||||||||||
| 663 | - | |||||||||||||||||||
| 664 | \sa addPixmap, addDescriptor, copyDescriptor | - | ||||||||||||||||||
| 665 | */ | - | ||||||||||||||||||
| 666 | void QPixmapStyle::copyPixmap(QPixmapStyle::ControlPixmap source, QPixmapStyle::ControlPixmap dest) | - | ||||||||||||||||||
| 667 | { | - | ||||||||||||||||||
| 668 | Q_D(QPixmapStyle); | - | ||||||||||||||||||
| 669 | d->pixmaps[dest] = d->pixmaps.value(source); | - | ||||||||||||||||||
| 670 | } never executed: end of block | 0 | ||||||||||||||||||
| 671 | - | |||||||||||||||||||
| 672 | /*! | - | ||||||||||||||||||
| 673 | \internal | - | ||||||||||||||||||
| 674 | - | |||||||||||||||||||
| 675 | Constructs a QPixmapStyle object. | - | ||||||||||||||||||
| 676 | */ | - | ||||||||||||||||||
| 677 | QPixmapStyle::QPixmapStyle(QPixmapStylePrivate &dd) | - | ||||||||||||||||||
| 678 | : QCommonStyle(dd) | - | ||||||||||||||||||
| 679 | {} never executed: end of block | 0 | ||||||||||||||||||
| 680 | - | |||||||||||||||||||
| 681 | void QPixmapStyle::drawPushButton(const QStyleOption *option, | - | ||||||||||||||||||
| 682 | QPainter *painter, const QWidget *) const | - | ||||||||||||||||||
| 683 | { | - | ||||||||||||||||||
| 684 | const bool checked = option->state & State_On; | - | ||||||||||||||||||
| 685 | const bool pressed = option->state & State_Sunken; | - | ||||||||||||||||||
| 686 | const bool enabled = option->state & State_Enabled; | - | ||||||||||||||||||
| 687 | - | |||||||||||||||||||
| 688 | ControlDescriptor control = PB_Enabled; | - | ||||||||||||||||||
| 689 | if (enabled)
| 0 | ||||||||||||||||||
| 690 | control = pressed ? PB_Pressed : (checked ? PB_Checked : PB_Enabled); never executed: control = pressed ? PB_Pressed : (checked ? PB_Checked : PB_Enabled);
| 0 | ||||||||||||||||||
| 691 | else | - | ||||||||||||||||||
| 692 | control = checked ? PB_PressedDisabled : PB_Disabled; never executed: control = checked ? PB_PressedDisabled : PB_Disabled;
| 0 | ||||||||||||||||||
| 693 | drawCachedPixmap(control, option->rect, painter); | - | ||||||||||||||||||
| 694 | } never executed: end of block | 0 | ||||||||||||||||||
| 695 | - | |||||||||||||||||||
| 696 | void QPixmapStyle::drawLineEdit(const QStyleOption *option, | - | ||||||||||||||||||
| 697 | QPainter *painter, const QWidget *widget) const | - | ||||||||||||||||||
| 698 | { | - | ||||||||||||||||||
| 699 | // Don't draw for the line edit inside a combobox | - | ||||||||||||||||||
| 700 | if (widget && qobject_cast<const QComboBox*>(widget->parentWidget()))
| 0 | ||||||||||||||||||
| 701 | return; never executed: return; | 0 | ||||||||||||||||||
| 702 | - | |||||||||||||||||||
| 703 | const bool enabled = option->state & State_Enabled; | - | ||||||||||||||||||
| 704 | const bool focused = option->state & State_HasFocus; | - | ||||||||||||||||||
| 705 | ControlDescriptor control = enabled ? (focused ? LE_Focused : LE_Enabled) : LE_Disabled;
| 0 | ||||||||||||||||||
| 706 | drawCachedPixmap(control, option->rect, painter); | - | ||||||||||||||||||
| 707 | } never executed: end of block | 0 | ||||||||||||||||||
| 708 | - | |||||||||||||||||||
| 709 | void QPixmapStyle::drawTextEdit(const QStyleOption *option, | - | ||||||||||||||||||
| 710 | QPainter *painter, const QWidget *) const | - | ||||||||||||||||||
| 711 | { | - | ||||||||||||||||||
| 712 | const bool enabled = option->state & State_Enabled; | - | ||||||||||||||||||
| 713 | const bool focused = option->state & State_HasFocus; | - | ||||||||||||||||||
| 714 | ControlDescriptor control = enabled ? (focused ? TE_Focused : TE_Enabled) : TE_Disabled;
| 0 | ||||||||||||||||||
| 715 | drawCachedPixmap(control, option->rect, painter); | - | ||||||||||||||||||
| 716 | } never executed: end of block | 0 | ||||||||||||||||||
| 717 | - | |||||||||||||||||||
| 718 | void QPixmapStyle::drawCheckBox(const QStyleOption *option, | - | ||||||||||||||||||
| 719 | QPainter *painter, const QWidget *) const | - | ||||||||||||||||||
| 720 | { | - | ||||||||||||||||||
| 721 | Q_D(const QPixmapStyle); | - | ||||||||||||||||||
| 722 | - | |||||||||||||||||||
| 723 | const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton*>(option); | - | ||||||||||||||||||
| 724 | - | |||||||||||||||||||
| 725 | const bool down = button->state & State_Sunken; | - | ||||||||||||||||||
| 726 | const bool enabled = button->state & State_Enabled; | - | ||||||||||||||||||
| 727 | const bool on = button->state & State_On; | - | ||||||||||||||||||
| 728 | - | |||||||||||||||||||
| 729 | ControlPixmap control; | - | ||||||||||||||||||
| 730 | if (enabled)
| 0 | ||||||||||||||||||
| 731 | control = on ? (down ? CB_PressedChecked : CB_Checked) : (down ? CB_Pressed : CB_Enabled); never executed: control = on ? (down ? CB_PressedChecked : CB_Checked) : (down ? CB_Pressed : CB_Enabled);
| 0 | ||||||||||||||||||
| 732 | else | - | ||||||||||||||||||
| 733 | control = on ? CB_DisabledChecked : CB_Disabled; never executed: control = on ? CB_DisabledChecked : CB_Disabled;
| 0 | ||||||||||||||||||
| 734 | painter->drawPixmap(button->rect, d->pixmaps.value(control).pixmap); | - | ||||||||||||||||||
| 735 | } never executed: end of block | 0 | ||||||||||||||||||
| 736 | - | |||||||||||||||||||
| 737 | void QPixmapStyle::drawRadioButton(const QStyleOption *option, | - | ||||||||||||||||||
| 738 | QPainter *painter, const QWidget *) const | - | ||||||||||||||||||
| 739 | { | - | ||||||||||||||||||
| 740 | Q_D(const QPixmapStyle); | - | ||||||||||||||||||
| 741 | - | |||||||||||||||||||
| 742 | const QStyleOptionButton *button = qstyleoption_cast<const QStyleOptionButton*>(option); | - | ||||||||||||||||||
| 743 | - | |||||||||||||||||||
| 744 | const bool down = button->state & State_Sunken; | - | ||||||||||||||||||
| 745 | const bool enabled = button->state & State_Enabled; | - | ||||||||||||||||||
| 746 | const bool on = button->state & State_On; | - | ||||||||||||||||||
| 747 | - | |||||||||||||||||||
| 748 | ControlPixmap control; | - | ||||||||||||||||||
| 749 | if (enabled)
| 0 | ||||||||||||||||||
| 750 | control = on ? RB_Checked : (down ? RB_Pressed : RB_Enabled); never executed: control = on ? RB_Checked : (down ? RB_Pressed : RB_Enabled);
| 0 | ||||||||||||||||||
| 751 | else | - | ||||||||||||||||||
| 752 | control = on ? RB_DisabledChecked : RB_Disabled; never executed: control = on ? RB_DisabledChecked : RB_Disabled;
| 0 | ||||||||||||||||||
| 753 | painter->drawPixmap(button->rect, d->pixmaps.value(control).pixmap); | - | ||||||||||||||||||
| 754 | } never executed: end of block | 0 | ||||||||||||||||||
| 755 | - | |||||||||||||||||||
| 756 | void QPixmapStyle::drawPanelItemViewItem(const QStyleOption *option, QPainter *painter, | - | ||||||||||||||||||
| 757 | const QWidget *widget) const | - | ||||||||||||||||||
| 758 | { | - | ||||||||||||||||||
| 759 | Q_D(const QPixmapStyle); | - | ||||||||||||||||||
| 760 | - | |||||||||||||||||||
| 761 | ControlPixmap cp = ID_Separator; | - | ||||||||||||||||||
| 762 | ControlDescriptor cd = ID_Selected; | - | ||||||||||||||||||
| 763 | - | |||||||||||||||||||
| 764 | if (widget && widget->property("_pixmap_combobox_list").toBool()) {
| 0 | ||||||||||||||||||
| 765 | cp = DD_ItemSeparator; | - | ||||||||||||||||||
| 766 | cd = DD_ItemSelected; | - | ||||||||||||||||||
| 767 | } never executed: end of block | 0 | ||||||||||||||||||
| 768 | - | |||||||||||||||||||
| 769 | QPixmap pix = d->pixmaps.value(cp).pixmap; | - | ||||||||||||||||||
| 770 | QRect rect = option->rect; | - | ||||||||||||||||||
| 771 | rect.setBottom(rect.top() + pix.height()-1); | - | ||||||||||||||||||
| 772 | painter->drawPixmap(rect, pix); | - | ||||||||||||||||||
| 773 | if (option->state & QStyle::State_Selected) {
| 0 | ||||||||||||||||||
| 774 | rect = option->rect; | - | ||||||||||||||||||
| 775 | rect.setTop(rect.top() + pix.height()); | - | ||||||||||||||||||
| 776 | drawCachedPixmap(cd, rect, painter); | - | ||||||||||||||||||
| 777 | } never executed: end of block | 0 | ||||||||||||||||||
| 778 | } never executed: end of block | 0 | ||||||||||||||||||
| 779 | - | |||||||||||||||||||
| 780 | void QPixmapStyle::drawProgressBarBackground(const QStyleOption *option, | - | ||||||||||||||||||
| 781 | QPainter *painter, const QWidget *) const | - | ||||||||||||||||||
| 782 | { | - | ||||||||||||||||||
| 783 | bool vertical = false; | - | ||||||||||||||||||
| 784 | if (const QStyleOptionProgressBar *pb =
| 0 | ||||||||||||||||||
| 785 | qstyleoption_cast<const QStyleOptionProgressBar *>(option)) {
| 0 | ||||||||||||||||||
| 786 | vertical = pb->orientation == Qt::Vertical; | - | ||||||||||||||||||
| 787 | } never executed: end of block | 0 | ||||||||||||||||||
| 788 | drawCachedPixmap(vertical ? PB_VBackground : PB_HBackground, option->rect, painter); | - | ||||||||||||||||||
| 789 | } never executed: end of block | 0 | ||||||||||||||||||
| 790 | - | |||||||||||||||||||
| 791 | void QPixmapStyle::drawProgressBarLabel(const QStyleOption *option, | - | ||||||||||||||||||
| 792 | QPainter *painter, const QWidget *) const | - | ||||||||||||||||||
| 793 | { | - | ||||||||||||||||||
| 794 | if (const QStyleOptionProgressBar *pb =
| 0 | ||||||||||||||||||
| 795 | qstyleoption_cast<const QStyleOptionProgressBar *>(option)) {
| 0 | ||||||||||||||||||
| 796 | const bool vertical = pb->orientation == Qt::Vertical; | - | ||||||||||||||||||
| 797 | if (!vertical) {
| 0 | ||||||||||||||||||
| 798 | QPalette::ColorRole textRole = QPalette::ButtonText; | - | ||||||||||||||||||
| 799 | proxy()->drawItemText(painter, pb->rect, | - | ||||||||||||||||||
| 800 | Qt::AlignCenter | Qt::TextSingleLine, pb->palette, | - | ||||||||||||||||||
| 801 | pb->state & State_Enabled, pb->text, textRole); | - | ||||||||||||||||||
| 802 | } never executed: end of block | 0 | ||||||||||||||||||
| 803 | } never executed: end of block | 0 | ||||||||||||||||||
| 804 | } never executed: end of block | 0 | ||||||||||||||||||
| 805 | - | |||||||||||||||||||
| 806 | void QPixmapStyle::drawProgressBarFill(const QStyleOption *option, | - | ||||||||||||||||||
| 807 | QPainter *painter, const QWidget *) const | - | ||||||||||||||||||
| 808 | { | - | ||||||||||||||||||
| 809 | const QStyleOptionProgressBar *pbar = | - | ||||||||||||||||||
| 810 | qstyleoption_cast<const QStyleOptionProgressBar*>(option); | - | ||||||||||||||||||
| 811 | const bool vertical = pbar->orientation == Qt::Vertical; | - | ||||||||||||||||||
| 812 | const bool flip = (pbar->direction == Qt::RightToLeft) ^ pbar->invertedAppearance; | - | ||||||||||||||||||
| 813 | - | |||||||||||||||||||
| 814 | if (pbar->progress == pbar->maximum) {
| 0 | ||||||||||||||||||
| 815 | drawCachedPixmap(vertical ? PB_VComplete : PB_HComplete, option->rect, painter); | - | ||||||||||||||||||
| 816 | - | |||||||||||||||||||
| 817 | } else { never executed: end of block | 0 | ||||||||||||||||||
| 818 | if (pbar->progress == 0)
| 0 | ||||||||||||||||||
| 819 | return; never executed: return; | 0 | ||||||||||||||||||
| 820 | const int maximum = pbar->maximum; | - | ||||||||||||||||||
| 821 | const qreal ratio = qreal(vertical?option->rect.height():option->rect.width())/maximum; | - | ||||||||||||||||||
| 822 | const int progress = pbar->progress*ratio; | - | ||||||||||||||||||
| 823 | - | |||||||||||||||||||
| 824 | QRect optRect = option->rect; | - | ||||||||||||||||||
| 825 | if (vertical) {
| 0 | ||||||||||||||||||
| 826 | if (flip)
| 0 | ||||||||||||||||||
| 827 | optRect.setBottom(optRect.top()+progress-1); never executed: optRect.setBottom(optRect.top()+progress-1); | 0 | ||||||||||||||||||
| 828 | else | - | ||||||||||||||||||
| 829 | optRect.setTop(optRect.bottom()-progress+1); never executed: optRect.setTop(optRect.bottom()-progress+1); | 0 | ||||||||||||||||||
| 830 | } else { | - | ||||||||||||||||||
| 831 | if (flip)
| 0 | ||||||||||||||||||
| 832 | optRect.setLeft(optRect.right()-progress+1); never executed: optRect.setLeft(optRect.right()-progress+1); | 0 | ||||||||||||||||||
| 833 | else | - | ||||||||||||||||||
| 834 | optRect.setRight(optRect.left()+progress-1); never executed: optRect.setRight(optRect.left()+progress-1); | 0 | ||||||||||||||||||
| 835 | } | - | ||||||||||||||||||
| 836 | - | |||||||||||||||||||
| 837 | drawCachedPixmap(vertical ? PB_VContent : PB_HContent, optRect, painter); | - | ||||||||||||||||||
| 838 | } never executed: end of block | 0 | ||||||||||||||||||
| 839 | } | - | ||||||||||||||||||
| 840 | - | |||||||||||||||||||
| 841 | void QPixmapStyle::drawSlider(const QStyleOptionComplex *option, | - | ||||||||||||||||||
| 842 | QPainter *painter, const QWidget *widget) const | - | ||||||||||||||||||
| 843 | { | - | ||||||||||||||||||
| 844 | Q_D(const QPixmapStyle); | - | ||||||||||||||||||
| 845 | - | |||||||||||||||||||
| 846 | const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider*>(option); | - | ||||||||||||||||||
| 847 | if (!slider)
| 0 | ||||||||||||||||||
| 848 | return; never executed: return; | 0 | ||||||||||||||||||
| 849 | - | |||||||||||||||||||
| 850 | const bool enabled = option->state & State_Enabled; | - | ||||||||||||||||||
| 851 | const bool pressed = option->state & State_Sunken; | - | ||||||||||||||||||
| 852 | const Qt::Orientation orient = slider->orientation; | - | ||||||||||||||||||
| 853 | - | |||||||||||||||||||
| 854 | const QRect handle = proxy()->subControlRect(CC_Slider, option, SC_SliderHandle, widget); | - | ||||||||||||||||||
| 855 | if (option->subControls & SC_SliderGroove) {
| 0 | ||||||||||||||||||
| 856 | QRect groove = proxy()->subControlRect(CC_Slider, option, SC_SliderGroove, widget); | - | ||||||||||||||||||
| 857 | if (groove.isValid()) {
| 0 | ||||||||||||||||||
| 858 | // Draw the background | - | ||||||||||||||||||
| 859 | ControlDescriptor control; | - | ||||||||||||||||||
| 860 | if (orient == Qt::Horizontal)
| 0 | ||||||||||||||||||
| 861 | control = enabled ? SG_HEnabled : SG_HDisabled; never executed: control = enabled ? SG_HEnabled : SG_HDisabled;
| 0 | ||||||||||||||||||
| 862 | else | - | ||||||||||||||||||
| 863 | control = enabled ? SG_VEnabled : SG_VDisabled; never executed: control = enabled ? SG_VEnabled : SG_VDisabled;
| 0 | ||||||||||||||||||
| 864 | drawCachedPixmap(control, groove, painter); | - | ||||||||||||||||||
| 865 | - | |||||||||||||||||||
| 866 | // Draw the active part | - | ||||||||||||||||||
| 867 | if (orient == Qt::Horizontal) {
| 0 | ||||||||||||||||||
| 868 | control = enabled ? (pressed ? SG_HActivePressed : SG_HActiveEnabled )
| 0 | ||||||||||||||||||
| 869 | : SG_HActiveDisabled; | - | ||||||||||||||||||
| 870 | } else { never executed: end of block | 0 | ||||||||||||||||||
| 871 | control = enabled ? (pressed ? SG_VActivePressed : SG_VActiveEnabled )
| 0 | ||||||||||||||||||
| 872 | : SG_VActiveDisabled; | - | ||||||||||||||||||
| 873 | } never executed: end of block | 0 | ||||||||||||||||||
| 874 | const QPixmapStyleDescriptor &desc = d->descriptors.value(control); | - | ||||||||||||||||||
| 875 | const QPixmap pix = d->getCachedPixmap(control, desc, groove.size()); | - | ||||||||||||||||||
| 876 | if (!pix.isNull()) {
| 0 | ||||||||||||||||||
| 877 | groove.setRight(orient == Qt::Horizontal | - | ||||||||||||||||||
| 878 | ? handle.center().x() : handle.center().y()); | - | ||||||||||||||||||
| 879 | painter->drawPixmap(groove, pix, groove); | - | ||||||||||||||||||
| 880 | } never executed: end of block | 0 | ||||||||||||||||||
| 881 | } never executed: end of block | 0 | ||||||||||||||||||
| 882 | } never executed: end of block | 0 | ||||||||||||||||||
| 883 | if (option->subControls & SC_SliderHandle) {
| 0 | ||||||||||||||||||
| 884 | if (handle.isValid()) {
| 0 | ||||||||||||||||||
| 885 | ControlPixmap pix; | - | ||||||||||||||||||
| 886 | if (orient == Qt::Horizontal)
| 0 | ||||||||||||||||||
| 887 | pix = enabled ? (pressed ? SH_HPressed : SH_HEnabled) : SH_HDisabled; never executed: pix = enabled ? (pressed ? SH_HPressed : SH_HEnabled) : SH_HDisabled;
| 0 | ||||||||||||||||||
| 888 | else | - | ||||||||||||||||||
| 889 | pix = enabled ? (pressed ? SH_VPressed : SH_VEnabled) : SH_VDisabled; never executed: pix = enabled ? (pressed ? SH_VPressed : SH_VEnabled) : SH_VDisabled;
| 0 | ||||||||||||||||||
| 890 | painter->drawPixmap(handle, d->pixmaps.value(pix).pixmap); | - | ||||||||||||||||||
| 891 | } never executed: end of block | 0 | ||||||||||||||||||
| 892 | } never executed: end of block | 0 | ||||||||||||||||||
| 893 | } never executed: end of block | 0 | ||||||||||||||||||
| 894 | - | |||||||||||||||||||
| 895 | void QPixmapStyle::drawComboBox(const QStyleOptionComplex *option, | - | ||||||||||||||||||
| 896 | QPainter *painter, const QWidget *widget) const | - | ||||||||||||||||||
| 897 | { | - | ||||||||||||||||||
| 898 | Q_D(const QPixmapStyle); | - | ||||||||||||||||||
| 899 | - | |||||||||||||||||||
| 900 | const bool enabled = option->state & State_Enabled; | - | ||||||||||||||||||
| 901 | const bool pressed = widget->property("_pixmapstyle_combobox_pressed").toBool(); | - | ||||||||||||||||||
| 902 | const bool opened = option->state & State_On; | - | ||||||||||||||||||
| 903 | - | |||||||||||||||||||
| 904 | ControlDescriptor control = | - | ||||||||||||||||||
| 905 | enabled ? (pressed ? DD_ButtonPressed : DD_ButtonEnabled) : DD_ButtonDisabled;
| 0 | ||||||||||||||||||
| 906 | drawCachedPixmap(control, option->rect, painter); | - | ||||||||||||||||||
| 907 | - | |||||||||||||||||||
| 908 | ControlPixmap cp = enabled ? (opened ? DD_ArrowOpen
| 0 | ||||||||||||||||||
| 909 | : (pressed ? DD_ArrowPressed : DD_ArrowEnabled))
| 0 | ||||||||||||||||||
| 910 | : DD_ArrowDisabled; | - | ||||||||||||||||||
| 911 | QPixmapStylePixmap pix = d->pixmaps.value(cp); | - | ||||||||||||||||||
| 912 | QRect rect = comboBoxSubControlRect(option, SC_ComboBoxArrow, widget); | - | ||||||||||||||||||
| 913 | painter->drawPixmap(rect, pix.pixmap); | - | ||||||||||||||||||
| 914 | } never executed: end of block | 0 | ||||||||||||||||||
| 915 | - | |||||||||||||||||||
| 916 | void QPixmapStyle::drawScrollBar(const QStyleOptionComplex *option, | - | ||||||||||||||||||
| 917 | QPainter *painter, const QWidget *widget) const | - | ||||||||||||||||||
| 918 | { | - | ||||||||||||||||||
| 919 | if (const QStyleOptionSlider *slider =
| 0 | ||||||||||||||||||
| 920 | qstyleoption_cast<const QStyleOptionSlider*>(option)) {
| 0 | ||||||||||||||||||
| 921 | // Do not draw the scrollbar | - | ||||||||||||||||||
| 922 | if (slider->minimum == slider->maximum)
| 0 | ||||||||||||||||||
| 923 | return; never executed: return; | 0 | ||||||||||||||||||
| 924 | - | |||||||||||||||||||
| 925 | QRect rect = scrollBarSubControlRect(option, SC_ScrollBarSlider, widget); | - | ||||||||||||||||||
| 926 | ControlDescriptor control = slider->orientation == Qt::Horizontal
| 0 | ||||||||||||||||||
| 927 | ? SB_Horizontal : SB_Vertical; | - | ||||||||||||||||||
| 928 | drawCachedPixmap(control, rect, painter); | - | ||||||||||||||||||
| 929 | } never executed: end of block | 0 | ||||||||||||||||||
| 930 | } never executed: end of block | 0 | ||||||||||||||||||
| 931 | - | |||||||||||||||||||
| 932 | QSize QPixmapStyle::pushButtonSizeFromContents(const QStyleOption *option, | - | ||||||||||||||||||
| 933 | const QSize &contentsSize, | - | ||||||||||||||||||
| 934 | const QWidget *widget) const | - | ||||||||||||||||||
| 935 | { | - | ||||||||||||||||||
| 936 | Q_D(const QPixmapStyle); | - | ||||||||||||||||||
| 937 | - | |||||||||||||||||||
| 938 | const QPixmapStyleDescriptor &desc = d->descriptors.value(PB_Enabled); | - | ||||||||||||||||||
| 939 | const int bm = proxy()->pixelMetric(PM_ButtonMargin, option, widget); | - | ||||||||||||||||||
| 940 | - | |||||||||||||||||||
| 941 | int w = contentsSize.width(); | - | ||||||||||||||||||
| 942 | int h = contentsSize.height(); | - | ||||||||||||||||||
| 943 | w += desc.margins.left() + desc.margins.right() + bm; | - | ||||||||||||||||||
| 944 | h += desc.margins.top() + desc.margins.bottom() + bm; | - | ||||||||||||||||||
| 945 | - | |||||||||||||||||||
| 946 | return d->computeSize(desc, w, h); never executed: return d->computeSize(desc, w, h); | 0 | ||||||||||||||||||
| 947 | } | - | ||||||||||||||||||
| 948 | - | |||||||||||||||||||
| 949 | QSize QPixmapStyle::lineEditSizeFromContents(const QStyleOption *, | - | ||||||||||||||||||
| 950 | const QSize &contentsSize, const QWidget *) const | - | ||||||||||||||||||
| 951 | { | - | ||||||||||||||||||
| 952 | Q_D(const QPixmapStyle); | - | ||||||||||||||||||
| 953 | - | |||||||||||||||||||
| 954 | const QPixmapStyleDescriptor &desc = d->descriptors.value(LE_Enabled); | - | ||||||||||||||||||
| 955 | const int border = 2 * proxy()->pixelMetric(PM_DefaultFrameWidth); | - | ||||||||||||||||||
| 956 | - | |||||||||||||||||||
| 957 | int w = contentsSize.width() + border + desc.margins.left() + desc.margins.right(); | - | ||||||||||||||||||
| 958 | int h = contentsSize.height() + border + desc.margins.top() + desc.margins.bottom(); | - | ||||||||||||||||||
| 959 | - | |||||||||||||||||||
| 960 | return d->computeSize(desc, w, h); never executed: return d->computeSize(desc, w, h); | 0 | ||||||||||||||||||
| 961 | } | - | ||||||||||||||||||
| 962 | - | |||||||||||||||||||
| 963 | QSize QPixmapStyle::progressBarSizeFromContents(const QStyleOption *option, | - | ||||||||||||||||||
| 964 | const QSize &contentsSize, | - | ||||||||||||||||||
| 965 | const QWidget *widget) const | - | ||||||||||||||||||
| 966 | { | - | ||||||||||||||||||
| 967 | Q_D(const QPixmapStyle); | - | ||||||||||||||||||
| 968 | - | |||||||||||||||||||
| 969 | bool vertical = false; | - | ||||||||||||||||||
| 970 | if (const QStyleOptionProgressBar *pb =
| 0 | ||||||||||||||||||
| 971 | qstyleoption_cast<const QStyleOptionProgressBar *>(option)) {
| 0 | ||||||||||||||||||
| 972 | vertical = pb->orientation == Qt::Vertical; | - | ||||||||||||||||||
| 973 | } never executed: end of block | 0 | ||||||||||||||||||
| 974 | QSize result = QCommonStyle::sizeFromContents(CT_Slider, option, contentsSize, widget); | - | ||||||||||||||||||
| 975 | if (vertical) {
| 0 | ||||||||||||||||||
| 976 | const QPixmapStyleDescriptor desc = d->descriptors.value(PB_VBackground); | - | ||||||||||||||||||
| 977 | return QSize(desc.size.height(), result.height()); never executed: return QSize(desc.size.height(), result.height()); | 0 | ||||||||||||||||||
| 978 | } else { | - | ||||||||||||||||||
| 979 | const QPixmapStyleDescriptor desc = d->descriptors.value(PB_HBackground); | - | ||||||||||||||||||
| 980 | return QSize(result.width(), desc.size.height()); never executed: return QSize(result.width(), desc.size.height()); | 0 | ||||||||||||||||||
| 981 | } | - | ||||||||||||||||||
| 982 | } | - | ||||||||||||||||||
| 983 | - | |||||||||||||||||||
| 984 | QSize QPixmapStyle::sliderSizeFromContents(const QStyleOption *option, | - | ||||||||||||||||||
| 985 | const QSize &contentsSize, | - | ||||||||||||||||||
| 986 | const QWidget *widget) const | - | ||||||||||||||||||
| 987 | { | - | ||||||||||||||||||
| 988 | Q_D(const QPixmapStyle); | - | ||||||||||||||||||
| 989 | - | |||||||||||||||||||
| 990 | const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider*>(option); | - | ||||||||||||||||||
| 991 | if (!slider)
| 0 | ||||||||||||||||||
| 992 | return QSize(); never executed: return QSize(); | 0 | ||||||||||||||||||
| 993 | - | |||||||||||||||||||
| 994 | QSize result = QCommonStyle::sizeFromContents(CT_Slider, option, contentsSize, widget); | - | ||||||||||||||||||
| 995 | - | |||||||||||||||||||
| 996 | const QPixmapStyleDescriptor desc = d->descriptors.value(slider->orientation == Qt::Horizontal | - | ||||||||||||||||||
| 997 | ? SG_HEnabled : SG_VEnabled); | - | ||||||||||||||||||
| 998 | - | |||||||||||||||||||
| 999 | if (slider->orientation == Qt::Horizontal)
| 0 | ||||||||||||||||||
| 1000 | return QSize(result.width(), desc.size.height()); never executed: return QSize(result.width(), desc.size.height()); | 0 | ||||||||||||||||||
| 1001 | else | - | ||||||||||||||||||
| 1002 | return QSize(desc.size.width(), result.height()); never executed: return QSize(desc.size.width(), result.height()); | 0 | ||||||||||||||||||
| 1003 | } | - | ||||||||||||||||||
| 1004 | - | |||||||||||||||||||
| 1005 | QSize QPixmapStyle::comboBoxSizeFromContents(const QStyleOption *option, | - | ||||||||||||||||||
| 1006 | const QSize &contentsSize, | - | ||||||||||||||||||
| 1007 | const QWidget *widget) const | - | ||||||||||||||||||
| 1008 | { | - | ||||||||||||||||||
| 1009 | Q_D(const QPixmapStyle); | - | ||||||||||||||||||
| 1010 | - | |||||||||||||||||||
| 1011 | const QPixmapStyleDescriptor &desc = d->descriptors.value(DD_ButtonEnabled); | - | ||||||||||||||||||
| 1012 | - | |||||||||||||||||||
| 1013 | QSize result = QCommonStyle::sizeFromContents(CT_ComboBox, option, contentsSize, widget); | - | ||||||||||||||||||
| 1014 | return d->computeSize(desc, result.width(), result.height()); never executed: return d->computeSize(desc, result.width(), result.height()); | 0 | ||||||||||||||||||
| 1015 | } | - | ||||||||||||||||||
| 1016 | - | |||||||||||||||||||
| 1017 | QSize QPixmapStyle::itemViewSizeFromContents(const QStyleOption *option, | - | ||||||||||||||||||
| 1018 | const QSize &contentsSize, | - | ||||||||||||||||||
| 1019 | const QWidget *widget) const | - | ||||||||||||||||||
| 1020 | { | - | ||||||||||||||||||
| 1021 | Q_D(const QPixmapStyle); | - | ||||||||||||||||||
| 1022 | - | |||||||||||||||||||
| 1023 | QSize size = QCommonStyle::sizeFromContents(CT_ItemViewItem, option, contentsSize, widget); | - | ||||||||||||||||||
| 1024 | - | |||||||||||||||||||
| 1025 | ControlPixmap cp = ID_Separator; | - | ||||||||||||||||||
| 1026 | ControlDescriptor cd = ID_Selected; | - | ||||||||||||||||||
| 1027 | if (widget && widget->property("_pixmap_combobox_list").toBool()) {
| 0 | ||||||||||||||||||
| 1028 | cp = DD_ItemSeparator; | - | ||||||||||||||||||
| 1029 | cd = DD_ItemSelected; | - | ||||||||||||||||||
| 1030 | } never executed: end of block | 0 | ||||||||||||||||||
| 1031 | - | |||||||||||||||||||
| 1032 | const QPixmapStyleDescriptor &desc = d->descriptors.value(cd); | - | ||||||||||||||||||
| 1033 | const QPixmapStylePixmap &pix = d->pixmaps.value(cp); | - | ||||||||||||||||||
| 1034 | size.setHeight(qMax(size.height(), | - | ||||||||||||||||||
| 1035 | desc.size.height() + pix.pixmap.height())); | - | ||||||||||||||||||
| 1036 | return size; never executed: return size; | 0 | ||||||||||||||||||
| 1037 | } | - | ||||||||||||||||||
| 1038 | - | |||||||||||||||||||
| 1039 | QRect QPixmapStyle::comboBoxSubControlRect(const QStyleOptionComplex *option, | - | ||||||||||||||||||
| 1040 | QStyle::SubControl sc, const QWidget *) const | - | ||||||||||||||||||
| 1041 | { | - | ||||||||||||||||||
| 1042 | Q_D(const QPixmapStyle); | - | ||||||||||||||||||
| 1043 | - | |||||||||||||||||||
| 1044 | QRect r = option->rect; // Default size | - | ||||||||||||||||||
| 1045 | const QPixmapStylePixmap &pix = d->pixmaps.value(DD_ArrowEnabled); | - | ||||||||||||||||||
| 1046 | const QPixmapStyleDescriptor &desc = d->descriptors.value(DD_ButtonEnabled); | - | ||||||||||||||||||
| 1047 | - | |||||||||||||||||||
| 1048 | switch (sc) { | - | ||||||||||||||||||
| 1049 | case SC_ComboBoxArrow: never executed: case SC_ComboBoxArrow: | 0 | ||||||||||||||||||
| 1050 | r.setRect(r.right() - pix.margins.right() - pix.pixmap.width(), | - | ||||||||||||||||||
| 1051 | r.top() + pix.margins.top(), | - | ||||||||||||||||||
| 1052 | pix.pixmap.width(), pix.pixmap.height()); | - | ||||||||||||||||||
| 1053 | break; never executed: break; | 0 | ||||||||||||||||||
| 1054 | case SC_ComboBoxEditField: never executed: case SC_ComboBoxEditField: | 0 | ||||||||||||||||||
| 1055 | r.adjust(desc.margins.left(), desc.margins.right(), | - | ||||||||||||||||||
| 1056 | -desc.margins.right(), -desc.margins.bottom()); | - | ||||||||||||||||||
| 1057 | r.setRight(r.right() - pix.margins.right() - pix.margins.left() - pix.pixmap.width()); | - | ||||||||||||||||||
| 1058 | break; never executed: break; | 0 | ||||||||||||||||||
| 1059 | default: never executed: default: | 0 | ||||||||||||||||||
| 1060 | break; never executed: break; | 0 | ||||||||||||||||||
| 1061 | } | - | ||||||||||||||||||
| 1062 | - | |||||||||||||||||||
| 1063 | r = visualRect(option->direction, option->rect, r); | - | ||||||||||||||||||
| 1064 | return r; never executed: return r; | 0 | ||||||||||||||||||
| 1065 | } | - | ||||||||||||||||||
| 1066 | - | |||||||||||||||||||
| 1067 | QRect QPixmapStyle::scrollBarSubControlRect(const QStyleOptionComplex *option, | - | ||||||||||||||||||
| 1068 | QStyle::SubControl sc, const QWidget *) const | - | ||||||||||||||||||
| 1069 | { | - | ||||||||||||||||||
| 1070 | if (const QStyleOptionSlider *slider =
| 0 | ||||||||||||||||||
| 1071 | qstyleoption_cast<const QStyleOptionSlider*>(option)) {
| 0 | ||||||||||||||||||
| 1072 | int length = (slider->orientation == Qt::Horizontal)
| 0 | ||||||||||||||||||
| 1073 | ? slider->rect.width() : slider->rect.height(); | - | ||||||||||||||||||
| 1074 | int page = length * slider->pageStep | - | ||||||||||||||||||
| 1075 | / (slider->maximum - slider->minimum + slider->pageStep); | - | ||||||||||||||||||
| 1076 | int pos = length * slider->sliderValue | - | ||||||||||||||||||
| 1077 | / (slider->maximum - slider->minimum + slider->pageStep); | - | ||||||||||||||||||
| 1078 | pos = qMin(pos+page, length) - page; | - | ||||||||||||||||||
| 1079 | - | |||||||||||||||||||
| 1080 | QRect rect = slider->rect; | - | ||||||||||||||||||
| 1081 | - | |||||||||||||||||||
| 1082 | if (slider->orientation == Qt::Horizontal) {
| 0 | ||||||||||||||||||
| 1083 | switch (sc) { | - | ||||||||||||||||||
| 1084 | case SC_ScrollBarAddPage: never executed: case SC_ScrollBarAddPage: | 0 | ||||||||||||||||||
| 1085 | rect.setLeft(pos+page); | - | ||||||||||||||||||
| 1086 | return rect; never executed: return rect; | 0 | ||||||||||||||||||
| 1087 | case SC_ScrollBarSubPage: never executed: case SC_ScrollBarSubPage: | 0 | ||||||||||||||||||
| 1088 | rect.setRight(pos); | - | ||||||||||||||||||
| 1089 | return rect; never executed: return rect; | 0 | ||||||||||||||||||
| 1090 | case SC_ScrollBarGroove: never executed: case SC_ScrollBarGroove: | 0 | ||||||||||||||||||
| 1091 | return rect; never executed: return rect; | 0 | ||||||||||||||||||
| 1092 | case SC_ScrollBarSlider: never executed: case SC_ScrollBarSlider: | 0 | ||||||||||||||||||
| 1093 | rect.setLeft(pos); | - | ||||||||||||||||||
| 1094 | rect.setRight(pos+page); | - | ||||||||||||||||||
| 1095 | return rect; never executed: return rect; | 0 | ||||||||||||||||||
| 1096 | default: ; never executed: default: | 0 | ||||||||||||||||||
| 1097 | } never executed: end of block | 0 | ||||||||||||||||||
| 1098 | } else { | - | ||||||||||||||||||
| 1099 | switch (sc) { | - | ||||||||||||||||||
| 1100 | case SC_ScrollBarAddPage: never executed: case SC_ScrollBarAddPage: | 0 | ||||||||||||||||||
| 1101 | rect.setTop(pos+page); | - | ||||||||||||||||||
| 1102 | return rect; never executed: return rect; | 0 | ||||||||||||||||||
| 1103 | case SC_ScrollBarSubPage: never executed: case SC_ScrollBarSubPage: | 0 | ||||||||||||||||||
| 1104 | rect.setBottom(pos); | - | ||||||||||||||||||
| 1105 | return rect; never executed: return rect; | 0 | ||||||||||||||||||
| 1106 | case SC_ScrollBarGroove: never executed: case SC_ScrollBarGroove: | 0 | ||||||||||||||||||
| 1107 | return rect; never executed: return rect; | 0 | ||||||||||||||||||
| 1108 | case SC_ScrollBarSlider: never executed: case SC_ScrollBarSlider: | 0 | ||||||||||||||||||
| 1109 | rect.setTop(pos); | - | ||||||||||||||||||
| 1110 | rect.setBottom(pos+page); | - | ||||||||||||||||||
| 1111 | return rect; never executed: return rect; | 0 | ||||||||||||||||||
| 1112 | default: ; never executed: default: | 0 | ||||||||||||||||||
| 1113 | } never executed: end of block | 0 | ||||||||||||||||||
| 1114 | } | - | ||||||||||||||||||
| 1115 | } | - | ||||||||||||||||||
| 1116 | return QRect(); never executed: return QRect(); | 0 | ||||||||||||||||||
| 1117 | } | - | ||||||||||||||||||
| 1118 | - | |||||||||||||||||||
| 1119 | QPixmap QPixmapStylePrivate::scale(int w, int h, const QPixmap &pixmap, const QPixmapStyleDescriptor &desc) | - | ||||||||||||||||||
| 1120 | { | - | ||||||||||||||||||
| 1121 | QPixmap result(w, h); | - | ||||||||||||||||||
| 1122 | { | - | ||||||||||||||||||
| 1123 | const QColor transparent(0, 0, 0, 0); | - | ||||||||||||||||||
| 1124 | result.fill( transparent ); | - | ||||||||||||||||||
| 1125 | QPainter p( &result ); | - | ||||||||||||||||||
| 1126 | const QMargins margins = desc.margins; | - | ||||||||||||||||||
| 1127 | qDrawBorderPixmap(&p, result.rect(), margins, pixmap, | - | ||||||||||||||||||
| 1128 | pixmap.rect(), margins, desc.tileRules); | - | ||||||||||||||||||
| 1129 | } | - | ||||||||||||||||||
| 1130 | return result; never executed: return result; | 0 | ||||||||||||||||||
| 1131 | } | - | ||||||||||||||||||
| 1132 | - | |||||||||||||||||||
| 1133 | QPixmap QPixmapStylePrivate::getCachedPixmap(QPixmapStyle::ControlDescriptor control, | - | ||||||||||||||||||
| 1134 | const QPixmapStyleDescriptor &desc, | - | ||||||||||||||||||
| 1135 | const QSize &size) const | - | ||||||||||||||||||
| 1136 | { | - | ||||||||||||||||||
| 1137 | Q_Q(const QPixmapStyle); | - | ||||||||||||||||||
| 1138 | - | |||||||||||||||||||
| 1139 | const QString sizeString = QString::number(size.width()) % QLatin1Char('*') | - | ||||||||||||||||||
| 1140 | % QString::number(size.height()); | - | ||||||||||||||||||
| 1141 | const QString key = QLatin1String(q->metaObject()->className()) % QString::number(control) | - | ||||||||||||||||||
| 1142 | % QLatin1Char('@') % sizeString; | - | ||||||||||||||||||
| 1143 | - | |||||||||||||||||||
| 1144 | QPixmap result; | - | ||||||||||||||||||
| 1145 | - | |||||||||||||||||||
| 1146 | if (!QPixmapCache::find( key, &result)) {
| 0 | ||||||||||||||||||
| 1147 | QPixmap source(desc.fileName); | - | ||||||||||||||||||
| 1148 | result = scale(size.width(), size.height(), source, desc); | - | ||||||||||||||||||
| 1149 | QPixmapCache::insert(key, result); | - | ||||||||||||||||||
| 1150 | } never executed: end of block | 0 | ||||||||||||||||||
| 1151 | return result; never executed: return result; | 0 | ||||||||||||||||||
| 1152 | } | - | ||||||||||||||||||
| 1153 | - | |||||||||||||||||||
| 1154 | QSize QPixmapStylePrivate::computeSize(const QPixmapStyleDescriptor &desc, int width, int height) const | - | ||||||||||||||||||
| 1155 | { | - | ||||||||||||||||||
| 1156 | if (desc.tileRules.horizontal != Qt::RepeatTile)
| 0 | ||||||||||||||||||
| 1157 | width = qMax(width, desc.size.width()); never executed: width = qMax(width, desc.size.width()); | 0 | ||||||||||||||||||
| 1158 | if (desc.tileRules.vertical != Qt::RepeatTile)
| 0 | ||||||||||||||||||
| 1159 | height = qMax(height, desc.size.height()); never executed: height = qMax(height, desc.size.height()); | 0 | ||||||||||||||||||
| 1160 | return QSize(width, height); never executed: return QSize(width, height); | 0 | ||||||||||||||||||
| 1161 | } | - | ||||||||||||||||||
| 1162 | - | |||||||||||||||||||
| 1163 | QT_END_NAMESPACE | - | ||||||||||||||||||
| Source code | Switch to Preprocessed file |