| 1 | /**************************************************************************** |
| 2 | ** |
| 3 | ** Copyright (C) 2016 The Qt Company Ltd. |
| 4 | ** Contact: https://www.qt.io/licensing/ |
| 5 | ** |
| 6 | ** This file is part of the QtWidgets module of the Qt Toolkit. |
| 7 | ** |
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ |
| 9 | ** Commercial License Usage |
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in |
| 11 | ** accordance with the commercial license agreement provided with the |
| 12 | ** Software or, alternatively, in accordance with the terms contained in |
| 13 | ** a written agreement between you and The Qt Company. For licensing terms |
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further |
| 15 | ** information use the contact form at https://www.qt.io/contact-us. |
| 16 | ** |
| 17 | ** GNU Lesser General Public License Usage |
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser |
| 19 | ** General Public License version 3 as published by the Free Software |
| 20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the |
| 21 | ** packaging of this file. Please review the following information to |
| 22 | ** ensure the GNU Lesser General Public License version 3 requirements |
| 23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. |
| 24 | ** |
| 25 | ** GNU General Public License Usage |
| 26 | ** Alternatively, this file may be used under the terms of the GNU |
| 27 | ** General Public License version 2.0 or (at your option) the GNU General |
| 28 | ** Public license version 3 or any later version approved by the KDE Free |
| 29 | ** Qt Foundation. The licenses are as published by the Free Software |
| 30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 |
| 31 | ** included in the packaging of this file. Please review the following |
| 32 | ** information to ensure the GNU General Public License requirements will |
| 33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and |
| 34 | ** https://www.gnu.org/licenses/gpl-3.0.html. |
| 35 | ** |
| 36 | ** $QT_END_LICENSE$ |
| 37 | ** |
| 38 | ****************************************************************************/ |
| 39 | |
| 40 | #ifndef QCOMMONSTYLE_P_H |
| 41 | #define QCOMMONSTYLE_P_H |
| 42 | |
| 43 | #include <QtWidgets/private/qtwidgetsglobal_p.h> |
| 44 | #include "qcommonstyle.h" |
| 45 | #include "qstyle_p.h" |
| 46 | #if QT_CONFIG(animation) |
| 47 | #include "qstyleanimation_p.h" |
| 48 | #endif |
| 49 | #include "qstyleoption.h" |
| 50 | |
| 51 | QT_BEGIN_NAMESPACE |
| 52 | |
| 53 | // |
| 54 | // W A R N I N G |
| 55 | // ------------- |
| 56 | // |
| 57 | // This file is not part of the Qt API. It exists for the convenience |
| 58 | // of qapplication_*.cpp, qwidget*.cpp and qfiledialog.cpp. This header |
| 59 | // file may change from version to version without notice, or even be removed. |
| 60 | // |
| 61 | // We mean it. |
| 62 | // |
| 63 | |
| 64 | class QTextOption; |
| 65 | |
| 66 | // Private class |
| 67 | class Q_WIDGETS_EXPORT QCommonStylePrivate : public QStylePrivate |
| 68 | { |
| 69 | Q_DECLARE_PUBLIC(QCommonStyle) |
| 70 | public: |
| 71 | inline QCommonStylePrivate() : |
| 72 | #if QT_CONFIG(itemviews) |
| 73 | cachedOption(nullptr), |
| 74 | #endif |
| 75 | animationFps(30) |
| 76 | { } |
| 77 | |
| 78 | ~QCommonStylePrivate() |
| 79 | { |
| 80 | #if QT_CONFIG(animation) |
| 81 | qDeleteAll(animations); |
| 82 | #endif |
| 83 | #if QT_CONFIG(itemviews) |
| 84 | delete cachedOption; |
| 85 | #endif |
| 86 | } |
| 87 | |
| 88 | QString calculateElidedText(const QString &text, const QTextOption &textOption, |
| 89 | const QFont &font, const QRect &textRect, const Qt::Alignment valign, |
| 90 | Qt::TextElideMode textElideMode, int flags, |
| 91 | bool lastVisibleLineShouldBeElided, QPointF *paintStartPosition) const; |
| 92 | #if QT_CONFIG(itemviews) |
| 93 | void viewItemDrawText(QPainter *p, const QStyleOptionViewItem *option, const QRect &rect) const; |
| 94 | void viewItemLayout(const QStyleOptionViewItem *opt, QRect *checkRect, |
| 95 | QRect *pixmapRect, QRect *textRect, bool sizehint) const; |
| 96 | QSize viewItemSize(const QStyleOptionViewItem *option, int role) const; |
| 97 | |
| 98 | mutable QRect decorationRect, displayRect, checkRect; |
| 99 | mutable QStyleOptionViewItem *cachedOption; |
| 100 | bool isViewItemCached(const QStyleOptionViewItem &option) const { |
| 101 | return cachedOption && (option.widget == cachedOption->widget |
| 102 | && option.index == cachedOption->index |
| 103 | && option.state == cachedOption->state |
| 104 | && option.rect == cachedOption->rect |
| 105 | && option.text == cachedOption->text |
| 106 | && option.direction == cachedOption->direction |
| 107 | && option.displayAlignment == cachedOption->displayAlignment |
| 108 | && option.decorationAlignment == cachedOption->decorationAlignment |
| 109 | && option.decorationPosition == cachedOption->decorationPosition |
| 110 | && option.decorationSize == cachedOption->decorationSize |
| 111 | && option.features == cachedOption->features |
| 112 | && option.icon.isNull() == cachedOption->icon.isNull() |
| 113 | && option.font == cachedOption->font |
| 114 | && option.viewItemPosition == cachedOption->viewItemPosition |
| 115 | && option.showDecorationSelected == cachedOption->showDecorationSelected); |
| 116 | } |
| 117 | #endif |
| 118 | #if QT_CONFIG(toolbutton) |
| 119 | QString toolButtonElideText(const QStyleOptionToolButton *toolbutton, |
| 120 | const QRect &textRect, int flags) const; |
| 121 | #endif |
| 122 | |
| 123 | mutable QIcon tabBarcloseButtonIcon; |
| 124 | #if QT_CONFIG(tabbar) |
| 125 | virtual void tabLayout(const QStyleOptionTab *opt, const QWidget *widget, QRect *textRect, QRect *pixmapRect) const; |
| 126 | #endif |
| 127 | |
| 128 | int animationFps; |
| 129 | #if QT_CONFIG(animation) |
| 130 | void _q_removeAnimation(); |
| 131 | |
| 132 | QList<const QObject*> animationTargets() const; |
| 133 | QStyleAnimation* animation(const QObject *target) const; |
| 134 | void startAnimation(QStyleAnimation *animation) const; |
| 135 | void stopAnimation(const QObject *target) const; |
| 136 | |
| 137 | private: |
| 138 | mutable QHash<const QObject*, QStyleAnimation*> animations; |
| 139 | #endif // animation |
| 140 | }; |
| 141 | |
| 142 | QT_END_NAMESPACE |
| 143 | |
| 144 | #endif //QCOMMONSTYLE_P_H |
| 145 | |