Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qquickstyle_p.h
Go to the documentation of this file.
1// Copyright (C) 2020 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 "qquickstyle.h"
8
9#include <QtCore/private/qobject_p.h>
10#include <QtGui/qguiapplication.h>
11
13
14//
15// W A R N I N G
16// -------------
17//
18// This file is not part of the Qt API. It exists for the convenience
19// of qstyle_*.cpp. This header file may change from version to version
20// without notice, or even be removed.
21//
22// We mean it.
23//
24
25// Private class
26
27namespace QQC2 {
28
30{
31 Q_DECLARE_PUBLIC(QStyle)
32
33public:
34 static bool useFullScreenForPopup();
35 mutable int layoutSpacingIndex = -1;
37};
38
40{
41 const qreal pixelRatio = qApp->devicePixelRatio();
42 QImage cacheImage = QImage(size * pixelRatio, QImage::Format_ARGB32_Premultiplied);
43 cacheImage.setDevicePixelRatio(pixelRatio);
44 return cacheImage;
45}
46
48{
49 const qreal pixelRatio = qApp->devicePixelRatio();
50 QPixmap cachePixmap = QPixmap(size * pixelRatio);
51 cachePixmap.setDevicePixelRatio(pixelRatio);
52 return cachePixmap;
53}
54
55#define BEGIN_STYLE_PIXMAPCACHE(a) \
56 QRect rect = option->rect; \
57 QPixmap internalPixmapCache; \
58 QImage imageCache; \
59 QPainter *p = painter; \
60 QString unique = QStyleHelper::uniqueName((a), option, option->rect.size()); \
61 int txType = painter->deviceTransform().type() | painter->worldTransform().type(); \
62 bool doPixmapCache = (!option->rect.isEmpty()) \
63 && ((txType <= QTransform::TxTranslate) || (painter->deviceTransform().type() == QTransform::TxScale)); \
64 if (doPixmapCache && QPixmapCache::find(unique, &internalPixmapCache)) { \
65 painter->drawPixmap(option->rect.topLeft(), internalPixmapCache); \
66 } else { \
67 if (doPixmapCache) { \
68 rect.setRect(0, 0, option->rect.width(), option->rect.height()); \
69 imageCache = styleCacheImage(option->rect.size()); \
70 imageCache.fill(0); \
71 p = new QPainter(&imageCache); \
72 }
73
74#define END_STYLE_PIXMAPCACHE \
75 if (doPixmapCache) { \
76 p->end(); \
77 delete p; \
78 internalPixmapCache = QPixmap::fromImage(imageCache); \
79 painter->drawPixmap(option->rect.topLeft(), internalPixmapCache); \
80 QPixmapCache::insert(unique, internalPixmapCache); \
81 } \
82 }
83
84} // namespace QQC2
85
87
88#endif //QSTYLE_P_H
\inmodule QtGui
Definition qimage.h:37
@ Format_ARGB32_Premultiplied
Definition qimage.h:48
Returns a copy of the pixmap that is transformed using the given transformation transform and transfo...
Definition qpixmap.h:27
static bool useFullScreenForPopup()
\inmodule QtCore
Definition qsize.h:25
QPixmap styleCachePixmap(const QSize &size)
QImage styleCacheImage(const QSize &size)
Combined button and popup list for selecting options.
#define qApp
GLenum GLuint GLintptr GLsizeiptr size
[1]
double qreal
Definition qtypes.h:187