diff --git a/fannyapp.pro b/fannyapp.pro index 37c93f1..ebf0d42 100644 --- a/fannyapp.pro +++ b/fannyapp.pro @@ -1,6 +1,8 @@ QT += qml quick quickcontrols2 xml CONFIG += c++11 +VERSION = 1.0.1 + # The following define makes your compiler emit warnings if you use # any feature of Qt which as been marked deprecated (the exact warnings # depend on your compiler). Please consult the documentation of the diff --git a/headers/serverconn.h b/headers/serverconn.h index 2b5b7c5..1b4e518 100644 --- a/headers/serverconn.h +++ b/headers/serverconn.h @@ -53,12 +53,8 @@ private: QString username; QString password; - QTimer *checkConnTimer; - int authErrorCount; - ReturnData_t senddata(QUrl serviceUrl, QUrlQuery postData); - QList apiVersion = {0,2,1}; private slots: @@ -71,7 +67,6 @@ public: public slots: Q_INVOKABLE int login(QString username, QString password, bool permanent); Q_INVOKABLE int logout(); - Q_INVOKABLE int checkConn(); Q_INVOKABLE int getFoodPlan(); Q_INVOKABLE int getEvents(QString day); diff --git a/qml/Components/AppToolBar.qml b/qml/Components/AppToolBar.qml index 08050b2..4be30a2 100644 --- a/qml/Components/AppToolBar.qml +++ b/qml/Components/AppToolBar.qml @@ -19,7 +19,7 @@ import QtQuick 2.6 import QtQuick.Controls 2.1 import QtGraphicalEffects 1.0 -import QtQuick.Controls.Material 2.3 +import QtQuick.Controls.Material 2.1 Item { id: control diff --git a/qml/Components/EventView.qml b/qml/Components/EventView.qml index 0ed83e7..6d77616 100644 --- a/qml/Components/EventView.qml +++ b/qml/Components/EventView.qml @@ -17,8 +17,8 @@ */ import Backend 1.0 -import QtQuick 2.9 -import QtQuick.Controls 2.4 +import QtQuick 2.1 +import QtQuick.Controls 2.2 FannyDataListView { id: eventList diff --git a/qml/Components/FancyButton.qml b/qml/Components/FancyButton.qml index 1e49121..6f31c7a 100644 --- a/qml/Components/FancyButton.qml +++ b/qml/Components/FancyButton.qml @@ -16,10 +16,10 @@ along with this program. If not, see . */ -import QtQuick 2.9 -import QtQuick.Controls 2.4 +import QtQuick 2.1 +import QtQuick.Controls 2.2 import QtGraphicalEffects 1.0 -import QtQuick.Controls.Material 2.3 +import QtQuick.Controls.Material 2.1 Button { id: control @@ -84,8 +84,6 @@ Button { height: parent.height * 0.5 width: height - mipmap: true - fillMode: Image.PreserveAspectFit scale: control.imageScale diff --git a/qml/Components/FannyDataListView.qml b/qml/Components/FannyDataListView.qml index aa14bbd..6affe30 100644 --- a/qml/Components/FannyDataListView.qml +++ b/qml/Components/FannyDataListView.qml @@ -17,8 +17,8 @@ */ import Backend 1.0 -import QtQuick 2.9 -import QtQuick.Controls 2.4 +import QtQuick 2.1 +import QtQuick.Controls 2.2 ListView { id: control diff --git a/qml/Components/FoodPlanView.qml b/qml/Components/FoodPlanView.qml index 784f06c..d1ab6f0 100644 --- a/qml/Components/FoodPlanView.qml +++ b/qml/Components/FoodPlanView.qml @@ -17,8 +17,8 @@ */ import Backend 1.0 -import QtQuick 2.9 -import QtQuick.Controls 2.4 +import QtQuick 2.1 +import QtQuick.Controls 2.2 FannyDataListView { id: foodList diff --git a/qml/Components/InfoArea.qml b/qml/Components/InfoArea.qml index 6f4e646..6d8be97 100644 --- a/qml/Components/InfoArea.qml +++ b/qml/Components/InfoArea.qml @@ -17,7 +17,7 @@ */ import QtQuick 2.9 -import QtQuick.Controls 2.4 +import QtQuick.Controls 2.2 Item { id: infoArea diff --git a/qml/Components/ProgressCircle.qml b/qml/Components/ProgressCircle.qml deleted file mode 100644 index 66042dd..0000000 --- a/qml/Components/ProgressCircle.qml +++ /dev/null @@ -1,108 +0,0 @@ -/* - Fannyapp - Application to view the cover plan of the Fanny-Leicht-Gymnasium ins Stuttgart Vaihingen, Germany - Copyright (C) 2019 Itsblue Development - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published - by the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . - */ - -import QtQuick 2.0 -import QtQml 2.2 - -Item { - id: root - - width: size - height: size - - property int size: 200 // The size of the circle in pixel - property real arcBegin: 0 // start arc angle in degree - property real arcEnd: 270 // end arc angle in degree - property real arcOffset: 0 // rotation - property bool isPie: false // paint a pie instead of an arc - property bool showBackground: false // a full circle as a background of the arc - property real lineWidth: 20 // width of the line - property string colorCircle: "#CC3333" - property string colorBackground: "#779933" - - property alias beginAnimation: animationArcBegin.enabled - property alias endAnimation: animationArcEnd.enabled - - property int animationDuration: 20 - - onArcBeginChanged: canvas.requestPaint() - onArcEndChanged: canvas.requestPaint() - - Behavior on arcBegin { - id: animationArcBegin - enabled: true - NumberAnimation { - duration: root.animationDuration - easing.type: Easing.InOutCubic - } - } - - Behavior on arcEnd { - id: animationArcEnd - enabled: true - NumberAnimation { - duration: root.animationDuration - easing.type: Easing.InOutCubic - } - } - - Canvas { - id: canvas - anchors.fill: parent - rotation: -90 + parent.arcOffset - - onPaint: { - var ctx = getContext("2d") - var x = width / 2 - var y = height / 2 - var start = Math.PI * (parent.arcBegin / 180) - var end = Math.PI * (parent.arcEnd / 180) - ctx.reset() - - if (root.isPie) { - if (root.showBackground) { - ctx.beginPath() - ctx.fillStyle = root.colorBackground - ctx.moveTo(x, y) - ctx.arc(x, y, width / 2, 0, Math.PI * 2, false) - ctx.lineTo(x, y) - ctx.fill() - } - ctx.beginPath() - ctx.fillStyle = root.colorCircle - ctx.moveTo(x, y) - ctx.arc(x, y, width / 2, start, end, false) - ctx.lineTo(x, y) - ctx.fill() - } else { - if (root.showBackground) { - ctx.beginPath(); - ctx.arc(x, y, (width / 2) - parent.lineWidth / 2, 0, Math.PI * 2, false) - ctx.lineWidth = root.lineWidth - ctx.strokeStyle = root.colorBackground - ctx.stroke() - } - ctx.beginPath(); - ctx.arc(x, y, (width / 2) - parent.lineWidth / 2, start, end, false) - ctx.lineWidth = root.lineWidth - ctx.strokeStyle = root.colorCircle - ctx.stroke() - } - } - } -} diff --git a/qml/Components/SettingsDelegate.qml b/qml/Components/SettingsDelegate.qml index a6dda00..abba267 100644 --- a/qml/Components/SettingsDelegate.qml +++ b/qml/Components/SettingsDelegate.qml @@ -17,7 +17,7 @@ */ import QtQuick 2.0 -import QtQuick.Controls 2.4 +import QtQuick.Controls 2.2 ItemDelegate { id: control diff --git a/qml/Forms/FilterForm.qml b/qml/Forms/FilterForm.qml index 3ca4897..4f6f9c5 100644 --- a/qml/Forms/FilterForm.qml +++ b/qml/Forms/FilterForm.qml @@ -16,10 +16,10 @@ along with this program. If not, see . */ -import QtQuick 2.9 -import QtQuick.Controls 2.4 +import QtQuick 2.1 +import QtQuick.Controls 2.2 import QtQuick.Layouts 1.3 -import QtQuick.Controls.Material 2.3 +import QtQuick.Controls.Material 2.1 import QtGraphicalEffects 1.0 import QtQuick.Controls.impl 2.0 import QtQuick.Templates 2.0 as T @@ -275,7 +275,6 @@ Page { background: Image { source: "/graphics/icons/delete.png" fillMode: Image.PreserveAspectFit - mipmap: true } Behavior on scale { diff --git a/qml/Forms/FoodPlanForm.qml b/qml/Forms/FoodPlanForm.qml index fe03990..58fb7b1 100644 --- a/qml/Forms/FoodPlanForm.qml +++ b/qml/Forms/FoodPlanForm.qml @@ -16,8 +16,8 @@ along with this program. If not, see . */ -import QtQuick 2.9 -import QtQuick.Controls 2.4 +import QtQuick 2.1 +import QtQuick.Controls 2.2 import QtGraphicalEffects 1.0 import "../Components" diff --git a/qml/Forms/HomeForm.qml b/qml/Forms/HomeForm.qml index 5888f96..b142f09 100644 --- a/qml/Forms/HomeForm.qml +++ b/qml/Forms/HomeForm.qml @@ -16,9 +16,9 @@ along with this program. If not, see . */ -import QtQuick 2.9 -import QtQuick.Controls 2.4 -import QtQuick.Controls.Material 2.3 +import QtQuick 2.1 +import QtQuick.Controls 2.2 +import QtQuick.Controls.Material 2.1 import "../Components" @@ -133,31 +133,34 @@ Page { onClicked: { logoutConfirmationDialog.open() } - - Dialog { - id: logoutConfirmationDialog - - x: (app.width - width) / 2 - y: (app.height - height) / 2 - parent: Overlay.overlay - - modal: true - standardButtons: Dialog.Cancel | Dialog.Ok - - Material.theme: app.style.style.nameMaterialStyle === "Dark" ? Material.Dark:Material.Light - - Column { - spacing: 20 - anchors.fill: parent - Label { - text: "Möchtest du dich wirklich abmelden?" - } - } - onAccepted: { - serverConn.logout() - } - } } } } + + Dialog { + id: logoutConfirmationDialog + + x: (parent.width - width) / 2 + y: (parent.height - height) / 2 + + modal: true + focus: true + + standardButtons: Dialog.Cancel | Dialog.Ok + + Material.theme: app.style.style.nameMaterialStyle === "Dark" ? Material.Dark:Material.Light + + Column { + spacing: 20 + anchors.fill: parent + Label { + text: "Möchtest du dich wirklich abmelden?" + } + } + + onAccepted: { + serverConn.logout() + } + } + } diff --git a/qml/Forms/LoadingForm.qml b/qml/Forms/LoadingForm.qml index 6a68eec..9d7939c 100644 --- a/qml/Forms/LoadingForm.qml +++ b/qml/Forms/LoadingForm.qml @@ -16,8 +16,8 @@ along with this program. If not, see . */ -import QtQuick 2.9 -import QtQuick.Controls 2.4 +import QtQuick 2.1 +import QtQuick.Controls 2.2 Page { id: root diff --git a/qml/Forms/SettingsForm.qml b/qml/Forms/SettingsForm.qml index ef7a51a..d91dc30 100644 --- a/qml/Forms/SettingsForm.qml +++ b/qml/Forms/SettingsForm.qml @@ -17,7 +17,7 @@ */ import QtQuick 2.0 -import QtQuick.Controls 2.4 +import QtQuick.Controls 2.2 import "../Components" diff --git a/qml/Pages/LoginPage.qml b/qml/Pages/LoginPage.qml index 9b850bf..9da974d 100644 --- a/qml/Pages/LoginPage.qml +++ b/qml/Pages/LoginPage.qml @@ -16,10 +16,11 @@ along with this program. If not, see . */ -import QtQuick 2.11 +import QtQuick 2.2 import QtQuick.Layouts 1.3 import QtQuick.Controls 2.2 -import QtQuick.Controls.Material 2.3 +import QtQuick.Controls.Material 2.1 + import "../Components" Page { @@ -64,7 +65,6 @@ Page { fillMode: Image.PreserveAspectFit - mipmap: true smooth: true } @@ -206,7 +206,6 @@ Page { } fillMode: Image.PreserveAspectFit smooth: true - mipmap: true source: "qrc:/graphics/icons/view.png" } @@ -223,7 +222,6 @@ Page { } fillMode: Image.PreserveAspectFit smooth: true - mipmap: true source: "qrc:/graphics/icons/hide.png" } } diff --git a/qml/Pages/MainPage.qml b/qml/Pages/MainPage.qml index d717d5e..354e8e1 100644 --- a/qml/Pages/MainPage.qml +++ b/qml/Pages/MainPage.qml @@ -16,8 +16,8 @@ along with this program. If not, see . */ -import QtQuick 2.9 -import QtQuick.Controls 2.4 +import QtQuick 2.2 +import QtQuick.Controls 2.1 import QtGraphicalEffects 1.0 import "../Components" @@ -27,7 +27,7 @@ Page { id: root objectName: "MainPage" - Shortcut { + /*Shortcut { sequences: ["Esc", "Back"] enabled: formStack.depth > 1 onActivated: { @@ -35,7 +35,7 @@ Page { formStack.pop() } } - } + }*/ Rectangle { anchors.fill: parent diff --git a/qml/main.qml b/qml/main.qml index 84c6886..2af5e7e 100644 --- a/qml/main.qml +++ b/qml/main.qml @@ -18,7 +18,7 @@ import QtQuick 2.9 import QtQuick.Controls 2.2 -import QtQuick.Controls.Material 2.3 +import QtQuick.Controls.Material 2.1 import Backend 1.0 diff --git a/qml/qml.qrc b/qml/qml.qrc index 3c756d1..d57283f 100644 --- a/qml/qml.qrc +++ b/qml/qml.qrc @@ -4,7 +4,6 @@ Pages/LoginPage.qml Components/AppToolBar.qml Forms/FoodPlanForm.qml - Components/ProgressCircle.qml Forms/EventForm.qml Pages/MainPage.qml Components/FancyButton.qml diff --git a/sources/appsettings.cpp b/sources/appsettings.cpp index 99e42a5..8cd53a1 100644 --- a/sources/appsettings.cpp +++ b/sources/appsettings.cpp @@ -23,7 +23,7 @@ AppSettings * pGlobalAppSettings = nullptr; AppSettings::AppSettings(QObject* parent) :QObject(parent) { - qDebug() << "+----- AppSettings konstruktor -----+"; + qDebug() << "+----- AppSettings cunstructor -----+"; pGlobalAppSettings = this; diff --git a/sources/serverconn.cpp b/sources/serverconn.cpp index 5812c15..251bdc3 100644 --- a/sources/serverconn.cpp +++ b/sources/serverconn.cpp @@ -23,7 +23,7 @@ ServerConn * pGlobalServConn = nullptr; ServerConn::ServerConn(QObject *parent) : QObject(parent) { - qDebug("+----- ServerConn konstruktor -----+"); + qDebug("+----- ServerConn constructor -----+"); pGlobalServConn = this; // check login state @@ -40,12 +40,6 @@ ServerConn::ServerConn(QObject *parent) : QObject(parent) else { this->setState("notLoggedIn"); } - - this->checkConnTimer = new QTimer(); - this->checkConnTimer->setInterval(1000); - this->checkConnTimer->setSingleShot(true); - connect(checkConnTimer, SIGNAL(timeout()), this, SLOT(checkConn())); - this->checkConnTimer->start(); } int ServerConn::login(QString username, QString password, bool permanent) @@ -57,7 +51,7 @@ int ServerConn::login(QString username, QString password, bool permanent) pdata.addQueryItem("password", password); // send the request - ReturnData_t ret = this->senddata(QUrl("https://www.fanny-leicht.de/j34/templates/g5_helium/intern/events.php"), pdata); + ReturnData_t ret = this->senddata(QUrl("http://www.fanny-leicht.de/j34/templates/g5_helium/intern/events.php"), pdata); if(ret.status_code == 200){ // if not 200 was returned -> user data was correct @@ -110,34 +104,6 @@ int ServerConn::logout() return(200); } -int ServerConn::checkConn() -{ - if(this->state == "notLoggedIn"){ - return(903); - } - - // add the data to the request - QUrlQuery pdata; - pdata.addQueryItem("username", this->username); - pdata.addQueryItem("password", this->password); - - // send the request - ReturnData_t ret = this->senddata(QUrl("https://www.fanny-leicht.de/j34/templates/g5_helium/intern/events.php"), pdata); - - if(ret.status_code == 401){ - // if the stats code is 401 -> userdata is incorrect - authErrorCount ++; - - if(authErrorCount > 3){ - qDebug() << "+----- checkconn: user data is incorrect -----+"; - logout(); - } - } - - this->checkConnTimer->start(); - return(ret.status_code); -} - int ServerConn::getEvents(QString day) { // day: 0-today; 1-tomorrow @@ -158,7 +124,14 @@ int ServerConn::getEvents(QString day) if(ret.status_code != 200){ // 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(ret.status_code); + + if(ret.status_code == 401){ + // if the stats code is 401 -> userdata is incorrect + qDebug() << "+----- checkconn: user data is incorrect -----+"; + logout(); + } + + return ret.status_code; } @@ -270,7 +243,6 @@ int ServerConn::getEvents(QString day) int ServerConn::getFoodPlan() { - // list with all data keys which need to be read from the API QStringList foodplanDataKeys = { "cookteam", "date", "mainDish", "mainDishVeg", "garnish", "dessert" }; QString foodplanDateKey = "date"; @@ -377,8 +349,6 @@ ReturnData_t ServerConn::senddata(QUrl serviceUrl, QUrlQuery pdata) QNetworkReply *reply; - reply = networkManager->post(request, pdata.toString(QUrl::FullyEncoded).toUtf8()); - connect(reply, &QNetworkReply::sslErrors, this, [=](){ reply->ignoreSslErrors(); }); // loop to wait until the request has finished before processing the data QEventLoop loop; // timer to cancel the request after 3 seconds @@ -391,9 +361,16 @@ ReturnData_t ServerConn::senddata(QUrl serviceUrl, QUrlQuery pdata) loop.connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit())); // start the timer timer.start(10000); + + qDebug() << "+--- starting request now..."; + reply = networkManager->post(request, pdata.toString(QUrl::FullyEncoded).toUtf8()); + connect(reply, &QNetworkReply::sslErrors, this, [=](){ reply->ignoreSslErrors(); }); + // start the loop loop.exec(); + qDebug() << "+--- request finished"; + //get the status code QVariant status_code = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute); @@ -403,10 +380,10 @@ ReturnData_t ServerConn::senddata(QUrl serviceUrl, QUrlQuery pdata) ret.text = QString::fromUtf8(reply->readAll()); // delete the reply object - delete reply; + reply->deleteLater(); // delete the newtwork access manager object - delete networkManager; + networkManager->deleteLater(); //return the data return(ret);