mirror of
https://github.com/monero-project/monero-gui.git
synced 2024-11-16 15:58:11 +00:00
Send money: confirmation popups added
This commit is contained in:
parent
409c5701e2
commit
39cb75e58c
4 changed files with 71 additions and 12 deletions
1
main.cpp
1
main.cpp
|
@ -56,6 +56,7 @@ int main(int argc, char *argv[])
|
||||||
qmlRegisterUncreatableType<Wallet>("Bitmonero.Wallet", 1, 0, "Wallet", "Wallet can't be instantiated directly");
|
qmlRegisterUncreatableType<Wallet>("Bitmonero.Wallet", 1, 0, "Wallet", "Wallet can't be instantiated directly");
|
||||||
qmlRegisterUncreatableType<PendingTransaction>("Bitmonero.PendingTransaction", 1, 0, "PendingTransaction",
|
qmlRegisterUncreatableType<PendingTransaction>("Bitmonero.PendingTransaction", 1, 0, "PendingTransaction",
|
||||||
"PendingTransaction can't be instantiated directly");
|
"PendingTransaction can't be instantiated directly");
|
||||||
|
qRegisterMetaType<PendingTransaction::Priority>();
|
||||||
|
|
||||||
|
|
||||||
QQmlApplicationEngine engine;
|
QQmlApplicationEngine engine;
|
||||||
|
|
79
main.qml
79
main.qml
|
@ -30,6 +30,7 @@ import QtQuick 2.2
|
||||||
import QtQuick.Window 2.0
|
import QtQuick.Window 2.0
|
||||||
import QtQuick.Controls 1.1
|
import QtQuick.Controls 1.1
|
||||||
import QtQuick.Controls.Styles 1.1
|
import QtQuick.Controls.Styles 1.1
|
||||||
|
import QtQuick.Dialogs 1.2
|
||||||
import Qt.labs.settings 1.0
|
import Qt.labs.settings 1.0
|
||||||
import Bitmonero.Wallet 1.0
|
import Bitmonero.Wallet 1.0
|
||||||
import Bitmonero.PendingTransaction 1.0
|
import Bitmonero.PendingTransaction 1.0
|
||||||
|
@ -47,6 +48,7 @@ ApplicationWindow {
|
||||||
property bool osx: false
|
property bool osx: false
|
||||||
property alias persistentSettings : persistentSettings
|
property alias persistentSettings : persistentSettings
|
||||||
property var wallet;
|
property var wallet;
|
||||||
|
property var transaction;
|
||||||
|
|
||||||
function altKeyReleased() { ctrlPressed = false; }
|
function altKeyReleased() { ctrlPressed = false; }
|
||||||
|
|
||||||
|
@ -133,6 +135,10 @@ ApplicationWindow {
|
||||||
wallet = walletManager.openWallet(wallet_path, "", persistentSettings.testnet);
|
wallet = walletManager.openWallet(wallet_path, "", persistentSettings.testnet);
|
||||||
if (wallet.status !== Wallet.Status_Ok) {
|
if (wallet.status !== Wallet.Status_Ok) {
|
||||||
console.log("Error opening wallet: ", wallet.errorString);
|
console.log("Error opening wallet: ", wallet.errorString);
|
||||||
|
informationPopup.title = qsTr("Error");
|
||||||
|
informationPopup.text = qsTr("Couldn't open wallet: ") + wallet.errorString;
|
||||||
|
informationPopup.icon = StandardIcon.Critical
|
||||||
|
informationPopup.open()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
console.log("Wallet opened successfully: ", wallet.errorString);
|
console.log("Wallet opened successfully: ", wallet.errorString);
|
||||||
|
@ -169,6 +175,8 @@ ApplicationWindow {
|
||||||
return wallets.length > 0;
|
return wallets.length > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// called on "transfer"
|
||||||
function handlePayment(address, paymentId, amount, mixinCount, priority) {
|
function handlePayment(address, paymentId, amount, mixinCount, priority) {
|
||||||
console.log("Creating transaction: ")
|
console.log("Creating transaction: ")
|
||||||
console.log("\taddress: ", address,
|
console.log("\taddress: ", address,
|
||||||
|
@ -180,22 +188,53 @@ ApplicationWindow {
|
||||||
var amountxmr = walletManager.amountFromString(amount);
|
var amountxmr = walletManager.amountFromString(amount);
|
||||||
|
|
||||||
console.log("integer amount: ", amountxmr);
|
console.log("integer amount: ", amountxmr);
|
||||||
var pendingTransaction = wallet.createTransaction(address, paymentId, amountxmr, mixinCount, priority);
|
transaction = wallet.createTransaction(address, paymentId, amountxmr, mixinCount, priority);
|
||||||
if (pendingTransaction.status !== PendingTransaction.Status_Ok) {
|
if (transaction.status !== PendingTransaction.Status_Ok) {
|
||||||
console.error("Can't create transaction: ", pendingTransaction.errorString);
|
console.error("Can't create transaction: ", transaction.errorString);
|
||||||
|
informationPopup.title = qsTr("Error");
|
||||||
|
informationPopup.text = qsTr("Can't create transaction: ") + transaction.errorString
|
||||||
|
informationPopup.icon = StandardIcon.Critical
|
||||||
|
informationPopup.open();
|
||||||
|
// deleting transaction object, we don't want memleaks
|
||||||
|
wallet.disposeTransaction(transaction);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
console.log("Transaction created, amount: " + walletManager.displayAmount(pendingTransaction.amount)
|
console.log("Transaction created, amount: " + walletManager.displayAmount(transaction.amount)
|
||||||
+ ", fee: " + walletManager.displayAmount(pendingTransaction.fee));
|
+ ", fee: " + walletManager.displayAmount(transaction.fee));
|
||||||
if (!pendingTransaction.commit()) {
|
|
||||||
console.log("Error committing transaction: " + pendingTransaction.errorString);
|
// here we show confirmation popup;
|
||||||
} else {
|
|
||||||
wallet.refresh();
|
transactionConfirmationPopup.title = qsTr("Confirmation")
|
||||||
}
|
transactionConfirmationPopup.text = qsTr("Please confirm transaction:\n\n")
|
||||||
|
+ "\naddress: " + address
|
||||||
|
+ "\npayment id: " + paymentId
|
||||||
|
+ "\namount: " + walletManager.displayAmount(transaction.amount)
|
||||||
|
+ "\nfee: " + walletManager.displayAmount(transaction.fee)
|
||||||
|
transactionConfirmationPopup.icon = StandardIcon.Question
|
||||||
|
transactionConfirmationPopup.open()
|
||||||
|
// committing transaction
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// called after user confirms transaction
|
||||||
|
function handleTransactionConfirmed() {
|
||||||
|
if (!transaction.commit()) {
|
||||||
|
console.log("Error committing transaction: " + transaction.errorString);
|
||||||
|
informationPopup.title = qsTr("Error");
|
||||||
|
informationPopup.text = qsTr("Couldn't send the money: ") + transaction.errorString
|
||||||
|
informationPopup.icon = StandardIcon.Critical
|
||||||
|
} else {
|
||||||
|
informationPopup.title = qsTr("Information")
|
||||||
|
informationPopup.text = qsTr("Money sent successfully")
|
||||||
|
informationPopup.icon = StandardIcon.Information
|
||||||
}
|
}
|
||||||
|
|
||||||
wallet.disposeTransaction(pendingTransaction);
|
informationPopup.open()
|
||||||
|
wallet.refresh()
|
||||||
|
wallet.disposeTransaction(transaction)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
visible: true
|
visible: true
|
||||||
width: rightPanelExpanded ? 1269 : 1269 - 300
|
width: rightPanelExpanded ? 1269 : 1269 - 300
|
||||||
height: 800
|
height: 800
|
||||||
|
@ -232,6 +271,24 @@ ApplicationWindow {
|
||||||
property string payment_id
|
property string payment_id
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: replace with customized popups
|
||||||
|
|
||||||
|
// Information dialog
|
||||||
|
MessageDialog {
|
||||||
|
id: informationPopup
|
||||||
|
standardButtons: StandardButton.Ok
|
||||||
|
}
|
||||||
|
|
||||||
|
// Confrirmation aka question dialog
|
||||||
|
MessageDialog {
|
||||||
|
id: transactionConfirmationPopup
|
||||||
|
standardButtons: StandardButton.Ok + StandardButton.Cancel
|
||||||
|
onAccepted: {
|
||||||
|
handleTransactionConfirmed()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: rootItem
|
id: rootItem
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "PendingTransaction.h"
|
#include "PendingTransaction.h"
|
||||||
|
|
||||||
|
|
||||||
PendingTransaction::Status PendingTransaction::status() const
|
PendingTransaction::Status PendingTransaction::status() const
|
||||||
{
|
{
|
||||||
return static_cast<Status>(m_pimpl->status());
|
return static_cast<Status>(m_pimpl->status());
|
||||||
|
|
|
@ -80,7 +80,7 @@ public:
|
||||||
//! creates transaction
|
//! creates transaction
|
||||||
Q_INVOKABLE PendingTransaction * createTransaction(const QString &dst_addr, const QString &payment_id,
|
Q_INVOKABLE PendingTransaction * createTransaction(const QString &dst_addr, const QString &payment_id,
|
||||||
quint64 amount, quint32 mixin_count,
|
quint64 amount, quint32 mixin_count,
|
||||||
PendingTransaction::Priority priority = PendingTransaction::Priority_Low);
|
PendingTransaction::Priority priority);
|
||||||
//! deletes transaction and frees memory
|
//! deletes transaction and frees memory
|
||||||
Q_INVOKABLE void disposeTransaction(PendingTransaction * t);
|
Q_INVOKABLE void disposeTransaction(PendingTransaction * t);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue