diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b8687a..d1029ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,17 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## unreleased +### Hinzugefügt +- Dunkler Modus +- ssl (https) Verschlüsselung + +### Behoben +- Fehler, der dafür sorgte, dass fälschlicherweise 'keine Verbindung zum server' angezeigt wurde + +### Geändert +- timeout auf 10 sekunden erhöht + ## [1.0.1] ### Behoben - Fehler, der dafür sorgte, dass die 'morgen' Taste immer den heutigen Vertretungsplan anzeigte diff --git a/headers/appstyle.h b/headers/appstyle.h index 9136f75..4f9919e 100644 --- a/headers/appstyle.h +++ b/headers/appstyle.h @@ -26,6 +26,7 @@ signals: public slots: QVariant getStyle(); Q_INVOKABLE void changeTheme(); + Q_INVOKABLE void refreshTheme(); }; #endif // APPSTYLE_H diff --git a/headers/serverconn.h b/headers/serverconn.h index cf12edd..2b5b7c5 100644 --- a/headers/serverconn.h +++ b/headers/serverconn.h @@ -52,9 +52,7 @@ private: // can be: loggedIn ; notLoggedIn QString username; QString password; - QNetworkAccessManager *networkManager; - QNetworkAccessManager *refreshNetworkManager; - QNetworkReply *networkReply; + QTimer *checkConnTimer; int authErrorCount; diff --git a/qml/Forms/SettingsForm.qml b/qml/Forms/SettingsForm.qml index 17f9224..fc9de02 100644 --- a/qml/Forms/SettingsForm.qml +++ b/qml/Forms/SettingsForm.qml @@ -128,13 +128,85 @@ Page { } } - SettingsDelegate { - showForwardIcon: false - title: "Design ändern" - description: "Ändere das Design der App" + SwitchDelegate { width: parent.width - onClicked: { - app.style.changeTheme() + height: 10 + shortDescription_.height + 2 + longDescription_.height + 10 + + checked: _cppAppSettings.loadSetting("theme") === "Dark" + + onCheckedChanged: { + _cppAppSettings.writeSetting("theme", checked ? "Dark":"Light") + app.style.refreshTheme() + } + + Label { + id: shortDescription_ + + anchors { + top: parent.top + left: parent.left + margins: 10 + } + + font.pixelSize: longDescription_.font.pixelSize * 1.4 + + text: "Dunkler Modus" + + color: app.style.style.textColor + + } + + Label { + id: longDescription_ + + anchors { + top: shortDescription_.bottom + topMargin: 2 + left: parent.left + leftMargin: 10 + } + + width: parent.width * 0.9 + + wrapMode: Label.Wrap + + text: "Dunklen Modus aktivieren" + + color: app.style.style.textColor + } + + 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 + } + } + } } } diff --git a/sources/appstyle.cpp b/sources/appstyle.cpp index 013a5f6..e357404 100644 --- a/sources/appstyle.cpp +++ b/sources/appstyle.cpp @@ -108,3 +108,16 @@ void AppStyle::changeTheme() { emit this->styleChanged(); } + +void AppStyle::refreshTheme() { + QString currentThemeString = pGlobalAppSettings->loadSetting("theme"); + + if(currentThemeString == "Light"){ + this->currentTheme = &this->lightTheme; + } + else if (currentThemeString == "Dark") { + this->currentTheme = &this->darkTheme; + } + + emit this->styleChanged(); +} diff --git a/sources/serverconn.cpp b/sources/serverconn.cpp index 0b67754..2dbbfec 100644 --- a/sources/serverconn.cpp +++ b/sources/serverconn.cpp @@ -25,8 +25,6 @@ ServerConn::ServerConn(QObject *parent) : QObject(parent) { qDebug("+----- ServerConn konstruktor -----+"); pGlobalServConn = this; - this->networkManager = new QNetworkAccessManager(); - this->refreshNetworkManager = new QNetworkAccessManager(); // check login state int perm = pGlobalAppSettings->loadSetting("permanent").toInt(); @@ -195,7 +193,7 @@ int ServerConn::getEvents(QString day) int versionMajor = version.split(".")[0].toInt(); int versionMinor = version.split(".")[1].toInt(); - int versionRevision = version.split(".")[2].toInt(); + //int versionRevision = version.split(".")[2].toInt(); if(versionMajor > this->apiVersion[0] || versionMinor > this->apiVersion[1]){ return(904); @@ -362,6 +360,8 @@ int ServerConn::getFoodPlan() ReturnData_t ServerConn::senddata(QUrl serviceUrl, QUrlQuery pdata) { + QNetworkAccessManager * networkManager = new QNetworkAccessManager(); + ReturnData_t ret; //this is a custom type to store the return-data // Create network request @@ -377,7 +377,7 @@ ReturnData_t ServerConn::senddata(QUrl serviceUrl, QUrlQuery pdata) QNetworkReply *reply; - reply = this->networkManager->post(request, pdata.toString(QUrl::FullyEncoded).toUtf8()); + 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; @@ -386,11 +386,11 @@ ReturnData_t ServerConn::senddata(QUrl serviceUrl, QUrlQuery pdata) timer.setSingleShot(true); // quit the loop when the request finised - loop.connect(this->networkManager, SIGNAL(finished(QNetworkReply*)), SLOT(quit())); + loop.connect(networkManager, SIGNAL(finished(QNetworkReply*)), SLOT(quit())); // or the timer timed out loop.connect(&timer, SIGNAL(timeout()), &loop, SLOT(quit())); // start the timer - timer.start(6000); + timer.start(10000); // start the loop loop.exec(); @@ -405,6 +405,9 @@ ReturnData_t ServerConn::senddata(QUrl serviceUrl, QUrlQuery pdata) // delete the reply object delete reply; + // delete the newtwork access manager object + delete networkManager; + //return the data return(ret); } @@ -425,6 +428,4 @@ void ServerConn::setState(QString state) { ServerConn::~ServerConn() { qDebug("+----- ServerConn destruktor -----+"); - delete this->networkManager; - delete this->refreshNetworkManager; }