Files
pay/desktop/SyncIndicator.qml
T

49 lines
1.7 KiB
QML
Raw Permalink Normal View History

2020-11-05 17:59:48 +01:00
/*
* This file is part of the Flowee project
2021-05-28 18:13:50 +02:00
* Copyright (C) 2020-2021 Tom Zander <tom@flowee.org>
2020-11-05 17:59:48 +01:00
*
* 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/>.
*/
2021-05-23 00:27:34 +02:00
import QtQuick 2.11
import QtQuick.Controls 2.11
/*
* A simple label that shows the amount of time a pair of block-heights are apart.
*/
Label {
property int accountBlockHeight: 0
2021-11-02 19:29:14 +01:00
property int globalPos: Pay.chainHeight
text: {
2021-05-28 18:13:50 +02:00
if (accountBlockHeight <= 0) // For accounts that only expect tx in the future.
return qsTr("Up to date")
var diff = globalPos - accountBlockHeight
if (diff < 0) // we are ahead???
2020-11-05 17:59:48 +01:00
return "--"
var days = diff / 144
var weeks = diff / 1008
if (days > 10)
2021-01-29 10:27:24 +01:00
return qsTr("%1 weeks behind", "", Math.ceil(weeks)).arg(Math.ceil(weeks));
var hours = diff / 6
if (hours > 48)
2021-01-29 10:27:24 +01:00
return qsTr("%1 days behind", "", Math.ceil(days)).arg(Math.ceil(days));
2020-11-05 17:59:48 +01:00
if (diff === 0)
2021-04-29 12:15:22 +02:00
return qsTr("Up to date")
if (diff < 3)
return qsTr("Updating");
2021-01-29 10:27:24 +01:00
return qsTr("%1 hours behind", "", Math.ceil(hours)).arg(Math.ceil(hours));
}
font.italic: true
}