qmlFrontend/qml/qmlFrontend/main.qml
branchqmlfrontend
changeset 10422 4cf23d4c7624
parent 10420 02c573d19224
child 10896 5a74923120d5
equal deleted inserted replaced
10420:02c573d19224 10422:4cf23d4c7624
     1 import QtQuick 2.0
     1 import QtQuick 2.0
     2 import Hedgewars.Engine 1.0
       
     3 
     2 
     4 Rectangle {
     3 Rectangle {
     5     width: 400
     4     id: pages
     6     height: 400
     5     width: 800
       
     6     height: 600
     7 
     7 
     8     HWButton {
     8     property variant pagesList  : [
     9         id: hwbutton1
     9         "First"
    10         x: 8
    10         , "LocalGame"
    11         y: 66
    11         , "GameConfig"
    12         width: 166
    12     ];
    13         height: 158
       
    14 
    13 
    15         onClicked: {
    14     property string  currentPage : "First";
    16             HWEngine.run()
       
    17         }
       
    18 
    15 
    19         Connections {
    16     Repeater {
    20             target: HWEngine
    17         model: pagesList;
    21             onPreviewImageChanged: previewImage.source = "image://preview/1"
    18 
       
    19         delegate: Loader {
       
    20             active: false
       
    21             asynchronous: true
       
    22             anchors.fill: parent
       
    23             visible: (currentPage === modelData)
       
    24             source: "%1.qml".arg(modelData)
       
    25             onVisibleChanged:      loadIfNotLoaded();
       
    26             Component.onCompleted: loadIfNotLoaded();
       
    27 
       
    28             function loadIfNotLoaded ()
       
    29             {
       
    30                 if (visible && !active)
       
    31                     active = true;
       
    32             }
    22         }
    33         }
    23     }
    34     }
    24 
       
    25     HWButton {
       
    26         id: hwbutton2
       
    27         x: 192
       
    28         y: 66
       
    29         width: 200
       
    30         height: 139
       
    31     }
       
    32 
       
    33     Image {
       
    34         id: previewImage
       
    35         x: 70
       
    36         y: 250
       
    37         width: 256
       
    38         height: 128
       
    39         cache: false
       
    40     }
       
    41 }
    35 }