qmlfrontend/Page1.qml
changeset 14371 90bd2c331703
parent 14298 00b56ec8b7df
child 14372 b6824a53d4b1
--- a/qmlfrontend/Page1.qml	Fri Dec 07 13:04:00 2018 +0100
+++ b/qmlfrontend/Page1.qml	Fri Dec 07 13:35:08 2018 +0100
@@ -2,24 +2,30 @@
 import Hedgewars.Engine 1.0
 
 Page1Form {
+  property var hwEngine
+
+  Component {
+    id: hwEngineComponent
+
+    HWEngine {
+      previewAcceptor: PreviewAcceptor
+      onPreviewImageChanged: previewImage.source = "image://preview/image"
+      onPreviewIsRendering: previewImage.source = "qrc:/res/iconTime.png"
+    }
+  }
+
+  Component.onCompleted: {
+    hwEngine = hwEngineComponent.createObject()
+  }
+
   tickButton.onClicked: {
     gameView.tick(100)
   }
   gameButton.onClicked: {
-    var engineInstance = HWEngine.runQuickGame()
+    var engineInstance = hwEngine.runQuickGame()
     gameView.engineInstance = engineInstance
   }
   button1.onClicked: {
-    HWEngine.getPreview()
-  }
-
-  Connections {
-    target: HWEngine
-    onPreviewImageChanged: {
-      previewImage.source = "image://preview/image"
-    }
-    onPreviewIsRendering: {
-      previewImage.source = "qrc:/res/iconTime.png"
-    }
+    hwEngine.getPreview()
   }
 }