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
qiconengine.cpp
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#include "qiconengine.h"
5#include "qiconengine_p.h"
6#include "qpainter.h"
7
9
47{
48 return size;
49}
50
58
66
73
74
81{
82 QPixmap pm(size);
83 {
84 QPainter p(&pm);
85 paint(&p, QRect(QPoint(0,0),size), mode, state);
86 }
87 return pm;
88}
89
97void QIconEngine::addPixmap(const QPixmap &/*pixmap*/, QIcon::Mode /*mode*/, QIcon::State /*state*/)
98{
99}
100
101
110void QIconEngine::addFile(const QString &/*fileName*/, const QSize &/*size*/, QIcon::Mode /*mode*/, QIcon::State /*state*/)
111{
112}
113
114
195{
196 return QString();
197}
198
211{
212 return false;
213}
214
222{
223 return false;
224}
225
237{
238 switch (id) {
240 // We don't have any notion of scale besides "@nx", so just call pixmap() here.
242 *reinterpret_cast<QIconEngine::ScaledPixmapArgument*>(data);
243 arg.pixmap = pixmap(arg.size, arg.mode, arg.state);
244 break;
245 }
246 default:
247 break;
248 }
249}
250
257QList<QSize> QIconEngine::availableSizes(QIcon::Mode /*mode*/, QIcon::State /*state*/)
258{
259 return {};
260}
261
268{
269 return QString();
270}
271
280{
281 bool isNull = false;
283 return isNull;
284}
285
301{
303 arg.size = size;
304 arg.mode = mode;
305 arg.state = state;
306 arg.scale = scale;
307 const_cast<QIconEngine *>(this)->virtual_hook(QIconEngine::ScaledPixmapHook, reinterpret_cast<void*>(&arg));
308 return arg.pixmap;
309}
310
311
312// ------- QProxyIconEngine -----
313
318
323
328
333
338
340{
341 return proxiedEngine()->key();
342}
343
345{
346 return proxiedEngine()->clone();
347}
348
350{
351 return proxiedEngine()->read(in);
352}
353
355{
356 return proxiedEngine()->write(out);
357}
358
360{
361 return proxiedEngine()->availableSizes(mode, state);
362}
363
365{
366 return proxiedEngine()->iconName();
367}
368
370{
371 return proxiedEngine()->isNull();
372}
373
378
380{
381 proxiedEngine()->virtual_hook(id, data);
382}
383
384
\inmodule QtCore\reentrant
Definition qdatastream.h:46
The QIconEngine class provides an abstract base class for QIcon renderers.
Definition qiconengine.h:15
virtual ~QIconEngine()
Destroys the icon engine.
virtual QPixmap scaledPixmap(const QSize &size, QIcon::Mode mode, QIcon::State state, qreal scale)
virtual bool read(QDataStream &in)
Reads icon engine contents from the QDataStream in.
virtual QString iconName()
virtual QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state)
Returns the icon as a pixmap with the required size, mode, and state.
virtual void addFile(const QString &fileName, const QSize &size, QIcon::Mode mode, QIcon::State state)
Called by QIcon::addFile().
virtual bool isNull()
virtual QList< QSize > availableSizes(QIcon::Mode mode=QIcon::Normal, QIcon::State state=QIcon::Off)
virtual QSize actualSize(const QSize &size, QIcon::Mode mode, QIcon::State state)
Returns the actual size of the icon the engine provides for the requested size, mode and state.
virtual void addPixmap(const QPixmap &pixmap, QIcon::Mode mode, QIcon::State state)
Called by QIcon::addPixmap().
virtual QString key() const
\variable QIconEngine::ScaledPixmapArgument::size
virtual void virtual_hook(int id, void *data)
virtual bool write(QDataStream &out) const
Writes the contents of this engine to the QDataStream out.
Mode
This enum type describes the mode for which a pixmap is intended to be used.
Definition qicon.h:22
State
This enum describes the state for which a pixmap is intended to be used.
Definition qicon.h:23
The QPainter class performs low-level painting on widgets and other paint devices.
Definition qpainter.h:46
Returns a copy of the pixmap that is transformed using the given transformation transform and transfo...
Definition qpixmap.h:27
\inmodule QtCore\reentrant
Definition qpoint.h:25
QPixmap scaledPixmap(const QSize &size, QIcon::Mode mode, QIcon::State state, qreal scale) override
void addFile(const QString &fileName, const QSize &size, QIcon::Mode mode, QIcon::State state) override
Called by QIcon::addFile().
virtual QIconEngine * proxiedEngine() const =0
void virtual_hook(int id, void *data) override
QPixmap pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state) override
Returns the icon as a pixmap with the required size, mode, and state.
QIconEngine * clone() const override
Reimplement this method to return a clone of this icon engine.
bool read(QDataStream &in) override
Reads icon engine contents from the QDataStream in.
QList< QSize > availableSizes(QIcon::Mode mode=QIcon::Normal, QIcon::State state=QIcon::Off) override
bool isNull() override
bool write(QDataStream &out) const override
Writes the contents of this engine to the QDataStream out.
QString key() const override
\variable QIconEngine::ScaledPixmapArgument::size
void addPixmap(const QPixmap &pixmap, QIcon::Mode mode, QIcon::State state) override
Called by QIcon::addPixmap().
void paint(QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state) override
Uses the given painter to paint the icon with the required mode and state into the rectangle rect.
QString iconName() override
QSize actualSize(const QSize &size, QIcon::Mode mode, QIcon::State state) override
Returns the actual size of the icon the engine provides for the requested size, mode and state.
\inmodule QtCore\reentrant
Definition qrect.h:30
\inmodule QtCore
Definition qsize.h:25
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
QPainter paint
rect
[4]
else opt state
[0]
Combined button and popup list for selecting options.
GLenum mode
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLuint in
GLfloat GLfloat p
[1]
GLenum GLenum GLenum GLenum GLenum scale
SSL_CTX int void * arg
double qreal
Definition qtypes.h:187
QTextStream out(stdout)
[7]
widget render & pixmap
QPainter painter(this)
[7]