qmlFrontend/qml/qmlFrontend/main.qml
author unc0rr
Sat, 22 Nov 2014 00:55:01 +0300
branchqmlfrontend
changeset 10519 af019fa70080
parent 10422 4cf23d4c7624
child 10896 5a74923120d5
permissions -rw-r--r--
Attempt on a custom combobox

import QtQuick 2.0

Rectangle {
    id: pages
    width: 800
    height: 600

    property variant pagesList  : [
        "First"
        , "LocalGame"
        , "GameConfig"
    ];

    property string  currentPage : "First";

    Repeater {
        model: pagesList;

        delegate: Loader {
            active: false
            asynchronous: true
            anchors.fill: parent
            visible: (currentPage === modelData)
            source: "%1.qml".arg(modelData)
            onVisibleChanged:      loadIfNotLoaded();
            Component.onCompleted: loadIfNotLoaded();

            function loadIfNotLoaded ()
            {
                if (visible && !active)
                    active = true;
            }
        }
    }
}