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,33 +1,129 @@
import QtQuick 2.6
import org.kde.kirigami 2.6 as Kirigami
import QtQuick.Controls 2.0 as Controls
import QtQuick 2.9
import org.kde.kirigami 2.12 as Kirigami
import QtQuick.Controls 2.9 as Controls
import QtQuick.Layouts 1.12 as Layouts
Kirigami.ApplicationWindow {
id: root
title: "Vehicle Voyage"
pageStack.initialPage: mainPageComponent
contextDrawer: Kirigami.ContextDrawer {}
Component {
id: mainPageComponent
Kirigami.Page {
id: mainPage
contextualActions: [
Kirigami.Action {
iconName: "help-about"
text: qsTr("About")
onTriggered: {
pageStack.replace(aboutPageComponent);
Kirigami.PageRouter {
id: router
initialRoute: "main"
pageStack: root.pageStack.columnView
Kirigami.PageRoute {
name: "main"
Component {
Kirigami.Page {
id: mainPage
mainAction: Kirigami.Action {
text: qsTr("Add Vehicle")
onTriggered: {
router.navigateToRoute(["main","addvehicle"]);
}
}
contextualActions: [
Kirigami.Action {
iconName: "help-about"
text: qsTr("About")
onTriggered: {
router.navigateToRoute("about");
}
}
]
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 {}
}
}
]
title: "Vehicles"
}
}
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 {
id: mainPage
mainAction: Kirigami.Action {
@@ -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
}
}
}