- cleaned up the views
- added teacher mode
This commit is contained in:
parent
e2e83ba5ea
commit
2ff52410d2
11 changed files with 222 additions and 98 deletions
|
@ -2,23 +2,15 @@ import Backend 1.0
|
|||
import QtQuick 2.9
|
||||
import QtQuick.Controls 2.4
|
||||
|
||||
ListView {
|
||||
FannyDataListView {
|
||||
id: eventList
|
||||
|
||||
signal refresh()
|
||||
|
||||
anchors.fill: parent
|
||||
anchors.margins: 10
|
||||
|
||||
model: EventModel {
|
||||
id: foodPlanModel
|
||||
}
|
||||
|
||||
onContentYChanged: {
|
||||
if(contentY < -125){
|
||||
eventList.refresh()
|
||||
}
|
||||
}
|
||||
|
||||
delegate: Button {
|
||||
id: delegate
|
||||
|
|
52
qml/Components/FannyDataListView.qml
Normal file
52
qml/Components/FannyDataListView.qml
Normal 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
|
||||
}
|
||||
}
|
|
@ -2,19 +2,10 @@ import Backend 1.0
|
|||
import QtQuick 2.9
|
||||
import QtQuick.Controls 2.4
|
||||
|
||||
ListView {
|
||||
FannyDataListView {
|
||||
id: foodList
|
||||
|
||||
signal refresh()
|
||||
|
||||
anchors.fill: parent
|
||||
anchors.margins: 10
|
||||
|
||||
onContentYChanged: {
|
||||
if(contentY < -125){
|
||||
foodList.refresh()
|
||||
}
|
||||
}
|
||||
|
||||
model: FoodPlanModel {
|
||||
id: foodPlanModel
|
||||
|
|
|
@ -47,7 +47,10 @@ Page {
|
|||
anchors.fill: parent
|
||||
source: "./LoadingForm.qml"
|
||||
|
||||
onSourceChanged: newItemAnimation.start()
|
||||
onSourceChanged: {
|
||||
pageLoader.item.status = root.status
|
||||
newItemAnimation.start()
|
||||
}
|
||||
|
||||
NumberAnimation {
|
||||
id: newItemAnimation
|
||||
|
@ -90,22 +93,8 @@ Page {
|
|||
running: true
|
||||
repeat: false
|
||||
onTriggered: {
|
||||
status = serverConn.getEvents(day)
|
||||
root.status = serverConn.getEvents(day)
|
||||
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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,20 +19,29 @@ Page {
|
|||
Dialog {
|
||||
id: filterDialog
|
||||
|
||||
signal finished(string grade, string classletter)
|
||||
signal finished(string grade, string classletter, string teacherShortcut)
|
||||
|
||||
property bool teacherMode: _cppAppSettings.loadSetting("teacherMode") === "true"
|
||||
|
||||
onFinished: {
|
||||
if(_cppAppSettings.loadSetting("teacherMode") === "true"){
|
||||
contactView.model.append(teacherShortcut, "")
|
||||
}
|
||||
else {
|
||||
if(parseInt(grade) > 10 || classletter === "alle"){
|
||||
classletter = ""
|
||||
}
|
||||
|
||||
contactView.model.append(grade, classletter)
|
||||
}
|
||||
}
|
||||
|
||||
function createContact() {
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -48,6 +57,7 @@ Page {
|
|||
id: form
|
||||
property alias grade: gradeSb
|
||||
property alias classLetter: classLetterCb
|
||||
property alias teacherShortcut: shortcutTf
|
||||
property int minimumInputSize: 120
|
||||
|
||||
rows: 4
|
||||
|
@ -56,6 +66,7 @@ Page {
|
|||
Label {
|
||||
text: qsTr("Stufe")
|
||||
Layout.alignment: Qt.AlignLeft | Qt.AlignBaseline
|
||||
visible: !filterDialog.teacherMode
|
||||
}
|
||||
|
||||
SpinBox {
|
||||
|
@ -68,11 +79,13 @@ Page {
|
|||
to: 12
|
||||
stepSize: 1
|
||||
value: 5
|
||||
visible: !filterDialog.teacherMode
|
||||
}
|
||||
|
||||
Label {
|
||||
text: qsTr("Klasse")
|
||||
Layout.alignment: Qt.AlignLeft | Qt.AlignBaseline
|
||||
visible: !filterDialog.teacherMode
|
||||
}
|
||||
|
||||
ComboBox {
|
||||
|
@ -82,10 +95,28 @@ Page {
|
|||
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
|
||||
}
|
||||
}
|
||||
|
||||
onAccepted: finished(form.grade.value.toString(), form.classLetter.currentText)
|
||||
onAccepted: finished(form.grade.value, form.classLetter.currentText, form.teacherShortcut.text)
|
||||
}
|
||||
|
||||
ListView {
|
||||
|
|
|
@ -48,7 +48,10 @@ Page {
|
|||
anchors.fill: parent
|
||||
source: "./LoadingForm.qml"
|
||||
|
||||
onSourceChanged: newItemAnimation.start()
|
||||
onSourceChanged: {
|
||||
pageLoader.item.status = root.status
|
||||
newItemAnimation.start()
|
||||
}
|
||||
|
||||
NumberAnimation {
|
||||
id: newItemAnimation
|
||||
|
@ -95,19 +98,4 @@ Page {
|
|||
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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ Page {
|
|||
height: mainMenu.buttonHeight
|
||||
|
||||
onClicked: {
|
||||
eventConfirmationDialog.openDay("sheute")
|
||||
eventConfirmationDialog.openDay( _cppAppSettings.loadSetting("teacherMode") === "true" ? "lheute":"sheute")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ Page {
|
|||
height: mainMenu.buttonHeight
|
||||
|
||||
onClicked: {
|
||||
eventConfirmationDialog.openDay("smorgen")
|
||||
eventConfirmationDialog.openDay( _cppAppSettings.loadSetting("teacherMode") === "true" ? "lmorgen":"smorgen")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,8 @@ Page {
|
|||
|
||||
signal refresh()
|
||||
|
||||
property int status: -1
|
||||
|
||||
BusyIndicator {
|
||||
anchors.centerIn: parent
|
||||
}
|
||||
|
|
|
@ -28,8 +28,85 @@ Page {
|
|||
formStack.push(filterForm)
|
||||
}
|
||||
|
||||
title: "Klassen"
|
||||
description: "Wähle die Klassen(stufen) aus, für die du den Vertretungsplan ansehen möchtest"
|
||||
title: "Filter"
|
||||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,5 +16,6 @@
|
|||
<file>Forms/SettingsForm.qml</file>
|
||||
<file>Forms/FilterForm.qml</file>
|
||||
<file>Components/SettingsDelegate.qml</file>
|
||||
<file>Components/FannyDataListView.qml</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
|
@ -253,7 +253,8 @@ int ServerConn::getEvents(QString day){
|
|||
QVariant status_code = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute);
|
||||
this->progress = 1;
|
||||
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());
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue