diff --git a/main.qml b/main.qml index cf355aab..2a8dc0df 100644 --- a/main.qml +++ b/main.qml @@ -423,33 +423,38 @@ ApplicationWindow { transactionDescription = description; // validate amount; - var amountxmr = walletManager.amountFromString(amount); - console.log("integer amount: ", amountxmr); - console.log("integer unlocked",currentWallet.unlockedBalance) - if (amountxmr <= 0) { - informationPopup.title = qsTr("Error") + translationManager.emptyString; - informationPopup.text = qsTr("Amount is wrong: expected number from %1 to %2") - .arg(walletManager.displayAmount(0)) - .arg(walletManager.maximumAllowedAmountAsSting()) - + translationManager.emptyString + if (amount !== "(all)") { + var amountxmr = walletManager.amountFromString(amount); + console.log("integer amount: ", amountxmr); + console.log("integer unlocked",currentWallet.unlockedBalance) + if (amountxmr <= 0) { + informationPopup.title = qsTr("Error") + translationManager.emptyString; + informationPopup.text = qsTr("Amount is wrong: expected number from %1 to %2") + .arg(walletManager.displayAmount(0)) + .arg(walletManager.maximumAllowedAmountAsSting()) + + translationManager.emptyString - informationPopup.icon = StandardIcon.Critical - informationPopup.onCloseCallback = null - informationPopup.open() - return; - } else if (amountxmr > currentWallet.unlockedBalance) { - informationPopup.title = qsTr("Error") + translationManager.emptyString; - informationPopup.text = qsTr("insufficient funds. Unlocked balance: %1") - .arg(walletManager.displayAmount(currentWallet.unlockedBalance)) - + translationManager.emptyString + informationPopup.icon = StandardIcon.Critical + informationPopup.onCloseCallback = null + informationPopup.open() + return; + } else if (amountxmr > currentWallet.unlockedBalance) { + informationPopup.title = qsTr("Error") + translationManager.emptyString; + informationPopup.text = qsTr("insufficient funds. Unlocked balance: %1") + .arg(walletManager.displayAmount(currentWallet.unlockedBalance)) + + translationManager.emptyString - informationPopup.icon = StandardIcon.Critical - informationPopup.onCloseCallback = null - informationPopup.open() - return; + informationPopup.icon = StandardIcon.Critical + informationPopup.onCloseCallback = null + informationPopup.open() + return; + } } - currentWallet.createTransactionAsync(address, paymentId, amountxmr, mixinCount, priority); + if (amount === "(all)") + currentWallet.createTransactionAllAsync(address, paymentId, amountxmr, mixinCount, priority); + else + currentWallet.createTransactionAsync(address, paymentId, amountxmr, mixinCount, priority); } function handleSweepUnmixable() { diff --git a/pages/Transfer.qml b/pages/Transfer.qml index 260f4b54..3c687ff1 100644 --- a/pages/Transfer.qml +++ b/pages/Transfer.qml @@ -89,7 +89,7 @@ Rectangle { LineEdit { id: amountLine placeholderText: qsTr("") + translationManager.emptyString - width: parent.width - 37 - 17 + width: parent.width - 37 - 17 - 60 validator: DoubleValidator { bottom: 0.0 top: 18446744.073709551615 @@ -98,6 +98,21 @@ Rectangle { locale: "C" } } + + StandardButton { + id: amountAllButton + //anchors.left: amountLine.right + //anchors.top: amountLine.top + //anchors.bottom: amountLine.bottom + width: 60 + text: qsTr("or ALL") + translationManager.emptyString + shadowReleasedColor: "#FF4304" + shadowPressedColor: "#B32D00" + releasedColor: "#FF6C3C" + pressedColor: "#FF4304" + enabled : true + onClicked: amountLine.text = "(all)" + } } ListModel { diff --git a/src/libwalletqt/Wallet.cpp b/src/libwalletqt/Wallet.cpp index d7fefbf9..9f15bb06 100644 --- a/src/libwalletqt/Wallet.cpp +++ b/src/libwalletqt/Wallet.cpp @@ -232,6 +232,16 @@ void Wallet::createTransactionAsync(const QString &dst_addr, const QString &paym }); } +PendingTransaction *Wallet::createTransactionAll(const QString &dst_addr, const QString &payment_id, + quint32 mixin_count, PendingTransaction::Priority priority) +{ + Bitmonero::PendingTransaction * ptImpl = m_walletImpl->createTransaction( + dst_addr.toStdString(), payment_id.toStdString(), Bitmonero::optional(), mixin_count, + static_cast(priority)); + PendingTransaction * result = new PendingTransaction(ptImpl, this); + return result; +} + PendingTransaction *Wallet::createSweepUnmixableTransaction() { Bitmonero::PendingTransaction * ptImpl = m_walletImpl->createSweepUnmixableTransaction(); diff --git a/src/libwalletqt/Wallet.h b/src/libwalletqt/Wallet.h index ecdfa2fd..65d955ba 100644 --- a/src/libwalletqt/Wallet.h +++ b/src/libwalletqt/Wallet.h @@ -126,12 +126,16 @@ public: Q_INVOKABLE PendingTransaction * createTransaction(const QString &dst_addr, const QString &payment_id, quint64 amount, quint32 mixin_count, PendingTransaction::Priority priority); + //! creates async transaction Q_INVOKABLE void createTransactionAsync(const QString &dst_addr, const QString &payment_id, quint64 amount, quint32 mixin_count, PendingTransaction::Priority priority); - // + //! creates transaction with all outputs + Q_INVOKABLE PendingTransaction * createTransactionAll(const QString &dst_addr, const QString &payment_id, + quint32 mixin_count, PendingTransaction::Priority priority); + //! creates sweep unmixable transaction Q_INVOKABLE PendingTransaction * createSweepUnmixableTransaction();