aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdrian Herrmann <adrian.herrmann@qt.io>2023-05-15 19:36:03 +0200
committerAdrian Herrmann <adrian.herrmann@qt.io>2023-05-30 11:08:05 +0200
commit55a0544de6de835aaa5e1277fe24773d7a4c2064 (patch)
tree99c0ba781423a06e12980f7b3c1bf3c14f7601dd
parentb81f2c3f9954bd92fa87944d1bcb72a536f035ab (diff)
Sync removed statemachine examples
Three qtstatemachine examples have been removed on the C++ side, remove them here as well. Pick-to: 6.5 Task-number: PYSIDE-2206 Change-Id: I18f4a63740804126b5f01473acff45ac53746a44 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
-rw-r--r--examples/statemachine/eventtrans/eventtrans.py57
-rw-r--r--examples/statemachine/eventtrans/eventtrans.pyproject3
-rw-r--r--examples/statemachine/factstates/factstates.py89
-rw-r--r--examples/statemachine/factstates/factstates.pyproject3
-rw-r--r--examples/statemachine/twowaybutton/twowaybutton.py33
-rw-r--r--examples/statemachine/twowaybutton/twowaybutton.pyproject3
6 files changed, 0 insertions, 188 deletions
diff --git a/examples/statemachine/eventtrans/eventtrans.py b/examples/statemachine/eventtrans/eventtrans.py
deleted file mode 100644
index b92118613..000000000
--- a/examples/statemachine/eventtrans/eventtrans.py
+++ /dev/null
@@ -1,57 +0,0 @@
-# Copyright (C) 2010 velociraptor Genjix <aphidia@hotmail.com>
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-import sys
-
-from PySide6.QtCore import QEvent, QRect
-from PySide6.QtWidgets import QApplication, QMainWindow, QPushButton
-from PySide6.QtStateMachine import QEventTransition, QState, QStateMachine
-
-
-class MainWindow(QMainWindow):
- def __init__(self):
- super().__init__()
- button = QPushButton(self)
- button.setGeometry(QRect(100, 100, 100, 100))
-
- machine = QStateMachine(self)
- s1 = QState()
- s1.assignProperty(button, 'text', 'Outside')
- s2 = QState()
- s2.assignProperty(button, 'text', 'Inside')
-
- enter_transition = QEventTransition(button, QEvent.Enter)
- enter_transition.setTargetState(s2)
- s1.addTransition(enter_transition)
-
- leave_transition = QEventTransition(button, QEvent.Leave)
- leave_transition.setTargetState(s1)
- s2.addTransition(leave_transition)
-
- s3 = QState()
- s3.assignProperty(button, 'text', 'Pressing...')
-
- press_transition = QEventTransition(button, QEvent.MouseButtonPress)
- press_transition.setTargetState(s3)
- s2.addTransition(press_transition)
-
- release_transition = QEventTransition(button, QEvent.MouseButtonRelease)
- release_transition.setTargetState(s2)
- s3.addTransition(release_transition)
-
- machine.addState(s1)
- machine.addState(s2)
- machine.addState(s3)
-
- machine.setInitialState(s1)
- machine.start()
-
- self.setCentralWidget(button)
- self.show()
-
-
-if __name__ == '__main__':
- app = QApplication(sys.argv)
- main_win = MainWindow()
- sys.exit(app.exec())
diff --git a/examples/statemachine/eventtrans/eventtrans.pyproject b/examples/statemachine/eventtrans/eventtrans.pyproject
deleted file mode 100644
index b2f660a8f..000000000
--- a/examples/statemachine/eventtrans/eventtrans.pyproject
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "files": ["eventtrans.py"]
-}
diff --git a/examples/statemachine/factstates/factstates.py b/examples/statemachine/factstates/factstates.py
deleted file mode 100644
index 5c2bc97bf..000000000
--- a/examples/statemachine/factstates/factstates.py
+++ /dev/null
@@ -1,89 +0,0 @@
-# Copyright (C) 2010 velociraptor Genjix <aphidia@hotmail.com>
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-import sys
-
-from PySide6.QtCore import QCoreApplication, QObject, Property, Signal
-from PySide6.QtStateMachine import (QFinalState, QSignalTransition, QState,
- QStateMachine)
-
-
-class Factorial(QObject):
- x_changed = Signal(int)
-
- def __init__(self):
- super().__init__()
- self.xval = -1
- self.facval = 1
-
- def get_x(self):
- return self.xval
-
- def set_x(self, x):
- if self.xval == x:
- return
- self.xval = x
- self.x_changed.emit(x)
- x = Property(int, get_x, set_x)
-
- def get_fact(self):
- return self.facval
-
- def set_fact(self, fac):
- self.facval = fac
-
- fac = Property(int, get_fact, set_fact)
-
-
-class FactorialLoopTransition(QSignalTransition):
- def __init__(self, fact):
- super().__init__(fact.x_changed)
- self.fact = fact
-
- def eventTest(self, e):
- if not super(FactorialLoopTransition, self).eventTest(e):
- return False
- return e.arguments()[0] > 1
-
- def onTransition(self, e):
- x = e.arguments()[0]
- fac = self.fact.fac
- self.fact.fac = x * fac
- self.fact.x = x - 1
-
-
-class FactorialDoneTransition(QSignalTransition):
- def __init__(self, fact):
- super().__init__(fact.x_changed)
- self.fact = fact
-
- def eventTest(self, e):
- if not super(FactorialDoneTransition, self).eventTest(e):
- return False
- return e.arguments()[0] <= 1
-
- def onTransition(self, e):
- print(self.fact.fac)
-
-
-if __name__ == '__main__':
- app = QCoreApplication(sys.argv)
- factorial = Factorial()
- machine = QStateMachine()
-
- compute = QState(machine)
- compute.assignProperty(factorial, 'fac', 1)
- compute.assignProperty(factorial, 'x', 6)
- compute.addTransition(FactorialLoopTransition(factorial))
-
- done = QFinalState(machine)
- done_transition = FactorialDoneTransition(factorial)
- done_transition.setTargetState(done)
- compute.addTransition(done_transition)
-
- machine.setInitialState(compute)
- machine.finished.connect(app.quit)
- machine.start()
-
- sys.exit(app.exec())
diff --git a/examples/statemachine/factstates/factstates.pyproject b/examples/statemachine/factstates/factstates.pyproject
deleted file mode 100644
index 751a5005b..000000000
--- a/examples/statemachine/factstates/factstates.pyproject
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "files": ["factstates.py"]
-}
diff --git a/examples/statemachine/twowaybutton/twowaybutton.py b/examples/statemachine/twowaybutton/twowaybutton.py
deleted file mode 100644
index 35a582f93..000000000
--- a/examples/statemachine/twowaybutton/twowaybutton.py
+++ /dev/null
@@ -1,33 +0,0 @@
-# Copyright (C) 2010 velociraptor Genjix <aphidia@hotmail.com>
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-import sys
-
-from PySide6.QtWidgets import QApplication, QPushButton
-from PySide6.QtStateMachine import QState, QStateMachine
-
-
-if __name__ == '__main__':
- app = QApplication(sys.argv)
- button = QPushButton()
- machine = QStateMachine()
-
- off = QState()
- off.assignProperty(button, 'text', 'Off')
- off.setObjectName('off')
-
- on = QState()
- on.setObjectName('on')
- on.assignProperty(button, 'text', 'On')
-
- off.addTransition(button.clicked, on)
- on.addTransition(button.clicked, off)
-
- machine.addState(off)
- machine.addState(on)
- machine.setInitialState(off)
- machine.start()
- button.resize(100, 50)
- button.show()
- sys.exit(app.exec())
diff --git a/examples/statemachine/twowaybutton/twowaybutton.pyproject b/examples/statemachine/twowaybutton/twowaybutton.pyproject
deleted file mode 100644
index 223a51e32..000000000
--- a/examples/statemachine/twowaybutton/twowaybutton.pyproject
+++ /dev/null
@@ -1,3 +0,0 @@
-{
- "files": ["twowaybutton.py"]
-}