summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorJarek Kobus <jaroslaw.kobus@theqtcompany.com>2015-09-03 14:14:03 +0200
committerErik Verbruggen <erik.verbruggen@theqtcompany.com>2015-10-30 13:07:58 +0000
commit91d6194d28843f477326084f3624a8e0ff570ca9 (patch)
treedb289462f2696c4e58147b6b70ba0060d93820c4 /examples
parent04f2385d0d4a31ffa05763de542b9dea28742d6a (diff)
Add more advanced version of Pinball with ecmascript
It uses ecmascript to count score / highscore. Change-Id: Idf0953e42d613cac95dc8b82027f61cac0ff890f Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/examples.pro1
-rw-r--r--examples/pinball-ecmascript-common/mainwindow.cpp129
-rw-r--r--examples/pinball-ecmascript-common/mainwindow.h69
-rw-r--r--examples/pinball-ecmascript-common/mainwindow.ui666
-rw-r--r--examples/pinball-ecmascript-common/pinball.scxml351
-rw-r--r--examples/pinball-ecmascript-widgets-static/pinball-ecmascript-widgets-static.cpp57
-rw-r--r--examples/pinball-ecmascript-widgets-static/pinball-ecmascript-widgets-static.pro21
7 files changed, 1294 insertions, 0 deletions
diff --git a/examples/examples.pro b/examples/examples.pro
index a315ed1..b7d4253 100644
--- a/examples/examples.pro
+++ b/examples/examples.pro
@@ -6,6 +6,7 @@ qtHaveModule(widgets) {
SUBDIRS += mediaplayer-widgets-static
SUBDIRS += mediaplayer-widgets-dynamic
SUBDIRS += pinball-widgets-static
+ SUBDIRS += pinball-ecmascript-widgets-static
}
qtHaveModule(qml) {
diff --git a/examples/pinball-ecmascript-common/mainwindow.cpp b/examples/pinball-ecmascript-common/mainwindow.cpp
new file mode 100644
index 0000000..2870c5d
--- /dev/null
+++ b/examples/pinball-ecmascript-common/mainwindow.cpp
@@ -0,0 +1,129 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "mainwindow.h"
+#include "ui_mainwindow.h"
+
+#include <QStringListModel>
+#include "pinball.h"
+
+QT_USE_NAMESPACE
+
+MainWindow::MainWindow(Pinball *machine, QWidget *parent) :
+ QWidget(parent),
+ ui(new Ui::MainWindow),
+ m_machine(machine)
+{
+ ui->setupUi(this);
+
+ // lights
+ initAndConnect(QLatin1String("cLightOn"), ui->cLabel);
+ initAndConnect(QLatin1String("rLightOn"), ui->rLabel);
+ initAndConnect(QLatin1String("aLightOn"), ui->aLabel);
+ initAndConnect(QLatin1String("zLightOn"), ui->zLabel);
+ initAndConnect(QLatin1String("yLightOn"), ui->yLabel);
+ initAndConnect(QLatin1String("hurryLightOn"), ui->hurryLabel);
+ initAndConnect(QLatin1String("jackpotLightOn"), ui->jackpotLabel);
+ initAndConnect(QLatin1String("gameOverLightOn"), ui->gameOverLabel);
+
+ // help labels
+ initAndConnect(QLatin1String("offState"), ui->offStateLabel);
+ initAndConnect(QLatin1String("normalState"), ui->normalStateLabel);
+ initAndConnect(QLatin1String("hurryState"), ui->hurryStateLabel);
+ initAndConnect(QLatin1String("jackpotStateOn"), ui->jackpotStateLabel);
+
+ // context enablement
+ initAndConnect(QLatin1String("offState"), ui->startButton);
+ initAndConnect(QLatin1String("onState"), ui->cButton);
+ initAndConnect(QLatin1String("onState"), ui->rButton);
+ initAndConnect(QLatin1String("onState"), ui->aButton);
+ initAndConnect(QLatin1String("onState"), ui->zButton);
+ initAndConnect(QLatin1String("onState"), ui->yButton);
+ initAndConnect(QLatin1String("onState"), ui->ballOutButton);
+
+ // gui interaction
+ connect(ui->cButton, &QAbstractButton::clicked,
+ [this] { m_machine->submitEvent("letterTriggered.C");
+ });
+ connect(ui->rButton, &QAbstractButton::clicked,
+ [this] { m_machine->submitEvent("letterTriggered.R");
+ });
+ connect(ui->aButton, &QAbstractButton::clicked,
+ [this] { m_machine->submitEvent("letterTriggered.A");
+ });
+ connect(ui->zButton, &QAbstractButton::clicked,
+ [this] { m_machine->submitEvent("letterTriggered.Z");
+ });
+ connect(ui->yButton, &QAbstractButton::clicked,
+ [this] { m_machine->submitEvent("letterTriggered.Y");
+ });
+ connect(ui->startButton, &QAbstractButton::clicked,
+ [this] { m_machine->submitEvent("startTriggered");
+ });
+ connect(ui->ballOutButton, &QAbstractButton::clicked,
+ [this] { m_machine->submitEvent("ballOutTriggered");
+ });
+
+ // datamodel update
+ connect(m_machine, &Pinball::event_updateScore,
+ this, &MainWindow::updateScore);
+}
+
+MainWindow::~MainWindow()
+{
+ delete ui;
+}
+
+void MainWindow::initAndConnect(const QString &state, QWidget *widget)
+{
+ widget->setEnabled(m_machine->isActive(state));
+ m_machine->connect(state, SIGNAL(activeChanged(bool)),
+ widget, SLOT(setEnabled(bool)));
+}
+
+void MainWindow::updateScore(const QVariant &data)
+{
+ const QString highScore = data.toMap().value("highScore").toString();
+ ui->highScoreLabel->setText(highScore);
+ const QString score = data.toMap().value("score").toString();
+ ui->scoreLabel->setText(score);
+ qDebug() << "HERE!!!" << highScore << score;
+}
+
diff --git a/examples/pinball-ecmascript-common/mainwindow.h b/examples/pinball-ecmascript-common/mainwindow.h
new file mode 100644
index 0000000..b8f8c02
--- /dev/null
+++ b/examples/pinball-ecmascript-common/mainwindow.h
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MAINWINDOW_H
+#define MAINWINDOW_H
+
+#include <QWidget>
+
+QT_BEGIN_NAMESPACE
+namespace Ui {
+class MainWindow;
+}
+QT_END_NAMESPACE
+
+class Pinball;
+
+class MainWindow : public QWidget
+{
+ Q_OBJECT
+
+public:
+ explicit MainWindow(Pinball *machine, QWidget *parent = 0);
+ ~MainWindow();
+
+private:
+ void initAndConnect(const QString &state, QWidget *widget);
+ void updateScore(const QVariant &data);
+ QT_PREPEND_NAMESPACE(Ui::MainWindow) *ui;
+ Pinball *m_machine;
+};
+
+#endif // MAINWINDOW_H
diff --git a/examples/pinball-ecmascript-common/mainwindow.ui b/examples/pinball-ecmascript-common/mainwindow.ui
new file mode 100644
index 0000000..cc25176
--- /dev/null
+++ b/examples/pinball-ecmascript-common/mainwindow.ui
@@ -0,0 +1,666 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MainWindow</class>
+ <widget class="QWidget" name="MainWindow">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>476</width>
+ <height>458</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Pinball</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0" colspan="5">
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QLabel" name="highScoreTextLabel">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>HIGH SCORE:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="highScoreLabel">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>0</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="scoreTextLabel">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>SCORE:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="scoreLabel">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>0</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="0" column="5" rowspan="7">
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>1</width>
+ <height>98</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QToolButton" name="startButton">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Minimum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>^
+^
+^
+
+S
+T
+A
+R
+T
+
+^
+^
+^</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="1" column="0" colspan="5">
+ <widget class="QLabel" name="gameOverLabel">
+ <property name="palette">
+ <palette>
+ <active>
+ <colorrole role="WindowText">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>255</red>
+ <green>0</green>
+ <blue>4</blue>
+ </color>
+ </brush>
+ </colorrole>
+ </active>
+ <inactive>
+ <colorrole role="WindowText">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>255</red>
+ <green>0</green>
+ <blue>4</blue>
+ </color>
+ </brush>
+ </colorrole>
+ </inactive>
+ <disabled>
+ <colorrole role="WindowText">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>190</red>
+ <green>190</green>
+ <blue>190</blue>
+ </color>
+ </brush>
+ </colorrole>
+ </disabled>
+ </palette>
+ </property>
+ <property name="font">
+ <font>
+ <pointsize>20</pointsize>
+ <weight>75</weight>
+ <bold>true</bold>
+ </font>
+ </property>
+ <property name="text">
+ <string>GAME OVER</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0" colspan="5">
+ <widget class="QLabel" name="jackpotLabel">
+ <property name="palette">
+ <palette>
+ <active>
+ <colorrole role="WindowText">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>55</red>
+ <green>200</green>
+ <blue>191</blue>
+ </color>
+ </brush>
+ </colorrole>
+ </active>
+ <inactive>
+ <colorrole role="WindowText">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>55</red>
+ <green>200</green>
+ <blue>191</blue>
+ </color>
+ </brush>
+ </colorrole>
+ </inactive>
+ <disabled>
+ <colorrole role="WindowText">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>190</red>
+ <green>190</green>
+ <blue>190</blue>
+ </color>
+ </brush>
+ </colorrole>
+ </disabled>
+ </palette>
+ </property>
+ <property name="font">
+ <font>
+ <pointsize>20</pointsize>
+ <weight>75</weight>
+ <bold>true</bold>
+ </font>
+ </property>
+ <property name="text">
+ <string>JACKPOT!</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0" colspan="5">
+ <widget class="QLabel" name="hurryLabel">
+ <property name="palette">
+ <palette>
+ <active>
+ <colorrole role="WindowText">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>67</red>
+ <green>24</green>
+ <blue>97</blue>
+ </color>
+ </brush>
+ </colorrole>
+ </active>
+ <inactive>
+ <colorrole role="WindowText">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>67</red>
+ <green>24</green>
+ <blue>97</blue>
+ </color>
+ </brush>
+ </colorrole>
+ </inactive>
+ <disabled>
+ <colorrole role="WindowText">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>190</red>
+ <green>190</green>
+ <blue>190</blue>
+ </color>
+ </brush>
+ </colorrole>
+ </disabled>
+ </palette>
+ </property>
+ <property name="font">
+ <font>
+ <pointsize>20</pointsize>
+ <weight>75</weight>
+ <bold>true</bold>
+ </font>
+ </property>
+ <property name="text">
+ <string>HURRY!</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="0">
+ <widget class="QLabel" name="cLabel">
+ <property name="palette">
+ <palette>
+ <active>
+ <colorrole role="WindowText">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>7</red>
+ <green>0</green>
+ <blue>222</blue>
+ </color>
+ </brush>
+ </colorrole>
+ </active>
+ <inactive>
+ <colorrole role="WindowText">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>7</red>
+ <green>0</green>
+ <blue>222</blue>
+ </color>
+ </brush>
+ </colorrole>
+ </inactive>
+ <disabled>
+ <colorrole role="WindowText">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>190</red>
+ <green>190</green>
+ <blue>190</blue>
+ </color>
+ </brush>
+ </colorrole>
+ </disabled>
+ </palette>
+ </property>
+ <property name="font">
+ <font>
+ <pointsize>20</pointsize>
+ <weight>75</weight>
+ <bold>true</bold>
+ </font>
+ </property>
+ <property name="text">
+ <string>C</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="1">
+ <widget class="QLabel" name="rLabel">
+ <property name="palette">
+ <palette>
+ <active>
+ <colorrole role="WindowText">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>6</red>
+ <green>208</green>
+ <blue>36</blue>
+ </color>
+ </brush>
+ </colorrole>
+ </active>
+ <inactive>
+ <colorrole role="WindowText">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>6</red>
+ <green>208</green>
+ <blue>36</blue>
+ </color>
+ </brush>
+ </colorrole>
+ </inactive>
+ <disabled>
+ <colorrole role="WindowText">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>190</red>
+ <green>190</green>
+ <blue>190</blue>
+ </color>
+ </brush>
+ </colorrole>
+ </disabled>
+ </palette>
+ </property>
+ <property name="font">
+ <font>
+ <pointsize>20</pointsize>
+ <weight>75</weight>
+ <bold>true</bold>
+ </font>
+ </property>
+ <property name="text">
+ <string>R</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="2">
+ <widget class="QLabel" name="aLabel">
+ <property name="palette">
+ <palette>
+ <active>
+ <colorrole role="WindowText">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>238</red>
+ <green>17</green>
+ <blue>1</blue>
+ </color>
+ </brush>
+ </colorrole>
+ </active>
+ <inactive>
+ <colorrole role="WindowText">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>238</red>
+ <green>17</green>
+ <blue>1</blue>
+ </color>
+ </brush>
+ </colorrole>
+ </inactive>
+ <disabled>
+ <colorrole role="WindowText">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>190</red>
+ <green>190</green>
+ <blue>190</blue>
+ </color>
+ </brush>
+ </colorrole>
+ </disabled>
+ </palette>
+ </property>
+ <property name="font">
+ <font>
+ <pointsize>20</pointsize>
+ <weight>75</weight>
+ <bold>true</bold>
+ </font>
+ </property>
+ <property name="text">
+ <string>A</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="3">
+ <widget class="QLabel" name="zLabel">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="palette">
+ <palette>
+ <active>
+ <colorrole role="WindowText">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>230</red>
+ <green>10</green>
+ <blue>230</blue>
+ </color>
+ </brush>
+ </colorrole>
+ </active>
+ <inactive>
+ <colorrole role="WindowText">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>230</red>
+ <green>10</green>
+ <blue>230</blue>
+ </color>
+ </brush>
+ </colorrole>
+ </inactive>
+ <disabled>
+ <colorrole role="WindowText">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>190</red>
+ <green>190</green>
+ <blue>190</blue>
+ </color>
+ </brush>
+ </colorrole>
+ </disabled>
+ </palette>
+ </property>
+ <property name="font">
+ <font>
+ <pointsize>20</pointsize>
+ <weight>75</weight>
+ <bold>true</bold>
+ </font>
+ </property>
+ <property name="text">
+ <string>Z</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="4">
+ <widget class="QLabel" name="yLabel">
+ <property name="palette">
+ <palette>
+ <active>
+ <colorrole role="WindowText">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>239</red>
+ <green>224</green>
+ <blue>9</blue>
+ </color>
+ </brush>
+ </colorrole>
+ </active>
+ <inactive>
+ <colorrole role="WindowText">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>239</red>
+ <green>224</green>
+ <blue>9</blue>
+ </color>
+ </brush>
+ </colorrole>
+ </inactive>
+ <disabled>
+ <colorrole role="WindowText">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>190</red>
+ <green>190</green>
+ <blue>190</blue>
+ </color>
+ </brush>
+ </colorrole>
+ </disabled>
+ </palette>
+ </property>
+ <property name="font">
+ <font>
+ <pointsize>20</pointsize>
+ <weight>75</weight>
+ <bold>true</bold>
+ </font>
+ </property>
+ <property name="text">
+ <string>Y</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="0">
+ <widget class="QPushButton" name="cButton">
+ <property name="text">
+ <string>C</string>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="1">
+ <widget class="QPushButton" name="rButton">
+ <property name="text">
+ <string>R</string>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="2">
+ <widget class="QPushButton" name="aButton">
+ <property name="text">
+ <string>A</string>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="3">
+ <widget class="QPushButton" name="zButton">
+ <property name="text">
+ <string>Z</string>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="4">
+ <widget class="QPushButton" name="yButton">
+ <property name="text">
+ <string>Y</string>
+ </property>
+ </widget>
+ </item>
+ <item row="6" column="0" colspan="5">
+ <widget class="QPushButton" name="ballOutButton">
+ <property name="text">
+ <string>BALL OUT</string>
+ </property>
+ </widget>
+ </item>
+ <item row="7" column="0" colspan="6">
+ <widget class="QLabel" name="offStateLabel">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Press START to release the ball.</string>
+ </property>
+ <property name="wordWrap">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="8" column="0" colspan="6">
+ <widget class="QLabel" name="normalStateLabel">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Try to hit all CRAZY letters. Watch out for ball and avoid BALL OUT since the game will end.</string>
+ </property>
+ <property name="wordWrap">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="9" column="0" colspan="6">
+ <widget class="QLabel" name="hurryStateLabel">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Now you need to hurry. Quickly hit all CRAZY letters again to gather the extra JACKPOT bonus. You have only 5 seconds. Otherwise you will need to start from scratch.</string>
+ </property>
+ <property name="wordWrap">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="10" column="0" colspan="6">
+ <widget class="QLabel" name="jackpotStateLabel">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>You did that! You have collected JACKPOT! Congratulations. Now you can continue game until you BALL OUT.</string>
+ </property>
+ <property name="wordWrap">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/examples/pinball-ecmascript-common/pinball.scxml b/examples/pinball-ecmascript-common/pinball.scxml
new file mode 100644
index 0000000..4ec2190
--- /dev/null
+++ b/examples/pinball-ecmascript-common/pinball.scxml
@@ -0,0 +1,351 @@
+<?xml version="1.0" ?>
+<scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0"
+ name="Pinball" datamodel="ecmascript">
+ <datamodel>
+ <data id="highScore" expr="0"/>
+ <data id="score" expr="0"/>
+ </datamodel>
+ <parallel id="global">
+ <parallel id="internalState">
+ <parallel id="logicalState">
+ <state id="letterState">
+ <parallel id="lettersState">
+ <state id="cState" initial="cLetterOff">
+ <state id="cLetterOff">
+ <transition event="letterTriggered.C" cond="In('onState')" target="cLetterOn"/>
+ </state>
+ <final id="cLetterOn">
+ <onentry>
+ <raise event="letterOn"/>
+ </onentry>
+ </final>
+ </state>
+ <state id="rState" initial="rLetterOff">
+ <state id="rLetterOff">
+ <transition event="letterTriggered.R" cond="In('onState')" target="rLetterOn"/>
+ </state>
+ <final id="rLetterOn">
+ <onentry>
+ <raise event="letterOn"/>
+ </onentry>
+ </final>
+ </state>
+ <state id="aState" initial="aLetterOff">
+ <state id="aLetterOff">
+ <transition event="letterTriggered.A" cond="In('onState')" target="aLetterOn"/>
+ </state>
+ <final id="aLetterOn">
+ <onentry>
+ <raise event="letterOn"/>
+ </onentry>
+ </final>
+ </state>
+ <state id="zState" initial="zLetterOff">
+ <state id="zLetterOff">
+ <transition event="letterTriggered.Z" cond="In('onState')" target="zLetterOn"/>
+ </state>
+ <final id="zLetterOn">
+ <onentry>
+ <raise event="letterOn"/>
+ </onentry>
+ </final>
+ </state>
+ <state id="yState" initial="yLetterOff">
+ <state id="yLetterOff">
+ <transition event="letterTriggered.Y" cond="In('onState')" target="yLetterOn"/>
+ </state>
+ <final id="yLetterOn">
+ <onentry>
+ <raise event="letterOn"/>
+ </onentry>
+ </final>
+ </state>
+ </parallel>
+ <transition event="resetLetters" target="lettersState" type="internal"/>
+ </state>
+ <state id="modeState" initial="offState">
+ <state id="offState">
+ <onentry>
+ <if cond="highScore &lt; score">
+ <assign location="highScore" expr="score"/>
+ </if>
+ <raise event="resetLetters"/>
+ <raise event="resetJackpot"/>
+ <raise event="update"/>
+ </onentry>
+ <transition event="startTriggered" target="normalState"/>
+ </state>
+ <state id="onState">
+ <onentry>
+ <assign location="score" expr="0"/>
+ </onentry>
+ <state id="normalState">
+ <onentry>
+ <raise event="resetLetters"/>
+ <raise event="update"/>
+ </onentry>
+ <transition event="goToHurry" target="hurryState"/>
+ </state>
+ <state id="hurryState">
+ <onentry>
+ <send event="hurryTimeout" id="hurried" delay="5s"/>
+ <raise event="resetLetters"/>
+ <raise event="update"/>
+ </onentry>
+ <transition event="goToNormal" target="normalState"/>
+ <transition event="hurryTimeout" target="normalState"/>
+ <onexit>
+ <cancel sendid="hurried"/>
+ </onexit>
+ </state>
+ </state>
+ </state>
+ <state id="jackpotState" initial="jackpotStateOff">
+ <state id="jackpotStateOff">
+ <onentry>
+ <raise event="update"/>
+ </onentry>
+ <transition event="goForJackpot" target="jackpotStateOn"/>
+ </state>
+ <state id="jackpotStateOn">
+ <onentry>
+ <raise event="update"/>
+ </onentry>
+ <transition event="resetJackpot" target="jackpotStateOff"/>
+ </state>
+ </state>
+ </parallel>
+
+ <state id="workflow">
+
+ <state id="lightImpulseGenerator">
+ <state id="lightImpulseOn"/>
+ <state id="lightImpulseOff"/>
+
+ <onentry>
+ <raise event="updateLights"/>
+ <raise event="scheduleNewImpulse"/>
+ </onentry>
+
+ <transition event="scheduleNewImpulse">
+ <cancel sendid="delayed"/>
+ <if cond="In('offState')">
+ <send event="lightImpulse" id="delayed" delay="1s"/>
+ <elseif cond="In('normalState')"/>
+ <send event="lightImpulse" id="delayed" delay="500ms"/>
+ <else/>
+ <send event="lightImpulse" id="delayed" delay="200ms"/>
+ </if>
+ </transition>
+
+ <onexit>
+ <cancel sendid="delayed"/>
+ </onexit>
+
+ <transition event="lightImpulse" cond="In('lightImpulseOn')" target="lightImpulseOff"/>
+ <transition event="lightImpulse" cond="In('lightImpulseOff')" target="lightImpulseOn"/>
+ </state>
+
+ <transition event="letterOn">
+ <if cond="In('normalState')">
+ <assign location="score" expr="score + 1000"/>
+ <elseif cond="In('hurryState')"/>
+ <assign location="score" expr="score + 10000"/>
+ </if>
+ <raise event="updateLights"/>
+ </transition>
+
+ <transition event="done.state.lettersState">
+ <if cond="In('normalState')">
+ <assign location="score" expr="score + 100000"/>
+ <raise event="goToHurry"/>
+ <elseif cond="In('hurryState')"/>
+ <assign location="score" expr="score + 1000000"/>
+ <raise event="goToNormal"/>
+ <raise event="goForJackpot"/>
+ </if>
+ </transition>
+
+ <transition event="update">
+ <raise event="scheduleNewImpulse"/>
+ <raise event="updateLights"/>
+ </transition>
+
+ <transition event="updateLights">
+ <send type="qt:signal" event="updateScore">
+ <param name="highScore" expr="highScore"/>
+ <param name="score" expr="score"/>
+ </send>
+ <if cond="In('jackpotStateOn')">
+ <raise event="turnOnJackpot"/>
+ <else/>
+ <raise event="turnOffJackpot"/>
+ </if>
+
+ <if cond="In('lightImpulseOn')">
+ <if cond="In('offState')">
+ <raise event="turnOnC"/>
+ <raise event="turnOnR"/>
+ <raise event="turnOnA"/>
+ <raise event="turnOnZ"/>
+ <raise event="turnOnY"/>
+ <raise event="turnOnHurry"/>
+ <raise event="turnOnJackpot"/>
+ <raise event="turnOnGameOver"/>
+ <elseif cond="In('normalState')"/>
+ <if cond="In('cLetterOn')">
+ <raise event="turnOnC"/>
+ <else/>
+ <raise event="turnOffC"/>
+ </if>
+ <if cond="In('rLetterOn')">
+ <raise event="turnOnR"/>
+ <else/>
+ <raise event="turnOffR"/>
+ </if>
+ <if cond="In('aLetterOn')">
+ <raise event="turnOnA"/>
+ <else/>
+ <raise event="turnOffA"/>
+ </if>
+ <if cond="In('zLetterOn')">
+ <raise event="turnOnZ"/>
+ <else/>
+ <raise event="turnOffZ"/>
+ </if>
+ <if cond="In('yLetterOn')">
+ <raise event="turnOnY"/>
+ <else/>
+ <raise event="turnOffY"/>
+ </if>
+ <raise event="turnOffHurry"/>
+ <raise event="turnOffGameOver"/>
+ <else/>
+ <raise event="turnOnC"/>
+ <raise event="turnOnR"/>
+ <raise event="turnOnA"/>
+ <raise event="turnOnZ"/>
+ <raise event="turnOnY"/>
+ <raise event="turnOnHurry"/>
+ <raise event="turnOffGameOver"/>
+ </if>
+ <else/>
+ <if cond="In('offState')">
+ <raise event="turnOffC"/>
+ <raise event="turnOffR"/>
+ <raise event="turnOffA"/>
+ <raise event="turnOffZ"/>
+ <raise event="turnOffY"/>
+ <raise event="turnOffHurry"/>
+ <raise event="turnOffJackpot"/>
+ <elseif cond="In('normalState')"/>
+ <raise event="turnOffC"/>
+ <raise event="turnOffR"/>
+ <raise event="turnOffA"/>
+ <raise event="turnOffZ"/>
+ <raise event="turnOffY"/>
+ <else/>
+ <if cond="In('cLetterOn')">
+ <raise event="turnOnC"/>
+ <else/>
+ <raise event="turnOffC"/>
+ </if>
+ <if cond="In('rLetterOn')">
+ <raise event="turnOnR"/>
+ <else/>
+ <raise event="turnOffR"/>
+ </if>
+ <if cond="In('aLetterOn')">
+ <raise event="turnOnA"/>
+ <else/>
+ <raise event="turnOffA"/>
+ </if>
+ <if cond="In('zLetterOn')">
+ <raise event="turnOnZ"/>
+ <else/>
+ <raise event="turnOffZ"/>
+ </if>
+ <if cond="In('yLetterOn')">
+ <raise event="turnOnY"/>
+ <else/>
+ <raise event="turnOffY"/>
+ </if>
+ </if>
+ <raise event="turnOffHurry"/>
+ <raise event="turnOffGameOver"/>
+ </if>
+ </transition>
+
+ </state>
+
+ <transition event="ballOutTriggered" cond="In('onState')" target="offState"/>
+ </parallel>
+
+ <parallel id="guiControl">
+ <state id="cLight">
+ <state id="cLightOn">
+ <transition event="turnOffC" target="cLightOff"/>
+ </state>
+ <state id="cLightOff">
+ <transition event="turnOnC" target="cLightOn"/>
+ </state>
+ </state>
+ <state id="rLight">
+ <state id="rLightOn">
+ <transition event="turnOffR" target="rLightOff"/>
+ </state>
+ <state id="rLightOff">
+ <transition event="turnOnR" target="rLightOn"/>
+ </state>
+ </state>
+ <state id="aLight">
+ <state id="aLightOn">
+ <transition event="turnOffA" target="aLightOff"/>
+ </state>
+ <state id="aLightOff">
+ <transition event="turnOnA" target="aLightOn"/>
+ </state>
+ </state>
+ <state id="zLight">
+ <state id="zLightOn">
+ <transition event="turnOffZ" target="zLightOff"/>
+ </state>
+ <state id="zLightOff">
+ <transition event="turnOnZ" target="zLightOn"/>
+ </state>
+ </state>
+ <state id="yLight">
+ <state id="yLightOn">
+ <transition event="turnOffY" target="yLightOff"/>
+ </state>
+ <state id="yLightOff">
+ <transition event="turnOnY" target="yLightOn"/>
+ </state>
+ </state>
+ <state id="hurryLight">
+ <state id="hurryLightOn">
+ <transition event="turnOffHurry" target="hurryLightOff"/>
+ </state>
+ <state id="hurryLightOff">
+ <transition event="turnOnHurry" target="hurryLightOn"/>
+ </state>
+ </state>
+ <state id="jackpotLight">
+ <state id="jackpotLightOn">
+ <transition event="turnOffJackpot" target="jackpotLightOff"/>
+ </state>
+ <state id="jackpotLightOff">
+ <transition event="turnOnJackpot" target="jackpotLightOn"/>
+ </state>
+ </state>
+ <state id="gameOverLight">
+ <state id="gameOverLightOn">
+ <transition event="turnOffGameOver" target="gameOverLightOff"/>
+ </state>
+ <state id="gameOverLightOff">
+ <transition event="turnOnGameOver" target="gameOverLightOn"/>
+ </state>
+ </state>
+ </parallel>
+ </parallel>
+</scxml>
diff --git a/examples/pinball-ecmascript-widgets-static/pinball-ecmascript-widgets-static.cpp b/examples/pinball-ecmascript-widgets-static/pinball-ecmascript-widgets-static.cpp
new file mode 100644
index 0000000..891cac8
--- /dev/null
+++ b/examples/pinball-ecmascript-widgets-static/pinball-ecmascript-widgets-static.cpp
@@ -0,0 +1,57 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "pinball.h"
+#include "../pinball-ecmascript-common/mainwindow.h"
+
+#include <QApplication>
+
+int main(int argc, char **argv)
+{
+ QApplication app(argc, argv);
+
+ Pinball machine;
+ MainWindow mainWindow(&machine);
+ machine.init();
+
+ machine.start();
+ mainWindow.show();
+ return app.exec();
+}
diff --git a/examples/pinball-ecmascript-widgets-static/pinball-ecmascript-widgets-static.pro b/examples/pinball-ecmascript-widgets-static/pinball-ecmascript-widgets-static.pro
new file mode 100644
index 0000000..d8d841d
--- /dev/null
+++ b/examples/pinball-ecmascript-widgets-static/pinball-ecmascript-widgets-static.pro
@@ -0,0 +1,21 @@
+QT += widgets scxml
+
+CONFIG += c++11
+
+STATECHARTS = ../pinball-ecmascript-common/pinball.scxml
+
+SOURCES += \
+ pinball-ecmascript-widgets-static.cpp \
+ ../pinball-ecmascript-common/mainwindow.cpp
+
+FORMS += \
+ ../pinball-ecmascript-common/mainwindow.ui
+
+HEADERS += \
+ ../pinball-ecmascript-common/mainwindow.h
+
+# install
+target.path = $$[QT_INSTALL_EXAMPLES]/scxml/pinball-ecmascript-widgets
+INSTALLS += target
+
+load(qscxmlc)