2015-04-01 08:56:05 +00:00
|
|
|
// Copyright (c) 2014-2015, The Monero Project
|
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
|
2014-07-07 17:08:30 +00:00
|
|
|
import QtQuick 2.0
|
2016-06-27 12:45:48 +00:00
|
|
|
import Bitmonero.PendingTransaction 1.0
|
2014-07-10 22:18:36 +00:00
|
|
|
import "../components"
|
2014-07-07 17:08:30 +00:00
|
|
|
|
2016-06-27 12:45:48 +00:00
|
|
|
|
2014-07-07 17:08:30 +00:00
|
|
|
Rectangle {
|
2016-06-27 12:45:48 +00:00
|
|
|
signal paymentClicked(string address, string paymentId, double amount, int mixinCount,
|
|
|
|
int priority)
|
2016-06-16 14:13:46 +00:00
|
|
|
|
2014-07-10 22:18:36 +00:00
|
|
|
color: "#F0EEEE"
|
|
|
|
|
2016-06-20 20:36:56 +00:00
|
|
|
function scaleValueToMixinCount(scaleValue) {
|
|
|
|
var scaleToMixinCount = [2,3,4,5,5,5,6,7,8,9,10,15,20,25];
|
|
|
|
if (scaleValue < scaleToMixinCount.length) {
|
|
|
|
return scaleToMixinCount[scaleValue];
|
|
|
|
} else {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-16 14:13:46 +00:00
|
|
|
|
2014-07-10 22:18:36 +00:00
|
|
|
Label {
|
|
|
|
id: amountLabel
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.top: parent.top
|
2014-07-16 14:48:17 +00:00
|
|
|
anchors.leftMargin: 17
|
|
|
|
anchors.rightMargin: 17
|
|
|
|
anchors.topMargin: 17
|
2016-07-20 19:28:11 +00:00
|
|
|
text: qsTr("Amount") + translationManager.emptyString
|
2014-07-11 14:19:13 +00:00
|
|
|
fontSize: 14
|
2014-07-10 22:18:36 +00:00
|
|
|
}
|
2016-06-27 12:45:48 +00:00
|
|
|
|
2014-07-10 22:18:36 +00:00
|
|
|
Label {
|
|
|
|
id: transactionPriority
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.topMargin: 17
|
2014-07-11 14:19:13 +00:00
|
|
|
fontSize: 14
|
2014-07-10 22:18:36 +00:00
|
|
|
x: (parent.width - 17) / 2 + 17
|
2016-07-20 19:28:11 +00:00
|
|
|
text: qsTr("Transaction priority") + translationManager.emptyString
|
2014-07-10 22:18:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Row {
|
2016-06-20 12:58:13 +00:00
|
|
|
id: amountRow
|
2014-07-10 22:18:36 +00:00
|
|
|
anchors.top: amountLabel.bottom
|
2014-07-11 14:19:13 +00:00
|
|
|
anchors.topMargin: 5
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.leftMargin: 7
|
|
|
|
width: (parent.width - 17) / 2 + 10
|
2014-07-10 22:18:36 +00:00
|
|
|
Item {
|
|
|
|
width: 37
|
|
|
|
height: 37
|
|
|
|
|
|
|
|
Image {
|
|
|
|
anchors.centerIn: parent
|
|
|
|
source: "../images/moneroIcon.png"
|
|
|
|
}
|
|
|
|
}
|
2016-06-16 14:13:46 +00:00
|
|
|
// Amount input
|
2014-07-10 22:18:36 +00:00
|
|
|
LineEdit {
|
2016-06-16 14:13:46 +00:00
|
|
|
id: amountLine
|
2016-07-20 19:28:11 +00:00
|
|
|
placeholderText: qsTr("Amount...") + translationManager.emptyString
|
2014-07-10 22:18:36 +00:00
|
|
|
width: parent.width - 37 - 17
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-07-16 16:04:34 +00:00
|
|
|
ListModel {
|
|
|
|
id: priorityModel
|
2016-07-20 19:28:11 +00:00
|
|
|
ListElement { column1: qsTr("LOW") + translationManager.emptyString; column2: ""; priority: PendingTransaction.Priority_Low }
|
|
|
|
ListElement { column1: qsTr("MEDIUM") + translationManager.emptyString; column2: ""; priority: PendingTransaction.Priority_Medium }
|
|
|
|
ListElement { column1: qsTr("HIGH") + translationManager.emptyString; column2: ""; priority: PendingTransaction.Priority_High }
|
2014-07-16 16:04:34 +00:00
|
|
|
}
|
2016-06-27 12:45:48 +00:00
|
|
|
|
2014-07-10 22:18:36 +00:00
|
|
|
StandardDropdown {
|
2014-07-11 14:19:13 +00:00
|
|
|
id: priorityDropdown
|
2014-07-10 22:18:36 +00:00
|
|
|
anchors.top: transactionPriority.bottom
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.rightMargin: 17
|
2014-07-11 14:19:13 +00:00
|
|
|
anchors.topMargin: 5
|
2014-07-10 22:18:36 +00:00
|
|
|
anchors.left: transactionPriority.left
|
|
|
|
shadowReleasedColor: "#FF4304"
|
|
|
|
shadowPressedColor: "#B32D00"
|
|
|
|
releasedColor: "#FF6C3C"
|
|
|
|
pressedColor: "#FF4304"
|
2014-07-16 16:04:34 +00:00
|
|
|
dataModel: priorityModel
|
2014-07-10 22:18:36 +00:00
|
|
|
z: 1
|
|
|
|
}
|
2016-06-27 12:45:48 +00:00
|
|
|
|
2016-06-20 12:58:13 +00:00
|
|
|
|
2014-07-11 14:19:13 +00:00
|
|
|
|
|
|
|
Label {
|
|
|
|
id: privacyLabel
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
2016-06-20 12:58:13 +00:00
|
|
|
anchors.top: amountRow.bottom
|
2014-07-11 14:19:13 +00:00
|
|
|
anchors.leftMargin: 17
|
|
|
|
anchors.rightMargin: 17
|
|
|
|
anchors.topMargin: 30
|
|
|
|
fontSize: 14
|
2016-07-20 19:28:11 +00:00
|
|
|
text: qsTr("Privacy Level") + translationManager.emptyString
|
2014-07-11 14:19:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
PrivacyLevel {
|
|
|
|
id: privacyLevelItem
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.top: privacyLabel.bottom
|
|
|
|
anchors.leftMargin: 17
|
|
|
|
anchors.rightMargin: 17
|
|
|
|
anchors.topMargin: 5
|
2016-06-20 20:36:56 +00:00
|
|
|
onFillLevelChanged: {
|
|
|
|
print ("PrivacyLevel changed:" + fillLevel)
|
|
|
|
print ("mixin count:" + scaleValueToMixinCount(fillLevel))
|
|
|
|
}
|
2014-07-11 14:19:13 +00:00
|
|
|
}
|
|
|
|
|
2016-06-20 12:58:13 +00:00
|
|
|
|
|
|
|
Label {
|
|
|
|
id: costLabel
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.top: amountRow.bottom
|
|
|
|
anchors.leftMargin: 17
|
|
|
|
anchors.rightMargin: 17
|
|
|
|
anchors.topMargin: 30
|
|
|
|
fontSize: 14
|
|
|
|
text: qsTr("Cost")
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-07-11 14:19:13 +00:00
|
|
|
Label {
|
|
|
|
id: addressLabel
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.top: privacyLevelItem.bottom
|
|
|
|
anchors.leftMargin: 17
|
|
|
|
anchors.rightMargin: 17
|
|
|
|
anchors.topMargin: 30
|
|
|
|
fontSize: 14
|
|
|
|
textFormat: Text.RichText
|
|
|
|
text: qsTr("<style type='text/css'>a {text-decoration: none; color: #FF6C3C; font-size: 14px;}</style>\
|
|
|
|
Address <font size='2'> ( Type in or select from </font> <a href='#'>Address</a><font size='2'> book )</font>")
|
2016-07-20 19:28:11 +00:00
|
|
|
+ translationManager.emptyString
|
2014-07-11 14:19:13 +00:00
|
|
|
|
2014-07-13 12:27:50 +00:00
|
|
|
onLinkActivated: appWindow.showPageRequest("AddressBook")
|
2014-07-11 14:19:13 +00:00
|
|
|
}
|
2016-06-16 14:13:46 +00:00
|
|
|
// recipient address input
|
2014-07-11 14:19:13 +00:00
|
|
|
LineEdit {
|
|
|
|
id: addressLine
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.top: addressLabel.bottom
|
|
|
|
anchors.leftMargin: 17
|
|
|
|
anchors.rightMargin: 17
|
|
|
|
anchors.topMargin: 5
|
2016-06-16 14:13:46 +00:00
|
|
|
// validator: RegExpValidator { regExp: /[0-9A-Fa-f]{95}/g }
|
2014-07-11 14:19:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Label {
|
2016-06-16 14:13:46 +00:00
|
|
|
id: paymentIdLabel
|
2014-07-11 14:19:13 +00:00
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.top: addressLine.bottom
|
|
|
|
anchors.leftMargin: 17
|
|
|
|
anchors.rightMargin: 17
|
|
|
|
anchors.topMargin: 17
|
|
|
|
fontSize: 14
|
2016-07-20 19:28:11 +00:00
|
|
|
text: qsTr("Payment ID <font size='2'>( Optional )</font>") + translationManager.emptyString
|
2014-07-11 14:19:13 +00:00
|
|
|
}
|
|
|
|
|
2016-06-16 14:13:46 +00:00
|
|
|
// payment id input
|
2014-07-15 14:03:39 +00:00
|
|
|
LineEdit {
|
2016-06-16 14:13:46 +00:00
|
|
|
id: paymentIdLine
|
2014-07-11 14:19:13 +00:00
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
2016-06-16 14:13:46 +00:00
|
|
|
anchors.top: paymentIdLabel.bottom
|
2014-07-11 14:19:13 +00:00
|
|
|
anchors.leftMargin: 17
|
|
|
|
anchors.rightMargin: 17
|
|
|
|
anchors.topMargin: 5
|
2016-06-16 14:13:46 +00:00
|
|
|
// validator: DoubleValidator { top: 0.0 }
|
2014-07-15 14:03:39 +00:00
|
|
|
}
|
2014-07-11 14:19:13 +00:00
|
|
|
|
2014-07-16 14:48:17 +00:00
|
|
|
Label {
|
|
|
|
id: descriptionLabel
|
2014-07-15 14:03:39 +00:00
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
2016-06-16 14:13:46 +00:00
|
|
|
anchors.top: paymentIdLine.bottom
|
2014-07-15 14:03:39 +00:00
|
|
|
anchors.leftMargin: 17
|
|
|
|
anchors.rightMargin: 17
|
|
|
|
anchors.topMargin: 17
|
2014-07-16 14:48:17 +00:00
|
|
|
fontSize: 14
|
2014-07-22 15:15:52 +00:00
|
|
|
text: qsTr("Description <font size='2'>( An optional description that will be saved to the local address book if entered )</font>")
|
2016-07-20 19:28:11 +00:00
|
|
|
+ translationManager.emptyString
|
2014-07-16 14:48:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
LineEdit {
|
|
|
|
id: descriptionLine
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.top: descriptionLabel.bottom
|
|
|
|
anchors.leftMargin: 17
|
|
|
|
anchors.rightMargin: 17
|
|
|
|
anchors.topMargin: 5
|
|
|
|
}
|
|
|
|
|
2014-07-22 15:15:52 +00:00
|
|
|
StandardButton {
|
|
|
|
id: sendButton
|
2014-07-16 14:48:17 +00:00
|
|
|
anchors.left: parent.left
|
2014-07-22 15:15:52 +00:00
|
|
|
anchors.top: descriptionLine.bottom
|
2014-07-16 14:48:17 +00:00
|
|
|
anchors.leftMargin: 17
|
|
|
|
anchors.topMargin: 17
|
2014-07-22 15:15:52 +00:00
|
|
|
width: 60
|
2016-07-20 19:28:11 +00:00
|
|
|
text: qsTr("SEND") + translationManager.emptyString
|
2014-07-22 15:15:52 +00:00
|
|
|
shadowReleasedColor: "#FF4304"
|
|
|
|
shadowPressedColor: "#B32D00"
|
|
|
|
releasedColor: "#FF6C3C"
|
|
|
|
pressedColor: "#FF4304"
|
2016-06-16 14:13:46 +00:00
|
|
|
onClicked: {
|
|
|
|
// do more smart validation
|
|
|
|
|
|
|
|
if (addressLine.text.length > 0 && amountLine.text.length > 0) {
|
|
|
|
console.log("paymentClicked")
|
2016-06-27 12:45:48 +00:00
|
|
|
var priority = priorityModel.get(priorityDropdown.currentIndex).priority
|
|
|
|
console.log("priority: " + priority)
|
|
|
|
paymentClicked(addressLine.text, paymentIdLine.text, amountLine.text, scaleValueToMixinCount(privacyLevelItem.fillLevel),
|
|
|
|
priority)
|
2016-06-16 14:13:46 +00:00
|
|
|
}
|
|
|
|
}
|
2014-07-11 14:19:13 +00:00
|
|
|
}
|
2014-07-07 17:08:30 +00:00
|
|
|
}
|