6#include <QtQuick/private/qquickvaluetypes_p.h>
7#include <QtQuick/private/qquickapplication_p.h>
8#include <QtQuick/private/qquickstate_p.h>
9#include <QtQuick/private/qquickpropertychanges_p.h>
10#include <QtQuick/private/qquickitemsmodule_p.h>
11#if QT_CONFIG(accessibility)
12# include <QtQuick/private/qquickaccessiblefactory_p.h>
14#include <QtGui/QGuiApplication>
15#include <QtGui/qdesktopservices.h>
16#include <QtGui/qfontdatabase.h>
17#include <QtGui/qstylehints.h>
19#include <QtQml/private/qqmlbinding_p.h>
20#include <QtQml/private/qqmldebugserviceinterfaces_p.h>
21#include <QtQml/private/qqmldebugstatesdelegate_p.h>
22#include <QtQml/private/qqmlglobal_p.h>
23#include <QtQml/private/qv4engine_p.h>
24#include <QtQml/private/qv4object_p.h>
25#include <QtQml/private/qqmlanybinding_p.h>
27#include <QtQml/qqmlextensionplugin.h>
29#include <QtCore/qiterable.h>
30#include <QtCore/qpointer.h>
34# pragma warning( disable : 4189
)
39#if QT_CONFIG(qml_debug)
41class QQmlQtQuick2DebugStatesDelegate :
public QQmlDebugStatesDelegate
44 QQmlQtQuick2DebugStatesDelegate();
45 ~QQmlQtQuick2DebugStatesDelegate();
46 void buildStatesList(
bool cleanList,
const QList<QPointer<QObject> > &instances) override;
47 void updateBinding(QQmlContext *context,
48 const QQmlProperty &property,
49 const QVariant &expression,
bool isLiteralValue,
50 const QString &fileName,
int line,
int column,
51 bool *isBaseState) override;
52 bool setBindingForInvalidProperty(QObject *object,
53 const QString &propertyName,
54 const QVariant &expression,
55 bool isLiteralValue) override;
56 void resetBindingForInvalidProperty(QObject *object,
57 const QString &propertyName) override;
60 void buildStatesList(QObject *obj);
62 QList<QPointer<QQuickState> > m_allStates;
65QQmlQtQuick2DebugStatesDelegate::QQmlQtQuick2DebugStatesDelegate()
69QQmlQtQuick2DebugStatesDelegate::~QQmlQtQuick2DebugStatesDelegate()
73void QQmlQtQuick2DebugStatesDelegate::buildStatesList(
bool cleanList,
74 const QList<QPointer<QObject> > &instances)
80 for (
int ii = 0; ii < instances.size(); ++ii) {
81 buildStatesList(instances.at(ii));
85void QQmlQtQuick2DebugStatesDelegate::buildStatesList(QObject *obj)
87 if (QQuickState *state = qobject_cast<QQuickState *>(obj)) {
88 m_allStates.append(state);
91 QObjectList children = obj->children();
92 for (
int ii = 0; ii < children.size(); ++ii) {
93 buildStatesList(children.at(ii));
97void QQmlQtQuick2DebugStatesDelegate::updateBinding(QQmlContext *context,
98 const QQmlProperty &property,
99 const QVariant &expression,
bool isLiteralValue,
100 const QString &fileName,
int line,
int column,
104 typedef QPointer<QQuickState> QuickStatePointer;
105 QObject *object = property.object();
106 QString propertyName = property.name();
107 for (
const QuickStatePointer& statePointer : std::as_const(m_allStates)) {
108 if (QQuickState *state = statePointer.data()) {
110 if (state->isStateActive() && state->containsPropertyInRevertList(object, propertyName)) {
111 *inBaseState =
false;
113 QQmlAnyBinding newBinding;
114 if (!isLiteralValue) {
115 newBinding = QQmlAnyBinding::createFromCodeString(property,
116 expression.toString(), object,
117 QQmlContextData::get(context), fileName,
120 state->changeBindingInRevertList(object, propertyName, newBinding);
123 state->changeValueInRevertList(object, propertyName, expression);
129bool QQmlQtQuick2DebugStatesDelegate::setBindingForInvalidProperty(QObject *object,
130 const QString &propertyName,
131 const QVariant &expression,
134 if (QQuickPropertyChanges *propertyChanges = qobject_cast<QQuickPropertyChanges *>(object)) {
136 propertyChanges->changeValue(propertyName, expression);
138 propertyChanges->changeExpression(propertyName, expression.toString());
145void QQmlQtQuick2DebugStatesDelegate::resetBindingForInvalidProperty(QObject *object,
const QString &propertyName)
147 if (QQuickPropertyChanges *propertyChanges = qobject_cast<QQuickPropertyChanges *>(object)) {
148 propertyChanges->removeProperty(propertyName);
152static QQmlDebugStatesDelegate *statesDelegateFactory()
154 return new QQmlQtQuick2DebugStatesDelegate;
159class QQuickColorProvider :
public QQmlColorProvider
162 QVariant colorFromString(
const QString &s,
bool *ok) override
164 QColor c = QColor::fromString(s);
174 unsigned rgbaFromString(
const QString &s,
bool *ok) override
176 QColor c = QColor::fromString(s);
186 QString stringFromRgba(
unsigned rgba)
188 QColor c(QColor::fromRgba(rgba));
190 return QVariant(c).toString();
196 QVariant fromRgbF(
double r,
double g,
double b,
double a) override
198 return QVariant(QColor::fromRgbF(r, g, b, a));
201 QVariant fromHslF(
double h,
double s,
double l,
double a) override
203 return QVariant(QColor::fromHslF(h, s, l, a));
206 QVariant fromHsvF(
double h,
double s,
double v,
double a) override
208 return QVariant(QColor::fromHsvF(h, s, v, a));
211 QVariant lighter(
const QVariant &var, qreal factor) override
213 return QVariant::fromValue(
214 QQuickColorValueType(var.value<QColor>()).lighter(factor));
217 QVariant darker(
const QVariant &var, qreal factor) override
219 return QVariant::fromValue(
220 QQuickColorValueType(var.value<QColor>()).darker(factor));
223 QVariant alpha(
const QVariant &var, qreal value) override
225 return QVariant::fromValue(
226 QQuickColorValueType(var.value<QColor>()).alpha(value));
229 QVariant tint(
const QVariant &baseVar,
const QVariant &tintVar) override
231 return QVariant::fromValue(
232 QQuickColorValueType(baseVar.value<QColor>()).tint(tintVar.value<QColor>()));
241 return new QQuickApplication(parent);
255 QStyleHints *sh = qGuiApp->styleHints();
256 QQmlEngine::setObjectOwnership(sh, QQmlEngine::CppOwnership);
262 return QFontDatabase::families();
267#ifndef QT_NO_DESKTOPSERVICES
268 return QDesktopServices::openUrl(url);
277 return QGuiApplication::platformName();
283 static QQuickColorProvider colorProvider;
284 return &colorProvider;
303 qRegisterMetaType<QVector<QVector<QPointF>>>();
308 QQuickItemsModule::defineModule();
310#if QT_CONFIG(accessibility)
311 QAccessible::installFactory(&qQuickAccessibleFactory);
314#if QT_CONFIG(qml_debug)
315 QQmlEngineDebugService::setStatesDelegateFactory(statesDelegateFactory);
QQuickApplication * application(QObject *parent) override
bool openUrlExternally(const QUrl &url) override
QString pluginName() const override
QStyleHints * styleHints() override
QStringList fontFamilies() override
static QQuickColorProvider * getColorProvider()
Q_GHS_KEEP_REFERENCE(qml_register_types_QtQml)
static QQuickGuiProvider * getGuiProvider()
void qml_register_types_QtQml()
void QQuick_initializeModule()
Q_GHS_KEEP_REFERENCE(QQuick_initializeModule)