Skip to content

Commit ee61fdb

Browse files
mohsenD98nirvn
authored andcommitted
Add indeterminateProgressComponent to QfButton.
1 parent 1e4e2d0 commit ee61fdb

File tree

2 files changed

+38
-3
lines changed

2 files changed

+38
-3
lines changed

src/qml/QFieldCloudScreen.qml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -801,6 +801,7 @@ Page {
801801
id: downloadProjectBtn
802802
Layout.fillWidth: true
803803
progressValue: projectDetails.cloudProject ? projectDetails.cloudProject.downloadProgress : 0
804+
showProgress: projectDetails.cloudProject != undefined && projectDetails.cloudProject.status === QFieldCloudProject.ProjectStatus.Downloading
804805
text: {
805806
if (projectDetails.cloudProject != undefined && projectDetails.cloudProject.status === QFieldCloudProject.ProjectStatus.Downloading) {
806807
if (projectDetails.cloudProject.packagingStatus === QFieldCloudProject.PackagingBusyStatus) {

src/qml/imports/Theme/QfButton.qml

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Button {
1414
property alias borderColor: backgroundRectangle.border.color
1515
property bool dropdown: false
1616
property real progressValue: 0.0
17+
property bool showProgress: false
1718

1819
signal dropdownClicked
1920

@@ -49,8 +50,8 @@ Button {
4950
}
5051

5152
Loader {
52-
active: progressValue != 0.0 && progressValue != 1.0
53-
sourceComponent: progressComponent
53+
active: showProgress
54+
sourceComponent: progressValue == 0.0 ? indeterminateProgressComponent : progressComponent
5455
}
5556

5657
Component {
@@ -63,10 +64,11 @@ Button {
6364
clip: true
6465

6566
Rectangle {
66-
width: Math.min(10, parent.width / 2)
67+
width: Math.min(20, parent.width / 2)
6768
height: parent.height
6869
anchors.right: parent.right
6970
color: parent.color
71+
radius: progressValue > 0.98 ? parent.radius : 0
7072
}
7173

7274
Behavior on width {
@@ -76,6 +78,38 @@ Button {
7678
}
7779
}
7880
}
81+
Component {
82+
id: indeterminateProgressComponent
83+
Item {
84+
width: backgroundRectangle.width
85+
height: backgroundRectangle.height
86+
clip: true
87+
88+
Rectangle {
89+
id: bar
90+
width: parent.width * 0.3
91+
height: parent.height
92+
radius: 2
93+
color: Theme.mainColor
94+
opacity: 0.9
95+
SequentialAnimation on x {
96+
loops: Animation.Infinite
97+
NumberAnimation {
98+
from: -bar.width
99+
to: parent.width
100+
duration: 2000
101+
easing.type: Easing.Linear
102+
}
103+
NumberAnimation {
104+
from: parent.width
105+
to: -bar.width
106+
duration: 2000
107+
easing.type: Easing.Linear
108+
}
109+
}
110+
}
111+
}
112+
}
79113
}
80114

81115
contentItem: IconLabel {

0 commit comments

Comments
 (0)