diff --git a/qml/Components/EventView.qml b/qml/Components/EventView.qml index 21a4101..85cfb17 100644 --- a/qml/Components/EventView.qml +++ b/qml/Components/EventView.qml @@ -5,6 +5,8 @@ import QtQuick.Controls 2.4 ListView { id: eventList + signal refresh() + anchors.fill: parent anchors.margins: 10 @@ -12,6 +14,12 @@ ListView { id: foodPlanModel } + onContentYChanged: { + if(contentY < -150){ + eventList.refresh() + } + } + delegate: Button { id: delegate diff --git a/qml/Forms/EventForm.qml b/qml/Forms/EventForm.qml index a04a43a..d1d44bc 100644 --- a/qml/Forms/EventForm.qml +++ b/qml/Forms/EventForm.qml @@ -17,49 +17,82 @@ Page { onOpened: { } -// Image{ -// source: "qrc:/graphics/chat_background.jpg"; -// height: parent.height -// width: parent.width -// fillMode: Image.Tile -// horizontalAlignment: Image.AlignLeft -// verticalAlignment: Image.AlignTop -// } -// LinearGradient { -// anchors.fill: parent -// start: Qt.point(0, 0) -// end: Qt.point(0, parent.height) -// gradient: Gradient { -// GradientStop { position: 0.0; color: "#4db2b3" } -// GradientStop { position: 1.0; color: "#8f4dae" } -// } -// } + // Image{ + // source: "qrc:/graphics/chat_background.jpg"; + // height: parent.height + // width: parent.width + // fillMode: Image.Tile + // horizontalAlignment: Image.AlignLeft + // verticalAlignment: Image.AlignTop + // } + // LinearGradient { + // anchors.fill: parent + // start: Qt.point(0, 0) + // end: Qt.point(0, parent.height) + // gradient: Gradient { + // GradientStop { position: 0.0; color: "#4db2b3" } + // GradientStop { position: 1.0; color: "#8f4dae" } + // } + // } Loader { id: pageLoader + + property string newSource: "" + + onNewSourceChanged: { + oldItemAnimation.start() + } + anchors.fill: parent source: "./LoadingForm.qml" - onSourceChanged: animation.start() + onSourceChanged: newItemAnimation.start() NumberAnimation { - id: animation - target: pageLoader.item + id: newItemAnimation + target: pageLoader property: "opacity" from: 0 to: 100 duration: 500 easing.type: Easing.InExpo } + + NumberAnimation { + id: oldItemAnimation + target: pageLoader + property: "opacity" + from: 100 + to: 0 + duration: 500 + easing.type: Easing.InExpo + + onRunningChanged: { + if(!running){ + pageLoader.source = pageLoader.newSource + } + } + } + + Connections { + target: pageLoader.item + onRefresh: { + pageLoader.newSource = "./LoadingForm.qml" + loadTimer.start() + } + } + } Timer { + id: loadTimer interval: 500 running: true repeat: false onTriggered: { status = serverConn.getEvents(day) - pageLoader.source = "../Components/EventView.qml" + pageLoader.newSource = "../Components/EventView.qml" } } diff --git a/qml/Forms/LoadingForm.qml b/qml/Forms/LoadingForm.qml index cca531d..144bed7 100644 --- a/qml/Forms/LoadingForm.qml +++ b/qml/Forms/LoadingForm.qml @@ -4,6 +4,8 @@ import QtQuick.Controls 2.4 Page { id: root + signal refresh() + BusyIndicator { anchors.centerIn: parent } diff --git a/sources/serverconn.cpp b/sources/serverconn.cpp index d6e6165..03d8367 100644 --- a/sources/serverconn.cpp +++ b/sources/serverconn.cpp @@ -415,6 +415,7 @@ int ServerConn::getEvents(QString day){ if(blocksOK != 3) { // if there are more or less than 3 filled blocks, the data is invalid + this->m_events.clear(); return(900); }