Qt 6.x
The Qt SDK
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
4#ifndef QSTYLE_P_H
5#define QSTYLE_P_H
6
7#include "private/qobject_p.h"
8#include <QtGui/qguiapplication.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:
34
35 static bool useFullScreenForPopup();
36
37 mutable int layoutSpacingIndex;
40};
41
43{
44 const qreal pixelRatio = qApp->devicePixelRatio();
45 QImage cacheImage = QImage(size * pixelRatio, QImage::Format_ARGB32_Premultiplied);
46 cacheImage.setDevicePixelRatio(pixelRatio);
47 return cacheImage;
48}
49
51{
52 const qreal pixelRatio = qApp->devicePixelRatio();
53 QPixmap cachePixmap = QPixmap(size * pixelRatio);
54 cachePixmap.setDevicePixelRatio(pixelRatio);
55 return cachePixmap;
56}
57
58#define BEGIN_STYLE_PIXMAPCACHE(a) \
59 QRect rect = option->rect; \
60 QPixmap internalPixmapCache; \
61 QImage imageCache; \
62 QPainter *p = painter; \
63 QString unique = QStyleHelper::uniqueName((a), option, option->rect.size()); \
64 int txType = painter->deviceTransform().type() | painter->worldTransform().type(); \
65 bool doPixmapCache = (!option->rect.isEmpty()) \
66 && ((txType <= QTransform::TxTranslate) || (painter->deviceTransform().type() == QTransform::TxScale)); \
67 if (doPixmapCache && QPixmapCache::find(unique, &internalPixmapCache)) { \
68 painter->drawPixmap(option->rect.topLeft(), internalPixmapCache); \
69 } else { \
70 if (doPixmapCache) { \
71 rect.setRect(0, 0, option->rect.width(), option->rect.height()); \
72 imageCache = styleCacheImage(option->rect.size()); \
73 imageCache.fill(0); \
74 p = new QPainter(&imageCache); \
75 }
76
77
78
79#define END_STYLE_PIXMAPCACHE \
80 if (doPixmapCache) { \
81 p->end(); \
82 delete p; \
83 internalPixmapCache = QPixmap::fromImage(imageCache); \
84 painter->drawPixmap(option->rect.topLeft(), internalPixmapCache); \
85 QPixmapCache::insert(unique, internalPixmapCache); \
86 } \
87 }
88
90
91#endif //QSTYLE_P_H
\inmodule QtGui
Definition qimage.h:37
@ Format_ARGB32_Premultiplied
Definition qimage.h:48
void setDevicePixelRatio(qreal scaleFactor)
Sets the device pixel ratio for the image.
Definition qimage.cpp:1488
Returns a copy of the pixmap that is transformed using the given transformation transform and transfo...
Definition qpixmap.h:27
void setDevicePixelRatio(qreal scaleFactor)
Sets the device pixel ratio for the pixmap.
Definition qpixmap.cpp:608
\inmodule QtCore
Definition qsize.h:25
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
QString name
Definition qstyle_p.h:39
QStyle * proxyStyle
Definition qstyle_p.h:38
int layoutSpacingIndex
Definition qstyle_p.h:37
static bool useFullScreenForPopup()
Definition qstyle.cpp:2421
The QStyle class is an abstract base class that encapsulates the look and feel of a GUI.
Definition qstyle.h:29
Combined button and popup list for selecting options.
#define qApp
GLenum GLuint GLintptr GLsizeiptr size
[1]
QImage styleCacheImage(const QSize &size)
Definition qstyle_p.h:42
QPixmap styleCachePixmap(const QSize &size)
Definition qstyle_p.h:50
double qreal
Definition qtypes.h:92
QObject::connect nullptr