Skip to content

Commit 175f5a9

Browse files

File tree

1 file changed

+75
-14
lines changed

1 file changed

+75
-14
lines changed

src/qml/components/BlockClock.qml

Lines changed: 75 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ Item {
2525
property int headerSize: 32
2626
property bool connected: nodeModel.numOutboundPeers > 0
2727
property bool synced: nodeModel.verificationProgress > 0.999
28+
property string syncProgress: formatProgressPercentage(nodeModel.verificationProgress * 100)
2829
property bool paused: false
30+
property var syncState: formatRemainingSyncTime(nodeModel.remainingSyncTime)
31+
property string syncTime: syncState.text
32+
property bool estimating: syncState.estimating
2933

3034
activeFocusOnTab: true
3135

@@ -94,15 +98,44 @@ Item {
9498
Label {
9599
id: subText
96100
anchors.top: mainText.bottom
101+
property bool estimating: root.estimating
97102
anchors.horizontalCenter: root.horizontalCenter
98103
font.family: "Inter"
99104
font.styleName: "Semi Bold"
100105
font.pixelSize: dial.width * (9/100)
101106
color: Theme.color.neutral4
102107

103-
Behavior on color {
104-
ColorAnimation { duration: 150 }
108+
Component.onCompleted: {
109+
colorChanged.connect(function() {
110+
if (!subText.estimating) {
111+
themeChange.restart();
112+
}
113+
});
114+
115+
estimatingChanged.connect(function() {
116+
if (subText.estimating) {
117+
estimatingTime.start();
118+
} else {
119+
estimatingTime.stop();
120+
}
121+
});
122+
123+
subText.estimatingChanged(subText.estimating);
124+
}
125+
126+
ColorAnimation on color{
127+
id: themeChange
128+
target: subText
129+
duration: 150
105130
}
131+
132+
SequentialAnimation {
133+
id: estimatingTime
134+
loops: Animation.Infinite
135+
ColorAnimation { target: subText; property: "color"; from: subText.color; to: Theme.color.neutral6; duration: 1000 }
136+
ColorAnimation { target: subText; property: "color"; from: Theme.color.neutral6; to: subText.color; duration: 1000 }
137+
}
138+
106139
}
107140

108141
PeersIndicator {
@@ -140,17 +173,17 @@ Item {
140173
name: "IBD"; when: !synced && !paused && connected
141174
PropertyChanges {
142175
target: root
143-
header: formatProgressPercentage(nodeModel.verificationProgress * 100)
144-
subText: formatRemainingSyncTime(nodeModel.remainingSyncTime)
176+
header: root.syncProgress
177+
subText: root.syncTime
145178
}
146179
},
147-
148180
State {
149181
name: "BLOCKCLOCK"; when: synced && !paused && connected
150182
PropertyChanges {
151183
target: root
152184
header: Number(nodeModel.blockTipHeight).toLocaleString(Qt.locale(), 'f', 0)
153185
subText: "Blocktime"
186+
estimating: false
154187
}
155188
},
156189

@@ -161,6 +194,7 @@ Item {
161194
header: "Paused"
162195
headerSize: dial.width * (3/25)
163196
subText: "Tap to resume"
197+
estimating: false
164198
}
165199
PropertyChanges {
166200
target: bitcoinIcon
@@ -179,6 +213,7 @@ Item {
179213
header: "Connecting"
180214
headerSize: dial.width * (3/25)
181215
subText: "Please wait"
216+
estimating: false
182217
}
183218
PropertyChanges {
184219
target: bitcoinIcon
@@ -212,29 +247,55 @@ Item {
212247
minutes %= 1440;
213248
var hours = Math.floor(minutes / 60);
214249
minutes %= 60;
250+
var result = "";
251+
var estimatingStatus = false;
215252

216253
if (weeks > 0) {
217-
return "~" + weeks + (weeks === 1 ? " week" : " weeks") + " left";
254+
return {
255+
text: "~" + weeks + (weeks === 1 ? " week" : " weeks") + " left",
256+
estimating: false
257+
};
218258
}
219259
if (days > 0) {
220-
return "~" + days + (days === 1 ? " day" : " days") + " left";
260+
return {
261+
text: "~" + days + (days === 1 ? " day" : " days") + " left",
262+
estimating: false
263+
};
221264
}
222265
if (hours >= 5) {
223-
return "~" + hours + (hours === 1 ? " hour" : " hours") + " left";
266+
return {
267+
text: "~" + hours + (hours === 1 ? " hour" : " hours") + " left",
268+
estimating: false
269+
};
224270
}
225271
if (hours > 0) {
226-
return "~" + hours + "h " + minutes + "m" + " left";
272+
return {
273+
text: "~" + hours + "h " + minutes + "m" + " left",
274+
estimating: false
275+
};
227276
}
228277
if (minutes >= 5) {
229-
return "~" + minutes + (minutes === 1 ? " minute" : " minutes") + " left";
278+
return {
279+
text: "~" + minutes + (minutes === 1 ? " minute" : " minutes") + " left",
280+
estimating: false
281+
};
230282
}
231283
if (minutes > 0) {
232-
return "~" + minutes + "m " + seconds + "s" + " left";
284+
return {
285+
text: "~" + minutes + "m " + seconds + "s" + " left",
286+
estimating: false
287+
};
233288
}
234289
if (seconds > 0) {
235-
return "~" + seconds + (seconds === 1 ? " second" : " seconds") + " left";
290+
return {
291+
text: "~" + seconds + (seconds === 1 ? " second" : " seconds") + " left",
292+
estimating: false
293+
};
294+
} else {
295+
return {
296+
text: "Estimating",
297+
estimating: true
298+
};
236299
}
237-
238-
return "Estimating";
239300
}
240301
}

0 commit comments

Comments
 (0)