Use PageRouter instead of page stack. Start implementing first add page.

This commit is contained in:
2020-06-07 00:18:53 -04:00
parent eda53f9663
commit b0780f1ede

View File

@@ -1,6 +1,6 @@
import QtQuick 2.6 import QtQuick 2.9
import org.kde.kirigami 2.6 as Kirigami import org.kde.kirigami 2.12 as Kirigami
import QtQuick.Controls 2.0 as Controls import QtQuick.Controls 2.9 as Controls
import QtQuick.Layouts 1.12 as Layouts import QtQuick.Layouts 1.12 as Layouts
Kirigami.ApplicationWindow { Kirigami.ApplicationWindow {
@@ -8,25 +8,121 @@ Kirigami.ApplicationWindow {
title: "Vehicle Voyage" title: "Vehicle Voyage"
Kirigami.PageRouter {
id: router
initialRoute: "main"
pageStack: root.pageStack.columnView
pageStack.initialPage: mainPageComponent Kirigami.PageRoute {
contextDrawer: Kirigami.ContextDrawer {} name: "main"
Component { Component {
id: mainPageComponent
Kirigami.Page { Kirigami.Page {
id: mainPage id: mainPage
mainAction: Kirigami.Action {
text: qsTr("Add Vehicle")
onTriggered: {
router.navigateToRoute(["main","addvehicle"]);
}
}
contextualActions: [ contextualActions: [
Kirigami.Action { Kirigami.Action {
iconName: "help-about" iconName: "help-about"
text: qsTr("About") text: qsTr("About")
onTriggered: { onTriggered: {
pageStack.replace(aboutPageComponent); router.navigateToRoute("about");
} }
} }
] ]
title: "Vehicles" title: "Vehicles"
Kirigami.CardsListView {
Layouts.Layout.fillWidth: true
Layouts.Layout.fillHeight: true
id: vehicleView
model: vehicleModel
delegate: Kirigami.Card {
id: card
banner {
title: name
}
}
Controls.ScrollBar.vertical: Controls.ScrollBar {}
}
}
}
}
Kirigami.PageRoute {
name: "about"
Component {
Kirigami.AboutPage {
id: aboutPage
actions.main: Kirigami.Action {
iconName: "window-close"
text: qsTr("Close")
onTriggered: {
router.navigateToRoute("main");
}
}
aboutData: appAboutData
}
}
}
Kirigami.PageRoute {
name: "addvehicle"
Component {
Kirigami.Page {
title: qsTr("Add Vehicle")
Layouts.ColumnLayout {
anchors.fill: parent
Layouts.RowLayout {
Controls.Label {
text: qsTr("Name")+":"
}
Controls.TextField {
//
}
}
Layouts.RowLayout {
Controls.Label {
text: qsTr("Make")+":"
}
Controls.TextField {
//
}
}
Layouts.RowLayout {
Controls.Label {
text: qsTr("Model")+":"
}
Controls.TextField {
//
}
}
Layouts.RowLayout {
Controls.Label {
text: qsTr("Year")+":"
}
Controls.TextField {
inputMethodHints: Qt.ImhDigitsOnly
validator: IntValidator {
bottom: 1900
top: 4000
}
}
}
Controls.Button {
text: qsTr("Add")
highlighted: true
onClicked: {
router.popRoute();
}
}
}
}
}
}
} }
/*Kirigami.Page { /*Kirigami.Page {
id: mainPage id: mainPage
@@ -249,21 +345,4 @@ Kirigami.ApplicationWindow {
} }
} }
}*/ }*/
}
Component {
id:aboutPageComponent
Kirigami.AboutPage {
id: aboutPage
actions.main: Kirigami.Action {
iconName: "window-close"
text: qsTr("Close")
onTriggered: {
pageStack.clear();
pageStack.push(mainPageComponent);
}
}
aboutData: appAboutData
}
}
} }