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
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
5
6#include <QtCore/qobject.h>
7#include <QtCore/qmetaobject.h>
8#include <QtQml/qqml.h>
9
11
13 : m_parent(parent),
14 m_slot(slot),
15 m_enabled(false)
16{
17 Q_ASSERT(slot != -1 && parent);
18}
19
21{
22 return m_enabled;
23}
24
26{
27 m_enabled = enabled;
28 if (m_enabled)
29 loadIcon();
30}
31
33{
34 QIcon fallback = QPixmap::fromImage(image());
35 QIcon icon = QIcon::fromTheme(m_icon.name(), fallback);
36 icon.setIsMask(m_icon.isMask());
37 return icon;
38}
39
44
46{
47 m_icon = icon;
48 if (m_enabled)
49 loadIcon();
50}
51
52void QQuickLabsPlatformIconLoader::loadIcon()
53{
54 if (m_icon.source().isEmpty()) {
55 clear(m_parent);
56 } else {
57 load(qmlEngine(m_parent), 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
The QIcon class provides scalable icons in different modes and states.
Definition qicon.h:20
static QIcon fromTheme(const QString &name)
Definition qicon.cpp:1344
\inmodule QtCore
Definition qobject.h:103
static QPixmap fromImage(const QImage &image, Qt::ImageConversionFlags flags=Qt::AutoColor)
Converts the given image to a pixmap using the specified flags to control the conversion.
Definition qpixmap.cpp:1437
void setIcon(const QQuickLabsPlatformIcon &icon)
QQuickLabsPlatformIcon icon() const
QQuickLabsPlatformIconLoader(int slot, QObject *parent)
QImage image() const
void load(QQmlEngine *, const QUrl &)
bool isLoading() const
bool connectFinished(QObject *, const char *)
Combined button and popup list for selecting options.
GLenum GLenum GLsizei const GLuint GLboolean enabled
QQmlEngine * qmlEngine(const QObject *obj)
Definition qqml.cpp:80
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
#define enabled