- cleaned up the views

- added teacher mode
This commit is contained in:
Dorian Zedler 2018-12-27 21:41:46 +01:00
parent e2e83ba5ea
commit 2ff52410d2
11 changed files with 222 additions and 98 deletions

View file

@ -2,23 +2,15 @@ import Backend 1.0
import QtQuick 2.9 import QtQuick 2.9
import QtQuick.Controls 2.4 import QtQuick.Controls 2.4
ListView { FannyDataListView {
id: eventList id: eventList
signal refresh()
anchors.fill: parent anchors.fill: parent
anchors.margins: 10
model: EventModel { model: EventModel {
id: foodPlanModel id: foodPlanModel
} }
onContentYChanged: {
if(contentY < -125){
eventList.refresh()
}
}
delegate: Button { delegate: Button {
id: delegate id: delegate

View file

@ -0,0 +1,52 @@
import Backend 1.0
import QtQuick 2.9
import QtQuick.Controls 2.4
ListView {
id: control
property int status: -1
signal refresh()
anchors.fill: parent
anchors.margins: 10
anchors.rightMargin: 14
ScrollBar.vertical: ScrollBar {
parent: control.parent
anchors {
top: parent.top
right: parent.right
bottom: parent.bottom
margins: 10
rightMargin: 3
}
width: 8
active: true
}
onContentYChanged: {
if(contentY < -125){
control.refresh()
}
}
InfoArea {
id: infoArea
anchors {
left: parent.left
right: parent.right
top: parent.top
margins: app.landscape() ? parent.width * 0.4:parent.width * 0.3
topMargin: parent.height*( status === 901 ? 0.6:0.5) - height * 0.8
}
excludedCodes: [200, 902]
errorCode: control.status
}
}

View file

@ -2,19 +2,10 @@ import Backend 1.0
import QtQuick 2.9 import QtQuick 2.9
import QtQuick.Controls 2.4 import QtQuick.Controls 2.4
ListView { FannyDataListView {
id: foodList id: foodList
signal refresh()
anchors.fill: parent anchors.fill: parent
anchors.margins: 10
onContentYChanged: {
if(contentY < -125){
foodList.refresh()
}
}
model: FoodPlanModel { model: FoodPlanModel {
id: foodPlanModel id: foodPlanModel

View file

@ -47,7 +47,10 @@ Page {
anchors.fill: parent anchors.fill: parent
source: "./LoadingForm.qml" source: "./LoadingForm.qml"
onSourceChanged: newItemAnimation.start() onSourceChanged: {
pageLoader.item.status = root.status
newItemAnimation.start()
}
NumberAnimation { NumberAnimation {
id: newItemAnimation id: newItemAnimation
@ -90,22 +93,8 @@ Page {
running: true running: true
repeat: false repeat: false
onTriggered: { onTriggered: {
status = serverConn.getEvents(day) root.status = serverConn.getEvents(day)
pageLoader.newSource = "../Components/EventView.qml" pageLoader.newSource = "../Components/EventView.qml"
} }
} }
InfoArea {
id: infoArea
anchors {
left: parent.left
right: parent.right
top: parent.top
margins: app.landscape() ? parent.width * 0.4:parent.width * 0.3
topMargin: parent.height*( status === 901 ? 0.6:0.5) - height * 0.8
}
errorCode: status
}
} }

View file

@ -19,20 +19,29 @@ Page {
Dialog { Dialog {
id: filterDialog id: filterDialog
signal finished(string grade, string classletter) signal finished(string grade, string classletter, string teacherShortcut)
property bool teacherMode: _cppAppSettings.loadSetting("teacherMode") === "true"
onFinished: { onFinished: {
if(parseInt(grade) > 10 || classletter === "alle"){ if(_cppAppSettings.loadSetting("teacherMode") === "true"){
classletter = "" contactView.model.append(teacherShortcut, "")
} }
else {
if(parseInt(grade) > 10 || classletter === "alle"){
classletter = ""
}
contactView.model.append(grade, classletter) contactView.model.append(grade, classletter)
}
} }
function createContact() { function createContact() {
form.grade.value = 5 form.grade.value = 5
form.classLetter.currentIndex = 0
form.teacherShortcut.text = ""
filterDialog.title = qsTr("Klasse hinzufügen"); filterDialog.title = qsTr("Filter hinzufügen");
filterDialog.open(); filterDialog.open();
} }
@ -45,47 +54,69 @@ Page {
standardButtons: Dialog.Ok | Dialog.Cancel standardButtons: Dialog.Ok | Dialog.Cancel
contentItem: GridLayout { contentItem: GridLayout {
id: form id: form
property alias grade: gradeSb property alias grade: gradeSb
property alias classLetter: classLetterCb property alias classLetter: classLetterCb
property int minimumInputSize: 120 property alias teacherShortcut: shortcutTf
property int minimumInputSize: 120
rows: 4 rows: 4
columns: 2 columns: 2
Label { Label {
text: qsTr("Stufe") text: qsTr("Stufe")
Layout.alignment: Qt.AlignLeft | Qt.AlignBaseline Layout.alignment: Qt.AlignLeft | Qt.AlignBaseline
visible: !filterDialog.teacherMode
}
SpinBox {
id: gradeSb
focus: true
Layout.fillWidth: true
Layout.minimumWidth: form.minimumInputSize
Layout.alignment: Qt.AlignLeft | Qt.AlignBaseline
from: 5
to: 12
stepSize: 1
value: 5
visible: !filterDialog.teacherMode
}
Label {
text: qsTr("Klasse")
Layout.alignment: Qt.AlignLeft | Qt.AlignBaseline
visible: !filterDialog.teacherMode
}
ComboBox {
id: classLetterCb
Layout.fillWidth: true
Layout.minimumWidth: form.minimumInputSize
Layout.alignment: Qt.AlignLeft | Qt.AlignBaseline
model: ["a", "b", "c", "d", "e", "alle"]
enabled: gradeSb.value < 11
visible: !filterDialog.teacherMode
}
Label {
text: qsTr("Kürzel")
Layout.alignment: Qt.AlignLeft | Qt.AlignBaseline
visible: filterDialog.teacherMode
}
TextField {
id: shortcutTf
focus: true
Layout.fillWidth: true
Layout.minimumWidth: form.minimumInputSize
Layout.alignment: Qt.AlignLeft | Qt.AlignBaseline
visible: filterDialog.teacherMode
}
} }
SpinBox { onAccepted: finished(form.grade.value, form.classLetter.currentText, form.teacherShortcut.text)
id: gradeSb
focus: true
Layout.fillWidth: true
Layout.minimumWidth: form.minimumInputSize
Layout.alignment: Qt.AlignLeft | Qt.AlignBaseline
from: 5
to: 12
stepSize: 1
value: 5
}
Label {
text: qsTr("Klasse")
Layout.alignment: Qt.AlignLeft | Qt.AlignBaseline
}
ComboBox {
id: classLetterCb
Layout.fillWidth: true
Layout.minimumWidth: form.minimumInputSize
Layout.alignment: Qt.AlignLeft | Qt.AlignBaseline
model: ["a", "b", "c", "d", "e", "alle"]
enabled: gradeSb.value < 11
}
}
onAccepted: finished(form.grade.value.toString(), form.classLetter.currentText)
} }
ListView { ListView {

View file

@ -48,7 +48,10 @@ Page {
anchors.fill: parent anchors.fill: parent
source: "./LoadingForm.qml" source: "./LoadingForm.qml"
onSourceChanged: newItemAnimation.start() onSourceChanged: {
pageLoader.item.status = root.status
newItemAnimation.start()
}
NumberAnimation { NumberAnimation {
id: newItemAnimation id: newItemAnimation
@ -95,19 +98,4 @@ Page {
pageLoader.newSource = "../Components/FoodPlanView.qml" pageLoader.newSource = "../Components/FoodPlanView.qml"
} }
} }
InfoArea {
id: infoArea
anchors {
left: parent.left
right: parent.right
top: parent.top
margins: app.landscape() ? parent.width * 0.4:parent.width * 0.3
topMargin: parent.height/2 - height * 0.8
}
excludedCodes: [200, 902]
errorCode: status
}
} }

View file

@ -38,7 +38,7 @@ Page {
height: mainMenu.buttonHeight height: mainMenu.buttonHeight
onClicked: { onClicked: {
eventConfirmationDialog.openDay("sheute") eventConfirmationDialog.openDay( _cppAppSettings.loadSetting("teacherMode") === "true" ? "lheute":"sheute")
} }
} }
@ -51,7 +51,7 @@ Page {
height: mainMenu.buttonHeight height: mainMenu.buttonHeight
onClicked: { onClicked: {
eventConfirmationDialog.openDay("smorgen") eventConfirmationDialog.openDay( _cppAppSettings.loadSetting("teacherMode") === "true" ? "lmorgen":"smorgen")
} }
} }

View file

@ -6,6 +6,8 @@ Page {
signal refresh() signal refresh()
property int status: -1
BusyIndicator { BusyIndicator {
anchors.centerIn: parent anchors.centerIn: parent
} }

View file

@ -28,8 +28,85 @@ Page {
formStack.push(filterForm) formStack.push(filterForm)
} }
title: "Klassen" title: "Filter"
description: "Wähle die Klassen(stufen) aus, für die du den Vertretungsplan ansehen möchtest" description: "Wähle die Klassen(stufen) bzw. Lehrerkürzel aus, für die du den Vertretungsplan ansehen möchtest"
}
SwitchDelegate {
width: parent.width
height: 10 + shortDescription.height + 2 + longDescription.height + 10
checked: _cppAppSettings.loadSetting("teacherMode") === "true"
onCheckedChanged: {
_cppAppSettings.writeSetting("teacherMode", checked)
}
Label {
id: shortDescription
anchors {
top: parent.top
left: parent.left
margins: 10
}
font.pixelSize: longDescription.font.pixelSize * 1.4
text: "Lehrermodus"
}
Label {
id: longDescription
anchors {
top: shortDescription.bottom
topMargin: 2
left: parent.left
leftMargin: 10
}
width: parent.width * 0.9
wrapMode: Label.Wrap
text: "Lehrermodus aktivieren"
}
indicator: Rectangle {
property bool checked: parent.checked
property bool down: parent.down
property int set_height: parent.font.pixelSize * 1.4
implicitWidth: set_height * 1.84
implicitHeight: set_height
x: parent.width - width - parent.rightPadding
y: parent.height / 2 - height / 2
radius: implicitHeight * 0.5
color: parent.checked ? "#17a81a" : "transparent"
border.color: parent.checked ? "#17a81a" : "#cccccc"
Behavior on color{
ColorAnimation{
duration: 200
}
}
Rectangle {
x: parent.checked ? parent.width - width : 0
width: parent.height
height: parent.height
radius: height * 0.5
color: parent.down ? "#cccccc" : "#ffffff"
border.color: parent.checked ? (parent.down ? "#17a81a" : "#21be2b") : "#999999"
Behavior on x{
NumberAnimation {
property: "x"
duration: 200
easing.type: Easing.InOutQuad
}
}
}
}
} }
} }
} }

View file

@ -16,5 +16,6 @@
<file>Forms/SettingsForm.qml</file> <file>Forms/SettingsForm.qml</file>
<file>Forms/FilterForm.qml</file> <file>Forms/FilterForm.qml</file>
<file>Components/SettingsDelegate.qml</file> <file>Components/SettingsDelegate.qml</file>
<file>Components/FannyDataListView.qml</file>
</qresource> </qresource>
</RCC> </RCC>

View file

@ -253,7 +253,8 @@ int ServerConn::getEvents(QString day){
QVariant status_code = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute); QVariant status_code = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute);
this->progress = 1; this->progress = 1;
if(status_code != 200){ if(status_code != 200){
// if the request didn't result in a success, return the error code // if the request didn't result in a success, clear the old events, as they are probaply incorrect and return the error code
this->m_events.clear();
return(status_code.toInt()); return(status_code.toInt());
} }