diff options
Diffstat (limited to 'src/widgets/styles/qstylesheetstyle_p.h')
-rw-r--r-- | src/widgets/styles/qstylesheetstyle_p.h | 98 |
1 files changed, 32 insertions, 66 deletions
diff --git a/src/widgets/styles/qstylesheetstyle_p.h b/src/widgets/styles/qstylesheetstyle_p.h index d4edb83525..95d9db19c9 100644 --- a/src/widgets/styles/qstylesheetstyle_p.h +++ b/src/widgets/styles/qstylesheetstyle_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtWidgets module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QSTYLESHEETSTYLE_P_H #define QSTYLESHEETSTYLE_P_H @@ -45,14 +9,14 @@ #ifndef QT_NO_STYLE_STYLESHEET +#include "QtWidgets/qapplication.h" #include "QtWidgets/qstyleoption.h" #include "QtCore/qhash.h" -#include "QtGui/qevent.h" -#include "QtCore/qvector.h" +#include "QtCore/qlist.h" #include "QtCore/qset.h" -#include "QtWidgets/qapplication.h" -#include "private/qcssparser_p.h" #include "QtGui/qbrush.h" +#include "QtGui/qevent.h" +#include "private/qcssparser_p.h" QT_BEGIN_NAMESPACE @@ -82,40 +46,40 @@ public: ~QStyleSheetStyle(); void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p, - const QWidget *w = 0) const override; + const QWidget *w = nullptr) const override; void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p, - const QWidget *w = 0) const override; + const QWidget *w = nullptr) const override; void drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, const QPixmap &pixmap) const override; void drawItemText(QPainter *painter, const QRect& rect, int alignment, const QPalette &pal, bool enabled, const QString& text, QPalette::ColorRole textRole = QPalette::NoRole) const override; void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, - const QWidget *w = 0) const override; + const QWidget *w = nullptr) const override; QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *option) const override; SubControl hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, - const QPoint &pt, const QWidget *w = 0) const override; + const QPoint &pt, const QWidget *w = nullptr) const override; QRect itemPixmapRect(const QRect &rect, int alignment, const QPixmap &pixmap) const override; QRect itemTextRect(const QFontMetrics &metrics, const QRect &rect, int alignment, bool enabled, const QString &text) const override; - int pixelMetric(PixelMetric metric, const QStyleOption *option = 0, const QWidget *widget = 0) const override; + int pixelMetric(PixelMetric metric, const QStyleOption *option = nullptr, const QWidget *widget = nullptr) const override; void polish(QWidget *widget) override; void polish(QApplication *app) override; void polish(QPalette &pal) override; QSize sizeFromContents(ContentsType ct, const QStyleOption *opt, - const QSize &contentsSize, const QWidget *widget = 0) const override; + const QSize &contentsSize, const QWidget *widget = nullptr) const override; QPalette standardPalette() const override; - QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *opt = 0, - const QWidget *widget = 0) const override; - QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *option = 0, - const QWidget *w = 0 ) const override; + QIcon standardIcon(StandardPixmap standardIcon, const QStyleOption *opt = nullptr, + const QWidget *widget = nullptr) const override; + QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *option = nullptr, + const QWidget *w = nullptr ) const override; int layoutSpacing(QSizePolicy::ControlType control1, QSizePolicy::ControlType control2, - Qt::Orientation orientation, const QStyleOption *option = 0, - const QWidget *widget = 0) const override; - int styleHint(StyleHint sh, const QStyleOption *opt = 0, const QWidget *w = 0, - QStyleHintReturn *shret = 0) const override; - QRect subElementRect(SubElement r, const QStyleOption *opt, const QWidget *widget = 0) const override; + Qt::Orientation orientation, const QStyleOption *option = nullptr, + const QWidget *widget = nullptr) const override; + int styleHint(StyleHint sh, const QStyleOption *opt = nullptr, const QWidget *w = nullptr, + QStyleHintReturn *shret = nullptr) const override; + QRect subElementRect(SubElement r, const QStyleOption *opt, const QWidget *widget = nullptr) const override; QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, - const QWidget *w = 0) const override; + const QWidget *w = nullptr) const override; // These functions are called from QApplication/QWidget. Be careful. QStyle *baseStyle() const; @@ -158,7 +122,7 @@ private: void setProperties(QWidget *); void setGeometry(QWidget *); void unsetStyleSheetFont(QWidget *) const; - QVector<QCss::StyleRule> styleRules(const QObject *obj) const; + QList<QCss::StyleRule> styleRules(const QObject *obj) const; bool hasStyleRule(const QObject *obj, int part) const; QHash<QStyle::SubControl, QRect> titleBarLayout(const QWidget *w, const QStyleOptionTitleBar *tb) const; @@ -169,11 +133,13 @@ private: static bool isNaturalChild(const QObject *obj); static QPixmap loadPixmap(const QString &fileName, const QObject *context); bool initObject(const QObject *obj) const; + void renderMenuItemIcon(const QStyleOptionMenuItem *mi, QPainter *p, const QWidget *w, + const QRect &rect, QRenderRule &subRule) const; public: static int numinstances; private: - Q_DISABLE_COPY(QStyleSheetStyle) + Q_DISABLE_COPY_MOVE(QStyleSheetStyle) Q_DECLARE_PRIVATE(QStyleSheetStyle) }; @@ -184,7 +150,7 @@ public Q_SLOTS: void objectDestroyed(QObject *); void styleDestroyed(QObject *); public: - QHash<const QObject *, QVector<QCss::StyleRule> > styleRulesCache; + QHash<const QObject *, QList<QCss::StyleRule>> styleRulesCache; QHash<const QObject *, QHash<int, bool> > hasStyleRuleCache; typedef QHash<int, QHash<quint64, QRenderRule> > QRenderRules; QHash<const QObject *, QRenderRules> renderRulesCache; @@ -194,7 +160,7 @@ public: template <typename T> struct Tampered { T oldWidgetValue; - uint resolveMask; + decltype(std::declval<T>().resolveMask()) resolveMask; // only call this function on an rvalue *this (it mangles oldWidgetValue) T reverted(T current) @@ -202,10 +168,10 @@ public: && #endif { - oldWidgetValue.resolve(oldWidgetValue.resolve() & resolveMask); - current.resolve(current.resolve() & ~resolveMask); + oldWidgetValue.setResolveMask(oldWidgetValue.resolveMask() & resolveMask); + current.setResolveMask(current.resolveMask() & ~resolveMask); current.resolve(oldWidgetValue); - current.resolve(current.resolve() | oldWidgetValue.resolve()); + current.setResolveMask(current.resolveMask() | oldWidgetValue.resolveMask()); return current; } }; @@ -214,7 +180,7 @@ public: }; template <typename T> class QTypeInfo<QStyleSheetStyleCaches::Tampered<T>> - : QTypeInfoMerger<QStyleSheetStyleCaches::Tampered<T>, T> {}; + : public QTypeInfoMerger<QStyleSheetStyleCaches::Tampered<T>, T> {}; // Returns a QStyleSheet from the given style. |