2016-06-26 15:04:45 +00:00
|
|
|
// Copyright (c) 2014-2015, The Monero Project
|
2016-10-04 10:15:29 +00:00
|
|
|
//
|
2016-06-26 15:04:45 +00:00
|
|
|
// All rights reserved.
|
2016-10-04 10:15:29 +00:00
|
|
|
//
|
2016-06-26 15:04:45 +00:00
|
|
|
// Redistribution and use in source and binary forms, with or without modification, are
|
|
|
|
// permitted provided that the following conditions are met:
|
2016-10-04 10:15:29 +00:00
|
|
|
//
|
2016-06-26 15:04:45 +00:00
|
|
|
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
|
|
|
// conditions and the following disclaimer.
|
2016-10-04 10:15:29 +00:00
|
|
|
//
|
2016-06-26 15:04:45 +00:00
|
|
|
// 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.
|
2016-10-04 10:15:29 +00:00
|
|
|
//
|
2016-06-26 15:04:45 +00:00
|
|
|
// 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.
|
2016-10-04 10:15:29 +00:00
|
|
|
//
|
2016-06-26 15:04:45 +00:00
|
|
|
// 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.
|
|
|
|
|
|
|
|
import QtQuick 2.0
|
|
|
|
import QtQuick.Controls 1.4
|
|
|
|
import QtQuick.Controls.Styles 1.4
|
|
|
|
import QtQuick.Layouts 1.1
|
|
|
|
|
|
|
|
import "../components"
|
2016-10-02 18:40:40 +00:00
|
|
|
import moneroComponents.Clipboard 1.0
|
2016-06-26 15:04:45 +00:00
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
|
|
|
|
color: "#F0EEEE"
|
|
|
|
property alias addressText : addressLine.text
|
|
|
|
property alias paymentIdText : paymentIdLine.text
|
|
|
|
property alias integratedAddressText : integratedAddressLine.text
|
|
|
|
|
2016-10-16 12:21:22 +00:00
|
|
|
function updatePaymentId(payment_id) {
|
|
|
|
if (typeof appWindow.currentWallet === 'undefined')
|
|
|
|
return
|
|
|
|
// generate a new one if not given as argument
|
|
|
|
if (typeof payment_id === 'undefined') {
|
2016-10-02 20:54:05 +00:00
|
|
|
payment_id = appWindow.currentWallet.generatePaymentId()
|
2016-06-26 15:04:45 +00:00
|
|
|
appWindow.persistentSettings.payment_id = payment_id
|
2016-10-16 12:21:22 +00:00
|
|
|
paymentIdLine.text = payment_id
|
2016-06-26 15:04:45 +00:00
|
|
|
}
|
2016-10-16 12:21:22 +00:00
|
|
|
addressLine.text = appWindow.currentWallet.address
|
|
|
|
integratedAddressLine.text = appWindow.currentWallet.integratedAddress(payment_id)
|
|
|
|
if (integratedAddressLine.text === "")
|
|
|
|
integratedAddressLine.text = qsTr("Invalid payment ID")
|
2016-06-26 15:04:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Clipboard { id: clipboard }
|
|
|
|
|
|
|
|
|
|
|
|
/* main layout */
|
|
|
|
ColumnLayout {
|
|
|
|
id: mainLayout
|
|
|
|
anchors.margins: 40
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
|
|
|
spacing: 20
|
|
|
|
property int labelWidth: 120
|
|
|
|
property int editWidth: 400
|
|
|
|
property int lineEditFontSize: 12
|
|
|
|
|
|
|
|
|
|
|
|
RowLayout {
|
|
|
|
id: addressRow
|
|
|
|
|
|
|
|
Label {
|
|
|
|
id: addressLabel
|
|
|
|
fontSize: 14
|
2016-07-20 19:28:11 +00:00
|
|
|
text: qsTr("Address") + translationManager.emptyString
|
2016-06-26 15:04:45 +00:00
|
|
|
width: mainLayout.labelWidth
|
|
|
|
}
|
|
|
|
|
|
|
|
LineEdit {
|
|
|
|
id: addressLine
|
|
|
|
fontSize: mainLayout.lineEditFontSize
|
2016-07-20 19:28:11 +00:00
|
|
|
placeholderText: qsTr("ReadOnly wallet address displayed here") + translationManager.emptyString;
|
2016-06-26 15:04:45 +00:00
|
|
|
readOnly: true
|
|
|
|
width: mainLayout.editWidth
|
|
|
|
Layout.fillWidth: true
|
2016-10-03 23:14:09 +00:00
|
|
|
onTextChanged: cursorPosition = 0
|
|
|
|
|
2016-06-26 15:04:45 +00:00
|
|
|
IconButton {
|
|
|
|
imageSource: "../images/copyToClipboard.png"
|
|
|
|
onClicked: {
|
|
|
|
if (addressLine.text.length > 0) {
|
|
|
|
clipboard.setText(addressLine.text)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
RowLayout {
|
|
|
|
id: integratedAddressRow
|
|
|
|
Label {
|
|
|
|
id: integratedAddressLabel
|
|
|
|
fontSize: 14
|
2016-07-20 19:28:11 +00:00
|
|
|
text: qsTr("Integrated address") + translationManager.emptyString
|
2016-06-26 15:04:45 +00:00
|
|
|
width: mainLayout.labelWidth
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LineEdit {
|
|
|
|
|
|
|
|
id: integratedAddressLine
|
|
|
|
fontSize: mainLayout.lineEditFontSize
|
2016-07-20 19:28:11 +00:00
|
|
|
placeholderText: qsTr("ReadOnly wallet integrated address displayed here") + translationManager.emptyString
|
2016-06-26 15:04:45 +00:00
|
|
|
readOnly: true
|
|
|
|
width: mainLayout.editWidth
|
|
|
|
Layout.fillWidth: true
|
2016-10-03 23:14:09 +00:00
|
|
|
|
|
|
|
onTextChanged: cursorPosition = 0
|
|
|
|
|
2016-06-26 15:04:45 +00:00
|
|
|
IconButton {
|
|
|
|
imageSource: "../images/copyToClipboard.png"
|
|
|
|
onClicked: {
|
|
|
|
if (integratedAddressLine.text.length > 0) {
|
|
|
|
clipboard.setText(integratedAddressLine.text)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
RowLayout {
|
|
|
|
id: paymentIdRow
|
|
|
|
Label {
|
|
|
|
id: paymentIdLabel
|
|
|
|
fontSize: 14
|
2016-07-20 19:28:11 +00:00
|
|
|
text: qsTr("Payment ID") + translationManager.emptyString
|
2016-06-26 15:04:45 +00:00
|
|
|
width: mainLayout.labelWidth
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
LineEdit {
|
|
|
|
id: paymentIdLine
|
|
|
|
fontSize: mainLayout.lineEditFontSize
|
2016-10-16 20:25:19 +00:00
|
|
|
placeholderText: qsTr("16 or 64 hexadecimal characters") + translationManager.emptyString;
|
2016-06-26 15:04:45 +00:00
|
|
|
readOnly: false
|
2016-10-16 12:21:22 +00:00
|
|
|
onTextChanged: updatePaymentId(paymentIdLine.text)
|
2016-06-26 15:04:45 +00:00
|
|
|
|
|
|
|
width: mainLayout.editWidth
|
|
|
|
Layout.fillWidth: true
|
|
|
|
|
|
|
|
IconButton {
|
|
|
|
imageSource: "../images/copyToClipboard.png"
|
|
|
|
onClicked: {
|
|
|
|
if (paymentIdLine.text.length > 0) {
|
|
|
|
clipboard.setText(paymentIdLine.text)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StandardButton {
|
|
|
|
id: generatePaymentId
|
|
|
|
width: 80
|
|
|
|
fontSize: 14
|
|
|
|
shadowReleasedColor: "#FF4304"
|
|
|
|
shadowPressedColor: "#B32D00"
|
|
|
|
releasedColor: "#FF6C3C"
|
|
|
|
pressedColor: "#FF4304"
|
|
|
|
text: qsTr("Generate")
|
|
|
|
anchors.right: parent.right
|
|
|
|
onClicked: {
|
2016-09-01 20:55:30 +00:00
|
|
|
appWindow.persistentSettings.payment_id = appWindow.currentWallet.generatePaymentId();
|
2016-06-26 15:04:45 +00:00
|
|
|
updatePaymentId()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-10-04 10:15:29 +00:00
|
|
|
function onPageCompleted() {
|
2016-06-26 15:04:45 +00:00
|
|
|
console.log("Receive page loaded");
|
2016-10-04 10:15:29 +00:00
|
|
|
|
|
|
|
if(addressLine.text.length == 0) {
|
|
|
|
updatePaymentId()
|
|
|
|
}
|
|
|
|
|
2016-06-26 15:04:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|