From 703ec65a66180b96567e6588d5a02e4f3a76e573 Mon Sep 17 00:00:00 2001 From: Martin Straka Date: Thu, 4 Jan 2018 13:42:57 +0100 Subject: [PATCH 1/5] Statusbar as alone QML component --- qml/components/ProgressBar.qml | 94 ++++++++++++++++++++++++++++++++++ qml/main.qml | 60 +--------------------- res/qml.qrc | 1 + src/main.cpp | 1 + 4 files changed, 97 insertions(+), 59 deletions(-) create mode 100644 qml/components/ProgressBar.qml diff --git a/qml/components/ProgressBar.qml b/qml/components/ProgressBar.qml new file mode 100644 index 00000000..6c46265d --- /dev/null +++ b/qml/components/ProgressBar.qml @@ -0,0 +1,94 @@ +/* + * Copyright (C) 2014-2018 CZ.NIC + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * In addition, as a special exception, the copyright holders give + * permission to link the code of portions of this program with the + * OpenSSL library under certain conditions as described in each + * individual source file, and distribute linked combinations including + * the two. + */ + +import QtGraphicalEffects 1.0 +import QtQuick 2.7 +import QtQuick.Layouts 1.3 +import QtQuick.Controls 2.1 + +Rectangle { + id: root + property int statusBarTimer: 5000 + anchors.left: parent.left + anchors.bottom: parent.bottom + anchors.right: parent.right + height: headerHeight + color: datovkaPalette.text + Column { + anchors.left: parent.left + anchors.right: parent.right + anchors.verticalCenter: parent.verticalCenter + anchors.margins: defaultMargin + spacing: formItemVerticalSpacing + Text { + id: statusBarText + color: datovkaPalette.base + anchors.horizontalCenter: parent.horizontalCenter + text: mainWindow.width + " x "+ mainWindow.height + Connections { + target: isds + onStatusBarTextChanged: { + root.visible = isVisible + statusBarText.text = txt + timer.running = !busy + progressBar.visible = busy + } + } + Connections { + target: files + onStatusBarTextChanged: { + root.visible = true + statusBarText.text = txt + timer.running = !busy + progressBar.visible = busy + } + } + Connections { + target: settings + onStatusBarTextChanged: { + root.visible = true + statusBarText.text = txt + timer.running = !busy + progressBar.visible = busy + } + } + } + ProgressBar { + id: progressBar + anchors.horizontalCenter: parent.horizontalCenter + indeterminate: true + } + } + Timer { + id: timer + interval: statusBarTimer + running: false + repeat: false + onTriggered: { + // reset timer and clear status text + timer.running = false + root.visible = false + statusBarText.text = "" + } + } +} diff --git a/qml/main.qml b/qml/main.qml index 9c6c8240..52882224 100644 --- a/qml/main.qml +++ b/qml/main.qml @@ -85,7 +85,6 @@ ApplicationWindow { // header background color property string mainHeaderBgColor: "#00539b" - property int statusBarTimer: 5000 // dimension and style based on font pixel size and screen dpi property int textFontSizeInPixels: defaultTextFont.font.pixelSize property int textPointSmall: Math.round(defaultTextFont.font.pointSize * 0.7) @@ -169,65 +168,8 @@ ApplicationWindow { } } } - Rectangle { + ProgressBar { id: statusBar - visible: false - anchors.left: parent.left - anchors.bottom: parent.bottom - anchors.right: parent.right - height: headerHeight * 0.5 - color: datovkaPalette.alternateBase - BusyIndicator { - id: busyuIndicator - width: parent.height - height: parent.height - anchors.centerIn: parent - running: false - } - Text { - id: statusBarText - color: datovkaPalette.text - anchors.centerIn: parent - text: mainWindow.width + " x "+ mainWindow.height - Connections { - target: isds - onStatusBarTextChanged: { - statusBar.visible = isVisible - statusBarText.text = txt - busyuIndicator.running = busy - timerId.running = !busy - } - } - Connections { - target: files - onStatusBarTextChanged: { - statusBar.visible = true - statusBarText.text = txt - busyuIndicator.running = busy - timerId.running = !busy - } - } - Connections { - target: settings - onStatusBarTextChanged: { - statusBar.visible = true - statusBarText.text = txt - busyuIndicator.running = busy - timerId.running = !busy - } - } - } - Timer { - id: timerId - interval: statusBarTimer; - running: false; - repeat: false - onTriggered: { - timerId.running = false - statusBar.visible = false - statusBarText.text = "" - } - } } } diff --git a/res/qml.qrc b/res/qml.qrc index 3bf8b1cf..b3e1512a 100644 --- a/res/qml.qrc +++ b/res/qml.qrc @@ -105,6 +105,7 @@ ../qml/components/MessageList.qml ../qml/components/OverlaidImage.qml ../qml/components/PageHeader.qml + ../qml/components/ProgressBar.qml ../qml/components/SpinBoxZeroMax.qml ../qml/dialogues/InputDialogue.qml ../qml/dialogues/FileDialogue.qml diff --git a/src/main.cpp b/src/main.cpp index aadf0fd6..9f0b27b8 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -127,6 +127,7 @@ const struct QmlTypeEntry qmlComponents[] = { { "MessageList", 1, 0 }, { "OverlaidImage", 1, 0 }, { "PageHeader", 1, 0 }, + { "ProgressBar", 1, 0 }, { "SpinBoxZeroMax", 1, 0 }, { NULL, 0, 0 } }; -- GitLab From 5a4232482612dd3d838762df4fc765f535122f53 Mon Sep 17 00:00:00 2001 From: Martin Straka Date: Thu, 4 Jan 2018 16:01:52 +0100 Subject: [PATCH 2/5] Added progressBar timer --- qml/components/ProgressBar.qml | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/qml/components/ProgressBar.qml b/qml/components/ProgressBar.qml index 6c46265d..bad38024 100644 --- a/qml/components/ProgressBar.qml +++ b/qml/components/ProgressBar.qml @@ -52,6 +52,7 @@ Rectangle { statusBarText.text = txt timer.running = !busy progressBar.visible = busy + progressTimer.running = busy } } Connections { @@ -61,6 +62,7 @@ Rectangle { statusBarText.text = txt timer.running = !busy progressBar.visible = busy + progressTimer.running = busy } } Connections { @@ -70,13 +72,25 @@ Rectangle { statusBarText.text = txt timer.running = !busy progressBar.visible = busy + progressTimer.running = busy } } } ProgressBar { id: progressBar anchors.horizontalCenter: parent.horizontalCenter - indeterminate: true + from: 0 + to: 100 + value: 0 + Timer { + id: progressTimer + interval: 100 + repeat: true + running: true + onTriggered: { + progressBar.value < progressBar.to ? progressBar.value += 5 : progressBar.value = 0 + } + } } } Timer { -- GitLab From 4db784912e4cd6e2e8888b4433a32480158dead7 Mon Sep 17 00:00:00 2001 From: Martin Straka Date: Thu, 4 Jan 2018 16:25:56 +0100 Subject: [PATCH 3/5] Removed statusbar from account page --- qml/pages/PageAccountList.qml | 1 - 1 file changed, 1 deletion(-) diff --git a/qml/pages/PageAccountList.qml b/qml/pages/PageAccountList.qml index 26c1d423..3c8a0592 100644 --- a/qml/pages/PageAccountList.qml +++ b/qml/pages/PageAccountList.qml @@ -107,7 +107,6 @@ Component { MouseArea { anchors.fill: parent onClicked: { - statusBarText.text = "" isds.doIsdsAction("syncAllAccounts", "") } } -- GitLab From 6ed81ee545a06be16d71ccbbc612dd0b2649797a Mon Sep 17 00:00:00 2001 From: Martin Straka Date: Fri, 5 Jan 2018 12:32:56 +0100 Subject: [PATCH 4/5] Progress bar is indeterminate --- qml/components/ProgressBar.qml | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/qml/components/ProgressBar.qml b/qml/components/ProgressBar.qml index bad38024..6c46265d 100644 --- a/qml/components/ProgressBar.qml +++ b/qml/components/ProgressBar.qml @@ -52,7 +52,6 @@ Rectangle { statusBarText.text = txt timer.running = !busy progressBar.visible = busy - progressTimer.running = busy } } Connections { @@ -62,7 +61,6 @@ Rectangle { statusBarText.text = txt timer.running = !busy progressBar.visible = busy - progressTimer.running = busy } } Connections { @@ -72,25 +70,13 @@ Rectangle { statusBarText.text = txt timer.running = !busy progressBar.visible = busy - progressTimer.running = busy } } } ProgressBar { id: progressBar anchors.horizontalCenter: parent.horizontalCenter - from: 0 - to: 100 - value: 0 - Timer { - id: progressTimer - interval: 100 - repeat: true - running: true - onTriggered: { - progressBar.value < progressBar.to ? progressBar.value += 5 : progressBar.value = 0 - } - } + indeterminate: true } } Timer { -- GitLab From a27ef5cf0bd1acb3fc394d842f6c25e2d52d1b61 Mon Sep 17 00:00:00 2001 From: Martin Straka Date: Fri, 5 Jan 2018 12:51:55 +0100 Subject: [PATCH 5/5] Statusbar is hidden in default --- qml/components/ProgressBar.qml | 1 + 1 file changed, 1 insertion(+) diff --git a/qml/components/ProgressBar.qml b/qml/components/ProgressBar.qml index 6c46265d..5afa85ed 100644 --- a/qml/components/ProgressBar.qml +++ b/qml/components/ProgressBar.qml @@ -28,6 +28,7 @@ import QtQuick.Controls 2.1 Rectangle { id: root + visible: false property int statusBarTimer: 5000 anchors.left: parent.left anchors.bottom: parent.bottom -- GitLab