Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qcommonstyle_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#ifndef QCOMMONSTYLE_P_H
6#define QCOMMONSTYLE_P_H
7
8#include <QtWidgets/private/qtwidgetsglobal_p.h>
9#include <QtGui/private/qguiapplication_p.h>
10#include <QtCore/private/qflatmap_p.h>
11#include "qcommonstyle.h"
12#include "qstyle_p.h"
13#if QT_CONFIG(animation)
14#include "qstyleanimation_p.h"
15#endif
16#include "qstyleoption.h"
17
19
20//
21// W A R N I N G
22// -------------
23//
24// This file is not part of the Qt API. It exists for the convenience
25// of qapplication_*.cpp, qwidget*.cpp and qfiledialog.cpp. This header
26// file may change from version to version without notice, or even be removed.
27//
28// We mean it.
29//
30
31class QTextOption;
32
33// Private class
34class Q_WIDGETS_EXPORT QCommonStylePrivate : public QStylePrivate
35{
36 Q_DECLARE_PUBLIC(QCommonStyle)
37public:
38 inline QCommonStylePrivate() = default;
39
40 ~QCommonStylePrivate()
41 {
42#if QT_CONFIG(animation)
43 for (auto it = animations.cbegin(); it != animations.cend(); ++it)
44 delete it.value();
45 animations.clear();
46#endif
47#if QT_CONFIG(itemviews)
48 delete cachedOption;
49#endif
50 }
51
52 QString calculateElidedText(const QString &text, const QTextOption &textOption,
53 const QFont &font, const QRect &textRect, const Qt::Alignment valign,
54 Qt::TextElideMode textElideMode, int flags,
55 bool lastVisibleLineShouldBeElided, QPointF *paintStartPosition) const;
56#if QT_CONFIG(itemviews)
57 void viewItemDrawText(QPainter *p, const QStyleOptionViewItem *option, const QRect &rect) const;
58 void viewItemLayout(const QStyleOptionViewItem *opt, QRect *checkRect,
59 QRect *pixmapRect, QRect *textRect, bool sizehint) const;
60 QSize viewItemSize(const QStyleOptionViewItem *option, int role) const;
61
62 mutable QRect decorationRect, displayRect, checkRect;
63 mutable QStyleOptionViewItem *cachedOption = nullptr;
64 bool isViewItemCached(const QStyleOptionViewItem &option) const {
65 return cachedOption && (option.widget == cachedOption->widget
66 && option.index == cachedOption->index
67 && option.state == cachedOption->state
68 && option.rect == cachedOption->rect
69 && option.text == cachedOption->text
70 && option.direction == cachedOption->direction
71 && option.displayAlignment == cachedOption->displayAlignment
72 && option.decorationAlignment == cachedOption->decorationAlignment
73 && option.decorationPosition == cachedOption->decorationPosition
74 && option.decorationSize == cachedOption->decorationSize
75 && option.features == cachedOption->features
76 && option.icon.isNull() == cachedOption->icon.isNull()
77 && option.font == cachedOption->font
78 && option.viewItemPosition == cachedOption->viewItemPosition
79 && option.showDecorationSelected == cachedOption->showDecorationSelected);
80 }
81#endif
82#if QT_CONFIG(toolbutton)
83 QString toolButtonElideText(const QStyleOptionToolButton *toolbutton,
84 const QRect &textRect, int flags) const;
85#endif
86
87 mutable QIcon tabBarcloseButtonIcon;
88#if QT_CONFIG(tabbar)
89 virtual void tabLayout(const QStyleOptionTab *opt, const QWidget *widget, QRect *textRect, QRect *pixmapRect) const;
90#endif
91
92#if QT_CONFIG(animation)
93 int animationFps = 30;
94 QStyleAnimation* animation(const QObject *target) const;
95 void startAnimation(QStyleAnimation *animation) const;
96 void stopAnimation(const QObject *target) const;
97 void removeAnimation(const QObject *target) const;
98#endif
99
100 QIcon iconFromWindowsTheme(QCommonStyle::StandardPixmap standardIcon,
101 const QStyleOption *option,
102 const QWidget *widget) const;
103 QIcon iconFromMacTheme(QCommonStyle::StandardPixmap standardIcon,
104 const QStyleOption *option,
105 const QWidget *widget) const;
106 QIcon iconFromApplicationTheme(QCommonStyle::StandardPixmap standardIcon,
107 const QStyleOption *option,
108 const QWidget *widget) const;
109 QIcon iconFromResourceTheme(QCommonStyle::StandardPixmap standardIcon,
110 const QStyleOption *option,
111 const QWidget *widget) const;
112 static bool inline rtl(const QStyleOption *option) {
113 return (option && option->direction == Qt::RightToLeft) ||
114 (!option && QGuiApplication::isRightToLeft());
115 }
116
117 static QStyle::PrimitiveElement arrowToPrimitiveElement(Qt::ArrowType arrowType);
118#if QT_CONFIG(animation)
119private:
120 mutable QVarLengthFlatMap<const QObject *, QStyleAnimation *, 8> animations;
121#endif // animation
122};
123
124QT_END_NAMESPACE
125
126#endif //QCOMMONSTYLE_P_H
The QCommonStyle class encapsulates the common Look and Feel of a GUI.
\inmodule QtCore\reentrant
Definition qpoint.h:232
Combined button and popup list for selecting options.
static QSizeF viewItemTextLayout(QTextLayout &textLayout, int lineWidth, int maxHeight=-1, int *lastVisibleLine=nullptr)
static uint qt_intensity(uint r, uint g, uint b)
#define qCWarning(category,...)
#define Q_STATIC_LOGGING_CATEGORY(name,...)