2020-11-04 18:33:50 +01:00
/*
* This file is part of the Flowee project
2021-07-30 23:07:14 +02:00
* Copyright (C) 2021 Tom Zander <tom@flowee.org>
2020-11-04 18:33:50 +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
2021-07-31 14:16:28 +02:00
import QtQuick . Layouts 1.11
2021-11-02 19:32:13 +01:00
import "widgets" as Flowee
2020-11-04 18:33:50 +01:00
2021-07-30 23:07:14 +02:00
Item {
2020-11-04 18:33:50 +01:00
id: root
2021-07-30 23:07:14 +02:00
property QtObject account: portfolio . current
2021-01-29 10:27:24 +01:00
2021-11-02 11:41:55 +01:00
Connections {
target: portfolio
function onCurrentChanged ( ) {
// The model in this case follows the UI, so we need to have this not very
// declarative code.
// When a new model is offered, copy the UI settings into it.
root . account . secrets . showChangeChain = changeAddresses . checked
root . account . secrets . showUsedAddresses = usedAddresses . checked
}
}
2021-11-09 20:52:58 +01:00
Component.onCompleted: {
root . account . secrets . showChangeChain = changeAddresses . checked
root . account . secrets . showUsedAddresses = usedAddresses . checked
}
2021-11-02 11:41:55 +01:00
2021-07-31 14:16:28 +02:00
Label {
id: walletDetailsLabel
2021-10-30 15:23:43 +02:00
text: qsTr ( "Wallet Details" )
2021-07-31 14:16:28 +02:00
font.pointSize: 18
color: "white"
2021-07-31 17:19:34 +02:00
anchors.horizontalCenter: parent . horizontalCenter
2021-07-30 23:07:14 +02:00
}
2021-05-08 14:40:08 +02:00
2021-11-02 19:32:13 +01:00
Flowee . CloseIcon {
2021-07-30 23:07:14 +02:00
id: closeIcon
2021-07-31 14:16:28 +02:00
anchors.bottom: walletDetailsLabel . bottom
2021-10-29 18:20:42 +02:00
anchors.margins: 6
anchors.right: parent . right
2021-10-30 16:17:02 +02:00
onClicked: accountDetails . state = "showTransactions"
2021-10-29 18:20:42 +02:00
}
2021-07-31 14:16:28 +02:00
2021-10-29 18:20:42 +02:00
RowLayout {
id: nameRow
anchors.top: walletDetailsLabel . bottom
anchors.topMargin: 20
x: 20
width: parent . width - 30
Label {
text: qsTr ( "Name" ) + ":"
2021-07-31 14:16:28 +02:00
}
2021-11-02 19:38:36 +01:00
Flowee . TextField {
2021-10-29 18:20:42 +02:00
id: accountNameEdit
text: root . account . name
onTextEdited: root . account . name = text
Layout.fillWidth: true
2021-10-30 16:12:41 +02:00
focus: true
2021-07-31 14:16:28 +02:00
}
2020-11-04 18:33:50 +01:00
}
2021-07-30 23:07:14 +02:00
2021-07-31 14:16:28 +02:00
Flickable {
2021-10-29 18:20:42 +02:00
id: scrollablePage
anchors.top: nameRow . bottom
anchors.left: parent . left
anchors.right: parent . right
2021-07-31 14:16:28 +02:00
anchors.bottom: parent . bottom
2021-10-29 18:20:42 +02:00
anchors.margins: 10
2021-07-31 14:16:28 +02:00
clip: true
2021-10-29 18:20:42 +02:00
2021-11-03 13:58:31 +01:00
contentHeight: detailsPane . height + 10 + addressesList . height + 10
2021-07-30 23:07:14 +02:00
2021-10-15 20:59:18 +02:00
ColumnLayout {
2021-10-29 18:20:42 +02:00
id: detailsPane
2021-10-15 20:59:18 +02:00
spacing: 10
2021-10-29 18:20:42 +02:00
width: parent . width - 20
x: 10
2021-07-31 14:16:28 +02:00
2021-07-31 17:19:34 +02:00
Label {
2021-11-03 13:58:31 +01:00
text: {
if ( syncIndicator . accountBlockHeight < 1 )
return ""
var time = Pay . formatDateTime ( root . account . lastBlockSynchedTime ) ;
if ( time !== "" )
time = " (" + time + ")" ;
return qsTr ( "Sync Status" ) + ": " + syncIndicator . accountBlockHeight + " / " + syncIndicator . globalPos + time ;
}
2021-07-31 17:19:34 +02:00
}
2021-10-29 18:20:42 +02:00
Label {
id: walletType
font.italic: true
text: {
if ( root . account . isSingleAddressAccount )
2021-11-02 17:18:32 +01:00
return qsTr ( "This wallet is a single-address wallet." )
2021-07-31 17:19:34 +02:00
2021-10-29 18:20:42 +02:00
if ( root . account . isHDWallet )
2021-11-09 21:34:40 +01:00
return qsTr ( "This wallet is based on a HD seed-phrase" )
2021-10-29 18:20:42 +02:00
// ok we only have one more type so far, so this is rather simple...
2021-11-02 17:18:32 +01:00
return qsTr ( "This wallet is a simple multiple-address wallet." )
2021-10-29 18:20:42 +02:00
}
}
/* TODO, features to add;
2021-07-31 14:16:28 +02:00
Label {
text: qsTr("Security:")
Layout.columnSpan: 3
font.italic: true
}
2021-10-29 18:20:42 +02:00
2021-11-02 19:35:38 +01:00
Flowee.CheckBox {
2021-07-31 14:16:28 +02:00
id: schnorr
checked: true
text: qsTr("Use Schnorr signatures");
}
2021-11-02 19:35:38 +01:00
Flowee.CheckBox {
2021-07-31 14:16:28 +02:00
id: pinToTray
checked: false
text: qsTr("Pin to Pay");
}
2021-11-02 19:35:38 +01:00
Flowee.CheckBox {
2021-07-31 14:16:28 +02:00
id: pinToOpen
checked: false
text: qsTr("Pin to Open");
}
2021-11-02 19:35:38 +01:00
Flowee.CheckBox {
2021-07-31 14:16:28 +02:00
id: syncOnStart
checked: false
text: qsTr("Sync on Start");
}
2021-11-02 19:35:38 +01:00
Flowee.CheckBox {
2021-07-31 14:16:28 +02:00
id: useIndexServer
checked: false
2021-10-15 20:59:18 +02:00
text: qsTr("Use Indexing Server");
2021-07-31 14:16:28 +02:00
}
2021-10-29 18:20:42 +02:00
*/
2021-07-31 14:16:28 +02:00
}
2021-11-02 19:38:36 +01:00
Flowee . GroupBox {
2021-10-29 18:20:42 +02:00
id: addressesList
2021-07-31 14:16:28 +02:00
width: parent . width
2021-10-29 18:20:42 +02:00
anchors.top: detailsPane . bottom
anchors.topMargin: 10
title: qsTr ( "Address List" )
2021-10-30 15:23:43 +02:00
collapsed: ! root . account . isSingleAddressAccount
2021-07-31 14:16:28 +02:00
2021-11-02 19:35:38 +01:00
Flowee . CheckBox {
2021-11-02 11:41:55 +01:00
id: changeAddresses
2021-10-29 18:20:42 +02:00
text: qsTr ( "Change Addresses" )
2021-11-01 18:51:10 +01:00
visible: root . account . isHDWallet
2021-11-02 11:41:55 +01:00
onClicked: root . account . secrets . showChangeChain = checked
2021-11-09 21:34:40 +01:00
tooltipText: qsTr ( "Switches between addresses others can pay you on, and addresses the wallet uses to send change back to yourself." )
2021-10-29 18:20:42 +02:00
}
2021-11-02 19:35:38 +01:00
Flowee . CheckBox {
2021-11-02 11:41:55 +01:00
id: usedAddresses
2021-10-29 18:20:42 +02:00
text: qsTr ( "Used Addresses" ) ;
2021-11-01 18:51:10 +01:00
visible: ! root . account . isSingleAddressAccount
2021-11-02 11:41:55 +01:00
onClicked: root . account . secrets . showUsedAddresses = checked
2021-11-09 21:34:40 +01:00
tooltipText: qsTr ( "Switches between unused and used Bitcoin addresses" )
2021-10-29 18:20:42 +02:00
}
ListView {
model: root . account . secrets
Layout.fillWidth: true
2021-10-30 15:23:43 +02:00
implicitHeight: root . account . isSingleAddressAccount ? contentHeight : scrollablePage . height / 10 * 7
2021-10-29 18:20:42 +02:00
clip: true
delegate: Rectangle {
id: delegateRoot
color: ( index % 2 ) == 0 ? mainWindow.palette.base : mainWindow . palette . alternateBase
width: ListView . view . width
height: addressLabel . height + 10 + amountLabel . height + 10
2021-07-31 14:16:28 +02:00
Label {
2021-10-29 18:20:42 +02:00
text: hdIndex
anchors.baseline: addressLabel . baseline
anchors.right: addressLabel . left
anchors.rightMargin: 10
visible: root . account . isHDWallet
2021-07-31 14:16:28 +02:00
}
2021-10-29 18:20:42 +02:00
LabelWithClipboard {
id: addressLabel
y: 5
x: root . account . isHDWallet ? 50 : 0
text: address
}
2021-07-31 14:16:28 +02:00
2021-11-03 13:45:26 +01:00
Flowee . BitcoinAmountLabel {
2021-10-29 18:20:42 +02:00
id: amountLabel
value: balance
anchors.right: parent . right
anchors.bottom: parent . bottom
anchors.bottomMargin: 12
}
Label {
2021-10-30 15:23:43 +02:00
id: coinCountLabel
2021-10-29 18:20:42 +02:00
anchors.left: parent . left
anchors.leftMargin: delegateRoot . width / 4
anchors.baseline: amountLabel . baseline
2021-10-30 15:23:43 +02:00
text: qsTr ( "Coins: %1 / %2" ) . arg ( numCoins ) . arg ( historicalCoinCount )
}
Label {
id: schnorrIndicator
anchors.left: coinCountLabel . right
anchors.leftMargin: 10
anchors.baseline: amountLabel . baseline
visible: usedSchnorr
text: "ⓢ"
MouseArea {
id: mousy
anchors.fill: parent
anchors.margins: - 10
hoverEnabled: true
ToolTip {
parent: schnorrIndicator
text: qsTr ( "Signed with Schnorr signatures in the past" )
delay: 700
visible: mousy . containsMouse
}
}
2021-10-29 18:20:42 +02:00
}
2021-07-31 17:19:34 +02:00
2021-10-29 18:20:42 +02:00
ConfigItem {
id: button
anchors.right: parent . right
wide: true
2021-11-10 13:05:07 +01:00
y: 5
2021-10-30 16:29:48 +02:00
contextMenu: Menu {
id: contextMenu
MenuItem {
text: qsTr ( "Copy Address" )
2021-11-10 10:50:16 +01:00
onTriggered: Pay . copyToClipboard ( address )
2021-10-30 16:29:48 +02:00
}
MenuItem {
text: qsTr ( "Copy Private Key" )
2021-11-10 10:50:16 +01:00
onTriggered: Pay . copyToClipboard ( privatekey )
2021-10-30 16:29:48 +02:00
}
/*
2021-10-29 18:20:42 +02:00
MenuItem {
text: qsTr("Move to New Wallet")
onTriggered: ;
} */
2021-07-31 17:19:34 +02:00
}
2021-07-31 14:16:28 +02:00
}
}
}
}
2021-11-02 19:38:36 +01:00
Flowee . GroupBox {
2021-10-30 16:12:41 +02:00
id: hdDetails
width: parent . width
anchors.top: addressesList . bottom
anchors.topMargin: 10
title: qsTr ( "Backup details" )
visible: root . account . isHDWallet
collapsed: true
Item {
width: parent . width
implicitHeight: grid . height + helpText . height + warningText . height + 20
GridLayout {
id: grid
width: parent . width
columns: 2
Label {
2021-11-09 21:34:40 +01:00
text: qsTr ( "Seed-phrase" ) + ":"
2021-10-30 16:12:41 +02:00
}
2021-11-01 18:51:10 +01:00
TextArea {
2021-10-30 16:12:41 +02:00
readOnly: true
text: root . account . mnemonic
Layout.fillWidth: true
2021-11-01 18:51:10 +01:00
selectByMouse: true
mouseSelectionMode: TextEdit . SelectWords
wrapMode: TextEdit . WordWrap
padding: 0
2021-10-30 16:12:41 +02:00
}
Label {
text: qsTr ( "Derivation" ) + ":"
}
LabelWithClipboard {
text: root . account . hdDerivationPath
}
}
Label {
id: helpText
width: parent . width
anchors.top: grid . bottom
anchors.topMargin: 10
2021-11-09 21:34:40 +01:00
text: qsTr ( "Please save the seed-phrase on paper, in the right order, with the derivation path. This seed will allow you to recover your wallet in case of computer failure." )
2021-10-30 16:12:41 +02:00
textFormat: Text . StyledText
wrapMode: Text . WrapAtWordBoundaryOrAnywhere
}
Label {
id: warningText
width: parent . width
anchors.top: helpText . bottom
anchors.topMargin: 10
2021-11-09 21:34:40 +01:00
text: qsTr ( "<b>Important</b>: Never share your seed-phrase with others!" )
2021-10-30 16:12:41 +02:00
textFormat: Text . StyledText
wrapMode: Text . WrapAtWordBoundaryOrAnywhere
}
}
}
2021-07-31 14:16:28 +02:00
}
2020-11-04 18:33:50 +01:00
}