2020-11-04 18:33:50 +01:00
/*
* This file is part of the Flowee project
2022-06-19 23:41:06 +02:00
* Copyright (C) 2021-2022 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-11-30 22:19:40 +01:00
focus: true
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.
2022-06-24 15:38:25 +02:00
if ( root . account . isDecrypted ) {
root . account . secrets . showChangeChain = changeAddresses . checked
root . account . secrets . showUsedAddresses = usedAddresses . checked
}
2021-11-02 11:41:55 +01:00
}
}
2021-11-09 20:52:58 +01:00
Component.onCompleted: {
2022-06-24 15:38:25 +02:00
if ( root . account . isDecrypted ) {
root . account . secrets . showChangeChain = changeAddresses . checked
root . account . secrets . showUsedAddresses = usedAddresses . checked
}
2021-11-09 20:52:58 +01:00
}
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
2022-05-18 15:44:28 +02:00
onClicked: accountOverlay . state = "showTransactions"
2021-10-29 18:20:42 +02:00
}
2021-07-31 14:16:28 +02:00
2022-06-24 15:38:25 +02:00
GridLayout {
id: basicProperties
2021-10-29 18:20:42 +02:00
anchors.top: walletDetailsLabel . bottom
anchors.topMargin: 20
x: 20
width: parent . width - 30
2022-06-24 15:38:25 +02:00
columns: 2
rowSpacing: 10
2021-10-29 18:20:42 +02:00
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
}
2022-06-24 15:38:25 +02:00
Label {
id: encLabel
text: qsTr ( "Encryption" ) + ":"
visible: encStatus . visible
}
WalletEncryptionStatus {
id: encStatus
Layout.fillWidth: true
account: root . account
}
2021-07-30 23:07:14 +02:00
2022-07-14 20:48:05 +02:00
Label {
id: pwdLabel
2022-07-21 16:09:08 +02:00
text: qsTr ( "Password" ) + ":"
2022-07-14 20:48:05 +02:00
visible: encStatus . visible
}
Flowee . TextField {
id: passwordField
onAccepted: decryptButton . clicked ( )
enabled: ! root . account . isDecrypted
Layout.fillWidth: true
2022-07-21 16:09:08 +02:00
echoMode: TextInput . Password
2022-07-14 20:48:05 +02:00
visible: pwdLabel . visible
}
Item {
visible: pwdLabel . visible
Layout.fillWidth: true
Layout.columnSpan: 2
implicitHeight: Math . max ( decryptWarning . implicitHeight , decryptButton . implicitHeight )
Flowee . WarningLabel {
id: decryptWarning
anchors.left: parent . left
anchors.leftMargin: 20
anchors.right: decryptButton . left
anchors.rightMargin: 10
}
Flowee . Button {
id: decryptButton
anchors.right: parent . right
text: qsTr ( "Open" )
enabled: passwordField . text . length > 3
onClicked: {
var rc = root . account . decrypt ( passwordField . text ) ;
if ( rc ) {
// decrypt went Ok
decryptWarning . text = ""
passwordField . text = ""
}
else {
decryptWarning . text = qsTr ( "Invalid PIN" )
passwordField . forceActiveFocus ( ) ;
}
}
}
}
}
2022-06-24 15:38:25 +02:00
2021-07-31 14:16:28 +02:00
Flickable {
2021-10-29 18:20:42 +02:00
id: scrollablePage
2022-06-24 15:38:25 +02:00
anchors.top: basicProperties . bottom
2021-10-29 18:20:42 +02:00
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: {
2022-04-06 20:58:47 +02:00
var height = root . account . lastBlockSynched
if ( height < 1 )
2021-11-03 13:58:31 +01:00
return ""
var time = Pay . formatDateTime ( root . account . lastBlockSynchedTime ) ;
if ( time !== "" )
time = " (" + time + ")" ;
2022-04-06 20:58:47 +02:00
return qsTr ( "Sync Status" ) + ": " + height + " / " + Pay . chainHeight + time ;
2021-11-03 13:58:31 +01:00
}
2021-07-31 17:19:34 +02:00
}
2021-10-29 18:20:42 +02:00
Label {
id: walletType
2022-07-14 20:48:05 +02:00
visible: root . account . isDecrypted || root . account . needsPinToPay
2021-10-29 18:20:42 +02:00
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: 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
2022-07-11 22:08:43 +02:00
visible: root . account . isDecrypted || ! root . account . needsPinToOpen
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 {
2021-11-30 22:19:40 +01:00
id: historyView
2021-10-29 18:20:42 +02:00
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-11-30 13:54:11 +01:00
Flowee . LabelWithClipboard {
2021-10-29 18:20:42 +02:00
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
2022-07-11 22:08:43 +02:00
property QtObject copyAddress: Action {
2022-06-19 23:41:06 +02:00
text: qsTr ( "Copy Address" )
onTriggered: Pay . copyToClipboard ( address )
2021-07-31 17:19:34 +02:00
}
2022-07-11 22:08:43 +02:00
property QtObject copyPrivKey: Action {
2022-06-19 23:41:06 +02:00
text: qsTr ( "Copy Private Key" )
onTriggered: Pay . copyToClipboard ( privatekey )
}
/*
Action {
text: qsTr("Move to New Wallet")
onTriggered: ;
} */
2022-07-11 22:08:43 +02:00
onAboutToOpen: {
var items = [ ] ;
items . push ( copyAddress ) ;
if ( root . account . isDecrypted )
items . push ( copyPrivKey ) ;
setMenuActions ( items )
}
2021-07-31 14:16:28 +02:00
}
}
2021-11-30 22:19:40 +01:00
ScrollBar.vertical: Flowee . ScrollThumb {
id: thumb
minimumSize: 20 / activityView . height
visible: size < 0.9
}
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" )
2022-07-14 20:48:05 +02:00
visible: root . account . isHDWallet
2021-10-30 16:12:41 +02:00
collapsed: true
Item {
width: parent . width
2022-07-14 20:48:05 +02:00
implicitHeight: {
if ( root . account . isDecrypted )
return grid . height + helpText . height + warningText . height + 20
return infoText . height
}
2021-10-30 16:12:41 +02:00
GridLayout {
id: grid
2022-07-14 20:48:05 +02:00
visible: root . account . isDecrypted
2021-10-30 16:12:41 +02:00
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" ) + ":"
}
2021-11-30 13:54:11 +01:00
Flowee . LabelWithClipboard {
2021-10-30 16:12:41 +02:00
text: root . account . hdDerivationPath
2021-12-14 13:03:38 +01:00
menuText: qsTr ( "Copy" )
2021-10-30 16:12:41 +02:00
}
}
Label {
id: helpText
2022-07-14 20:48:05 +02:00
visible: grid . visible
2021-10-30 16:12:41 +02:00
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
2022-07-14 20:48:05 +02:00
visible: grid . visible
2021-10-30 16:12:41 +02:00
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
}
2022-07-14 20:48:05 +02:00
Label {
id: infoText
visible: ! root . account . isDecrypted
width: parent . width
text: qsTr ( "This wallet is protected by password (pin-to-pay). To see the backup details you need to provide the password." )
textFormat: Text . StyledText
wrapMode: Text . WrapAtWordBoundaryOrAnywhere
}
2021-10-30 16:12:41 +02:00
}
}
2021-07-31 14:16:28 +02:00
}
2021-11-30 22:19:40 +01:00
Keys.forwardTo: Flowee . ListViewKeyHandler {
target: historyView
}
2020-11-04 18:33:50 +01:00
}