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
qstyle_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 QSTYLE_P_H
6#define QSTYLE_P_H
7
8#include "private/qobject_p.h"
9#include <QtWidgets/qstyle.h>
10
12
13//
14// W A R N I N G
15// -------------
16//
17// This file is not part of the Qt API. It exists for the convenience
18// of qstyle_*.cpp. This header file may change from version to version
19// without notice, or even be removed.
20//
21// We mean it.
22//
23
24// Private class
25
26class QStyle;
27
29{
30 Q_DECLARE_PUBLIC(QStyle)
31public:
32 static QStylePrivate *get(QStyle *s) { return s ? s->d_func() : nullptr; }
33 static const QStylePrivate *get(const QStyle *s) { return s ? s->d_func() : nullptr; }
34
35 static bool useFullScreenForPopup();
36
37 QStyle *proxyStyle;
39};
40
41inline QPixmap styleCachePixmap(const QSize &size, qreal pixelRatio)
42{
43 QPixmap cachePixmap = QPixmap(size * pixelRatio);
44 cachePixmap.setDevicePixelRatio(pixelRatio);
45 cachePixmap.fill(Qt::transparent);
46 return cachePixmap;
47}
48
49// small helper to read out the pixmap to paint from QPixmapCache or re-draw
50// it and put it into the QPixmapCache for later usage
51class Q_WIDGETS_EXPORT QCachedPainter
52{
53public:
54 QCachedPainter(QPainter *painter, const QString &cachePrefix,
55 const QStyleOption *option, QSize size = {}, QRect paintRect = {});
56 ~QCachedPainter();
57 void finish();
58 bool needsPainting() const
59 {
60 return !m_alreadyCached;
61 }
62 QRect pixmapRect() const
63 {
64 const auto sz = m_pixmap.deviceIndependentSize();
65 return QRect(0, 0, sz.width(), sz.height());
66 }
67 QPainter *operator->()
68 {
69 return painter();
70 }
71 QPainter *painter()
72 {
73 Q_ASSERT_X(m_pixmapPainter, "painter()", "Must only be called when painting on a pixmap to cache");
74 return m_pixmapPainter.get();
75 }
76
77 // clean pixmap cache from all cached pixmaps (e.g. due to palette change)
78 // to make sure the widgets are painted correctly afterwards
79 static void cleanupPixmapCache();
80private:
81 QPainter *m_painter = nullptr;
82 const QStyleOption *m_option = nullptr;
83 std::unique_ptr<QPainter> m_pixmapPainter;
84 QString m_pixmapName;
85 QPixmap m_pixmap;
86 QRect m_paintRect;
87 bool m_alreadyCached;
88 bool m_pixmapDrawn = false;
89 static QSet<QString> s_pixmapCacheKeys;
90};
91
92QT_END_NAMESPACE
93
94#endif //QSTYLE_P_H
The QCommonStyle class encapsulates the common Look and Feel of a GUI.
\inmodule QtCore\reentrant
Definition qpoint.h:231
QString name
Definition qstyle_p.h:38
QStyle * proxyStyle
Definition qstyle_p.h:37
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,...)
QPixmap styleCachePixmap(const QSize &size, qreal pixelRatio)
Definition qstyle_p.h:41