diff options
-rw-r--r-- | examples/AnimatedBox.qs | 55 | ||||
-rw-r--r-- | examples/TwoWayButton.qs | 21 | ||||
-rw-r--r-- | generator/shellimplgenerator.cpp | 7 | ||||
-rw-r--r-- | generator/typesystem_core-common.xml | 30 | ||||
-rw-r--r-- | generator/typesystem_core-qtscript.xml | 43 | ||||
-rw-r--r-- | generator/typesystem_core.xml | 65 | ||||
-rw-r--r-- | generator/typesystem_gui-common.xml | 3 | ||||
-rw-r--r-- | generator/typesystem_gui-qtscript.xml | 13 | ||||
-rw-r--r-- | generator/typesystem_gui.xml | 14 |
9 files changed, 249 insertions, 2 deletions
diff --git a/examples/AnimatedBox.qs b/examples/AnimatedBox.qs new file mode 100644 index 0000000..3564545 --- /dev/null +++ b/examples/AnimatedBox.qs @@ -0,0 +1,55 @@ +function createBox(parent) { + var result = new QWidget(); + result.styleSheet = "background: #00f060"; + return result; +} + +var scene = new QGraphicsScene(); +scene.setSceneRect(0, 0, 400, 400); +scene.itemIndexMethod = QGraphicsScene.NoIndex; + +box = scene.addWidget(createBox()); + +var machine = new QStateMachine(); + +var s1 = new QState(machine.rootState); +s1.assignProperty(box, "geometry", new QRect(-50, 50, 100, 100)); +s1.assignProperty(box, "opacity", 1.0); + +var s2 = new QState(machine.rootState); +s2.assignProperty(box, "geometry", new QRect(250, 200, 200, 150)); +s2.assignProperty(box, "opacity", 0.2); + +var timer = new QTimer(); +timer.interval = 2000; +timer.singleShot = false; +timer.start(); + +var t1 = s1.addTransition(timer, "timeout()", s2); + +var geometryAnim = new QPropertyAnimation(box, "geometry"); +geometryAnim.easingCurve = new QEasingCurve(QEasingCurve.InOutElastic); +geometryAnim.duration = 1500; +t1.addAnimation(geometryAnim); + +var opacityAnim = new QPropertyAnimation(box, "opacity"); +opacityAnim.easingCurve = new QEasingCurve(QEasingCurve.InOutQuad); +opacityAnim.duration = 1500; +t1.addAnimation(opacityAnim); + +var t2 = s2.addTransition(timer, "timeout()", s1); +t2.addAnimation(geometryAnim); +t2.addAnimation(opacityAnim); + +machine.initialState = s1; +machine.start(); + +var view = new QGraphicsView(scene); +view.setRenderHint(QPainter.Antialiasing); +view.backgroundBrush = new QBrush(new QColor(0, 48, 32)); +view.viewportUpdateMode = QGraphicsView.FullViewportUpdate; + +view.resize(600, 410); +view.show(); + +QCoreApplication.exec(); diff --git a/examples/TwoWayButton.qs b/examples/TwoWayButton.qs new file mode 100644 index 0000000..d4d5dcc --- /dev/null +++ b/examples/TwoWayButton.qs @@ -0,0 +1,21 @@ +var button = new QPushButton(); + +var off = new QState(); +off.assignProperty(button, "text", "Off"); + +var on = new QState(); +on.assignProperty(button, "text", "On"); + +off.addTransition(button, "clicked()", on); +on.addTransition(button, "clicked()", off); + +var machine = new QStateMachine(); +machine.addState(off); +machine.addState(on); +machine.initialState = off; + +machine.start(); +button.resize(100, 100); +button.show(); + +QCoreApplication.exec(); diff --git a/generator/shellimplgenerator.cpp b/generator/shellimplgenerator.cpp index 38dc9d7..04e50d2 100644 --- a/generator/shellimplgenerator.cpp +++ b/generator/shellimplgenerator.cpp @@ -134,8 +134,11 @@ void ShellImplGenerator::write(QTextStream &s, const AbstractMetaClass *meta_cla "QtScriptShell_"); s << endl << "{" << endl; QString scriptFunctionName = fun->name(); - if (QPropertySpec *read = meta_class->propertySpecForRead(fun->name())) { - if (read->name() == fun->name()) { + { + QPropertySpec *read = 0; + for (const AbstractMetaClass *cls = meta_class; !read && cls; cls = cls->baseClass()) + read = cls->propertySpecForRead(fun->name()); + if (read && (read->name() == fun->name())) { // use different name to avoid infinite recursion // ### not sure if this is the best solution though... scriptFunctionName.prepend("_qs_"); diff --git a/generator/typesystem_core-common.xml b/generator/typesystem_core-common.xml index 0601924..54caa48 100644 --- a/generator/typesystem_core-common.xml +++ b/generator/typesystem_core-common.xml @@ -563,6 +563,8 @@ <reject-enum-value name="WA_MacMetalStyle"/> </enum-type> + <enum-type name="Qt::TileRule" /> + <value-type name="QBasicTimer"/> <value-type name="QByteArrayMatcher"> <modify-function signature="operator=(QByteArrayMatcher)" remove="all"/> @@ -1180,6 +1182,34 @@ <value-type name="QModelIndex"/> + <object-type name="QAbstractAnimation" /> + <object-type name="QAnimationGroup" /> + <value-type name="QEasingCurve" /> + <object-type name="QParallelAnimationGroup" /> + <object-type name="QPauseAnimation" /> + <object-type name="QPropertyAnimation" /> + <object-type name="QSequentialAnimationGroup" /> + <object-type name="QVariantAnimation" /> + <enum-type name="QAbstractAnimation::DeletionPolicy" /> + <enum-type name="QAbstractAnimation::Direction" /> + <enum-type name="QAbstractAnimation::State" /> + <enum-type name="QEasingCurve::Type" /> + + <object-type name="QAbstractState" /> + <object-type name="QAbstractTransition" /> + <object-type name="QEventTransition" /> + <object-type name="QFinalState" /> + <object-type name="QHistoryState" /> + <object-type name="QSignalEvent" /> + <object-type name="QSignalTransition" /> + <object-type name="QState" /> + <object-type name="QStateMachine" /> + <object-type name="QWrappedEvent" /> + <enum-type name="QHistoryState::HistoryType" /> + <enum-type name="QState::ChildMode" /> + <enum-type name="QStateMachine::Error" /> + <enum-type name="QStateMachine::RestorePolicy" /> + <suppress-warning text="WARNING(MetaJavaBuilder) :: skipping * unmatched *type 'std::*'"/> <suppress-warning text="WARNING(MetaJavaBuilder) :: skipping * unmatched *type '*Private\*'"/> <suppress-warning text="WARNING(MetaJavaBuilder) :: skipping * unmatched *type '*Private&'"/> diff --git a/generator/typesystem_core-qtscript.xml b/generator/typesystem_core-qtscript.xml index bf5a47b..bc3ab33 100644 --- a/generator/typesystem_core-qtscript.xml +++ b/generator/typesystem_core-qtscript.xml @@ -22,6 +22,10 @@ %out% = QScriptValue(context->engine(), %in%); </template> + <template name="core.convert_string_arg_to_latin1"> + QByteArray %out% = %in%.toString().toLatin1(); + </template> + <template name="core.convert_string_arg_to_char*"> QByteArray tmp_%out% = %in%.toString().toLatin1(); const char * %out% = tmp_%out%.constData(); @@ -1442,6 +1446,45 @@ </object-type> + <value-type name="QEasingCurve"> + <modify-function signature="QEasingCurve(QEasingCurve)" remove="all" /> + <modify-function signature="operator=(QEasingCurve)" remove="all"/> + <modify-function signature="operator==(const QEasingCurve &)const" remove="all"/> + <modify-function signature="operator!=(const QEasingCurve &)const" remove="all"/> + <modify-function signature="setCustomType(double)" remove="all"/> + <modify-function signature="customType()const" remove="all"/> + </value-type> + + <object-type name="QPropertyAnimation"> + <modify-function signature="QPropertyAnimation(QObject*,QByteArray,QObject*)"> + <modify-argument index="2"> + <replace-type modified-type="QString"/> + <conversion-rule class="native"> + <insert-template name="core.convert_string_arg_to_latin1"/> + </conversion-rule> + </modify-argument> + </modify-function> + </object-type> + + <object-type name="QState"> + <modify-function signature="addTransition(QObject*,const char*,QAbstractState*)"> + <modify-argument index="2"> + <replace-type modified-type="QString"/> + <conversion-rule class="native"> + <insert-template name="core.convert_string_arg_to_char*"/> + </conversion-rule> + </modify-argument> + </modify-function> + <modify-function signature="assignProperty(QObject*,const char*,QVariant)"> + <modify-argument index="2"> + <replace-type modified-type="QString"/> + <conversion-rule class="native"> + <insert-template name="core.convert_string_arg_to_char*"/> + </conversion-rule> + </modify-argument> + </modify-function> + </object-type> + <primitive-type name="bool"/> <primitive-type name="double"/> <primitive-type name="qreal"/> diff --git a/generator/typesystem_core.xml b/generator/typesystem_core.xml index a748a3b..a100b07 100644 --- a/generator/typesystem_core.xml +++ b/generator/typesystem_core.xml @@ -14,6 +14,8 @@ %out% = context->engine()->nullValue(); else %out% = QScriptValue(context->engine(), %in%); + </template><template name="core.convert_string_arg_to_latin1"> + QByteArray %out% = %in%.toString().toLatin1(); </template><template name="core.convert_string_arg_to_char*"> QByteArray tmp_%out% = %in%.toString().toLatin1(); const char * %out% = tmp_%out%.constData(); @@ -599,6 +601,8 @@ <reject-enum-value name="WA_MacMetalStyle"/> </enum-type> + <enum-type name="Qt::TileRule"/> + <value-type name="QBasicTimer"/> <value-type name="QByteArrayMatcher"> <modify-function signature="operator=(QByteArrayMatcher)" remove="all"/> @@ -2512,6 +2516,67 @@ <value-type name="QModelIndex"/> + <object-type name="QAbstractAnimation"/> + <object-type name="QAnimationGroup"/> + <value-type name="QEasingCurve"> + <modify-function signature="QEasingCurve(QEasingCurve)" remove="all"/> + <modify-function signature="operator=(QEasingCurve)" remove="all"/> + <modify-function signature="operator==(const QEasingCurve &)const" remove="all"/> + <modify-function signature="operator!=(const QEasingCurve &)const" remove="all"/> + <modify-function signature="setCustomType(double)" remove="all"/> + <modify-function signature="customType()const" remove="all"/> + </value-type> + <object-type name="QParallelAnimationGroup"/> + <object-type name="QPauseAnimation"/> + <object-type name="QPropertyAnimation"> + <modify-function signature="QPropertyAnimation(QObject*,QByteArray,QObject*)"> + <modify-argument index="2"> + <replace-type modified-type="QString"/> + <conversion-rule class="native"> + <insert-template name="core.convert_string_arg_to_latin1"/> + </conversion-rule> + </modify-argument> + </modify-function> + </object-type> + <object-type name="QSequentialAnimationGroup"/> + <object-type name="QVariantAnimation"/> + <enum-type name="QAbstractAnimation::DeletionPolicy"/> + <enum-type name="QAbstractAnimation::Direction"/> + <enum-type name="QAbstractAnimation::State"/> + <enum-type name="QEasingCurve::Type"/> + + <object-type name="QAbstractState"/> + <object-type name="QAbstractTransition"/> + <object-type name="QEventTransition"/> + <object-type name="QFinalState"/> + <object-type name="QHistoryState"/> + <object-type name="QSignalEvent"/> + <object-type name="QSignalTransition"/> + <object-type name="QState"> + <modify-function signature="addTransition(QObject*,const char*,QAbstractState*)"> + <modify-argument index="2"> + <replace-type modified-type="QString"/> + <conversion-rule class="native"> + <insert-template name="core.convert_string_arg_to_char*"/> + </conversion-rule> + </modify-argument> + </modify-function> + <modify-function signature="assignProperty(QObject*,const char*,QVariant)"> + <modify-argument index="2"> + <replace-type modified-type="QString"/> + <conversion-rule class="native"> + <insert-template name="core.convert_string_arg_to_char*"/> + </conversion-rule> + </modify-argument> + </modify-function> + </object-type> + <object-type name="QStateMachine"/> + <object-type name="QWrappedEvent"/> + <enum-type name="QHistoryState::HistoryType"/> + <enum-type name="QState::ChildMode"/> + <enum-type name="QStateMachine::Error"/> + <enum-type name="QStateMachine::RestorePolicy"/> + <suppress-warning text="WARNING(MetaJavaBuilder) :: skipping * unmatched *type 'std::*'"/> <suppress-warning text="WARNING(MetaJavaBuilder) :: skipping * unmatched *type '*Private\*'"/> <suppress-warning text="WARNING(MetaJavaBuilder) :: skipping * unmatched *type '*Private&'"/> diff --git a/generator/typesystem_gui-common.xml b/generator/typesystem_gui-common.xml index 3a10fbc..5b7cb48 100644 --- a/generator/typesystem_gui-common.xml +++ b/generator/typesystem_gui-common.xml @@ -4930,6 +4930,9 @@ <object-type name="QPictureFormatPlugin" /> <object-type name="QStylePlugin" /> + <object-type name="QKeyEventTransition" /> + <object-type name="QMouseEventTransition" /> + <suppress-warning text="WARNING(MetaJavaBuilder) :: skipping function 'QPixmap::QPixmap', unmatched parameter type 'QPixmapData*'" /> <suppress-warning text="WARNING(MetaJavaBuilder) :: skipping * unmatched *type '*Private&'"/> <suppress-warning text="WARNING(MetaJavaBuilder) :: skipping * unmatched *type '*Private\*'"/> diff --git a/generator/typesystem_gui-qtscript.xml b/generator/typesystem_gui-qtscript.xml index e613952..076d617 100644 --- a/generator/typesystem_gui-qtscript.xml +++ b/generator/typesystem_gui-qtscript.xml @@ -65,6 +65,19 @@ </extra-includes> </object-type> + <object-type name="QGraphicsScene"> + <modify-function signature="addWidget(QWidget*,QFlags<Qt::WindowType>)"> + <modify-argument index="1"> + <conversion-rule class="native"> + QScriptValue %out%_orig = %in%; + QWidget* %out% = qscriptvalue_cast<QWidget*>(%out%_orig); + if (%out% != 0) + context->engine()->newQObject(%out%_orig, %out%, QScriptEngine::QtOwnership); + </conversion-rule> + </modify-argument> + </modify-function> + </object-type> + <value-type name="QFontInfo"> <modify-function signature="QFontInfo(QFontInfo)"> <modify-argument index="1"> diff --git a/generator/typesystem_gui.xml b/generator/typesystem_gui.xml index 48fd016..2276ade 100644 --- a/generator/typesystem_gui.xml +++ b/generator/typesystem_gui.xml @@ -3193,6 +3193,17 @@ <reference-count action="set" variable-name="__rcFocusItem"/> </modify-argument> </modify-function> + + <modify-function signature="addWidget(QWidget*,QFlags<Qt::WindowType>)"> + <modify-argument index="1"> + <conversion-rule class="native"> + QScriptValue %out%_orig = %in%; + QWidget* %out% = qscriptvalue_cast<QWidget*>(%out%_orig); + if (%out% != 0) + context->engine()->newQObject(%out%_orig, %out%, QScriptEngine::QtOwnership); + </conversion-rule> + </modify-argument> + </modify-function> </object-type> @@ -5389,6 +5400,9 @@ <object-type name="QPictureFormatPlugin"/> <object-type name="QStylePlugin"/> + <object-type name="QKeyEventTransition"/> + <object-type name="QMouseEventTransition"/> + <suppress-warning text="WARNING(MetaJavaBuilder) :: skipping function 'QPixmap::QPixmap', unmatched parameter type 'QPixmapData*'"/> <suppress-warning text="WARNING(MetaJavaBuilder) :: skipping * unmatched *type '*Private&'"/> <suppress-warning text="WARNING(MetaJavaBuilder) :: skipping * unmatched *type '*Private\*'"/> |