forked from Public/monero-gui
progress bar improvements
This commit is contained in:
@@ -37,27 +37,16 @@ Rectangle {
|
|||||||
color: "#1C1C1C"
|
color: "#1C1C1C"
|
||||||
|
|
||||||
function updateProgress(currentBlock,targetBlock, blocksToSync, statusTxt){
|
function updateProgress(currentBlock,targetBlock, blocksToSync, statusTxt){
|
||||||
if(targetBlock == 1) {
|
|
||||||
fillLevel = 0
|
|
||||||
progressText.text = qsTr("Establishing connection...");
|
|
||||||
progressBar.visible = true
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if(targetBlock > 0) {
|
if(targetBlock > 0) {
|
||||||
var remaining = (currentBlock < targetBlock) ? targetBlock - currentBlock : 0
|
var remaining = (currentBlock < targetBlock) ? targetBlock - currentBlock : 0
|
||||||
var progressLevel = (blocksToSync > 0) ? (100*(blocksToSync - remaining)/blocksToSync).toFixed(0) : 100
|
var progressLevel = (blocksToSync > 0 && blocksToSync != remaining) ? (100*(blocksToSync - remaining)/blocksToSync).toFixed(0) : 100*(currentBlock / targetBlock).toFixed(0)
|
||||||
fillLevel = progressLevel
|
fillLevel = progressLevel
|
||||||
if(typeof statusTxt != "undefined" && statusTxt != "") {
|
if(typeof statusTxt != "undefined" && statusTxt != "") {
|
||||||
progressText.text = statusTxt;
|
progressText.text = statusTxt;
|
||||||
} else {
|
} else {
|
||||||
progressText.text = syncText + remaining.toFixed(0);
|
progressText.text = syncText + remaining.toFixed(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(remaining == 0 && (typeof statusTxt == "undefined" || statusTxt == ""))
|
|
||||||
progressText.text = qsTr("%1 is synchronized").arg(syncType)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
|
|||||||
25
main.qml
25
main.qml
@@ -57,6 +57,7 @@ ApplicationWindow {
|
|||||||
property bool isNewWallet: false
|
property bool isNewWallet: false
|
||||||
property int restoreHeight:0
|
property int restoreHeight:0
|
||||||
property bool daemonSynced: false
|
property bool daemonSynced: false
|
||||||
|
property bool walletSynced: false
|
||||||
property int maxWindowHeight: (isAndroid || isIOS)? screenHeight : (screenHeight < 900)? 720 : 800;
|
property int maxWindowHeight: (isAndroid || isIOS)? screenHeight : (screenHeight < 900)? 720 : 800;
|
||||||
property bool daemonRunning: false
|
property bool daemonRunning: false
|
||||||
property alias toolTip: toolTip
|
property alias toolTip: toolTip
|
||||||
@@ -405,6 +406,9 @@ ApplicationWindow {
|
|||||||
// Daemon connected
|
// Daemon connected
|
||||||
leftPanel.networkStatus.connected = currentWallet.connected()
|
leftPanel.networkStatus.connected = currentWallet.connected()
|
||||||
|
|
||||||
|
// Wallet height
|
||||||
|
var bcHeight = currentWallet.blockChainHeight();
|
||||||
|
|
||||||
// Check daemon status
|
// Check daemon status
|
||||||
var dCurrentBlock = currentWallet.daemonBlockChainHeight();
|
var dCurrentBlock = currentWallet.daemonBlockChainHeight();
|
||||||
var dTargetBlock = currentWallet.daemonBlockChainTargetHeight();
|
var dTargetBlock = currentWallet.daemonBlockChainTargetHeight();
|
||||||
@@ -412,18 +416,25 @@ ApplicationWindow {
|
|||||||
// TODO: implement onDaemonSynced or similar in wallet API and don't start refresh thread before daemon is synced
|
// TODO: implement onDaemonSynced or similar in wallet API and don't start refresh thread before daemon is synced
|
||||||
// targetBlock = currentBlock = 1 before network connection is established.
|
// targetBlock = currentBlock = 1 before network connection is established.
|
||||||
daemonSynced = dCurrentBlock >= dTargetBlock && dTargetBlock != 1
|
daemonSynced = dCurrentBlock >= dTargetBlock && dTargetBlock != 1
|
||||||
// Update daemon sync progress
|
walletSynced = bcHeight >= dTargetBlock
|
||||||
leftPanel.daemonProgressBar.updateProgress(dCurrentBlock,dTargetBlock);
|
|
||||||
if(!daemonSynced)
|
// Update progress bars
|
||||||
|
if(!daemonSynced) {
|
||||||
|
leftPanel.daemonProgressBar.updateProgress(dCurrentBlock,dTargetBlock, dTargetBlock-dCurrentBlock);
|
||||||
leftPanel.progressBar.updateProgress(0,dTargetBlock, dTargetBlock, qsTr("Waiting for daemon to sync"));
|
leftPanel.progressBar.updateProgress(0,dTargetBlock, dTargetBlock, qsTr("Waiting for daemon to sync"));
|
||||||
|
} else {
|
||||||
|
leftPanel.daemonProgressBar.updateProgress(dCurrentBlock,dTargetBlock, 0, qsTr("Daemon is synchronized (%1)").arg(dCurrentBlock.toFixed(0)));
|
||||||
|
if(walletSynced)
|
||||||
|
leftPanel.progressBar.updateProgress(bcHeight,dTargetBlock,dTargetBlock-bcHeight, qsTr("Wallet is synchronized"))
|
||||||
|
}
|
||||||
|
|
||||||
// Update wallet sync progress
|
// Update wallet sync progress
|
||||||
updateSyncing((currentWallet.connected() !== Wallet.ConnectionStatus_Disconnected) && !daemonSynced)
|
updateSyncing((currentWallet.connected() !== Wallet.ConnectionStatus_Disconnected) && !daemonSynced)
|
||||||
// Update transfer page status
|
// Update transfer page status
|
||||||
middlePanel.updateStatus();
|
middlePanel.updateStatus();
|
||||||
|
|
||||||
// Refresh is succesfull if blockchain height > 1
|
// Refresh is succesfull if blockchain height > 1
|
||||||
if (currentWallet.blockChainHeight() > 1){
|
if (bcHeight > 1){
|
||||||
|
|
||||||
// Save new wallet after first refresh
|
// Save new wallet after first refresh
|
||||||
// Wallet is nomrmally saved to disk on app exit. This prevents rescan from block 0 after app crash
|
// Wallet is nomrmally saved to disk on app exit. This prevents rescan from block 0 after app crash
|
||||||
if(isNewWallet){
|
if(isNewWallet){
|
||||||
@@ -498,6 +509,10 @@ ApplicationWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
leftPanel.progressBar.updateProgress(blockHeight,targetHeight, blocksToSync);
|
leftPanel.progressBar.updateProgress(blockHeight,targetHeight, blocksToSync);
|
||||||
|
|
||||||
|
// If wallet is syncing, daemon is already synced
|
||||||
|
leftPanel.daemonProgressBar.updateProgress(1,1,0,qsTr("Daemon is synchronized"));
|
||||||
|
|
||||||
foundNewBlock = true;
|
foundNewBlock = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user