From f9fd8055f280f379b0a04b67e7ebdbbbbb69e60f Mon Sep 17 00:00:00 2001 From: miruka Date: Wed, 6 Nov 2019 13:49:48 -0400 Subject: [PATCH] Add HCircleProgressBar --- .gitmodules | 3 ++ TODO.md | 3 +- harmonyqml.pro | 6 ++-- src/main.cpp | 4 +++ src/qml/Base/HCircleProgressBar.qml | 48 +++++++++++++++++++++++++++++ src/themes/Default.qpl | 7 +++++ submodules/RadialBarDemo | 1 + 7 files changed, 68 insertions(+), 4 deletions(-) create mode 100644 src/qml/Base/HCircleProgressBar.qml create mode 160000 submodules/RadialBarDemo diff --git a/.gitmodules b/.gitmodules index 0d0751c3..2004d2c5 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "submodules/qsyncable"] path = submodules/qsyncable url = https://github.com/benlau/qsyncable +[submodule "submodules/RadialBarDemo"] + path = submodules/RadialBarDemo + url = https://github.com/arunpkqt/RadialBarDemo diff --git a/TODO.md b/TODO.md index 22216f60..d22636cb 100644 --- a/TODO.md +++ b/TODO.md @@ -1,10 +1,9 @@ - Media - - Show upload progression - Theming (upload bar, media text bubbles) - Downloading - Bottom/top bar - - Image loading progress bar - Verify things work with chat.privacytools.io (subdomain weirdness) + - Show real progression for thumbnail loadings, uploads and downloads - Support m.file thumbnails - Generate video thumbnails diff --git a/harmonyqml.pro b/harmonyqml.pro index 38ce5481..13e21938 100644 --- a/harmonyqml.pro +++ b/harmonyqml.pro @@ -12,8 +12,10 @@ RCC_DIR = $$BUILD_DIR/rcc QRC_FILE = $$BUILD_DIR/resources.qrc RESOURCES += $$QRC_FILE -HEADERS += src/utils.h src/clipboard.h -SOURCES += src/main.cpp src/utils.cpp src/clipboard.cpp +HEADERS += src/utils.h src/clipboard.h \ + submodules/RadialBarDemo/radialbar.h +SOURCES += src/main.cpp src/utils.cpp src/clipboard.cpp \ + submodules/RadialBarDemo/radialbar.cpp TARGET = harmonyqml diff --git a/src/main.cpp b/src/main.cpp index 55155e73..9c1dbc91 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4,6 +4,8 @@ #include #include +#include "../submodules/RadialBarDemo/radialbar.h" + #include "utils.h" #include "clipboard.h" @@ -28,6 +30,8 @@ int main(int argc, char *argv[]) { objectContext->setContextProperty("CppUtils", new Utils()); objectContext->setContextProperty("Clipboard", new Clipboard()); + qmlRegisterType("RadialBar", 1, 0, "RadialBar"); + QFileInfo qrcPath(":src/qml/Window.qml"); QQmlComponent component( diff --git a/src/qml/Base/HCircleProgressBar.qml b/src/qml/Base/HCircleProgressBar.qml new file mode 100644 index 00000000..4af2ec62 --- /dev/null +++ b/src/qml/Base/HCircleProgressBar.qml @@ -0,0 +1,48 @@ +import QtQuick 2.12 +import RadialBar 1.0 + +RadialBar { + id: bar + foregroundColor: theme.controls.circleProgressBar.background + progressColor: theme.controls.circleProgressBar.foreground + dialWidth: theme.controls.circleProgressBar.thickness + startAngle: 0 + spanAngle: 360 + + from: 0 + to: 100 + value: 0 + + showText: true + suffixText: qsTr("%") + textFont.pixelSize: theme.fontSize.big + textColor: theme.controls.circleProgressBar.text + + + property alias from: bar.minValue + property alias to: bar.maxValue + property bool indeterminate: false + + + Binding { + target: bar; + property: "value"; + value: bar.to * theme.controls.circleProgressBar.indeterminateSpan + when: bar.indeterminate + } + + Binding { + target: bar + property: "showText" + value: false + when: bar.indeterminate + } + + RotationAnimator on rotation { + running: bar.indeterminate + from: 0 + to: 360 + loops: Animation.Infinite + duration: theme ? (theme.animationDuration * 6) : 600 + } +} diff --git a/src/themes/Default.qpl b/src/themes/Default.qpl index df5b2c27..da640358 100644 --- a/src/themes/Default.qpl +++ b/src/themes/Default.qpl @@ -176,6 +176,13 @@ controls: color background: colors.inputBackground color foreground: colors.accentBackground + circleProgressBar: + int thickness: Math.max(2, spacing / 2) + color background: colors.inputBackground + color foreground: colors.accentBackground + color text: colors.text + real indeterminateSpan: 0.2 // 0-1 + slider: int radius: 2 int height: controls.progressBar.height diff --git a/submodules/RadialBarDemo b/submodules/RadialBarDemo new file mode 160000 index 00000000..7c3ebecf --- /dev/null +++ b/submodules/RadialBarDemo @@ -0,0 +1 @@ +Subproject commit 7c3ebecf4ef0c23776c591ee5d37ff104d04f798