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
|
2020-10-19 17:59:04 +02:00
|
|
|
import Flowee.org.pay 1.0
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* A simple label that shows the amount of time a pair of block-heights are apart.
|
|
|
|
|
*/
|
|
|
|
|
Label {
|
|
|
|
|
property int accountBlockHeight: 0
|
2020-12-26 14:40:01 +01:00
|
|
|
property int globalPos: Flowee.chainHeight
|
2020-10-19 17:59:04 +02:00
|
|
|
|
|
|
|
|
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")
|
2020-10-19 17:59:04 +02:00
|
|
|
var diff = globalPos - accountBlockHeight
|
|
|
|
|
if (diff < 0) // we are ahead???
|
2020-11-05 17:59:48 +01:00
|
|
|
return "--"
|
2020-10-19 17:59:04 +02:00
|
|
|
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));
|
2020-10-19 17:59:04 +02:00
|
|
|
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")
|
2020-10-29 21:51:19 +01:00
|
|
|
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));
|
2020-10-19 17:59:04 +02:00
|
|
|
}
|
|
|
|
|
font.italic: true
|
|
|
|
|
}
|