This repository has been archived on 2022-08-16. You can view files and clone it, but cannot push or open issues or pull requests.
fanny-app/qml/Pages/MainPage.qml

261 lines
7.5 KiB
QML
Raw Normal View History

2018-06-21 08:47:09 +02:00
import QtQuick 2.9
import QtQuick.Controls 2.2
2018-07-19 20:08:46 +02:00
import QtQuick.Layouts 1.1
import QtQuick.Controls.Styles 1.2
import "../Components"
import "../Forms"
2018-07-19 20:08:46 +02:00
2018-06-21 08:47:09 +02:00
Page {
id: root
2018-06-25 08:07:05 +02:00
objectName: "MainPage"
2018-06-25 10:04:11 +02:00
2018-06-30 11:05:39 +02:00
Shortcut {
sequences: ["Esc", "Back"]
enabled: stackView.depth > 1
onActivated: {
stackView.pop()
}
}
2018-06-21 16:41:02 +02:00
header: AppToolBar {
2018-06-21 08:47:09 +02:00
2018-07-19 20:08:46 +02:00
Button {
id:toolButton
enabled: window.is_error === false
2018-06-25 10:04:11 +02:00
anchors {
left: parent.left
verticalCenter: parent.verticalCenter
2018-07-19 20:08:46 +02:00
leftMargin: parent.width *0.02
2018-06-25 10:04:11 +02:00
}
2018-07-19 20:08:46 +02:00
height: parent.height - parent.height * 0.5
width: height
2018-06-21 16:41:02 +02:00
2018-06-21 08:47:09 +02:00
onClicked: {
if (stackView.depth > 1) {
stackView.pop()
} else {
drawer.open()
}
}
2018-07-19 20:08:46 +02:00
onPressed: toolButton.scale = 0.9
onReleased: toolButton.scale = 1.0
background: Image {
source: stackView.depth > 1 ? "qrc:/graphics/icons/back.png" : "qrc:/graphics/icons/drawer.png"
height: parent.height
width: parent.width
Behavior on scale {
PropertyAnimation {
duration: 100
}
}
}
2018-06-21 08:47:09 +02:00
}
Label {
text: stackView.currentItem.title
2018-07-19 17:19:09 +02:00
anchors {
verticalCenter: parent.verticalCenter
left: toolButton.right
2018-07-19 20:08:46 +02:00
leftMargin: parent.width * 0.02
2018-07-19 17:19:09 +02:00
}
2018-07-19 20:08:46 +02:00
font.bold: true
2018-06-25 10:04:11 +02:00
color: "white"
2018-06-21 08:47:09 +02:00
}
2018-07-19 17:19:09 +02:00
Image {
2018-07-19 20:08:46 +02:00
id: logo
2018-07-19 17:19:09 +02:00
source: stackView.currentItem.icon
anchors.right: parent.right
2018-07-19 20:08:46 +02:00
anchors.rightMargin: parent.width * 0.02
2018-07-19 17:19:09 +02:00
anchors.top: parent.top
height: parent.height
fillMode: Image.PreserveAspectFit
mipmap: true
2018-07-19 20:08:46 +02:00
Behavior on scale {
PropertyAnimation {
duration: 100
}
}
MouseArea {
enabled: stackView.currentItem.link !== undefined && stackView.currentItem.objectName !== "WebsitePage"
anchors.fill: parent
onPressed: logo.scale = 0.9
onReleased: logo.scale = 1.0
onClicked: {
stackView.push("qrc:/WebsitePage.qml",{title: "Web", link: stackView.currentItem.link, icon: stackView.currentItem.icon})
}
}
2018-07-19 17:19:09 +02:00
}
2018-06-21 08:47:09 +02:00
}
Drawer {
id: drawer
width: window.width * 0.66
height: window.height
2018-07-19 17:19:09 +02:00
AppToolBar {
id: header
showErrorBar: false
anchors {
top: parent.top
left: parent.left
right: parent.right
}
2018-06-21 08:47:09 +02:00
2018-07-19 17:19:09 +02:00
Label {
text: "Menü"
anchors {
verticalCenter: parent.verticalCenter
left: parent.left
leftMargin: 17
}
font.bold: true
}
}
2018-06-21 08:47:09 +02:00
Column {
2018-07-19 17:19:09 +02:00
anchors {
top: header.bottom
bottom: parent.bottom
left: parent.left
right: parent.right
}
2018-06-21 08:47:09 +02:00
ItemDelegate {
2018-06-21 16:41:02 +02:00
text: qsTr("Fanny Webseite")
2018-06-21 08:47:09 +02:00
width: parent.width
onClicked: {
2018-07-19 20:08:46 +02:00
stackView.push("qrc:/WebsitePage.qml",{title: "Fanny Webseite", link: "http://www.fanny-leicht.de/j34", icon: stackView.currentItem.icon})
2018-06-21 08:47:09 +02:00
drawer.close()
}
}
2018-06-22 15:33:16 +02:00
ItemDelegate {
text: qsTr("Vertretungsplan")
width: parent.width
onClicked: {
busyDialog.open()
var ret = _cppServerConn.getEvents();
drawer.close()
busyDialog.close()
if(ret === 200 || _cppServerConn.getEventData(0).grade !== ""){
2018-12-21 23:56:10 +01:00
stackView.push("qrc:/Forms/EventForm.qml")
}
}
}
2018-06-22 15:33:16 +02:00
ItemDelegate {
text: qsTr("Speiseplan")
width: parent.width
onClicked: {
2018-06-25 00:15:18 +02:00
busyDialog.open()
var ret = _cppServerConn.getFoodPlan();
2018-06-22 15:33:16 +02:00
drawer.close()
2018-06-25 00:15:18 +02:00
busyDialog.close()
if(ret === 200 || _cppServerConn.getFoodPlanData(1).cookteam !== ""){
2018-07-19 20:08:46 +02:00
stackView.push("qrc:/FoodPlanForm.qml")
2018-06-25 00:15:18 +02:00
}
2018-06-22 15:33:16 +02:00
}
}
2018-06-21 08:47:09 +02:00
ItemDelegate {
2018-07-19 17:19:09 +02:00
Label {
text: "abmelden"
color: "red"
anchors {
verticalCenter: parent.verticalCenter
left: parent.left
leftMargin: 17
}
font.bold: true
2018-06-21 16:41:02 +02:00
}
2018-07-19 17:19:09 +02:00
width: parent.width
2018-07-19 20:08:46 +02:00
onClicked: {
confirmationDialog.open()
}
2018-06-21 16:41:02 +02:00
Dialog {
id: confirmationDialog
x: (window.width - width) / 2
y: (window.height - height) / 2
parent: ApplicationWindow.overlay
modal: true
standardButtons: Dialog.Cancel | Dialog.Ok
Column {
spacing: 20
anchors.fill: parent
Label {
text: "Möchtest du dich wirklich abmelden?"
}
}
onAccepted: {
_cppServerConn.logout()
drawer.close()
2018-07-19 20:08:46 +02:00
root.StackView.view.push("qrc:/LoginPage.qml")
2018-06-21 16:41:02 +02:00
}
2018-06-21 08:47:09 +02:00
}
}
}
}
StackView {
id: stackView
initialItem: "qrc:/Forms/HomeForm.qml"
2018-06-21 08:47:09 +02:00
anchors.fill: parent
}
2018-06-25 00:15:18 +02:00
Dialog {
id: busyDialog
modal: true
focus: true
//title: "Please wait..."
x: (window.width - width) / 2
y: window.height / 6
//width: Math.min(window.width, window.height) / 3 * 2
height: contentHeight * 1.5
width: contentWidth * 1.5
2018-06-30 20:59:42 +02:00
contentHeight: progressCircle.height
contentWidth: progressCircle.width
ProgressCircle {
id: progressCircle
size: 50
lineWidth: 5
2018-06-25 00:15:18 +02:00
anchors.centerIn: parent
2018-06-30 20:59:42 +02:00
colorCircle: "#FF3333"
colorBackground: "#E6E6E6"
showBackground: true
arcBegin: 0
arcEnd: 0
Label {
id: progress
anchors.centerIn: parent
text: "0%"
}
Timer {
id: refreshTimer
interval: 1;
running: busyDialog.visible
repeat: true
onTriggered: {
var ret = _cppServerConn.getProgress()
if(ret > 100 || ret < 0){
ret = 0
}
progress.text = Math.round( ret * 100 ) + "%"
progressCircle.arcEnd = 360 * ret
}
}
2018-06-25 00:15:18 +02:00
}
}
2018-06-21 08:47:09 +02:00
}