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
qquickicon.cpp
Go to the documentation of this file.
1// Copyright (C) 2017 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 "qquickicon_p.h"
5
6#include <private/qqmlcontextdata_p.h>
7#include <private/qqmldata_p.h>
8
10
12{
13public:
14 // This is based on QFont's resolve_mask.
24 int resolveMask = 0;
25
29 int width = 0;
30 int height = 0;
32 bool cache = true;
33};
34
39
44
48
50{
51 d = other.d;
52 return *this;
53}
54
56{
57 return d == other.d || (d->name == other.d->name
58 && d->source == other.d->source
59 && d->resolvedSource == other.d->resolvedSource
60 && d->width == other.d->width
61 && d->height == other.d->height
62 && d->color == other.d->color
63 && d->cache == other.d->cache);
64}
65
67{
68 return !(*this == other);
69}
70
72{
73 return d->name.isEmpty() && d->source.isEmpty();
74}
75
77{
78 return d->name;
79}
80
82{
84 return;
85
86 d.detach();
87 d->name = name;
89}
90
92{
93 d.detach();
94 d->name = QString();
95 d->resolveMask &= ~QQuickIconPrivate::NameResolved;
96}
97
99{
100 return d->source;
101}
102
104{
106 return;
107
108 d.detach();
109 d->source = source;
112}
113
115{
116 d.detach();
117 d->source = QString();
119 d->resolveMask &= ~QQuickIconPrivate::SourceResolved;
120}
121
123{
124 return d->resolvedSource.isEmpty() ? d->source : d->resolvedSource;
125}
126
127// must be called by the property owner (e.g. Button) prior to emitting changed signal.
129{
130 if (d->source.isEmpty())
131 return;
132 if (!d->resolvedSource.isEmpty())
133 return; // already resolved relative to (possibly) different owner
134 const QQmlData *data = QQmlData::get(owner);
135 if (!data || !data->outerContext)
136 return;
137 d.detach();
138 d->resolvedSource = data->outerContext->resolvedUrl(d->source);
139}
140
142{
143 return d->width;
144}
145
147{
149 return;
150
151 d.detach();
152 d->width = width;
154}
155
157{
158 d.detach();
159 d->width = 0;
160 d->resolveMask &= ~QQuickIconPrivate::WidthResolved;
161}
162
164{
165 return d->height;
166}
167
169{
171 return;
172
173 d.detach();
174 d->height = height;
176}
177
179{
180 d.detach();
181 d->height = 0;
182 d->resolveMask &= ~QQuickIconPrivate::HeightResolved;
183}
184
186{
187 return d->color;
188}
189
191{
193 return;
194
195 d.detach();
196 d->color = color;
198}
199
201{
202 d.detach();
204 d->resolveMask &= ~QQuickIconPrivate::ColorResolved;
205}
206
208{
209 return d->cache;
210}
211
213{
215 return;
216
217 d.detach();
218 d->cache = cache;
220}
221
223{
224 d.detach();
225 d->cache = true;
226 d->resolveMask &= ~QQuickIconPrivate::CacheResolved;
227}
228
230{
231 QQuickIcon resolved = *this;
232 resolved.d.detach();
233
235 resolved.d->name = other.d->name;
236
238 resolved.d->source = other.d->source;
239 resolved.d->resolvedSource = other.d->resolvedSource;
240 }
241
243 resolved.d->width = other.d->width;
244
246 resolved.d->height = other.d->height;
247
249 resolved.d->color = other.d->color;
250
252 resolved.d->cache = other.d->cache;
253
254 return resolved;
255}
256
258
259#include "moc_qquickicon_p.cpp"
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition qcolor.h:31
void detach()
If the shared data object's reference count is greater than 1, this function creates a deep copy of t...
\inmodule QtCore
Definition qobject.h:103
static QQmlData * get(QObjectPrivate *priv, bool create)
Definition qqmldata_p.h:199
void setName(const QString &name)
bool operator!=(const QQuickIcon &other) const
QUrl resolvedSource() const
void resetHeight()
bool isEmpty() const
QString name
void setHeight(int height)
void setSource(const QUrl &source)
QQuickIcon resolve(const QQuickIcon &other) const
void resetSource()
void resetColor()
bool operator==(const QQuickIcon &other) const
void setCache(bool cache)
void setColor(const QColor &color)
void resetCache()
void setWidth(int width)
QQuickIcon & operator=(const QQuickIcon &other)
QColor color
void resetWidth()
void resetName()
void ensureRelativeSourceResolved(const QObject *owner)
\inmodule QtCore
Definition qshareddata.h:19
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
Definition qstring.h:192
\inmodule QtCore
Definition qurl.h:94
bool isEmpty() const
Returns true if the URL has no data; otherwise returns false.
Definition qurl.cpp:1896
void clear()
Resets the content of the QUrl.
Definition qurl.cpp:1909
QCache< int, Employee > cache
[0]
Combined button and popup list for selecting options.
@ transparent
Definition qnamespace.h:47
GLint GLsizei GLsizei height
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLint GLsizei width
GLuint color
[2]
GLuint name
GLsizei GLsizei GLchar * source
QSharedPointer< T > other(t)
[5]