Merge remote-tracking branch 'origin/master'

This commit is contained in:
dorian 2019-10-26 13:37:07 +02:00
commit 69a7e08bdf
21 changed files with 80 additions and 217 deletions

View file

@ -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

View file

@ -53,12 +53,8 @@ private:
QString username;
QString password;
QTimer *checkConnTimer;
int authErrorCount;
ReturnData_t senddata(QUrl serviceUrl, QUrlQuery postData);
QList<int> 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);

View file

@ -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

View file

@ -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

View file

@ -16,10 +16,10 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
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

View file

@ -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

View file

@ -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

View file

@ -17,7 +17,7 @@
*/
import QtQuick 2.9
import QtQuick.Controls 2.4
import QtQuick.Controls 2.2
Item {
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.Controls 2.4
import QtQuick.Controls 2.2
ItemDelegate {
id: control

View file

@ -16,10 +16,10 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
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 {

View file

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

View file

@ -16,9 +16,9 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
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()
}
}
}

View file

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

View file

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

View file

@ -16,10 +16,11 @@
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.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"
}
}

View file

@ -16,8 +16,8 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
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

View file

@ -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

View file

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

View file

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

View file

@ -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);