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
qquickstatechangescript.cpp
Go to the documentation of this file.
1
// Copyright (C) 2016 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
"qquickstatechangescript_p.h"
6
7
#
include
<
qqml
.
h
>
8
#
include
<
qqmlcontext
.
h
>
9
#
include
<
qqmlexpression
.
h
>
10
#
include
<
qqmlinfo
.
h
>
11
#
include
<
private
/
qqmlcontext_p
.
h
>
12
#
include
<
private
/
qqmlproperty_p
.
h
>
13
#
include
<
private
/
qqmlbinding_p
.
h
>
14
#
include
"qquickstate_p_p.h"
15
16
#
include
<
QtCore
/
qdebug
.
h
>
17
#
include
<
QtCore
/
qmath
.
h
>
18
19
#
include
<
private
/
qobject_p
.
h
>
20
21
QT_BEGIN_NAMESPACE
22
23
class
QQuickStateChangeScriptPrivate
:
public
QQuickStateOperationPrivate
24
{
25
public
:
26
QQuickStateChangeScriptPrivate
() {}
27
28
QQmlScriptString
script
;
29
QString
name
;
30
};
31
32
/*!
33
\qmltype StateChangeScript
34
\nativetype QQuickStateChangeScript
35
\inqmlmodule QtQuick
36
\ingroup qtquick-states
37
\brief Specifies how to run a script in a state.
38
39
A StateChangeScript is run upon entering a state. You can optionally use
40
ScriptAction to specify the point in the transition at which
41
the StateChangeScript should be run.
42
43
\snippet qml/states/statechangescript.qml state and transition
44
45
\sa ScriptAction
46
*/
47
48
QQuickStateChangeScript::QQuickStateChangeScript(QObject *parent)
49
: QQuickStateOperation(*(
new
QQuickStateChangeScriptPrivate), parent)
50
{
51
}
52
53
/*!
54
\qmlproperty script QtQuick::StateChangeScript::script
55
This property holds the script to run when the state is current.
56
*/
57
QQmlScriptString QQuickStateChangeScript::script()
const
58
{
59
Q_D(
const
QQuickStateChangeScript);
60
return
d->script;
61
}
62
63
void
QQuickStateChangeScript::setScript(
const
QQmlScriptString &s)
64
{
65
Q_D(QQuickStateChangeScript);
66
d->script = s;
67
}
68
69
/*!
70
\qmlproperty string QtQuick::StateChangeScript::name
71
This property holds the name of the script. This name can be used by a
72
ScriptAction to target a specific script.
73
74
\sa ScriptAction::scriptName
75
*/
76
QString QQuickStateChangeScript::name()
const
77
{
78
Q_D(
const
QQuickStateChangeScript);
79
return
d->name;
80
}
81
82
void
QQuickStateChangeScript::setName(
const
QString &n)
83
{
84
Q_D(QQuickStateChangeScript);
85
d->name = n;
86
}
87
88
void
QQuickStateChangeScript::execute()
89
{
90
Q_D(QQuickStateChangeScript);
91
if
(!d->script.isEmpty()) {
92
QQmlExpression expr(d->script);
93
expr.evaluate();
94
if
(expr.hasError())
95
qmlWarning(
this
, expr.error());
96
}
97
}
98
99
QQuickStateChangeScript::ActionList QQuickStateChangeScript::actions()
100
{
101
ActionList rv;
102
QQuickStateAction a;
103
a.event =
this
;
104
rv << a;
105
return
rv;
106
}
107
108
QQuickStateActionEvent::EventType QQuickStateChangeScript::type()
const
109
{
110
return
Script;
111
}
112
113
QT_END_NAMESPACE
114
115
#
include
<
moc_qquickstatechangescript_p
.
cpp
>
QQuickStateChangeScriptPrivate
Definition
qquickstatechangescript.cpp:24
QQuickStateChangeScriptPrivate::script
QQmlScriptString script
Definition
qquickstatechangescript.cpp:28
QQuickStateChangeScriptPrivate::name
QString name
Definition
qquickstatechangescript.cpp:29
QQuickStateChangeScriptPrivate::QQuickStateChangeScriptPrivate
QQuickStateChangeScriptPrivate()
Definition
qquickstatechangescript.cpp:26
QQuickStateOperationPrivate
Definition
qquickstate_p_p.h:152
QPlatformGraphicsBufferHelper
\inmodule QtGui
qtdeclarative
src
quick
util
qquickstatechangescript.cpp
Generated on
for Qt by
1.14.0