- some cleanup

- changed requirements to work with Qt 5.9
- removed constant background refresh to drastically reduce data consumption and fix some crashes on IOS
This commit is contained in:
Dorian Zedler 2019-10-24 19:43:33 +02:00
parent b259974af8
commit 96a4aa19e4
21 changed files with 80 additions and 217 deletions

View file

@ -1,6 +1,8 @@
QT += qml quick quickcontrols2 xml QT += qml quick quickcontrols2 xml
CONFIG += c++11 CONFIG += c++11
VERSION = 1.0.1
# The following define makes your compiler emit warnings if you use # The following define makes your compiler emit warnings if you use
# any feature of Qt which as been marked deprecated (the exact warnings # any feature of Qt which as been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the # depend on your compiler). Please consult the documentation of the

View file

@ -53,12 +53,8 @@ private:
QString username; QString username;
QString password; QString password;
QTimer *checkConnTimer;
int authErrorCount;
ReturnData_t senddata(QUrl serviceUrl, QUrlQuery postData); ReturnData_t senddata(QUrl serviceUrl, QUrlQuery postData);
QList<int> apiVersion = {0,2,1}; QList<int> apiVersion = {0,2,1};
private slots: private slots:
@ -71,7 +67,6 @@ public:
public slots: public slots:
Q_INVOKABLE int login(QString username, QString password, bool permanent); Q_INVOKABLE int login(QString username, QString password, bool permanent);
Q_INVOKABLE int logout(); Q_INVOKABLE int logout();
Q_INVOKABLE int checkConn();
Q_INVOKABLE int getFoodPlan(); Q_INVOKABLE int getFoodPlan();
Q_INVOKABLE int getEvents(QString day); Q_INVOKABLE int getEvents(QString day);

View file

@ -19,7 +19,7 @@
import QtQuick 2.6 import QtQuick 2.6
import QtQuick.Controls 2.1 import QtQuick.Controls 2.1
import QtGraphicalEffects 1.0 import QtGraphicalEffects 1.0
import QtQuick.Controls.Material 2.3 import QtQuick.Controls.Material 2.1
Item { Item {
id: control id: control

View file

@ -17,8 +17,8 @@
*/ */
import Backend 1.0 import Backend 1.0
import QtQuick 2.9 import QtQuick 2.1
import QtQuick.Controls 2.4 import QtQuick.Controls 2.2
FannyDataListView { FannyDataListView {
id: eventList id: eventList

View file

@ -16,10 +16,10 @@
along with this program. If not, see <https://www.gnu.org/licenses/>. along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import QtQuick 2.9 import QtQuick 2.1
import QtQuick.Controls 2.4 import QtQuick.Controls 2.2
import QtGraphicalEffects 1.0 import QtGraphicalEffects 1.0
import QtQuick.Controls.Material 2.3 import QtQuick.Controls.Material 2.1
Button { Button {
id: control id: control
@ -84,8 +84,6 @@ Button {
height: parent.height * 0.5 height: parent.height * 0.5
width: height width: height
mipmap: true
fillMode: Image.PreserveAspectFit fillMode: Image.PreserveAspectFit
scale: control.imageScale scale: control.imageScale

View file

@ -17,8 +17,8 @@
*/ */
import Backend 1.0 import Backend 1.0
import QtQuick 2.9 import QtQuick 2.1
import QtQuick.Controls 2.4 import QtQuick.Controls 2.2
ListView { ListView {
id: control id: control

View file

@ -17,8 +17,8 @@
*/ */
import Backend 1.0 import Backend 1.0
import QtQuick 2.9 import QtQuick 2.1
import QtQuick.Controls 2.4 import QtQuick.Controls 2.2
FannyDataListView { FannyDataListView {
id: foodList id: foodList

View file

@ -17,7 +17,7 @@
*/ */
import QtQuick 2.9 import QtQuick 2.9
import QtQuick.Controls 2.4 import QtQuick.Controls 2.2
Item { Item {
id: infoArea id: infoArea

View file

@ -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 <development@itsblue.de>
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 <https://www.gnu.org/licenses/>.
*/
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()
}
}
}
}

View file

@ -17,7 +17,7 @@
*/ */
import QtQuick 2.0 import QtQuick 2.0
import QtQuick.Controls 2.4 import QtQuick.Controls 2.2
ItemDelegate { ItemDelegate {
id: control id: control

View file

@ -16,10 +16,10 @@
along with this program. If not, see <https://www.gnu.org/licenses/>. along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import QtQuick 2.9 import QtQuick 2.1
import QtQuick.Controls 2.4 import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3 import QtQuick.Layouts 1.3
import QtQuick.Controls.Material 2.3 import QtQuick.Controls.Material 2.1
import QtGraphicalEffects 1.0 import QtGraphicalEffects 1.0
import QtQuick.Controls.impl 2.0 import QtQuick.Controls.impl 2.0
import QtQuick.Templates 2.0 as T import QtQuick.Templates 2.0 as T
@ -275,7 +275,6 @@ Page {
background: Image { background: Image {
source: "/graphics/icons/delete.png" source: "/graphics/icons/delete.png"
fillMode: Image.PreserveAspectFit fillMode: Image.PreserveAspectFit
mipmap: true
} }
Behavior on scale { Behavior on scale {

View file

@ -16,8 +16,8 @@
along with this program. If not, see <https://www.gnu.org/licenses/>. along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import QtQuick 2.9 import QtQuick 2.1
import QtQuick.Controls 2.4 import QtQuick.Controls 2.2
import QtGraphicalEffects 1.0 import QtGraphicalEffects 1.0
import "../Components" import "../Components"

View file

@ -16,9 +16,9 @@
along with this program. If not, see <https://www.gnu.org/licenses/>. along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import QtQuick 2.9 import QtQuick 2.1
import QtQuick.Controls 2.4 import QtQuick.Controls 2.2
import QtQuick.Controls.Material 2.3 import QtQuick.Controls.Material 2.1
import "../Components" import "../Components"
@ -133,15 +133,19 @@ Page {
onClicked: { onClicked: {
logoutConfirmationDialog.open() logoutConfirmationDialog.open()
} }
}
}
}
Dialog { Dialog {
id: logoutConfirmationDialog id: logoutConfirmationDialog
x: (app.width - width) / 2 x: (parent.width - width) / 2
y: (app.height - height) / 2 y: (parent.height - height) / 2
parent: Overlay.overlay
modal: true modal: true
focus: true
standardButtons: Dialog.Cancel | Dialog.Ok standardButtons: Dialog.Cancel | Dialog.Ok
Material.theme: app.style.style.nameMaterialStyle === "Dark" ? Material.Dark:Material.Light Material.theme: app.style.style.nameMaterialStyle === "Dark" ? Material.Dark:Material.Light
@ -153,11 +157,10 @@ Page {
text: "Möchtest du dich wirklich abmelden?" text: "Möchtest du dich wirklich abmelden?"
} }
} }
onAccepted: { onAccepted: {
serverConn.logout() serverConn.logout()
} }
} }
}
}
}
} }

View file

@ -16,8 +16,8 @@
along with this program. If not, see <https://www.gnu.org/licenses/>. along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import QtQuick 2.9 import QtQuick 2.1
import QtQuick.Controls 2.4 import QtQuick.Controls 2.2
Page { Page {
id: root id: root

View file

@ -17,7 +17,7 @@
*/ */
import QtQuick 2.0 import QtQuick 2.0
import QtQuick.Controls 2.4 import QtQuick.Controls 2.2
import "../Components" import "../Components"

View file

@ -16,10 +16,11 @@
along with this program. If not, see <https://www.gnu.org/licenses/>. along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import QtQuick 2.11 import QtQuick 2.2
import QtQuick.Layouts 1.3 import QtQuick.Layouts 1.3
import QtQuick.Controls 2.2 import QtQuick.Controls 2.2
import QtQuick.Controls.Material 2.3 import QtQuick.Controls.Material 2.1
import "../Components" import "../Components"
Page { Page {
@ -64,7 +65,6 @@ Page {
fillMode: Image.PreserveAspectFit fillMode: Image.PreserveAspectFit
mipmap: true
smooth: true smooth: true
} }
@ -206,7 +206,6 @@ Page {
} }
fillMode: Image.PreserveAspectFit fillMode: Image.PreserveAspectFit
smooth: true smooth: true
mipmap: true
source: "qrc:/graphics/icons/view.png" source: "qrc:/graphics/icons/view.png"
} }
@ -223,7 +222,6 @@ Page {
} }
fillMode: Image.PreserveAspectFit fillMode: Image.PreserveAspectFit
smooth: true smooth: true
mipmap: true
source: "qrc:/graphics/icons/hide.png" source: "qrc:/graphics/icons/hide.png"
} }
} }

View file

@ -16,8 +16,8 @@
along with this program. If not, see <https://www.gnu.org/licenses/>. along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import QtQuick 2.9 import QtQuick 2.2
import QtQuick.Controls 2.4 import QtQuick.Controls 2.1
import QtGraphicalEffects 1.0 import QtGraphicalEffects 1.0
import "../Components" import "../Components"
@ -27,7 +27,7 @@ Page {
id: root id: root
objectName: "MainPage" objectName: "MainPage"
Shortcut { /*Shortcut {
sequences: ["Esc", "Back"] sequences: ["Esc", "Back"]
enabled: formStack.depth > 1 enabled: formStack.depth > 1
onActivated: { onActivated: {
@ -35,7 +35,7 @@ Page {
formStack.pop() formStack.pop()
} }
} }
} }*/
Rectangle { Rectangle {
anchors.fill: parent anchors.fill: parent

View file

@ -18,7 +18,7 @@
import QtQuick 2.9 import QtQuick 2.9
import QtQuick.Controls 2.2 import QtQuick.Controls 2.2
import QtQuick.Controls.Material 2.3 import QtQuick.Controls.Material 2.1
import Backend 1.0 import Backend 1.0

View file

@ -4,7 +4,6 @@
<file>Pages/LoginPage.qml</file> <file>Pages/LoginPage.qml</file>
<file>Components/AppToolBar.qml</file> <file>Components/AppToolBar.qml</file>
<file>Forms/FoodPlanForm.qml</file> <file>Forms/FoodPlanForm.qml</file>
<file>Components/ProgressCircle.qml</file>
<file>Forms/EventForm.qml</file> <file>Forms/EventForm.qml</file>
<file>Pages/MainPage.qml</file> <file>Pages/MainPage.qml</file>
<file>Components/FancyButton.qml</file> <file>Components/FancyButton.qml</file>

View file

@ -23,7 +23,7 @@ AppSettings * pGlobalAppSettings = nullptr;
AppSettings::AppSettings(QObject* parent) AppSettings::AppSettings(QObject* parent)
:QObject(parent) :QObject(parent)
{ {
qDebug() << "+----- AppSettings konstruktor -----+"; qDebug() << "+----- AppSettings cunstructor -----+";
pGlobalAppSettings = this; pGlobalAppSettings = this;

View file

@ -23,7 +23,7 @@ ServerConn * pGlobalServConn = nullptr;
ServerConn::ServerConn(QObject *parent) : QObject(parent) ServerConn::ServerConn(QObject *parent) : QObject(parent)
{ {
qDebug("+----- ServerConn konstruktor -----+"); qDebug("+----- ServerConn constructor -----+");
pGlobalServConn = this; pGlobalServConn = this;
// check login state // check login state
@ -40,12 +40,6 @@ ServerConn::ServerConn(QObject *parent) : QObject(parent)
else { else {
this->setState("notLoggedIn"); 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) 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); pdata.addQueryItem("password", password);
// send the request // 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(ret.status_code == 200){
// if not 200 was returned -> user data was correct // if not 200 was returned -> user data was correct
@ -110,34 +104,6 @@ int ServerConn::logout()
return(200); 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) int ServerConn::getEvents(QString day)
{ {
// day: 0-today; 1-tomorrow // day: 0-today; 1-tomorrow
@ -158,7 +124,14 @@ int ServerConn::getEvents(QString day)
if(ret.status_code != 200){ 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 // 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(); 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() int ServerConn::getFoodPlan()
{ {
// list with all data keys which need to be read from the API // list with all data keys which need to be read from the API
QStringList foodplanDataKeys = { "cookteam", "date", "mainDish", "mainDishVeg", "garnish", "dessert" }; QStringList foodplanDataKeys = { "cookteam", "date", "mainDish", "mainDishVeg", "garnish", "dessert" };
QString foodplanDateKey = "date"; QString foodplanDateKey = "date";
@ -377,8 +349,6 @@ ReturnData_t ServerConn::senddata(QUrl serviceUrl, QUrlQuery pdata)
QNetworkReply *reply; 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 // loop to wait until the request has finished before processing the data
QEventLoop loop; QEventLoop loop;
// timer to cancel the request after 3 seconds // 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())); loop.connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit()));
// start the timer // start the timer
timer.start(10000); 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 // start the loop
loop.exec(); loop.exec();
qDebug() << "+--- request finished";
//get the status code //get the status code
QVariant status_code = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute); 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()); ret.text = QString::fromUtf8(reply->readAll());
// delete the reply object // delete the reply object
delete reply; reply->deleteLater();
// delete the newtwork access manager object // delete the newtwork access manager object
delete networkManager; networkManager->deleteLater();
//return the data //return the data
return(ret); return(ret);