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
qquickasyncitembuilder_p.h
Go to the documentation of this file.
1
// Copyright (C) 2026 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
#
ifndef
QQUICKASYNCITEMBUILDER_P_H
5
#
define
QQUICKASYNCITEMBUILDER_P_H
6
7
//
8
// W A R N I N G
9
// -------------
10
//
11
// This file is not part of the Qt API. It exists purely as an
12
// implementation detail. This header file may change from version to
13
// version without notice, or even be removed.
14
//
15
// We mean it.
16
//
17
18
#
include
<
QtQuickVectorImageGenerator
/
qtquickvectorimagegeneratorexports
.
h
>
19
#
include
<
QtQuickVectorImageGenerator
/
private
/
qquickvectorimageglobal_p
.
h
>
20
#
include
<
QtQuickVectorImageGenerator
/
private
/
qquickvectorimagesource_p
.
h
>
21
22
#
include
<
QtCore
/
qlist
.
h
>
23
#
include
<
QtCore
/
qobject
.
h
>
24
25
#
include
<
functional
>
26
#
include
<
memory
>
27
#
include
<
vector
>
28
29
QT_BEGIN_NAMESPACE
30
31
class
QQmlContext;
32
class
QQuickItem;
33
class
QQuickVectorImagePluginGenerator;
34
struct
QQuickAsyncItemBuilderShared
;
35
36
// Builds the item tree for a vector image on a worker thread using QQuickItemGenerator. Calls
37
// which have to be made on the GUI thread are deferred by the generator. When the tree is done,
38
// it is moved to the GUI thread, where the deferred calls are executed in time-limited slices,
39
// so that input and rendering are not starved.
40
class
Q_QUICKVECTORIMAGEGENERATOR_EXPORT
QQuickAsyncItemBuilder
:
public
QObject
41
{
42
Q_OBJECT
43
public
:
44
enum
class
State { Idle, Generating, Initializing, Finished, Cancelled };
45
46
QQuickAsyncItemBuilder(
const
QQuickVectorImageSource &source,
47
QQuickVectorImageGenerator::GeneratorFlags flags,
48
QQmlContext *context,
49
QObject *parent =
nullptr
);
50
~QQuickAsyncItemBuilder() override;
51
52
// Plugin generators must be created on the GUI thread. They are tried before the default
53
// generator, the same way as in the synchronous case.
54
void
start(std::vector<std::unique_ptr<QQuickVectorImagePluginGenerator>> pluginGenerators);
55
void
cancel();
56
57
State state()
const
{
return
m_state; }
58
bool
isRunning()
const
{
return
m_state == State::Generating || m_state == State::Initializing; }
59
QQuickVectorImageGenerator::ErrorState errorState()
const
{
return
m_errorState; }
60
QQuickItem *takeRootItem();
61
62
Q_SIGNALS:
63
// Emitted when generation has completed, successfully or not. Not emitted when cancelled.
64
void
finished();
65
66
protected
:
67
bool
event(QEvent *e) override;
68
69
private
:
70
void
initializeItems();
71
void
finish(QQuickVectorImageGenerator::ErrorState errorState);
72
void
detach();
73
74
QQuickVectorImageSource m_source;
75
QQuickVectorImageGenerator::GeneratorFlags m_flags;
76
QQmlContext *m_context =
nullptr
;
77
std::shared_ptr<QQuickAsyncItemBuilderShared> m_shared;
78
QQuickItem *m_rootItem =
nullptr
;
79
QList<std::function<
void
()>> m_deferredCalls;
80
qsizetype m_nextDeferredCall = 0;
81
State m_state = State::Idle;
82
QQuickVectorImageGenerator::ErrorState m_errorState = QQuickVectorImageGenerator::NoError;
83
};
84
85
QT_END_NAMESPACE
86
87
#
endif
// QQUICKASYNCITEMBUILDER_P_H
QQuickAsyncItemBuilder
Definition
qquickasyncitembuilder_p.h:41
QQuickItemGenerator
Definition
qquickitemgenerator_p.h:48
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
std
[33]
Definition
src_corelib_tools_qhash.cpp:421
QQuickAsyncItemBuilderShared
Definition
qquickasyncitembuilder.cpp:25
QQuickAsyncItemBuilderShared::cancelled
std::atomic< bool > cancelled
Definition
qquickasyncitembuilder.cpp:26
QQuickAsyncItemBuilderShared::receiver
QObject * receiver
Definition
qquickasyncitembuilder.cpp:28
QQuickAsyncItemBuilderShared::mutex
QMutex mutex
Definition
qquickasyncitembuilder.cpp:27
qtdeclarative
src
quickvectorimage
generator
qquickasyncitembuilder_p.h
Generated on
for Qt by
1.18.0