Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qquicklabsplatformiconloader.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
6
7#include <QtCore/qobject.h>
8#include <QtCore/qmetaobject.h>
9#include <QtQml/qqml.h>
10
12
13QQuickLabsPlatformIconLoader::QQuickLabsPlatformIconLoader(int slot, QObject *parent)
14 : m_parent(parent),
15 m_slot(slot),
16 m_enabled(false)
17{
18 Q_ASSERT(slot != -1 && parent);
19}
20
22{
23 return m_enabled;
24}
25
27{
28 m_enabled = enabled;
29 if (m_enabled)
30 loadIcon();
31}
32
34{
35 QIcon fallback = QPixmap::fromImage(image());
36 QIcon icon = QIcon::fromTheme(m_icon.name(), fallback);
37 icon.setIsMask(m_icon.isMask());
38 return icon;
39}
40
42{
43 return m_icon;
44}
45
47{
48 m_icon = icon;
49 if (m_enabled)
50 loadIcon();
51}
52
53void QQuickLabsPlatformIconLoader::loadIcon()
54{
55 if (m_icon.source().isEmpty()) {
56 clear(m_parent);
57 } else {
58 load(qmlEngine(m_parent), m_icon.source());
59 if (m_slot != -1 && isLoading()) {
60 connectFinished(m_parent, m_slot);
61 m_slot = -1;
62 }
63 }
64
65 if (!isLoading())
66 m_parent->metaObject()->method(m_slot).invoke(m_parent);
67}
68
69QT_END_NAMESPACE
void setIcon(const QQuickLabsPlatformIcon &icon)
QQuickLabsPlatformIcon icon() const