Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
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
// Qt-Security score:significant reason:default
4
5
#
include
"qquickicon_p.h"
6
#
include
"qquickicon_p_p.h"
7
8
#
include
<
private
/
qqmlcontextdata_p
.
h
>
9
#
include
<
private
/
qqmldata_p
.
h
>
10
11
QT_BEGIN_NAMESPACE
12
13
bool
QQuickIconPrivate::isResolved(
const
QQuickIcon &icon,
int
resolveMask)
14
{
15
return
icon.d->resolveMask & resolveMask;
16
}
17
18
QQuickIcon::QQuickIcon()
19
: d(
new
QQuickIconPrivate)
20
{
21
}
22
23
QQuickIcon::QQuickIcon(
const
QQuickIcon &other)
24
: d(other.d)
25
{
26
}
27
28
QQuickIcon::~QQuickIcon()
29
{
30
}
31
32
QQuickIcon &QQuickIcon::operator=(
const
QQuickIcon &other)
33
{
34
d = other.d;
35
return
*
this
;
36
}
37
38
bool
QQuickIcon::operator==(
const
QQuickIcon &other)
const
39
{
40
return
d == other.d || (d->name == other.d->name
41
&& d->source == other.d->source
42
&& d->resolvedSource == other.d->resolvedSource
43
&& d->width == other.d->width
44
&& d->height == other.d->height
45
&& d->color == other.d->color
46
&& d->cache == other.d->cache);
47
}
48
49
bool
QQuickIcon::operator!=(
const
QQuickIcon &other)
const
50
{
51
return
!(*
this
== other);
52
}
53
54
bool
QQuickIcon::isEmpty()
const
55
{
56
return
d->name.isEmpty() && d->source.isEmpty();
57
}
58
59
QString QQuickIcon::name()
const
60
{
61
return
d->name;
62
}
63
64
void
QQuickIcon::setName(
const
QString &name)
65
{
66
if
((d->resolveMask & QQuickIconPrivate::NameResolved) && d->name == name)
67
return
;
68
69
d.detach();
70
d->name = name;
71
d->resolveMask |= QQuickIconPrivate::NameResolved;
72
}
73
74
void
QQuickIcon::resetName()
75
{
76
d.detach();
77
d->name = QString();
78
d->resolveMask &= ~QQuickIconPrivate::NameResolved;
79
}
80
81
QUrl QQuickIcon::source()
const
82
{
83
return
d->source;
84
}
85
86
void
QQuickIcon::setSource(
const
QUrl &source)
87
{
88
if
((d->resolveMask & QQuickIconPrivate::SourceResolved) && d->source == source)
89
return
;
90
91
d.detach();
92
d->source = source;
93
d->resolvedSource.clear();
94
d->resolveMask |= QQuickIconPrivate::SourceResolved;
95
}
96
97
void
QQuickIcon::resetSource()
98
{
99
d.detach();
100
d->source = {};
101
d->resolvedSource.clear();
102
d->resolveMask &= ~QQuickIconPrivate::SourceResolved;
103
}
104
105
QUrl QQuickIcon::resolvedSource()
const
106
{
107
return
d->resolvedSource.isEmpty() ? d->source : d->resolvedSource;
108
}
109
110
// must be called by the property owner (e.g. Button) prior to emitting changed signal.
111
void
QQuickIcon::ensureRelativeSourceResolved(
const
QObject *owner)
112
{
113
if
(d->source.isEmpty())
114
return
;
115
if
(!d->resolvedSource.isEmpty())
116
return
;
// already resolved relative to (possibly) different owner
117
const
QQmlData *data = QQmlData::get(owner);
118
if
(!data || !data->outerContext)
119
return
;
120
d.detach();
121
d->resolvedSource = data->outerContext->resolvedUrl(d->source);
122
}
123
124
int
QQuickIcon::width()
const
125
{
126
return
d->width;
127
}
128
129
void
QQuickIcon::setWidth(
int
width)
130
{
131
if
((d->resolveMask & QQuickIconPrivate::WidthResolved) && d->width == width)
132
return
;
133
134
d.detach();
135
d->width = width;
136
d->resolveMask |= QQuickIconPrivate::WidthResolved;
137
}
138
139
void
QQuickIcon::resetWidth()
140
{
141
d.detach();
142
d->width = 0;
143
d->resolveMask &= ~QQuickIconPrivate::WidthResolved;
144
}
145
146
int
QQuickIcon::height()
const
147
{
148
return
d->height;
149
}
150
151
void
QQuickIcon::setHeight(
int
height)
152
{
153
if
((d->resolveMask & QQuickIconPrivate::HeightResolved) && d->height == height)
154
return
;
155
156
d.detach();
157
d->height = height;
158
d->resolveMask |= QQuickIconPrivate::HeightResolved;
159
}
160
161
void
QQuickIcon::resetHeight()
162
{
163
d.detach();
164
d->height = 0;
165
d->resolveMask &= ~QQuickIconPrivate::HeightResolved;
166
}
167
168
QColor QQuickIcon::color()
const
169
{
170
return
d->color;
171
}
172
173
void
QQuickIcon::setColor(
const
QColor &color)
174
{
175
if
((d->resolveMask & QQuickIconPrivate::ColorResolved) && d->color == color)
176
return
;
177
178
d.detach();
179
d->color = color;
180
resolveColor();
181
}
182
183
void
QQuickIcon::resetColor()
184
{
185
d.detach();
186
d->color = Qt::transparent;
187
d->resolveMask &= ~QQuickIconPrivate::ColorResolved;
188
}
189
190
void
QQuickIcon::resolveColor()
191
{
192
d->resolveMask |= QQuickIconPrivate::ColorResolved;
193
}
194
195
bool
QQuickIcon::cache()
const
196
{
197
return
d->cache;
198
}
199
200
void
QQuickIcon::setCache(
bool
cache)
201
{
202
if
((d->resolveMask & QQuickIconPrivate::CacheResolved) && d->cache == cache)
203
return
;
204
205
d.detach();
206
d->cache = cache;
207
d->resolveMask |= QQuickIconPrivate::CacheResolved;
208
}
209
210
void
QQuickIcon::resetCache()
211
{
212
d.detach();
213
d->cache =
true
;
214
d->resolveMask &= ~QQuickIconPrivate::CacheResolved;
215
}
216
217
QQuickIcon QQuickIcon::resolve(
const
QQuickIcon &other)
const
218
{
219
QQuickIcon resolved = *
this
;
220
resolved.d.detach();
221
222
if
(!(d->resolveMask & QQuickIconPrivate::NameResolved))
223
resolved.d->name = other.d->name;
224
225
if
(!(d->resolveMask & QQuickIconPrivate::SourceResolved)) {
226
resolved.d->source = other.d->source;
227
resolved.d->resolvedSource = other.d->resolvedSource;
228
}
229
230
if
(!(d->resolveMask & QQuickIconPrivate::WidthResolved))
231
resolved.d->width = other.d->width;
232
233
if
(!(d->resolveMask & QQuickIconPrivate::HeightResolved))
234
resolved.d->height = other.d->height;
235
236
if
(!(d->resolveMask & QQuickIconPrivate::ColorResolved))
237
resolved.d->color = other.d->color;
238
239
if
(!(d->resolveMask & QQuickIconPrivate::CacheResolved))
240
resolved.d->cache = other.d->cache;
241
242
return
resolved;
243
}
244
245
QT_END_NAMESPACE
246
247
#
include
"moc_qquickicon_p.cpp"
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
qtdeclarative
src
quicktemplates
qquickicon.cpp
Generated on
for Qt by
1.18.0