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 "qhash.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() :
39#if QT_CONFIG(itemviews)
40 cachedOption(nullptr),
41#endif
42 animationFps(30)
43 { }
44
45 ~QCommonStylePrivate()
46 {
47#if QT_CONFIG(animation)
48 qDeleteAll(animations);
49#endif
50#if QT_CONFIG(itemviews)
51 delete cachedOption;
52#endif
53 }
54
55 QString calculateElidedText(const QString &text, const QTextOption &textOption,
56 const QFont &font, const QRect &textRect, const Qt::Alignment valign,
57 Qt::TextElideMode textElideMode, int flags,
58 bool lastVisibleLineShouldBeElided, QPointF *paintStartPosition) const;
59#if QT_CONFIG(itemviews)
60 void viewItemDrawText(QPainter *p, const QStyleOptionViewItem *option, const QRect &rect) const;
61 void viewItemLayout(const QStyleOptionViewItem *opt, QRect *checkRect,
62 QRect *pixmapRect, QRect *textRect, bool sizehint) const;
63 QSize viewItemSize(const QStyleOptionViewItem *option, int role) const;
64
65 mutable QRect decorationRect, displayRect, checkRect;
66 mutable QStyleOptionViewItem *cachedOption;
67 bool isViewItemCached(const QStyleOptionViewItem &option) const {
68 return cachedOption && (option.widget == cachedOption->widget
69 && option.index == cachedOption->index
70 && option.state == cachedOption->state
71 && option.rect == cachedOption->rect
72 && option.text == cachedOption->text
73 && option.direction == cachedOption->direction
74 && option.displayAlignment == cachedOption->displayAlignment
75 && option.decorationAlignment == cachedOption->decorationAlignment
76 && option.decorationPosition == cachedOption->decorationPosition
77 && option.decorationSize == cachedOption->decorationSize
78 && option.features == cachedOption->features
79 && option.icon.isNull() == cachedOption->icon.isNull()
80 && option.font == cachedOption->font
81 && option.viewItemPosition == cachedOption->viewItemPosition
82 && option.showDecorationSelected == cachedOption->showDecorationSelected);
83 }
84#endif
85#if QT_CONFIG(toolbutton)
86 QString toolButtonElideText(const QStyleOptionToolButton *toolbutton,
87 const QRect &textRect, int flags) const;
88#endif
89
90 mutable QIcon tabBarcloseButtonIcon;
91#if QT_CONFIG(tabbar)
92 virtual void tabLayout(const QStyleOptionTab *opt, const QWidget *widget, QRect *textRect, QRect *pixmapRect) const;
93#endif
94
95 int animationFps;
96#if QT_CONFIG(animation)
97 QStyleAnimation* animation(const QObject *target) const;
98 void startAnimation(QStyleAnimation *animation) const;
99 void stopAnimation(const QObject *target) const;
100 void removeAnimation(const QObject *target) const;
101#endif
102
103 QIcon iconFromWindowsTheme(QCommonStyle::StandardPixmap standardIcon,
104 const QStyleOption *option,
105 const QWidget *widget) const;
106 QIcon iconFromMacTheme(QCommonStyle::StandardPixmap standardIcon,
107 const QStyleOption *option,
108 const QWidget *widget) const;
109 QIcon iconFromApplicationTheme(QCommonStyle::StandardPixmap standardIcon,
110 const QStyleOption *option,
111 const QWidget *widget) const;
112 QIcon iconFromResourceTheme(QCommonStyle::StandardPixmap standardIcon,
113 const QStyleOption *option,
114 const QWidget *widget) const;
115 static bool inline rtl(const QStyleOption *option) {
116 return (option && option->direction == Qt::RightToLeft) ||
117 (!option && QGuiApplication::isRightToLeft());
118 }
119#if QT_CONFIG(animation)
120private:
121 mutable QHash<const QObject*, QStyleAnimation*> animations;
122#endif // animation
123};
124
125QT_END_NAMESPACE
126
127#endif //QCOMMONSTYLE_P_H
The QCommonStyle class encapsulates the common Look and Feel of a GUI.
\inmodule QtCore\reentrant
Definition qpoint.h:231
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,...)