Skip to content

Add ProgressIndicator control #69

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Makefile.qt.include
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ QML_RES_QML = \
qml/components/BlockCounter.qml \
qml/components/ConnectionOptions.qml \
qml/controls/OptionButton.qml \
qml/controls/ProgressIndicator.qml \
qml/pages/initerrormessage.qml \
qml/pages/stub.qml

Expand Down
1 change: 1 addition & 0 deletions src/qml/bitcoin_qml.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<file>components/BlockCounter.qml</file>
<file>components/ConnectionOptions.qml</file>
<file>controls/OptionButton.qml</file>
<file>controls/ProgressIndicator.qml</file>
<file>pages/initerrormessage.qml</file>
<file>pages/stub.qml</file>
</qresource>
Expand Down
33 changes: 33 additions & 0 deletions src/qml/controls/ProgressIndicator.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright (c) 2021 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

import QtQuick 2.12
import QtQuick.Controls 2.12

Control {
property real progress: 0
Behavior on progress {
NumberAnimation {
easing.type: Easing.Bezier
easing.bezierCurve: [0.5, 0.0, 0.2, 1, 1, 1]
duration: 250
}
}
contentItem: Rectangle {
implicitHeight: 6
radius: Math.floor(height / 2)
color: "#404040"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we avoid magic numbers?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to move these constants somewhere, something to follow up.

Item {
width: Math.round(progress * contentItem.width)
height: parent.height
clip: true
Rectangle {
width: contentItem.width
height: contentItem.height
radius: contentItem.radius
color: "orange"
}
}
}
}
9 changes: 9 additions & 0 deletions src/qml/pages/stub.qml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import QtQuick 2.12
import QtQuick.Controls 2.12
import QtQuick.Layouts 1.11
import "../components"
import "../controls"

ApplicationWindow {
id: appWindow
Expand All @@ -31,6 +32,14 @@ ApplicationWindow {
Layout.alignment: Qt.AlignCenter
blockHeight: nodeModel.blockTipHeight
}
ProgressIndicator {
id: indicator
Layout.fillWidth: true
progress: 0.666
background: MouseArea {
onClicked: indicator.progress = mouseX / width
}
}
ConnectionOptions {
Layout.preferredWidth: 400
focus: true
Expand Down