123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- import QtQuick 1.0
- import "KPageStack.js" as SVM
- Rectangle {
- id: root
- anchors.fill: parent
- default property alias content: viewsContainer.children
- clip: true
- PropertyAnimation {
- id: currentViewAnimation
- duration : 500
- property: "x"
- easing.type: Easing.InQuad
- onRunningChanged: if(!running) target.visible = false
- }
- PropertyAnimation {
- id: nextViewAnimation
- duration : 500
- property: "x"
- easing.type: Easing.InQuad
- }
- Rectangle {
- id: viewsContainer
- anchors.fill: parent
- color: "red"
- onWidthChanged: {
- var views = viewsContainer.children;
- if(views.length > 0) {
- SVM.currentView = views[0];
- var view;
- for(var i = 0; i < views.length; i++) {
- view = views[i]
- if (view.visible==true){
- view.anchors.fill = viewsContainer;
- //view.width= viewsContainer.width
- //view.height = viewsContainer.height
- }
- }
- }
- }
- }
- Component.onCompleted: {
- var views = viewsContainer.children;
- if(views.length > 0) {
- SVM.currentView = views[0];
- var view;
- for(var i = 0; i < views.length; i++) {
- view = views[i]
- view.visible = (i == 0);
- //view.anchors.fill = parent;
- SVM.connectViewEvents(view);
- /*if(i > 0)
- {
- view.x = root.width;
- }*/
- }
- }
- }
- function push(page,properties){
- var pageComp;
- if (page.createObject) {
- // page defined as component
- pageComp = page;
- } else if (typeof page == "string") {
- // page defined as string (a url)
- pageComp = Qt.createComponent(page);
- }
- if (pageComp) {
- if (pageComp.status == Component.Error) {
- throw new Error("Error while loading page: " + pageComp.errorString());
- } else {
- // instantiate page from component
- page = pageComp.createObject(viewsContainer);
- }
- }
- //Copy properties to the page
- console.log("Propierties "+ properties)
- for (var prop in properties) {
- page[prop] = properties[prop];
- console.log("Propiedad "+ prop + " " +properties[prop])
- }
- //page.visible=false
- page.width= root.width
- page.height= root.height
- page.parent=viewsContainer
- SVM.connectViewEvents(page);
- //SVM.showView(page);
- page.visible=true
- }
- function pop(){
- var page=SVM.viewHistory.pop()
- page.visible=true
- page=SVM.viewHistory.pop()
- }
- }
|