From 11cf64da33112c5d379cfa6841e1e76d8e1ace90 Mon Sep 17 00:00:00 2001 From: dorian Date: Mon, 25 Jun 2018 00:15:18 +0200 Subject: [PATCH] update 0.03 --- android-sources/AndroidManifest.xml | 2 +- fannyapp.pro.user | 357 ++++++++++++++++++++++++++-- headers/serverconn.h | 2 +- qml/FoodPlanForm.qml | 1 + qml/HomeForm.qml | 14 +- qml/MainPage.qml | 51 +++- qml/main.qml | 20 +- source/serverconn.cpp | 9 +- 8 files changed, 427 insertions(+), 29 deletions(-) diff --git a/android-sources/AndroidManifest.xml b/android-sources/AndroidManifest.xml index 71ea905..ed686a9 100644 --- a/android-sources/AndroidManifest.xml +++ b/android-sources/AndroidManifest.xml @@ -1,5 +1,5 @@ - + diff --git a/fannyapp.pro.user b/fannyapp.pro.user index 9cb3139..864f934 100644 --- a/fannyapp.pro.user +++ b/fannyapp.pro.user @@ -1,10 +1,10 @@ - + EnvironmentId - {736334c7-59b9-42fb-bb64-0bbe827a8b2c} + {21eb7c7e-fe37-4955-bdba-642d7341ba98} ProjectExplorer.Project.ActiveTarget @@ -59,14 +59,333 @@ ProjectExplorer.Project.Target.0 - Desktop Qt 5.10.1 clang 64bit - Desktop Qt 5.10.1 clang 64bit - qt.qt5.5101.clang_64_kit + Android for armeabi-v7a (GCC 4.9, Qt 5.10.1 for Android armv7) + Android for armeabi-v7a (GCC 4.9, Qt 5.10.1 for Android armv7) + {c2d2fa4a-1656-4ab9-a542-92c96158a688} 1 0 0 - /Users/dorian/Documents/git/build-fannyapp-Desktop_Qt_5_10_1_clang_64bit-Debug + /home/dorian/Documents/Fanny App/build-fannyapp-Android_for_armeabi_v7a_GCC_4_9_Qt_5_10_1_for_Android_armv7-Debug + + + true + qmake + + QtProjectManager.QMakeBuildStep + true + + false + false + false + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + false + + + + + true + Copy application data + + Qt4ProjectManager.AndroidPackageInstallationStep + + + android-27 + + true + Build Android APK + + QmakeProjectManager.AndroidBuildApkStep + false + false + + 4 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + true + clean + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Debug + Debug + Qt4ProjectManager.Qt4BuildConfiguration + 2 + true + + + /home/dorian/Documents/builds/Qt/fanny-app/build-fannyapp-Android_for_armeabi_v7a_GCC_4_9_Qt_5_10_1_for_Android_armv7-Release + + + true + qmake + + QtProjectManager.QMakeBuildStep + false + + false + false + false + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + false + + + + + true + Copy application data + + Qt4ProjectManager.AndroidPackageInstallationStep + + + android-27 + /home/dorian/Documents/gitlab/fanny-app/android_release.keystore + true + Build Android APK + + QmakeProjectManager.AndroidBuildApkStep + false + false + + 4 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + true + clean + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Release + Release + Qt4ProjectManager.Qt4BuildConfiguration + 0 + true + + + /home/dorian/Documents/Fanny App/build-fannyapp-Android_for_armeabi_v7a_GCC_4_9_Qt_5_10_1_for_Android_armv7-Profile + + + true + qmake + + QtProjectManager.QMakeBuildStep + true + + false + true + false + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + false + + + + + true + Copy application data + + Qt4ProjectManager.AndroidPackageInstallationStep + + + android-27 + + true + Build Android APK + + QmakeProjectManager.AndroidBuildApkStep + false + false + + 4 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + -w + -r + + true + clean + + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + Profile + Profile + Qt4ProjectManager.Qt4BuildConfiguration + 0 + true + + 3 + + + + true + Deploy to Android device + + Qt4ProjectManager.AndroidDeployQtStep + false + + 1 + Deploy + + ProjectExplorer.BuildSteps.Deploy + + 1 + Deploy to Android device + + Qt4ProjectManager.AndroidDeployConfiguration2 + + 1 + + MWS0216A15001488 + 24 + + + false + false + 1000 + + true + + false + false + false + false + true + 0.01 + 10 + true + 1 + 25 + + 1 + true + false + true + valgrind + + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 + 11 + 12 + 13 + 14 + + + + + fannyapp + fannyapp + Qt4ProjectManager.AndroidRunConfiguration:/home/dorian/Documents/gitlab/fanny-app/fannyapp.pro + fannyapp.pro + 3768 + false + true + false + false + true + + 1 + + + + ProjectExplorer.Project.Target.1 + + Desktop Qt 5.10.1 GCC 64bit + Desktop Qt 5.10.1 GCC 64bit + qt.qt5.5101.gcc_64_kit + 0 + 0 + 0 + + /home/dorian/Documents/builds/Qt/fanny-app true @@ -93,7 +412,7 @@ 2 - Erstellen + Build ProjectExplorer.BuildSteps.Build @@ -112,7 +431,7 @@ 1 - Bereinigen + Clean ProjectExplorer.BuildSteps.Clean @@ -126,7 +445,7 @@ true - /Users/dorian/Documents/git/build-fannyapp-Desktop_Qt_5_10_1_clang_64bit-Release + /home/dorian/Documents/Fanny App/build-fannyapp-Desktop_Qt_5_10_1_GCC_64bit-Release true @@ -153,7 +472,7 @@ 2 - Erstellen + Build ProjectExplorer.BuildSteps.Build @@ -172,7 +491,7 @@ 1 - Bereinigen + Clean ProjectExplorer.BuildSteps.Clean @@ -186,7 +505,7 @@ true - /Users/dorian/Documents/git/build-fannyapp-Desktop_Qt_5_10_1_clang_64bit-Profile + /home/dorian/Documents/Fanny App/build-fannyapp-Desktop_Qt_5_10_1_GCC_64bit-Profile true @@ -213,7 +532,7 @@ 2 - Erstellen + Build ProjectExplorer.BuildSteps.Build @@ -232,7 +551,7 @@ 1 - Bereinigen + Clean ProjectExplorer.BuildSteps.Clean @@ -249,12 +568,12 @@ 0 - Deployment + Deploy ProjectExplorer.BuildSteps.Deploy 1 - Deployment-Konfiguration + Deploy Configuration ProjectExplorer.DefaultDeployConfiguration @@ -304,13 +623,13 @@ fannyapp fannyapp2 - Qt4ProjectManager.Qt4RunConfiguration:/Users/dorian/Documents/git/fanny-app/fanny-app.git/fannyapp.pro + Qt4ProjectManager.Qt4RunConfiguration:/home/dorian/Documents/gitlab/fanny-app/fannyapp.pro true fannyapp.pro false - /Users/dorian/Documents/git/build-fannyapp-Desktop_Qt_5_10_1_clang_64bit-Release/fannyapp.app/Contents/MacOS + /home/dorian/Documents/builds/Qt/fanny-app/build-fannyapp-Android_for_armeabi_v7a_GCC_4_9_Qt_5_10_1_for_Android_armv7-Release 3768 false true @@ -323,7 +642,7 @@ ProjectExplorer.Project.TargetCount - 1 + 2 ProjectExplorer.Project.Updater.FileVersion diff --git a/headers/serverconn.h b/headers/serverconn.h index 69cdc6d..5a9559e 100644 --- a/headers/serverconn.h +++ b/headers/serverconn.h @@ -35,7 +35,7 @@ public: Q_INVOKABLE QString getDay(QString day); Q_INVOKABLE int checkConn(); Q_INVOKABLE float getProgress(); - Q_INVOKABLE QString getFoodPlan(); + Q_INVOKABLE int getFoodPlan(); Q_INVOKABLE QVariantMap getFoodPlanData(int index); ReturnData_t senddata(QUrl serviceUrl, QUrlQuery postData); diff --git a/qml/FoodPlanForm.qml b/qml/FoodPlanForm.qml index 276fb16..f653e46 100644 --- a/qml/FoodPlanForm.qml +++ b/qml/FoodPlanForm.qml @@ -137,6 +137,7 @@ Page { else { return(Qt.formatDateTime(_cppServerConn.getFoodPlanData(index).date, "dddd, d.M.yy")) } + } function isDayVisible(index){ var date = _cppServerConn.getFoodPlanData(index).date diff --git a/qml/HomeForm.qml b/qml/HomeForm.qml index 30e8177..c43f3c1 100644 --- a/qml/HomeForm.qml +++ b/qml/HomeForm.qml @@ -22,6 +22,7 @@ Page { Button { id:buttToday + enabled: window.is_error === false anchors { left: parent.left leftMargin: (window.width / 4) - (buttToday.width / 2) @@ -40,6 +41,7 @@ Page { Button { id: buttTomorrow + enabled: window.is_error === false anchors { right: parent.right rightMargin: (window.width / 4) - (buttTomorrow.width / 2) @@ -56,6 +58,17 @@ Page { } } + Rectangle { + id: buttonsDisabled + anchors.left: buttToday.left + anchors.right: buttTomorrow.right + anchors.top: buttToday.top + anchors.bottom: buttToday.bottom + color: "white" + opacity: 0.7 + visible: window.is_error + } + Dialog { property string day id: verificationDialog @@ -133,7 +146,6 @@ Page { repeat: true onTriggered: { var ret = _cppServerConn.getProgress() - console.log(ret) progress.text = Math.round( ret * 100 ) + "%" progressBar.value = ret } diff --git a/qml/MainPage.qml b/qml/MainPage.qml index 2449c2c..90c0939 100644 --- a/qml/MainPage.qml +++ b/qml/MainPage.qml @@ -48,9 +48,14 @@ Page { text: qsTr("Speiseplan") width: parent.width onClicked: { - _cppServerConn.getFoodPlan(); - stackView.push("FoodPlanForm.qml") + busyDialog.open() + var ret = _cppServerConn.getFoodPlan(); + console.log(ret, _cppServerConn.getFoodPlanData(1).cookteam, isNaN(_cppServerConn.getFoodPlanData(0).date.toString)) drawer.close() + busyDialog.close() + if(ret === 200 || _cppServerConn.getFoodPlanData(1).cookteam !== ""){ + stackView.push("FoodPlanForm.qml") + } } } @@ -92,4 +97,46 @@ Page { initialItem: "HomeForm.qml" anchors.fill: parent } + + Dialog { + id: busyDialog + modal: true + focus: true + //title: "Please wait..." + x: (window.width - width) / 2 + y: window.height / 6 + //width: Math.min(window.width, window.height) / 3 * 2 + height: contentHeight * 1.5 + width: contentWidth * 1.5 + contentHeight: busyIndicator.height + contentWidth: busyIndicator.width + BusyIndicator { + id: busyIndicator + visible: true + anchors.centerIn: parent + Label { + id: progress + anchors.centerIn: parent + text: _cppServerConn.getProgress() + } + Timer { + id: refreshTimer + interval: 1; + running: busyDialog.visible + repeat: true + onTriggered: { + var ret = _cppServerConn.getProgress() + progress.text = Math.round( ret * 100 ) + "%" + progressBar.value = ret + } + } + } + ProgressBar { + id: progressBar + anchors.top: parent.top + anchors.left: parent.left + anchors.right: parent.right + anchors.topMargin: busyDialog.height / 1.5 + } + } } diff --git a/qml/main.qml b/qml/main.qml index 06d577a..80e6905 100644 --- a/qml/main.qml +++ b/qml/main.qml @@ -9,14 +9,22 @@ ApplicationWindow { property bool is_error property string error + property bool initdone: false Timer { //runs only one time at applictaion lauch id: initTimer interval: 1; running: true - repeat: false + repeat: initdone === false onTriggered: { + var init = _cppAppSettings.loadSetting("init") + if(init !== "1"){ + stackView.push("qrc:/LoginPage.qml") + initdone = true + return + } + var perm = _cppAppSettings.loadSetting("permanent") console.log("checkoldlogin", perm); if(perm === "1"){ @@ -26,6 +34,12 @@ ApplicationWindow { _cppAppSettings.writeSetting("init", 1); window.is_error = false; } + else if(ret === "Keine Verbindung zum Server."){ + handleError(0) + initTimer.interval = 100 + return + } + else { ret = _cppServerConn.checkConn() handleError(ret) @@ -34,13 +48,14 @@ ApplicationWindow { else { stackView.push("qrc:/LoginPage.qml") } + initdone = true } } Timer { id: refreshTimer interval: 1000; - running: true + running: initdone repeat: true onTriggered: { var ret = _cppServerConn.checkConn() @@ -60,6 +75,7 @@ ApplicationWindow { window.error = ""; } else if(error_code === 401){ + console.warn("401") _cppAppSettings.writeSetting("permanent", 0) _cppAppSettings.writeSetting("username", "") _cppAppSettings.writeSetting("password", "") diff --git a/source/serverconn.cpp b/source/serverconn.cpp index 16191d5..7bd6442 100644 --- a/source/serverconn.cpp +++ b/source/serverconn.cpp @@ -50,6 +50,7 @@ QString ServerConn::login(QString username, QString password, bool permanent) this->username = username; this->password = password; if(permanent){ + qDebug() << "permanent"; pGlobalAppSettings->writeSetting("permanent", "1"); pGlobalAppSettings->writeSetting("username", username); pGlobalAppSettings->writeSetting("password", password); @@ -183,7 +184,7 @@ float ServerConn::getProgress() return(this->progress); } -QString ServerConn::getFoodPlan() +int ServerConn::getFoodPlan() { ReturnData_t ret; //this is a custom type to store the returned data // Call the webservice @@ -199,6 +200,8 @@ QString ServerConn::getFoodPlan() QUrlQuery pdata; reply = this->networkManager->post(request, pdata.toString(QUrl::FullyEncoded).toUtf8()); + connect(reply, SIGNAL(downloadProgress(qint64, qint64)), + this, SLOT(updateProgress(qint64, qint64))); //wait until the request has finished QEventLoop loop; loop.connect(this->networkManager, SIGNAL(finished(QNetworkReply*)), SLOT(quit())); @@ -208,7 +211,7 @@ QString ServerConn::getFoodPlan() QVariant status_code = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute); if(status_code != 200){ - return(status_code.toString()); + return(status_code.toInt()); } //initialize the weekplan to store information to it @@ -285,7 +288,7 @@ QString ServerConn::getFoodPlan() this->m_weekplan = temp_weekplan; - return(""); + return(200); } QVariantMap ServerConn::getFoodPlanData(int index)