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
qquicknativeiconloader.cpp
Go to the documentation of this file.
1
// Copyright (C) 2023 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
"qquicknativeiconloader_p.h"
6
7
#
include
<
QtCore
/
qobject
.
h
>
8
#
include
<
QtCore
/
qmetaobject
.
h
>
9
#
include
<
QtQml
/
qqml
.
h
>
10
11
QT_BEGIN_NAMESPACE
12
13
QQuickNativeIconLoader::QQuickNativeIconLoader(
int
slot, QObject *parent, QQmlEngine *engine)
14
: m_parent(parent),
15
m_engine(engine),
16
m_slot(slot),
17
m_enabled(
false
)
18
{
19
Q_ASSERT(slot != -1 && parent && engine);
20
}
21
22
bool
QQuickNativeIconLoader
::
isEnabled
()
const
23
{
24
return
m_enabled;
25
}
26
27
void
QQuickNativeIconLoader
::
setEnabled
(
bool
enabled)
28
{
29
m_enabled = enabled;
30
if
(m_enabled)
31
loadIcon();
32
}
33
34
QIcon
QQuickNativeIconLoader
::
toQIcon
()
const
35
{
36
const
QIcon fallback = QPixmap::fromImage(image());
37
return
QIcon::fromTheme(m_icon.name(), fallback);
38
}
39
40
QQuickIcon
QQuickNativeIconLoader
::
icon
()
const
41
{
42
return
m_icon;
43
}
44
45
void
QQuickNativeIconLoader
::
setIcon
(
const
QQuickIcon &icon)
46
{
47
m_icon = icon;
48
if
(m_enabled)
49
loadIcon();
50
}
51
52
void
QQuickNativeIconLoader
::loadIcon()
53
{
54
if
(m_icon.source().isEmpty()) {
55
clear(m_parent);
56
}
else
{
57
load(m_engine, m_icon.source());
58
if
(m_slot != -1 && isLoading()) {
59
connectFinished(m_parent, m_slot);
60
m_slot = -1;
61
}
62
}
63
64
if
(!isLoading())
65
m_parent->metaObject()->method(m_slot).invoke(m_parent);
66
}
67
68
QT_END_NAMESPACE
QQuickNativeIconLoader
Definition
qquicknativeiconloader_p.h:33
QQuickNativeIconLoader::setIcon
void setIcon(const QQuickIcon &icon)
Definition
qquicknativeiconloader.cpp:45
QQuickNativeIconLoader::icon
QQuickIcon icon() const
Definition
qquicknativeiconloader.cpp:40
QQuickNativeIconLoader::toQIcon
QIcon toQIcon() const
Definition
qquicknativeiconloader.cpp:34
QQuickNativeIconLoader::isEnabled
bool isEnabled() const
Definition
qquicknativeiconloader.cpp:22
QQuickNativeIconLoader::setEnabled
void setEnabled(bool enabled)
Definition
qquicknativeiconloader.cpp:27
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
qtdeclarative
src
quicktemplates
qquicknativeiconloader.cpp
Generated on
for Qt by
1.18.0