- Pages qmlfrontend
authorunc0rr
Fri, 26 Sep 2014 00:56:36 +0400
branchqmlfrontend
changeset 10422 4cf23d4c7624
parent 10420 02c573d19224
child 10424 4be6cd55f1cf
- Pages - Animations on buttons hovering
qmlFrontend/qml/qmlFrontend/First.qml
qmlFrontend/qml/qmlFrontend/GameConfig.qml
qmlFrontend/qml/qmlFrontend/HWButton.qml
qmlFrontend/qml/qmlFrontend/LocalGame.qml
qmlFrontend/qml/qmlFrontend/main.qml
qmlFrontend/qmlFrontend.pro
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/qmlFrontend/qml/qmlFrontend/First.qml	Fri Sep 26 00:56:36 2014 +0400
@@ -0,0 +1,29 @@
+import QtQuick 2.0
+
+Rectangle {
+    HWButton {
+        id: btnLocalGame
+        x: 8
+        y: 80
+        width: 166
+        height: 166
+
+        onClicked: pages.currentPage = "LocalGame"
+    }
+
+    HWButton {
+        id: btnNetwork
+        x: 192
+        y: 80
+        width: 166
+        height: 166
+    }
+
+    HWButton {
+        id: btnAbout
+        x: 100
+        y: 16
+        width: 200
+        height: 50
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/qmlFrontend/qml/qmlFrontend/GameConfig.qml	Fri Sep 26 00:56:36 2014 +0400
@@ -0,0 +1,30 @@
+import QtQuick 2.0
+import Hedgewars.Engine 1.0
+
+Rectangle {
+    HWButton {
+        id: btnPreview
+        x: 50
+        y: 66
+        width: 150
+        height: 150
+
+        onClicked: {
+            HWEngine.run()
+        }
+
+        Connections {
+            target: HWEngine
+            onPreviewImageChanged: previewImage.source = "image://preview/1"
+        }
+    }
+
+    Image {
+        id: previewImage
+        x: 210
+        y: 70
+        width: 256
+        height: 128
+        cache: false
+    }
+}
--- a/qmlFrontend/qml/qmlFrontend/HWButton.qml	Mon Sep 22 02:10:39 2014 +0400
+++ b/qmlFrontend/qml/qmlFrontend/HWButton.qml	Fri Sep 26 00:56:36 2014 +0400
@@ -7,17 +7,36 @@
     color: "#15193a"
     radius: 8
     border.width: 4
-    border.color: "#ea761d"
     opacity: 1
 
     signal clicked()
 
+    Behavior on border.color {
+        ColorAnimation {}
+    }
+
     MouseArea {
         id: mousearea
         anchors.fill: parent
         hoverEnabled: true
-        onEntered: parent.border.color = "#eaea00"
-        onExited: parent.border.color = "#ea761d"
-        onClicked: hwbutton.clicked()
+        onClicked: parent.clicked()
     }
+
+    states: [
+        State {
+            when: mousearea.containsMouse
+
+            PropertyChanges {
+                target: hwbutton
+                border.color: "#eaea00"
+            }
+        }
+        , State {
+            when: !mousearea.containsMouse
+
+            PropertyChanges {
+                target: hwbutton
+                border.color: "#ea761d"
+            }
+    }]
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/qmlFrontend/qml/qmlFrontend/LocalGame.qml	Fri Sep 26 00:56:36 2014 +0400
@@ -0,0 +1,22 @@
+import QtQuick 2.0
+//import Hedgewars.Engine 1.0
+
+Rectangle {
+    HWButton {
+        id: btnQuickGame
+        x: 8
+        y: 66
+        width: 150
+        height: 150
+    }
+
+    HWButton {
+        id: btnMultiplayer
+        x: 192
+        y: 66
+        width: 150
+        height: 150
+
+        onClicked: pages.currentPage = "GameConfig"
+    }
+}
--- a/qmlFrontend/qml/qmlFrontend/main.qml	Mon Sep 22 02:10:39 2014 +0400
+++ b/qmlFrontend/qml/qmlFrontend/main.qml	Fri Sep 26 00:56:36 2014 +0400
@@ -1,41 +1,35 @@
 import QtQuick 2.0
-import Hedgewars.Engine 1.0
 
 Rectangle {
-    width: 400
-    height: 400
+    id: pages
+    width: 800
+    height: 600
+
+    property variant pagesList  : [
+        "First"
+        , "LocalGame"
+        , "GameConfig"
+    ];
+
+    property string  currentPage : "First";
+
+    Repeater {
+        model: pagesList;
 
-    HWButton {
-        id: hwbutton1
-        x: 8
-        y: 66
-        width: 166
-        height: 158
+        delegate: Loader {
+            active: false
+            asynchronous: true
+            anchors.fill: parent
+            visible: (currentPage === modelData)
+            source: "%1.qml".arg(modelData)
+            onVisibleChanged:      loadIfNotLoaded();
+            Component.onCompleted: loadIfNotLoaded();
 
-        onClicked: {
-            HWEngine.run()
-        }
-
-        Connections {
-            target: HWEngine
-            onPreviewImageChanged: previewImage.source = "image://preview/1"
+            function loadIfNotLoaded ()
+            {
+                if (visible && !active)
+                    active = true;
+            }
         }
     }
-
-    HWButton {
-        id: hwbutton2
-        x: 192
-        y: 66
-        width: 200
-        height: 139
-    }
-
-    Image {
-        id: previewImage
-        x: 70
-        y: 250
-        width: 256
-        height: 128
-        cache: false
-    }
 }
--- a/qmlFrontend/qmlFrontend.pro	Mon Sep 22 02:10:39 2014 +0400
+++ b/qmlFrontend/qmlFrontend.pro	Fri Sep 26 00:56:36 2014 +0400
@@ -32,4 +32,7 @@
 OTHER_FILES += \
     qtquick2applicationviewer/qtquick2applicationviewer.pri \
     qml/qmlFrontend/HWButton.qml \
-    qml/qmlFrontend/main.qml
+    qml/qmlFrontend/main.qml \
+    qml/qmlFrontend/LocalGame.qml \
+    qml/qmlFrontend/GameConfig.qml \
+    qml/qmlFrontend/First.qml