From 609f78f6108256d1f1c051f9934ec2b6b43c0dc7 Mon Sep 17 00:00:00 2001 From: dorian Date: Sat, 30 Jun 2018 20:59:42 +0200 Subject: [PATCH] See 0.03.2 for Details --- android-sources/AndroidManifest.xml | 2 +- fannyapp.pro.user | 42 +++++++------- headers/serverconn.h | 2 +- qml/FoodPlanForm.qml | 10 ++-- qml/HomeForm.qml | 63 ++++++++++---------- qml/MainPage.qml | 59 ++++++++++--------- qml/ProgressCircle.qml | 90 +++++++++++++++++++++++++++++ qml/WebsitePage.qml | 24 +++++--- qml/qml.qrc | 1 + source/serverconn.cpp | 12 ++-- 10 files changed, 202 insertions(+), 103 deletions(-) create mode 100644 qml/ProgressCircle.qml diff --git a/android-sources/AndroidManifest.xml b/android-sources/AndroidManifest.xml index ca7e7a8..6c6a516 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 ab97835..69c9aec 100644 --- a/fannyapp.pro.user +++ b/fannyapp.pro.user @@ -1,6 +1,6 @@ - + EnvironmentId @@ -8,7 +8,7 @@ ProjectExplorer.Project.ActiveTarget - 1 + 0 ProjectExplorer.Project.EditorSettings @@ -59,14 +59,14 @@ ProjectExplorer.Project.Target.0 - Android for armeabi-v7a (GCC 4.9, Qt 5.11.1 for Android armv7) - Android for armeabi-v7a (GCC 4.9, Qt 5.11.1 for Android armv7) - {90080436-d11a-44c6-8604-3a0027d99b29} - 0 + Android for armeabi-v7a (GCC 4.9, Qt 5.10.1 for Android armv72) + Android for armeabi-v7a (GCC 4.9, Qt 5.10.1 for Android armv72) + {0560b570-8c4b-4d85-a4a2-e3653c24ac2c} + 1 0 0 - /home/dorian/Documents/gitlab/build-fannyapp-Android_for_armeabi_v7a_GCC_4_9_Qt_5_11_1_for_Android_armv7-Debug + /home/dorian/Documents/gitlab/build-fannyapp-Android_for_armeabi_v7a_GCC_4_9_Qt_5_10_1_for_Android_armv72-Debug true @@ -100,7 +100,7 @@ android-27 - + /home/dorian/Documents/gitlab/fanny-app/android_release.keystore true Build Android APK @@ -142,7 +142,7 @@ true - /home/dorian/Documents/gitlab/build-fannyapp-Android_for_armeabi_v7a_GCC_4_9_Qt_5_11_1_for_Android_armv7-Release + /home/dorian/Documents/builds/Qt/fanny-app/build-fannyapp-Android_for_armeabi_v7a_GCC_4_9_Qt_5_10_1_for_Android_armv72-Release true @@ -153,7 +153,7 @@ false false - true + false true @@ -218,7 +218,7 @@ true - /home/dorian/Documents/gitlab/build-fannyapp-Android_for_armeabi_v7a_GCC_4_9_Qt_5_11_1_for_Android_armv7-Profile + /home/dorian/Documents/gitlab/build-fannyapp-Android_for_armeabi_v7a_GCC_4_9_Qt_5_10_1_for_Android_armv72-Profile true @@ -229,7 +229,7 @@ false true - true + false true @@ -378,14 +378,14 @@ ProjectExplorer.Project.Target.1 - Desktop Qt 5.11.1 GCC 64bit - Desktop Qt 5.11.1 GCC 64bit - qt.qt5.5111.gcc_64_kit + Desktop Qt 5.10.1 GCC 64bit2 + Desktop Qt 5.10.1 GCC 64bit2 + qt.qt5.5101.gcc_64_kit 0 0 0 - /home/dorian/Documents/gitlab/build-fannyapp-Desktop_Qt_5_11_1_GCC_64bit-Debug + /home/dorian/Documents/gitlab/build-fannyapp-Desktop_Qt_5_10_1_GCC_64bit2-Debug true @@ -445,7 +445,7 @@ true - /home/dorian/Documents/gitlab/build-fannyapp-Desktop_Qt_5_11_1_GCC_64bit-Release + /home/dorian/Documents/gitlab/build-fannyapp-Desktop_Qt_5_10_1_GCC_64bit2-Release true @@ -456,7 +456,7 @@ false false - true + false true @@ -505,7 +505,7 @@ true - /home/dorian/Documents/gitlab/build-fannyapp-Desktop_Qt_5_11_1_GCC_64bit-Profile + /home/dorian/Documents/gitlab/build-fannyapp-Desktop_Qt_5_10_1_GCC_64bit2-Profile true @@ -516,7 +516,7 @@ false true - true + false true @@ -629,7 +629,7 @@ fannyapp.pro false - /home/dorian/Documents/gitlab/build-fannyapp-Desktop_Qt_5_11_1_GCC_64bit-Debug + /home/dorian/Documents/builds/Qt/fanny-app/build-fannyapp-Android_for_armeabi_v7a_GCC_4_9_Qt_5_10_1_for_Android_armv72-Release 3768 false true diff --git a/headers/serverconn.h b/headers/serverconn.h index 5a9559e..6c09106 100644 --- a/headers/serverconn.h +++ b/headers/serverconn.h @@ -42,7 +42,7 @@ public: signals: public slots: - void updateProgress(qint64 read, qint64 total); + Q_INVOKABLE void updateProgress(qint64 read, qint64 total); private: diff --git a/qml/FoodPlanForm.qml b/qml/FoodPlanForm.qml index 73b66af..22cfab2 100644 --- a/qml/FoodPlanForm.qml +++ b/qml/FoodPlanForm.qml @@ -76,7 +76,7 @@ Page { text: _cppServerConn.getFoodPlanData(index).cookteam width: parent.width - 10 wrapMode: Label.Wrap - height: text!=""? none:0 + height: text!=""? undefined:0 } Label { anchors.left: parent.left @@ -109,7 +109,7 @@ Page { wrapMode: Label.Wrap id: main_dish text: _cppServerConn.getFoodPlanData(index).main_dish - height: text!=""? none:0 + height: text!=""? undefined:0 } Rectangle { @@ -132,7 +132,7 @@ Page { text: _cppServerConn.getFoodPlanData(index).main_dish_veg width: parent.width - 10 wrapMode: Label.Wrap - height: text!=""? none:0 + height: text!=""? undefined:0 } Rectangle { @@ -154,7 +154,7 @@ Page { text: _cppServerConn.getFoodPlanData(index).garnish width: parent.width - 10 wrapMode: Label.Wrap - height: text!=""? none:0 + height: text!=""? undefined:0 } Rectangle { @@ -177,7 +177,7 @@ Page { text: _cppServerConn.getFoodPlanData(index).dessert width: parent.width - 10 wrapMode: Label.Wrap - height: text!=""? none:0 + height: text!=""? undefined:0 } Label { diff --git a/qml/HomeForm.qml b/qml/HomeForm.qml index 1c7ab0d..560354a 100644 --- a/qml/HomeForm.qml +++ b/qml/HomeForm.qml @@ -123,11 +123,12 @@ Page { contentHeight: aboutColumn.height standardButtons: Dialog.Ok | Dialog.Cancel onAccepted: { + _cppServerConn.updateProgress(0,100) busyDialog.open() text.visible = false - console.log("getting file of ", day) var ret = _cppServerConn.getDay(day) - console.log(ret) + progressCircle.arcEnd = 36000 + progress.text = "100%" busyDialog.close() text.visible = true if(ret === "OK"){ @@ -168,35 +169,37 @@ Page { //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 + contentHeight: progressCircle.height + contentWidth: progressCircle.width + + ProgressCircle { + id: progressCircle + size: 50 + lineWidth: 5 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 + colorCircle: "#FF3333" + colorBackground: "#E6E6E6" + showBackground: true + arcBegin: 0 + arcEnd: 0 + Label { + id: progress + anchors.centerIn: parent + text: "0%" + } + Timer { + id: refreshTimer + interval: 1; + running: busyDialog.visible + repeat: true + onTriggered: { + var ret = _cppServerConn.getProgress() + + progressCircle.arcEnd = 360 * ret * 1.2 + progress.text = Math.round( ret * 100 ) + "%" + console.log(ret) + } + } } } } diff --git a/qml/MainPage.qml b/qml/MainPage.qml index 23efd42..3185ecb 100644 --- a/qml/MainPage.qml +++ b/qml/MainPage.qml @@ -127,35 +127,38 @@ Page { //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 + contentHeight: progressCircle.height + contentWidth: progressCircle.width + ProgressCircle { + id: progressCircle + size: 50 + lineWidth: 5 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 + colorCircle: "#FF3333" + colorBackground: "#E6E6E6" + showBackground: true + arcBegin: 0 + arcEnd: 0 + Label { + id: progress + anchors.centerIn: parent + text: "0%" + } + Timer { + id: refreshTimer + interval: 1; + running: busyDialog.visible + repeat: true + onTriggered: { + var ret = _cppServerConn.getProgress() + if(ret > 100 || ret < 0){ + ret = 0 + } + + progress.text = Math.round( ret * 100 ) + "%" + progressCircle.arcEnd = 360 * ret + } + } } } } diff --git a/qml/ProgressCircle.qml b/qml/ProgressCircle.qml new file mode 100644 index 0000000..26268d3 --- /dev/null +++ b/qml/ProgressCircle.qml @@ -0,0 +1,90 @@ +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/WebsitePage.qml b/qml/WebsitePage.qml index 5fe02e6..1471efd 100644 --- a/qml/WebsitePage.qml +++ b/qml/WebsitePage.qml @@ -13,6 +13,7 @@ Page { objectName: "WebsitePage"; title: qsTr("Fanny Webseite") + ProgressBar { id: progress width: parent.width @@ -25,15 +26,9 @@ Page { value: webView.loadProgress == 100 ? 0 : webView.loadProgress / 100 } - Button { - z: 1 - anchors.top: parent.top - text:"\u21BA" - onClicked: webView.reload() - } - WebView { id: webView + onLoadProgressChanged: console.log(loadProgress) anchors { top: webView.loadProgress < 100 ? progress.bottom:parent.top bottom: parent.bottom @@ -46,7 +41,18 @@ Page { if (loadRequest.errorString) console.error(loadRequest.errorString); } + +// RoundButton { +// //z: -1 +// anchors { +// bottom: parent.bottom +// bottomMargin: 10 +// right: parent.right +// rightMargin: 10 +// } + +// text:"\u21BA" +// onClicked: webView.reload() +// } } - - } diff --git a/qml/qml.qrc b/qml/qml.qrc index 285067a..f33724f 100644 --- a/qml/qml.qrc +++ b/qml/qml.qrc @@ -8,5 +8,6 @@ AppToolBar.qml WebsitePage.qml FoodPlanForm.qml + ProgressCircle.qml diff --git a/source/serverconn.cpp b/source/serverconn.cpp index f774278..3e00faa 100644 --- a/source/serverconn.cpp +++ b/source/serverconn.cpp @@ -82,7 +82,7 @@ int ServerConn::logout() QString ServerConn::getDay(QString day) { - qDebug("getting file of day"); + this->progress = 0; // Create request QNetworkRequest request; request.setUrl( QUrl( "http://www.fanny-leicht.de/static15/http.intern/" + day + ".pdf" ) ); @@ -101,14 +101,13 @@ QString ServerConn::getDay(QString day) connect(reply, SIGNAL(downloadProgress(qint64, qint64)), this, SLOT(updateProgress(qint64, qint64))); - this->progress = 0; QEventLoop loop; loop.connect(this->networkManager, SIGNAL(finished(QNetworkReply*)), SLOT(quit())); loop.exec(); + this->progress = 1; int status_code = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); if(status_code == 200){ - qDebug("OK"); QString path = QStandardPaths::writableLocation(QStandardPaths::DownloadLocation); QDir dir; @@ -119,12 +118,9 @@ QString ServerConn::getDay(QString day) file.open(QIODevice::ReadWrite); file.write(reply->readAll()); file.close(); - - this->progress = 1; - + qDebug("opening PDF..."); QDesktopServices::openUrl(QUrl::fromLocalFile(path + "/.fannyapp-tmp/" + day + ".pdf")); - qDebug() << QString::fromUtf8(reply->readAll()); - qDebug() << reply->attribute(QNetworkRequest::HttpStatusCodeAttribute); + qDebug("open"); return("OK"); } else if(status_code == 401){