Commit 703ec65a authored by Martin Straka's avatar Martin Straka

Statusbar as alone QML component

parent a96ba567
/*
* 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 <http://www.gnu.org/licenses/>.
*
* 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 = ""
}
}
}
......@@ -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 = ""
}
}
}
}
......
......@@ -105,6 +105,7 @@
<file>../qml/components/MessageList.qml</file>
<file>../qml/components/OverlaidImage.qml</file>
<file>../qml/components/PageHeader.qml</file>
<file>../qml/components/ProgressBar.qml</file>
<file>../qml/components/SpinBoxZeroMax.qml</file>
<file>../qml/dialogues/InputDialogue.qml</file>
<file>../qml/dialogues/FileDialogue.qml</file>
......
......@@ -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 }
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment