47f991a36e
The ImportWalletPage now loads the QML provided by the module, exposed via the metadata of modules. The module gets just a blockheight property and then will do "its thing". This will either instantly close when there is nothing to do and continue instantly to the actual import. Or the module will check the server, initiate download and when all is setup and done THEN close the popup and continue with the actual import.
186 lines
6.4 KiB
QML
186 lines
6.4 KiB
QML
/*
|
|
* This file is part of the Flowee project
|
|
* Copyright (C) 2020-2024 Tom Zander <tom@flowee.org>
|
|
*
|
|
* 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/>.
|
|
*/
|
|
import QtQuick
|
|
import QtQuick.Controls as QQC2
|
|
import QtQuick.Layouts
|
|
import "../Flowee" as Flowee
|
|
|
|
Item {
|
|
id: root
|
|
width: parent.width
|
|
height: column.height + 3
|
|
|
|
property QtObject infoObject: null
|
|
property int minedHeight: model.height // local cache
|
|
property bool isRejected: root.minedHeight == -2; // -2 is the magic block-height indicating 'rejected'
|
|
property bool isMoved: {
|
|
if (model.isCoinbase || model.isFused || model.fundsIn === 0)
|
|
return false;
|
|
var amount = model.fundsOut - model.fundsIn
|
|
return amount < 0 && amount > -2500 // then the diff is likely just fees.
|
|
}
|
|
property double amountBch: isMoved ? model.fundsIn
|
|
: (model.fundsOut - model.fundsIn)
|
|
|
|
ColumnLayout {
|
|
id: column
|
|
width: parent.width
|
|
Flowee.Label {
|
|
id: rejectedLabel
|
|
property bool isRejected: root.minedHeight == -2; // -2 is the magic block-height indicating 'rejected'
|
|
text: {
|
|
if (isRejected)
|
|
return qsTr("Transaction is rejected")
|
|
if (typeof root.minedHeight < 1)
|
|
return qsTr("Processing")
|
|
return "";
|
|
}
|
|
visible: text !== ""
|
|
color: isRejected ? mainWindow.errorRed : palette.windowText
|
|
}
|
|
|
|
GridLayout {
|
|
width: parent.width
|
|
columns: 2
|
|
|
|
Flowee.Label {
|
|
visible: root.minedHeight > 0
|
|
text: qsTr("Mined") + ":"
|
|
}
|
|
Flowee.Label {
|
|
visible: root.minedHeight > 0
|
|
text: {
|
|
if (root.minedHeight <= 0)
|
|
return "";
|
|
|
|
var rc = Pay.formatBlockTime(root.minedHeight);
|
|
var confirmations = Pay.headerChainHeight - root.minedHeight + 1;
|
|
if (confirmations > 0 && confirmations < 20)
|
|
rc += " (" + qsTr("%1 blocks ago", "Confirmations", confirmations).arg(confirmations) + ")";
|
|
return rc;
|
|
}
|
|
|
|
property string toolTipText: {
|
|
if (root.minedHeight <= 0)
|
|
return "";
|
|
var loc = Qt.locale();
|
|
var format = loc.dateTimeFormat(Locale.ShortFormat);
|
|
return loc.toString(Pay.timeOfBlockHeight(root.minedHeight), format);
|
|
}
|
|
|
|
QQC2.ToolTip.delay: 800
|
|
QQC2.ToolTip.visible: hoverArea.containsMouse
|
|
QQC2.ToolTip.text: toolTipText
|
|
MouseArea {
|
|
id: hoverArea
|
|
enabled: parent.text !== parent.toolTipText
|
|
anchors.fill: parent
|
|
hoverEnabled: true
|
|
cursorShape: enabled ? Qt.PointingHandCursor : Qt.ArrowCursor
|
|
}
|
|
}
|
|
|
|
// value line
|
|
Flowee.Label {
|
|
id: paymentTypeLabel
|
|
visible: {
|
|
if (isMoved)
|
|
return false;
|
|
if (Pay.activityShowsBch) // avoid just duplicating data from the main delegate
|
|
return false;
|
|
return true;
|
|
}
|
|
text: {
|
|
if (model.isFused)
|
|
return qsTr("Fees") + ":";
|
|
return mainLabel.text + ":"
|
|
}
|
|
}
|
|
Flowee.BitcoinAmountLabel {
|
|
visible: paymentTypeLabel.visible
|
|
colorizeValue: amountBch + (infoObject == null ? 0 : infoObject.fees)
|
|
value: Math.abs(colorizeValue)
|
|
fiatTimestamp: model.date
|
|
}
|
|
// txid line
|
|
Flowee.Label {
|
|
text: "TXID:"
|
|
}
|
|
Flowee.LabelWithClipboard {
|
|
menuText: qsTr("Copy transaction-ID")
|
|
text: model.txid
|
|
font.pixelSize: mainLabel.font.pixelSize * 0.9
|
|
Layout.fillWidth: true
|
|
}
|
|
}
|
|
|
|
Image {
|
|
sourceSize.width: 22
|
|
sourceSize.height: 22
|
|
smooth: true
|
|
visible: {
|
|
if (root.infoObject == null)
|
|
return false;
|
|
// visible if at least one output has a token.
|
|
var outputs = root.infoObject.knownOutputs;
|
|
for (let o of outputs) {
|
|
if (o !== null && o.hasCashToken)
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
source: visible ? "qrc:/CashTokens.svg" : ""
|
|
Flowee.Label {
|
|
x: 30
|
|
text: qsTr("Holds a token")
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
}
|
|
}
|
|
|
|
Flowee.FiatTxInfo {
|
|
txInfo: infoObject
|
|
width: parent.width
|
|
}
|
|
}
|
|
Rectangle {
|
|
width: parent.width * 0.7
|
|
height: 2
|
|
color: palette.midlight
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
anchors.bottom: parent.bottom
|
|
}
|
|
Flowee.ImageButton {
|
|
source: "qrc:/internet.svg"
|
|
smooth: true
|
|
iconSize: 25
|
|
onClicked: Pay.openInExplorer(model.txid);
|
|
responseText: qsTr("Opening Website")
|
|
anchors.right: moreInfo.left
|
|
anchors.rightMargin: 10
|
|
}
|
|
Flowee.ImageButton {
|
|
id: moreInfo
|
|
smooth: true
|
|
source: "qrc:/infoIcon" + (Pay.useDarkSkin ? "-light.svg" : ".svg");
|
|
iconSize: 25
|
|
anchors.right: parent.right
|
|
anchors.rightMargin: 20
|
|
onClicked: txDetailsWindow.openTab(model.walletIndex);
|
|
}
|
|
}
|