2024-01-27 19:12:09 +00:00
|
|
|
// Copyright (c) 2014-2024, The Monero Project
|
2015-04-01 08:56:05 +00:00
|
|
|
//
|
|
|
|
// All rights reserved.
|
|
|
|
//
|
|
|
|
// Redistribution and use in source and binary forms, with or without modification, are
|
|
|
|
// permitted provided that the following conditions are met:
|
|
|
|
//
|
|
|
|
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
|
|
|
// conditions and the following disclaimer.
|
|
|
|
//
|
|
|
|
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
|
|
|
// of conditions and the following disclaimer in the documentation and/or other
|
|
|
|
// materials provided with the distribution.
|
|
|
|
//
|
|
|
|
// 3. Neither the name of the copyright holder nor the names of its contributors may be
|
|
|
|
// used to endorse or promote products derived from this software without specific
|
|
|
|
// prior written permission.
|
|
|
|
//
|
|
|
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
|
|
|
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
|
|
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
|
|
|
|
// THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
|
|
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
|
|
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
|
|
|
|
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
2019-04-11 01:17:29 +00:00
|
|
|
import QtQuick 2.9
|
2019-04-05 16:49:37 +00:00
|
|
|
import QtQuick.Controls 2.0
|
2017-03-08 20:39:12 +00:00
|
|
|
import QtQuick.Layouts 1.1
|
2019-02-01 18:53:01 +00:00
|
|
|
import QtQuick.Dialogs 1.2
|
2019-04-11 01:17:29 +00:00
|
|
|
|
2018-12-12 21:31:24 +00:00
|
|
|
import "../components" as MoneroComponents
|
2019-04-11 01:17:29 +00:00
|
|
|
import "../components/effects/" as MoneroEffects
|
|
|
|
|
2019-02-01 18:53:01 +00:00
|
|
|
import "../js/TxUtils.js" as TxUtils
|
2016-12-10 01:01:04 +00:00
|
|
|
import moneroComponents.AddressBook 1.0
|
|
|
|
import moneroComponents.AddressBookModel 1.0
|
2018-12-12 21:31:24 +00:00
|
|
|
import moneroComponents.Clipboard 1.0
|
2019-02-24 21:25:11 +00:00
|
|
|
import moneroComponents.NetworkType 1.0
|
2019-04-05 16:49:37 +00:00
|
|
|
import FontAwesome 1.0
|
2014-07-07 17:08:30 +00:00
|
|
|
|
2019-04-05 16:49:37 +00:00
|
|
|
Rectangle {
|
2016-12-10 01:01:04 +00:00
|
|
|
id: root
|
2019-04-05 16:49:37 +00:00
|
|
|
color: "transparent"
|
2019-05-07 05:19:40 +00:00
|
|
|
property alias addressbookHeight: mainLayout.height
|
2019-01-15 16:48:22 +00:00
|
|
|
property bool selectAndSend: false
|
2019-04-05 16:49:37 +00:00
|
|
|
property bool editEntry: false
|
|
|
|
|
2018-12-12 21:31:24 +00:00
|
|
|
Clipboard { id: clipboard }
|
2014-07-09 14:18:48 +00:00
|
|
|
|
2017-08-08 09:18:15 +00:00
|
|
|
ColumnLayout {
|
2019-04-05 16:49:37 +00:00
|
|
|
id: mainLayout
|
2019-09-05 22:11:12 +00:00
|
|
|
anchors.margins: 20
|
2019-04-25 19:09:23 +00:00
|
|
|
anchors.topMargin: 40
|
2019-04-05 16:49:37 +00:00
|
|
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
2019-04-25 19:09:23 +00:00
|
|
|
spacing: 20
|
2019-04-05 16:49:37 +00:00
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
id: addressBookEmptyLayout
|
|
|
|
visible: addressBookListView.count == 0
|
|
|
|
spacing: 0
|
2018-12-12 21:31:24 +00:00
|
|
|
Layout.fillWidth: true
|
2019-04-05 16:49:37 +00:00
|
|
|
|
2019-11-27 12:09:50 +00:00
|
|
|
Text {
|
2019-04-05 16:49:37 +00:00
|
|
|
id: titleLabel
|
|
|
|
Layout.fillWidth: true
|
|
|
|
color: MoneroComponents.Style.defaultFontColor
|
|
|
|
font.family: MoneroComponents.Style.fontRegular.name
|
2019-04-25 19:09:23 +00:00
|
|
|
font.pixelSize: 32
|
2019-04-05 16:49:37 +00:00
|
|
|
horizontalAlignment: TextInput.AlignLeft
|
|
|
|
wrapMode: Text.WordWrap;
|
|
|
|
leftPadding: 0
|
|
|
|
topPadding: 0
|
|
|
|
text: qsTr("Save your most used addresses here") + translationManager.emptyString
|
|
|
|
width: parent.width
|
2019-02-24 21:25:11 +00:00
|
|
|
}
|
2019-04-05 16:49:37 +00:00
|
|
|
|
2019-11-27 12:09:50 +00:00
|
|
|
Text {
|
2019-04-05 16:49:37 +00:00
|
|
|
Layout.fillWidth: true
|
2019-04-11 01:17:29 +00:00
|
|
|
color: MoneroComponents.Style.dimmedFontColor
|
2019-04-05 16:49:37 +00:00
|
|
|
font.family: MoneroComponents.Style.fontRegular.name
|
2019-04-25 19:09:23 +00:00
|
|
|
font.pixelSize: 16
|
2019-04-05 16:49:37 +00:00
|
|
|
horizontalAlignment: TextInput.AlignLeft
|
|
|
|
wrapMode: Text.WordWrap;
|
|
|
|
leftPadding: 0
|
|
|
|
topPadding: 0
|
|
|
|
text: qsTr("This makes it easier to send or receive Monero and reduces errors when typing in addresses manually.") + translationManager.emptyString
|
|
|
|
width: parent.width
|
2019-02-01 18:53:01 +00:00
|
|
|
}
|
2019-04-05 16:49:37 +00:00
|
|
|
|
|
|
|
MoneroComponents.StandardButton {
|
|
|
|
id: addFirstEntryButton
|
|
|
|
Layout.topMargin: 20
|
2021-11-20 18:38:29 +00:00
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
small: true
|
2019-04-05 16:49:37 +00:00
|
|
|
text: qsTr("Add an address") + translationManager.emptyString
|
|
|
|
onClicked: {
|
|
|
|
root.showAddAddress();
|
|
|
|
}
|
2017-08-08 09:18:15 +00:00
|
|
|
}
|
|
|
|
}
|
2014-07-16 08:24:59 +00:00
|
|
|
|
2019-04-05 16:49:37 +00:00
|
|
|
ColumnLayout {
|
|
|
|
id: addressBookLayout
|
|
|
|
visible: addressBookListView.count >= 1
|
|
|
|
spacing: 0
|
|
|
|
|
|
|
|
MoneroComponents.Label {
|
|
|
|
Layout.bottomMargin: 20
|
2019-04-25 19:09:23 +00:00
|
|
|
fontSize: 32
|
2019-04-05 16:49:37 +00:00
|
|
|
text: qsTr("Address book") + translationManager.emptyString
|
|
|
|
}
|
|
|
|
|
2021-11-20 18:38:29 +00:00
|
|
|
MoneroComponents.StandardButton {
|
|
|
|
id: addAddressButton
|
|
|
|
Layout.bottomMargin: 8
|
|
|
|
Layout.alignment: Qt.AlignRight
|
|
|
|
small: true
|
|
|
|
text: qsTr("Add address") + translationManager.emptyString
|
|
|
|
fontSize: 13
|
|
|
|
onClicked: {
|
|
|
|
root.showAddAddress();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-05 16:49:37 +00:00
|
|
|
ColumnLayout {
|
|
|
|
id: addressBookListRow
|
2019-04-25 19:09:23 +00:00
|
|
|
property int addressBookListItemHeight: 50
|
2019-04-05 16:49:37 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.minimumWidth: 240
|
|
|
|
Layout.preferredHeight: addressBookListItemHeight * addressBookListView.count
|
|
|
|
|
|
|
|
ListView {
|
|
|
|
id: addressBookListView
|
|
|
|
Layout.fillWidth: true
|
2019-07-22 19:39:56 +00:00
|
|
|
Layout.fillHeight: true
|
2019-04-05 16:49:37 +00:00
|
|
|
clip: true
|
|
|
|
boundsBehavior: ListView.StopAtBounds
|
|
|
|
interactive: false
|
|
|
|
delegate: Rectangle {
|
|
|
|
id: tableItem2
|
|
|
|
height: addressBookListRow.addressBookListItemHeight
|
2020-09-20 22:47:32 +00:00
|
|
|
width: parent ? parent.width : undefined
|
2019-04-05 16:49:37 +00:00
|
|
|
Layout.fillWidth: true
|
2021-05-22 09:31:05 +00:00
|
|
|
color: itemMouseArea.containsMouse ? MoneroComponents.Style.titleBarButtonHoverColor : "transparent"
|
2019-04-05 16:49:37 +00:00
|
|
|
|
|
|
|
function doSend() {
|
|
|
|
console.log("Sending to: ", address +" "+ paymentId);
|
2021-02-05 15:26:15 +00:00
|
|
|
middlePanel.sendTo(address, paymentId);
|
2019-04-05 16:49:37 +00:00
|
|
|
leftPanel.selectItem(middlePanel.state)
|
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle {
|
2019-04-11 01:17:29 +00:00
|
|
|
color: MoneroComponents.Style.appWindowBorderColor
|
2019-04-05 16:49:37 +00:00
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.top: parent.top
|
|
|
|
height: 1
|
2019-04-11 01:17:29 +00:00
|
|
|
|
|
|
|
MoneroEffects.ColorTransition {
|
|
|
|
targetObj: parent
|
|
|
|
blackColor: MoneroComponents.Style._b_appWindowBorderColor
|
|
|
|
whiteColor: MoneroComponents.Style._w_appWindowBorderColor
|
|
|
|
}
|
2019-04-05 16:49:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
anchors.fill: parent
|
2019-04-25 19:09:23 +00:00
|
|
|
anchors.topMargin: 5
|
2021-06-09 08:30:24 +00:00
|
|
|
anchors.rightMargin: 125
|
2019-04-05 16:49:37 +00:00
|
|
|
color: "transparent"
|
|
|
|
|
|
|
|
MoneroComponents.Label {
|
|
|
|
id: descriptionLabel
|
|
|
|
color: MoneroComponents.Style.defaultFontColor
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
anchors.left: parent.left
|
2019-04-25 19:09:23 +00:00
|
|
|
anchors.leftMargin: 6
|
|
|
|
fontSize: 16
|
2019-04-05 16:49:37 +00:00
|
|
|
text: description
|
|
|
|
elide: Text.ElideRight
|
|
|
|
textWidth: addressLabel.x - descriptionLabel.x - 1
|
|
|
|
}
|
|
|
|
|
|
|
|
MoneroComponents.Label {
|
|
|
|
id: addressLabel
|
|
|
|
color: MoneroComponents.Style.defaultFontColor
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
anchors.left: parent.right
|
2019-04-25 19:09:23 +00:00
|
|
|
anchors.leftMargin: -addressLabel.width - 5
|
2019-04-05 16:49:37 +00:00
|
|
|
|
2019-04-25 19:09:23 +00:00
|
|
|
fontSize: 16
|
2019-04-05 16:49:37 +00:00
|
|
|
fontFamily: MoneroComponents.Style.fontMonoRegular.name;
|
|
|
|
text: TxUtils.addressTruncatePretty(address, mainLayout.width < 540 ? 1 : (mainLayout.width < 700 ? 2 : 3));
|
|
|
|
}
|
|
|
|
|
|
|
|
MouseArea {
|
2021-05-22 09:31:05 +00:00
|
|
|
id: itemMouseArea
|
2019-04-05 16:49:37 +00:00
|
|
|
anchors.fill: parent
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
2021-05-22 09:31:05 +00:00
|
|
|
hoverEnabled: true
|
2019-04-05 16:49:37 +00:00
|
|
|
visible: root.selectAndSend
|
|
|
|
onClicked: {
|
|
|
|
doSend();
|
|
|
|
}
|
2019-02-01 18:53:01 +00:00
|
|
|
}
|
|
|
|
}
|
2019-04-05 16:49:37 +00:00
|
|
|
|
2019-04-11 01:17:29 +00:00
|
|
|
RowLayout {
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
2019-04-05 16:49:37 +00:00
|
|
|
anchors.right: parent.right
|
2019-04-11 01:17:29 +00:00
|
|
|
anchors.rightMargin: 6
|
|
|
|
height: 21
|
|
|
|
spacing: 10
|
|
|
|
|
|
|
|
MoneroComponents.IconButton {
|
|
|
|
id: sendToButton
|
|
|
|
image: "qrc:///images/arrow-right-in-circle-outline-medium-white.svg"
|
|
|
|
color: MoneroComponents.Style.defaultFontColor
|
2021-05-21 01:32:43 +00:00
|
|
|
opacity: isOpenGL ? 0.5 : 1
|
2021-06-02 15:07:01 +00:00
|
|
|
fontAwesomeFallbackIcon: FontAwesome.arrowRight
|
|
|
|
fontAwesomeFallbackSize: 22
|
|
|
|
fontAwesomeFallbackOpacity: 0.5
|
2019-04-11 01:17:29 +00:00
|
|
|
Layout.preferredWidth: 20
|
|
|
|
Layout.preferredHeight: 20
|
2021-05-19 16:36:44 +00:00
|
|
|
tooltip: qsTr("Send to this address") + translationManager.emptyString
|
2021-06-02 15:07:01 +00:00
|
|
|
|
2019-04-11 01:17:29 +00:00
|
|
|
onClicked: {
|
|
|
|
doSend();
|
|
|
|
}
|
2019-04-05 16:49:37 +00:00
|
|
|
}
|
|
|
|
|
2021-06-09 08:30:24 +00:00
|
|
|
MoneroComponents.IconButton {
|
|
|
|
fontAwesomeFallbackIcon: FontAwesome.searchPlus
|
|
|
|
fontAwesomeFallbackSize: 22
|
|
|
|
color: MoneroComponents.Style.defaultFontColor
|
|
|
|
fontAwesomeFallbackOpacity: 0.5
|
|
|
|
Layout.preferredWidth: 23
|
|
|
|
Layout.preferredHeight: 21
|
|
|
|
tooltip: qsTr("See transactions") + translationManager.emptyString
|
|
|
|
|
|
|
|
onClicked: doSearchInHistory(address)
|
|
|
|
}
|
|
|
|
|
2019-04-11 01:17:29 +00:00
|
|
|
MoneroComponents.IconButton {
|
2021-11-19 18:09:44 +00:00
|
|
|
id: editEntryButton
|
2019-04-11 01:17:29 +00:00
|
|
|
image: "qrc:///images/edit.svg"
|
|
|
|
color: MoneroComponents.Style.defaultFontColor
|
2021-05-21 01:32:43 +00:00
|
|
|
opacity: isOpenGL ? 0.5 : 1
|
2021-06-02 15:07:01 +00:00
|
|
|
fontAwesomeFallbackIcon: FontAwesome.edit
|
|
|
|
fontAwesomeFallbackSize: 22
|
|
|
|
fontAwesomeFallbackOpacity: 0.5
|
2019-04-11 01:17:29 +00:00
|
|
|
Layout.preferredWidth: 23
|
|
|
|
Layout.preferredHeight: 21
|
2021-11-19 18:09:44 +00:00
|
|
|
tooltip: qsTr("Edit entry") + translationManager.emptyString
|
2019-04-05 16:49:37 +00:00
|
|
|
|
2019-04-11 01:17:29 +00:00
|
|
|
onClicked: {
|
|
|
|
addressBookListView.currentIndex = index;
|
|
|
|
root.showEditAddress(address, description);
|
|
|
|
}
|
2019-04-05 16:49:37 +00:00
|
|
|
}
|
|
|
|
|
2019-04-11 01:17:29 +00:00
|
|
|
MoneroComponents.IconButton {
|
|
|
|
id: copyButton
|
|
|
|
image: "qrc:///images/copy.svg"
|
|
|
|
color: MoneroComponents.Style.defaultFontColor
|
2021-05-21 01:32:43 +00:00
|
|
|
opacity: isOpenGL ? 0.5 : 1
|
2021-06-02 15:07:01 +00:00
|
|
|
fontAwesomeFallbackIcon: FontAwesome.clipboard
|
|
|
|
fontAwesomeFallbackSize: 22
|
|
|
|
fontAwesomeFallbackOpacity: 0.5
|
|
|
|
Layout.preferredWidth: 16
|
|
|
|
Layout.preferredHeight: 21
|
2021-05-19 16:36:44 +00:00
|
|
|
tooltip: qsTr("Copy address to clipboard") + translationManager.emptyString
|
2019-04-05 16:49:37 +00:00
|
|
|
|
2019-04-11 01:17:29 +00:00
|
|
|
onClicked: {
|
|
|
|
console.log("Address copied to clipboard");
|
|
|
|
clipboard.setText(address);
|
|
|
|
appWindow.showStatusMessage(qsTr("Address copied to clipboard"), 3);
|
|
|
|
}
|
2019-04-05 16:49:37 +00:00
|
|
|
}
|
2019-02-01 18:53:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-04-05 16:49:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle {
|
2019-04-11 01:17:29 +00:00
|
|
|
id: border2
|
|
|
|
color: MoneroComponents.Style.appWindowBorderColor
|
2019-04-05 16:49:37 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
height: 1
|
2019-04-11 01:17:29 +00:00
|
|
|
|
|
|
|
MoneroEffects.ColorTransition {
|
|
|
|
targetObj: border2
|
|
|
|
blackColor: MoneroComponents.Style._b_appWindowBorderColor
|
|
|
|
whiteColor: MoneroComponents.Style._w_appWindowBorderColor
|
|
|
|
}
|
2019-04-05 16:49:37 +00:00
|
|
|
}
|
2017-08-08 09:18:15 +00:00
|
|
|
}
|
2019-04-05 16:49:37 +00:00
|
|
|
ColumnLayout {
|
|
|
|
id: addContactLayout
|
|
|
|
visible: false
|
|
|
|
spacing: 0
|
2016-12-10 01:01:04 +00:00
|
|
|
|
2019-04-05 16:49:37 +00:00
|
|
|
MoneroComponents.Label {
|
2019-04-25 19:09:23 +00:00
|
|
|
fontSize: 32
|
2019-04-05 16:49:37 +00:00
|
|
|
wrapMode: Text.WordWrap
|
2020-09-20 22:41:02 +00:00
|
|
|
text: (root.editEntry ? qsTr("Edit entry") : qsTr("Add an address")) + translationManager.emptyString
|
2019-04-05 16:49:37 +00:00
|
|
|
}
|
2017-03-08 20:39:12 +00:00
|
|
|
|
2019-04-05 16:49:37 +00:00
|
|
|
MoneroComponents.LineEditMulti {
|
|
|
|
id: addressLine
|
2020-09-20 22:41:02 +00:00
|
|
|
visible: !root.editEntry
|
2019-04-05 16:49:37 +00:00
|
|
|
Layout.topMargin: 20
|
2021-06-17 11:24:16 +00:00
|
|
|
KeyNavigation.backtab: deleteButton.visible ? deleteButton: cancelButton
|
|
|
|
KeyNavigation.tab: resolveButton.visible ? resolveButton : descriptionLine
|
2019-12-08 21:06:31 +00:00
|
|
|
labelText: "<style type='text/css'>a {text-decoration: none; color: #858585; font-size: 14px;}</style> %1"
|
|
|
|
.arg(qsTr("Address")) + translationManager.emptyString
|
2019-04-05 16:49:37 +00:00
|
|
|
placeholderText: {
|
|
|
|
if(persistentSettings.nettype == NetworkType.MAINNET){
|
2021-09-20 11:50:32 +00:00
|
|
|
return "4.. / 8.. / monero:.. / OpenAlias";
|
2019-04-05 16:49:37 +00:00
|
|
|
} else if (persistentSettings.nettype == NetworkType.STAGENET){
|
2021-09-20 11:50:32 +00:00
|
|
|
return "5.. / 7.. / monero:..";
|
2019-04-05 16:49:37 +00:00
|
|
|
} else if(persistentSettings.nettype == NetworkType.TESTNET){
|
2021-09-20 11:50:32 +00:00
|
|
|
return "9.. / B.. / monero:..";
|
2019-04-05 16:49:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
wrapMode: Text.WrapAnywhere
|
|
|
|
addressValidation: true
|
2021-11-20 18:38:29 +00:00
|
|
|
pasteButton: false
|
2019-11-08 00:56:10 +00:00
|
|
|
onTextChanged: {
|
|
|
|
const parsed = walletManager.parse_uri_to_object(addressLine.text);
|
2019-04-05 16:49:37 +00:00
|
|
|
if (!parsed.error) {
|
|
|
|
addressLine.text = parsed.address;
|
|
|
|
descriptionLine.text = parsed.tx_description;
|
|
|
|
}
|
|
|
|
}
|
2021-06-17 11:24:16 +00:00
|
|
|
onEnterPressed: addButton.enabled ? addButton.clicked() : ""
|
|
|
|
onReturnPressed: addButton.enabled ? addButton.clicked() : ""
|
2019-04-11 01:17:29 +00:00
|
|
|
|
2021-07-23 04:46:48 +00:00
|
|
|
MoneroComponents.InlineButton {
|
|
|
|
fontFamily: FontAwesome.fontFamilySolid
|
|
|
|
fontStyleName: "Solid"
|
|
|
|
fontPixelSize: 18
|
|
|
|
text: FontAwesome.desktop
|
|
|
|
tooltip: qsTr("Grab QR code from screen") + translationManager.emptyString
|
|
|
|
onClicked: {
|
|
|
|
clearFields();
|
|
|
|
const codes = oshelper.grabQrCodesFromScreen();
|
|
|
|
for (var index = 0; index < codes.length; ++index) {
|
|
|
|
const parsed = walletManager.parse_uri_to_object(codes[index]);
|
|
|
|
if (!parsed.error) {
|
|
|
|
addressLine.text = parsed.address
|
|
|
|
descriptionLine.text = parsed.recipient_name
|
|
|
|
break;
|
|
|
|
} else if (walletManager.addressValid(codes[index], appWindow.persistentSettings.nettype)) {
|
|
|
|
addressLine.text = codes[index];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-24 08:05:14 +00:00
|
|
|
MoneroComponents.InlineButton {
|
|
|
|
buttonColor: MoneroComponents.Style.orange
|
|
|
|
fontFamily: FontAwesome.fontFamily
|
|
|
|
text: FontAwesome.qrcode
|
|
|
|
visible : appWindow.qrScannerEnabled && !addressLine.text
|
|
|
|
onClicked: {
|
|
|
|
cameraUi.state = "Capture"
|
|
|
|
cameraUi.qrcode_decoded.connect(root.updateFromQrCode)
|
|
|
|
}
|
2019-04-05 16:49:37 +00:00
|
|
|
}
|
|
|
|
}
|
2017-08-08 09:18:15 +00:00
|
|
|
|
2019-04-05 16:49:37 +00:00
|
|
|
MoneroComponents.StandardButton {
|
|
|
|
id: resolveButton
|
2021-06-17 11:24:16 +00:00
|
|
|
KeyNavigation.backtab: addressLine
|
|
|
|
KeyNavigation.tab: descriptionLine
|
2019-04-05 16:49:37 +00:00
|
|
|
Layout.topMargin: 10
|
|
|
|
text: qsTr("Resolve") + translationManager.emptyString
|
|
|
|
visible: TxUtils.isValidOpenAliasAddress(addressLine.text)
|
|
|
|
enabled : visible
|
2017-08-08 09:18:15 +00:00
|
|
|
onClicked: {
|
2023-04-21 12:45:09 +00:00
|
|
|
const response = TxUtils.handleOpenAliasResolution(addressLine.text, descriptionLine.text);
|
|
|
|
if (response) {
|
|
|
|
if (response.message) {
|
|
|
|
oa_message(response.message);
|
|
|
|
}
|
|
|
|
if (response.address) {
|
|
|
|
addressLine.text = response.address;
|
|
|
|
}
|
|
|
|
if (response.description) {
|
|
|
|
descriptionLine.text = response.description;
|
2019-04-05 16:49:37 +00:00
|
|
|
}
|
2017-08-08 09:18:15 +00:00
|
|
|
}
|
2017-03-08 20:39:12 +00:00
|
|
|
}
|
2016-12-10 01:01:04 +00:00
|
|
|
}
|
2014-07-16 14:48:17 +00:00
|
|
|
|
2021-06-17 11:24:16 +00:00
|
|
|
MoneroComponents.LineEdit {
|
2019-04-05 16:49:37 +00:00
|
|
|
id: descriptionLine
|
2021-06-17 11:24:16 +00:00
|
|
|
KeyNavigation.backtab: resolveButton.visible ? resolveButton : addressLine
|
|
|
|
KeyNavigation.tab: addButton.enabled ? addButton : cancelButton
|
2019-04-05 16:49:37 +00:00
|
|
|
Layout.topMargin: 20
|
2021-06-17 11:24:16 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
fontSize: 16
|
|
|
|
placeholderFontSize: 16
|
2019-12-08 21:06:31 +00:00
|
|
|
labelText: "<style type='text/css'>a {text-decoration: none; color: #858585; font-size: 14px;}</style> %1"
|
|
|
|
.arg(qsTr("Description")) + translationManager.emptyString
|
2019-04-05 16:49:37 +00:00
|
|
|
placeholderText: qsTr("Add a name...") + translationManager.emptyString
|
2021-06-17 11:24:16 +00:00
|
|
|
onAccepted: addButton.enabled ? addButton.clicked() : ""
|
2019-04-05 16:49:37 +00:00
|
|
|
}
|
|
|
|
RowLayout {
|
|
|
|
Layout.topMargin: 20
|
2021-11-20 18:38:29 +00:00
|
|
|
Layout.alignment: Qt.AlignRight
|
|
|
|
|
|
|
|
MoneroComponents.StandardButton {
|
|
|
|
id: cancelButton
|
|
|
|
KeyNavigation.backtab: addButton
|
|
|
|
KeyNavigation.tab: deleteButton.visible ? deleteButton : addressLine
|
|
|
|
small: true
|
|
|
|
text: qsTr("Cancel") + translationManager.emptyString
|
|
|
|
primary: false
|
|
|
|
onClicked: root.showAddressBook();
|
|
|
|
}
|
|
|
|
|
|
|
|
MoneroComponents.StandardButton {
|
|
|
|
id: deleteButton
|
|
|
|
KeyNavigation.backtab: cancelButton
|
|
|
|
KeyNavigation.tab: addressLine
|
|
|
|
small: true
|
|
|
|
visible: root.editEntry
|
|
|
|
text: qsTr("Delete") + translationManager.emptyString
|
|
|
|
primary: false
|
|
|
|
onClicked: {
|
|
|
|
currentWallet.addressBook.deleteRow(addressBookListView.currentIndex);
|
|
|
|
root.showAddressBook();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-05 16:49:37 +00:00
|
|
|
MoneroComponents.StandardButton {
|
|
|
|
id: addButton
|
2021-06-17 11:24:16 +00:00
|
|
|
KeyNavigation.backtab: descriptionLine
|
|
|
|
KeyNavigation.tab: cancelButton
|
2021-11-20 18:38:29 +00:00
|
|
|
small: true
|
2019-04-05 16:49:37 +00:00
|
|
|
text: (root.editEntry ? qsTr("Save") : qsTr("Add")) + translationManager.emptyString
|
|
|
|
enabled: root.checkInformation(addressLine.text, appWindow.persistentSettings.nettype)
|
|
|
|
onClicked: {
|
2022-03-16 12:39:59 +00:00
|
|
|
if (!root.editEntry) {
|
|
|
|
if (currentWallet.addressBook.addRow(addressLine.text.trim(),"", descriptionLine.text)) {
|
|
|
|
console.log("Entry added")
|
|
|
|
} else {
|
|
|
|
informationPopup.title = qsTr("Error") + translationManager.emptyString;
|
|
|
|
// TODO: check currentWallet.addressBook.errorString() instead.
|
|
|
|
if (currentWallet.addressBook.errorCode() === AddressBook.Invalid_Address)
|
|
|
|
informationPopup.text = qsTr("Invalid address") + translationManager.emptyString
|
|
|
|
else if (currentWallet.addressBook.errorCode() === AddressBook.Invalid_Payment_Id)
|
|
|
|
informationPopup.text = currentWallet.addressBook.errorString()
|
|
|
|
else
|
|
|
|
informationPopup.text = qsTr("Can't create entry") + translationManager.emptyString
|
|
|
|
|
|
|
|
informationPopup.onCloseCallback = null
|
|
|
|
informationPopup.open();
|
|
|
|
}
|
2019-04-05 16:49:37 +00:00
|
|
|
} else {
|
2020-09-20 22:41:02 +00:00
|
|
|
currentWallet.addressBook.setDescription(addressBookListView.currentIndex, descriptionLine.text);
|
2022-03-16 12:39:59 +00:00
|
|
|
console.log("Description edited")
|
2019-04-05 16:49:37 +00:00
|
|
|
}
|
2020-09-20 22:41:02 +00:00
|
|
|
root.showAddressBook()
|
2019-04-05 16:49:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-07-16 08:24:59 +00:00
|
|
|
}
|
|
|
|
}
|
2016-12-10 01:01:04 +00:00
|
|
|
|
2019-04-05 16:49:37 +00:00
|
|
|
function checkInformation(address, nettype) {
|
|
|
|
address = address.trim()
|
|
|
|
var address_ok = walletManager.addressValid(address, nettype)
|
|
|
|
addressLine.error = !address_ok
|
|
|
|
return address_ok
|
|
|
|
}
|
2016-12-10 01:01:04 +00:00
|
|
|
|
2019-04-05 16:49:37 +00:00
|
|
|
function clearFields() {
|
|
|
|
addressLine.text = "";
|
|
|
|
descriptionLine.text = "";
|
|
|
|
}
|
2016-12-10 01:01:04 +00:00
|
|
|
|
2019-04-05 16:49:37 +00:00
|
|
|
function showAddressBook() {
|
|
|
|
addressBookEmptyLayout.visible = addressBookListView.count == 0
|
|
|
|
addressBookLayout.visible = addressBookListView.count >= 1;
|
|
|
|
addContactLayout.visible = false;
|
|
|
|
clearFields();
|
2016-12-10 01:01:04 +00:00
|
|
|
}
|
|
|
|
|
2019-04-05 16:49:37 +00:00
|
|
|
function showAddAddress() {
|
|
|
|
root.editEntry = false;
|
|
|
|
addressBookEmptyLayout.visible = false
|
|
|
|
addressBookLayout.visible = false;
|
|
|
|
addContactLayout.visible = true;
|
2021-06-17 11:24:16 +00:00
|
|
|
addressLine.forceActiveFocus();
|
2019-01-15 16:48:22 +00:00
|
|
|
}
|
|
|
|
|
2019-04-05 16:49:37 +00:00
|
|
|
function showEditAddress(address, description) {
|
|
|
|
//TODO: real contact editing, requires API change
|
|
|
|
root.editEntry = true;
|
|
|
|
addressBookEmptyLayout.visible = false
|
|
|
|
addressBookLayout.visible = false;
|
|
|
|
addContactLayout.visible = true;
|
|
|
|
addressLine.text = address;
|
|
|
|
descriptionLine.text = description;
|
2021-06-17 11:24:16 +00:00
|
|
|
addressLine.forceActiveFocus();
|
|
|
|
addressLine.cursorPosition = addressLine.text.length;
|
2016-12-10 01:01:04 +00:00
|
|
|
}
|
|
|
|
|
2017-01-31 04:36:08 +00:00
|
|
|
function updateFromQrCode(address, payment_id, amount, tx_description, recipient_name) {
|
|
|
|
console.log("updateFromQrCode")
|
|
|
|
addressLine.text = address
|
2021-07-23 04:46:48 +00:00
|
|
|
descriptionLine.text = recipient_name
|
2017-01-31 04:36:08 +00:00
|
|
|
cameraUi.qrcode_decoded.disconnect(updateFromQrCode)
|
|
|
|
}
|
2016-12-10 01:01:04 +00:00
|
|
|
|
2019-02-01 18:53:01 +00:00
|
|
|
function oa_message(text) {
|
|
|
|
oaPopup.title = qsTr("OpenAlias error") + translationManager.emptyString
|
|
|
|
oaPopup.text = text
|
|
|
|
oaPopup.icon = StandardIcon.Information
|
|
|
|
oaPopup.onCloseCallback = null
|
|
|
|
oaPopup.open()
|
|
|
|
}
|
|
|
|
|
|
|
|
MoneroComponents.StandardDialog {
|
|
|
|
// dynamically change onclose handler
|
|
|
|
property var onCloseCallback
|
|
|
|
id: oaPopup
|
|
|
|
cancelVisible: false
|
2019-04-05 16:49:37 +00:00
|
|
|
onAccepted: {
|
2019-02-01 18:53:01 +00:00
|
|
|
if (onCloseCallback) {
|
|
|
|
onCloseCallback()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-04-05 16:49:37 +00:00
|
|
|
function onPageCompleted() {
|
|
|
|
console.log("adress book");
|
|
|
|
addressBookListView.model = currentWallet.addressBookModel;
|
|
|
|
showAddressBook();
|
|
|
|
}
|
|
|
|
|
|
|
|
function onPageClosed() {
|
|
|
|
root.selectAndSend = false;
|
|
|
|
root.editEntry = false;
|
|
|
|
clearFields();
|
|
|
|
}
|
2014-07-07 17:08:30 +00:00
|
|
|
}
|