This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
Doric/doric-Qt/example/app/main.qml

217 lines
6.9 KiB
QML
Raw Permalink Normal View History

2021-01-28 17:06:40 +08:00
import QtQuick 2.12
import QtQuick.Controls 2.5
2021-06-16 13:51:45 +08:00
import QtQuick.Layouts 1.14
2021-01-28 17:06:40 +08:00
ApplicationWindow {
visible: true
2021-04-23 17:56:08 +08:00
width: 600
2021-06-09 11:44:27 +08:00
height: 844
2021-06-08 10:25:36 +08:00
title: qsTr("Doric Demo")
2021-06-09 11:44:27 +08:00
ColumnLayout{
spacing: 0
2021-06-08 10:25:36 +08:00
anchors.fill: parent
2021-06-09 11:44:27 +08:00
Rectangle {
id: navbar
2021-06-10 17:15:56 +08:00
objectName: "navbar"
2021-06-09 11:44:27 +08:00
visible: false
Layout.fillWidth: true
Layout.preferredHeight: 44
2021-06-09 14:40:57 +08:00
2021-06-10 17:15:56 +08:00
Rectangle {
anchors.fill: parent
color: "transparent"
Text {
anchors.centerIn: parent
objectName: "title"
font.pixelSize: 16
}
Rectangle {
anchors.centerIn: parent
objectName: "center"
width: childrenRect.width
height: childrenRect.height
}
2021-06-09 14:40:57 +08:00
}
RowLayout {
anchors.verticalCenter: parent.verticalCenter
Rectangle {
Layout.preferredWidth: 10
}
2021-06-10 17:15:56 +08:00
RowLayout {
objectName: "left"
2021-06-09 14:40:57 +08:00
2021-06-10 17:15:56 +08:00
Image {
Layout.preferredWidth: 24
Layout.preferredHeight: 24
id: name
source: "qrc:/doric/qml/doric_icon_back.png"
}
2021-06-09 14:40:57 +08:00
}
MouseArea {
2021-06-10 14:19:00 +08:00
width: parent.width
height: parent.height
2021-06-09 14:40:57 +08:00
onClicked: {
2021-06-09 20:55:44 +08:00
navigatorPop()
2021-06-09 14:40:57 +08:00
}
}
}
RowLayout {
2021-06-25 19:35:23 +08:00
id: rightSection
height: navbar.height
2021-06-09 14:40:57 +08:00
anchors.verticalCenter: parent.verticalCenter
2021-06-10 17:15:56 +08:00
RowLayout {
objectName: "right"
2021-06-25 19:35:23 +08:00
width: childrenRect.width
2021-06-09 14:40:57 +08:00
2021-06-25 19:35:23 +08:00
onChildrenRectChanged: {
rightSection.x = navbar.width - this.childrenRect.width - 10
}
2021-06-09 14:40:57 +08:00
}
}
2021-06-09 11:44:27 +08:00
}
Rectangle {
2021-06-10 14:19:00 +08:00
id: content
2021-06-09 11:44:27 +08:00
Layout.fillWidth: true
Layout.fillHeight: true
StackView {
id: stack
objectName: "stackView"
2021-06-10 14:19:00 +08:00
anchors.fill: content
2021-06-09 11:44:27 +08:00
initialItem: ScrollView {
id: entry
2021-01-28 17:06:40 +08:00
2021-06-10 14:19:00 +08:00
width: content.width
height: content.height
2021-04-16 19:31:00 +08:00
2021-06-09 11:44:27 +08:00
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
ScrollBar.vertical.policy: ScrollBar.AlwaysOff
ListView {
2021-06-10 14:06:36 +08:00
id: list
2021-06-10 14:19:00 +08:00
width: content.width
2021-06-11 11:55:36 +08:00
model: 25
2021-06-09 11:44:27 +08:00
boundsBehavior: Flickable.StopAtBounds
2021-06-10 14:06:36 +08:00
function getSource(index) : string {
switch (index) {
case 0:
return "ComponetDemo.js"
case 1:
return "Counter.js"
case 2:
return "DraggableDemo.js"
case 3:
return "EffectsDemo.js"
case 4:
return "FlexDemo.js"
case 5:
return "Gobang.js"
case 6:
return "ImageDemo.js"
case 7:
return "InputDemo.js"
case 8:
return "LayoutDemo.js"
case 9:
return "LayoutTestDemo.js"
case 10:
2021-06-11 11:55:36 +08:00
return "ListDemo.js"
2021-06-10 14:06:36 +08:00
case 11:
2021-06-11 11:55:36 +08:00
return "ModalDemo.js"
2021-06-10 14:06:36 +08:00
case 12:
2021-06-11 11:55:36 +08:00
return "ModularDemo.js"
2021-06-10 14:06:36 +08:00
case 13:
2021-06-11 11:55:36 +08:00
return "NavBarDemo.js"
2021-06-10 14:06:36 +08:00
case 14:
2021-06-11 11:55:36 +08:00
return "NavigatorDemo.js"
2021-06-10 14:06:36 +08:00
case 15:
2021-06-11 11:55:36 +08:00
return "NetworkDemo.js"
2021-06-10 14:06:36 +08:00
case 16:
2021-06-11 11:55:36 +08:00
return "NotificationDemo.js"
2021-06-10 14:06:36 +08:00
case 17:
2021-06-11 11:55:36 +08:00
return "PopoverDemo.js"
2021-06-10 14:06:36 +08:00
case 18:
2021-06-11 11:55:36 +08:00
return "ScrollerDemo.js"
2021-06-10 14:06:36 +08:00
case 19:
2021-06-11 11:55:36 +08:00
return "SimpleDemo.js"
2021-06-10 14:06:36 +08:00
case 20:
2021-06-11 11:55:36 +08:00
return "SliderDemo.js"
2021-06-10 14:06:36 +08:00
case 21:
2021-06-11 11:55:36 +08:00
return "Snake.js"
2021-06-10 14:06:36 +08:00
case 22:
2021-06-11 11:55:36 +08:00
return "StorageDemo.js"
2021-06-10 17:15:56 +08:00
case 23:
2021-06-11 11:55:36 +08:00
return "SwitchDemo.js"
case 24:
2021-06-10 14:06:36 +08:00
return "TextDemo.js"
}
}
2021-06-09 11:44:27 +08:00
delegate: Rectangle {
Column {
anchors.centerIn: parent
Text {
text: {
2021-06-10 14:06:36 +08:00
return list.getSource(index)
2021-06-09 11:44:27 +08:00
}
}
}
2021-06-10 14:19:00 +08:00
width: content.width
2021-06-09 11:44:27 +08:00
height: 60
MouseArea {
anchors.fill: parent
onClicked: {
2021-06-10 14:06:36 +08:00
let source = list.getSource(index)
demoBridge.navigate("assets://src/" + source, source)
2021-06-08 11:43:34 +08:00
}
2021-03-01 18:59:09 +08:00
}
2021-06-08 11:43:34 +08:00
}
2021-03-01 18:59:09 +08:00
}
2021-02-02 20:42:37 +08:00
}
2021-01-28 17:06:40 +08:00
}
}
2021-06-08 11:43:34 +08:00
}
function navigatorPush(page) {
stack.push(page)
2021-06-09 11:44:27 +08:00
if (stack.depth > 1) {
navbar.visible = true
} else {
navbar.visible = false
}
}
function navigatorPop() {
stack.pop()
if (stack.depth > 1) {
navbar.visible = true
} else {
navbar.visible = false
}
2021-01-28 17:06:40 +08:00
}
2021-06-10 11:31:46 +08:00
function navigatorPopToRoot() {
while (stack.depth > 1) {
stack.pop()
}
if (stack.depth > 1) {
navbar.visible = true
} else {
navbar.visible = false
}
}
2021-01-28 17:06:40 +08:00
}