2020-10-07 10:36:04 +00:00
// SPDX-License-Identifier: BSD-3-Clause
2024-01-01 17:07:58 +00:00
// SPDX-FileCopyrightText: 2020-2024 The Monero Project
2020-10-07 10:36:04 +00:00
2021-06-28 17:48:23 +00:00
# include "SendWidget.h"
# include "ui_SendWidget.h"
2020-10-07 10:36:04 +00:00
# include <QMessageBox>
2021-06-28 17:48:23 +00:00
# include "ColorScheme.h"
2021-05-18 15:59:18 +00:00
# include "constants.h"
2021-05-02 18:22:38 +00:00
# include "utils/AppData.h"
2023-03-01 02:05:56 +00:00
# include "utils/config.h"
2021-06-25 14:14:49 +00:00
# include "Icons.h"
2023-03-01 02:05:56 +00:00
# include "libwalletqt/WalletManager.h"
2021-06-25 14:14:49 +00:00
2023-10-10 12:21:11 +00:00
# if defined(WITH_SCANNER)
2023-12-02 18:28:31 +00:00
# include "wizard/offline_tx_signing/OfflineTxSigningWizard.h"
2023-03-29 07:39:03 +00:00
# include "qrcode/scanner/QrCodeScanDialog.h"
2022-12-27 15:52:06 +00:00
# include <QMediaDevices>
2021-06-25 14:14:49 +00:00
# endif
2020-10-07 10:36:04 +00:00
2023-03-01 02:05:56 +00:00
SendWidget : : SendWidget ( Wallet * wallet , QWidget * parent )
2021-05-02 18:22:38 +00:00
: QWidget ( parent )
, ui ( new Ui : : SendWidget )
2023-03-01 02:05:56 +00:00
, m_wallet ( wallet )
2020-10-07 10:36:04 +00:00
{
ui - > setupUi ( this ) ;
QString amount_rx = R " (^ \ d{0,8}[ \ .,] \ d{0,12}|(all)$) " ;
2022-03-04 10:05:20 +00:00
QRegularExpression rx ;
2020-10-07 10:36:04 +00:00
rx . setPattern ( amount_rx ) ;
2022-03-04 10:05:20 +00:00
QValidator * validator = new QRegularExpressionValidator ( rx , this ) ;
2020-10-07 10:36:04 +00:00
ui - > lineAmount - > setValidator ( validator ) ;
2023-12-15 13:10:55 +00:00
connect ( m_wallet , & Wallet : : initiateTransaction , this , & SendWidget : : disableSendButton ) ;
connect ( m_wallet , & Wallet : : transactionCreated , this , & SendWidget : : enableSendButton ) ;
connect ( m_wallet , & Wallet : : beginCommitTransaction , this , & SendWidget : : disableSendButton ) ;
connect ( m_wallet , & Wallet : : transactionCommitted , this , & SendWidget : : enableSendButton ) ;
2021-10-22 22:14:34 +00:00
connect ( WalletManager : : instance ( ) , & WalletManager : : openAliasResolved , this , & SendWidget : : onOpenAliasResolved ) ;
2021-05-02 18:22:38 +00:00
2021-06-25 14:14:49 +00:00
connect ( ui - > btnScan , & QPushButton : : clicked , this , & SendWidget : : scanClicked ) ;
2020-10-07 10:36:04 +00:00
connect ( ui - > btnSend , & QPushButton : : clicked , this , & SendWidget : : sendClicked ) ;
connect ( ui - > btnClear , & QPushButton : : clicked , this , & SendWidget : : clearClicked ) ;
connect ( ui - > btnMax , & QPushButton : : clicked , this , & SendWidget : : btnMaxClicked ) ;
connect ( ui - > comboCurrencySelection , QOverload < int > : : of ( & QComboBox : : currentIndexChanged ) , this , & SendWidget : : currencyComboChanged ) ;
2021-01-26 23:55:27 +00:00
connect ( ui - > lineAmount , & QLineEdit : : textChanged , this , & SendWidget : : amountEdited ) ;
connect ( ui - > lineAddress , & QPlainTextEdit : : textChanged , this , & SendWidget : : addressEdited ) ;
2020-10-07 10:36:04 +00:00
connect ( ui - > btn_openAlias , & QPushButton : : clicked , this , & SendWidget : : aliasClicked ) ;
2021-07-07 22:48:17 +00:00
connect ( ui - > lineAddress , & PayToEdit : : dataPasted , this , & SendWidget : : onDataPasted ) ;
2020-10-15 02:17:57 +00:00
ui - > label_conversionAmount - > setText ( " " ) ;
ui - > label_conversionAmount - > hide ( ) ;
2020-10-07 10:36:04 +00:00
ui - > btn_openAlias - > hide ( ) ;
2020-11-24 21:16:24 +00:00
2023-09-12 14:15:40 +00:00
ui - > label_PayTo - > setHelpText ( " Recipient of the funds " ,
" You may enter a Monero address, or an alias (email-like address that forwards to a Monero address) " ,
" send_transaction " ) ;
ui - > label_Description - > setHelpText ( " Description of the transaction (optional) " ,
2020-12-16 15:28:13 +00:00
" The description is not sent to the recipient of the funds. It is stored in your wallet cache, "
2023-09-12 14:15:40 +00:00
" and displayed in the 'History' tab. " ,
" send_transaction " ) ;
ui - > label_Amount - > setHelpText ( " Amount to be sent " , " This is the exact amount the recipient will receive. "
2020-12-16 15:28:13 +00:00
" In addition to this amount a transaction fee will be subtracted from your balance. "
" You will be able to review the transaction fee before the transaction is broadcast. \n \n "
2023-09-12 14:15:40 +00:00
" To send all your balance, click the Max button to the right. " , " send_transaction " ) ;
2020-12-16 15:28:13 +00:00
2021-05-18 15:59:18 +00:00
ui - > lineAddress - > setNetType ( constants : : networkType ) ;
2020-11-24 21:16:24 +00:00
this - > setupComboBox ( ) ;
2024-04-28 19:26:54 +00:00
this - > setManualFeeSelectionEnabled ( conf ( ) - > get ( Config : : manualFeeTierSelection ) . toBool ( ) ) ;
this - > setSubtractFeeFromAmountEnabled ( conf ( ) - > get ( Config : : subtractFeeFromAmount ) . toBool ( ) ) ;
2020-10-07 10:36:04 +00:00
}
void SendWidget : : currencyComboChanged ( int index ) {
2023-03-29 09:00:41 +00:00
Q_UNUSED ( index )
2020-10-07 10:36:04 +00:00
QString amount = ui - > lineAmount - > text ( ) ;
2023-03-29 09:00:41 +00:00
if ( amount . isEmpty ( ) ) {
return ;
}
2020-10-07 10:36:04 +00:00
this - > amountEdited ( amount ) ;
}
2021-01-26 23:55:27 +00:00
void SendWidget : : addressEdited ( ) {
QVector < PartialTxOutput > outputs = ui - > lineAddress - > getOutputs ( ) ;
2021-05-25 13:20:10 +00:00
bool freezeAmounts = ! outputs . empty ( ) ;
2021-01-26 23:55:27 +00:00
ui - > lineAmount - > setReadOnly ( freezeAmounts ) ;
ui - > lineAmount - > setFrame ( ! freezeAmounts ) ;
ui - > btnMax - > setDisabled ( freezeAmounts ) ;
2021-02-03 18:42:31 +00:00
ui - > comboCurrencySelection - > setDisabled ( freezeAmounts ) ;
2021-01-26 23:55:27 +00:00
2021-05-25 13:20:10 +00:00
if ( ! outputs . empty ( ) ) {
ui - > lineAmount - > setText ( WalletManager : : displayAmount ( ui - > lineAddress - > getTotal ( ) , false ) ) ;
2021-02-03 18:42:31 +00:00
ui - > comboCurrencySelection - > setCurrentIndex ( 0 ) ;
2021-01-26 23:55:27 +00:00
}
ui - > btn_openAlias - > setVisible ( ui - > lineAddress - > isOpenAlias ( ) ) ;
2023-10-16 20:13:59 +00:00
// Clear donation description if address no longer matches
if ( ui - > lineDescription - > text ( ) = = constants : : donationDescription & & ui - > lineAddress - > text ( ) ! = constants : : donationAddress ) {
ui - > lineDescription - > clear ( ) ;
}
2020-10-07 10:36:04 +00:00
}
void SendWidget : : amountEdited ( const QString & text ) {
2023-03-29 09:00:41 +00:00
Q_UNUSED ( text )
2020-10-07 10:36:04 +00:00
this - > updateConversionLabel ( ) ;
}
void SendWidget : : fill ( double amount ) {
ui - > lineAmount - > setText ( QString : : number ( amount ) ) ;
}
void SendWidget : : fill ( const QString & address , const QString & description , double amount ) {
ui - > lineAddress - > setText ( address ) ;
2021-01-26 23:55:27 +00:00
ui - > lineAddress - > moveCursor ( QTextCursor : : Start ) ;
2021-07-02 16:01:11 +00:00
ui - > lineDescription - > setText ( description ) ;
2020-12-14 00:59:32 +00:00
if ( amount > 0 )
ui - > lineAmount - > setText ( QString : : number ( amount ) ) ;
2021-07-02 16:01:11 +00:00
ui - > lineAmount - > setFocus ( ) ;
2020-12-14 00:59:32 +00:00
this - > updateConversionLabel ( ) ;
2020-10-07 10:36:04 +00:00
}
void SendWidget : : fillAddress ( const QString & address ) {
ui - > lineAddress - > setText ( address ) ;
2021-01-26 23:55:27 +00:00
ui - > lineAddress - > moveCursor ( QTextCursor : : Start ) ;
2020-10-07 10:36:04 +00:00
}
2021-06-25 14:14:49 +00:00
void SendWidget : : scanClicked ( ) {
2023-10-12 22:12:42 +00:00
# if defined(WITH_SCANNER)
2022-12-27 15:52:06 +00:00
auto cameras = QMediaDevices : : videoInputs ( ) ;
if ( cameras . empty ( ) ) {
2023-09-12 14:15:40 +00:00
Utils : : showError ( this , " Can't open QR scanner " , " No available cameras found " ) ;
2022-12-27 15:52:06 +00:00
return ;
}
2023-12-02 18:28:31 +00:00
auto dialog = new QrCodeScanDialog ( this , false ) ;
2022-12-27 15:52:06 +00:00
dialog - > exec ( ) ;
2023-12-02 18:28:31 +00:00
ui - > lineAddress - > setText ( dialog - > decodedString ( ) ) ;
2022-12-27 15:52:06 +00:00
dialog - > deleteLater ( ) ;
2021-06-25 14:14:49 +00:00
# else
2023-09-12 14:15:40 +00:00
Utils : : showError ( this , " Can't open QR scanner " , " Feather was built without webcam QR scanner support " ) ;
2021-06-25 14:14:49 +00:00
# endif
}
2020-10-07 10:36:04 +00:00
void SendWidget : : sendClicked ( ) {
2023-03-01 02:05:56 +00:00
if ( ! m_wallet - > isConnected ( ) ) {
2023-09-12 14:15:40 +00:00
Utils : : showError ( this , " Unable to create transaction " , " Wallet is not connected to a node. " ,
{ " Wait for the wallet to automatically connect to a node. " , " Go to File -> Settings -> Network -> Node to manually connect to a node. " } ,
" nodes " ) ;
2020-12-22 23:46:42 +00:00
return ;
}
2023-03-01 02:05:56 +00:00
if ( ! m_wallet - > isSynchronized ( ) ) {
2023-09-12 14:15:40 +00:00
Utils : : showError ( this , " Unable to create transaction " , " Wallet is not synchronized " , { " Wait for wallet synchronization to complete " } , " synchronization " ) ;
2022-02-25 15:24:27 +00:00
return ;
}
2020-10-30 21:13:56 +00:00
QString recipient = ui - > lineAddress - > text ( ) . simplified ( ) . remove ( ' ' ) ;
2021-10-22 22:14:34 +00:00
if ( recipient . isEmpty ( ) ) {
2023-09-12 14:15:40 +00:00
Utils : : showError ( this , " Unable to create transaction " , " No address was entered " , { " Enter an address in the 'Pay to' field. " } , " send_transaction " ) ;
2020-10-07 10:36:04 +00:00
return ;
}
2021-01-26 23:55:27 +00:00
QVector < PartialTxOutput > outputs = ui - > lineAddress - > getOutputs ( ) ;
QVector < PayToLineError > errors = ui - > lineAddress - > getErrors ( ) ;
2022-02-11 11:50:09 +00:00
if ( ! errors . empty ( ) & & ui - > lineAddress - > isMultiline ( ) ) {
2021-01-26 23:55:27 +00:00
QString errorText ;
for ( auto & error : errors ) {
errorText + = QString ( " Line #%1: \n %2 \n " ) . arg ( QString : : number ( error . idx + 1 ) , error . error ) ;
}
2023-09-12 14:15:40 +00:00
Utils : : showError ( this , " Unable to create transaction " , QString ( " Invalid address lines found: \n \n %1 " ) . arg ( errorText ) , { } , " pay_to_many " ) ;
2021-01-26 23:55:27 +00:00
return ;
}
2024-04-28 19:26:54 +00:00
bool subtractFeeFromAmount = conf ( ) - > get ( Config : : subtractFeeFromAmount ) . toBool ( ) & & ui - > check_subtractFeeFromAmount - > isChecked ( ) ;
2022-05-22 17:13:19 +00:00
QString description = ui - > lineDescription - > text ( ) ;
2022-02-11 11:50:09 +00:00
if ( ! outputs . empty ( ) ) { // multi destination transaction
2024-05-03 19:32:26 +00:00
if ( outputs . size ( ) > 15 ) {
Utils : : showError ( this , " Unable to create transaction " , " Maximum number of outputs (15) exceeded. " , { } , " pay_to_many " ) ;
2021-01-26 23:55:27 +00:00
return ;
}
QVector < QString > addresses ;
QVector < quint64 > amounts ;
for ( auto & output : outputs ) {
addresses . push_back ( output . address ) ;
amounts . push_back ( output . amount ) ;
}
2024-04-28 19:26:54 +00:00
QtFuture : : connect ( m_wallet , & Wallet : : preTransactionChecksComplete )
. then ( [ this , addresses , amounts , description , subtractFeeFromAmount ] ( int feeLevel ) {
m_wallet - > createTransactionMultiDest ( addresses , amounts , description , feeLevel , subtractFeeFromAmount ) ;
} ) ;
m_wallet - > preTransactionChecks ( ui - > combo_feePriority - > currentIndex ( ) ) ;
2021-01-26 23:55:27 +00:00
return ;
}
2022-05-22 17:13:19 +00:00
bool sendAll = ( ui - > lineAmount - > text ( ) = = " all " ) ;
QString currency = ui - > comboCurrencySelection - > currentText ( ) ;
quint64 amount = this - > amount ( ) ;
if ( amount = = 0 & & ! sendAll ) {
2023-09-12 14:15:40 +00:00
Utils : : showError ( this , " Unable to create transaction " , " No amount was entered " , { } , " send_transaction " , " Amount field " ) ;
2022-05-22 17:13:19 +00:00
return ;
}
if ( currency ! = " XMR " & & ! sendAll ) {
// Convert fiat amount to XMR, but only if we're not sending the entire balance
2020-12-31 03:26:03 +00:00
amount = WalletManager : : amountFromDouble ( this - > conversionAmount ( ) ) ;
2020-10-07 10:36:04 +00:00
}
2022-05-22 17:13:19 +00:00
2023-09-12 14:15:40 +00:00
quint64 unlocked_balance = m_wallet - > unlockedBalance ( ) ;
quint64 total_balance = m_wallet - > balance ( ) ;
if ( total_balance = = 0 ) {
Utils : : showError ( this , " Unable to create transaction " , " No money to spend " ) ;
return ;
}
2023-10-25 23:23:22 +00:00
if ( unlocked_balance = = 0 ) {
Utils : : showError ( this , " Unable to create transaction " , QString ( " No spendable balance. \n \n %1 XMR becomes spendable within 10 blocks (~20 minutes). " ) . arg ( WalletManager : : displayAmount ( total_balance - unlocked_balance ) ) , { " Wait for more balance to unlock. " , " Click 'Help' to learn more about how balance works. " } , " balance " ) ;
return ;
}
2023-09-12 14:15:40 +00:00
if ( ! sendAll & & amount > unlocked_balance ) {
Utils : : showError ( this , " Unable to create transaction " , QString ( " Not enough money to spend. \n \n "
" Spendable balance: %1 " ) . arg ( WalletManager : : displayAmount ( unlocked_balance ) ) ) ;
return ;
}
2023-12-02 18:28:31 +00:00
// TODO: allow using file-only airgapped signing without scanner
if ( m_wallet - > keyImageSyncNeeded ( amount , sendAll ) ) {
# if defined(WITH_SCANNER)
OfflineTxSigningWizard wizard ( this , m_wallet ) ;
auto r = wizard . exec ( ) ;
m_wallet - > setForceKeyImageSync ( false ) ;
if ( r = = QDialog : : Rejected ) {
return ;
}
# else
Utils : : showError ( this , " Can't open offline transaction signing wizard " , " Feather was built without webcam QR scanner support " ) ;
return ;
# endif
}
2024-04-28 19:26:54 +00:00
QtFuture : : connect ( m_wallet , & Wallet : : preTransactionChecksComplete )
. then ( [ this , recipient , amount , description , sendAll , subtractFeeFromAmount ] ( int feeLevel ) {
m_wallet - > createTransaction ( recipient , amount , description , sendAll , feeLevel , subtractFeeFromAmount ) ;
} ) ;
m_wallet - > preTransactionChecks ( ui - > combo_feePriority - > currentIndex ( ) ) ;
2020-10-07 10:36:04 +00:00
}
void SendWidget : : aliasClicked ( ) {
2021-10-22 23:46:38 +00:00
ui - > btn_openAlias - > setEnabled ( false ) ;
2021-10-22 22:14:34 +00:00
auto alias = ui - > lineAddress - > text ( ) ;
WalletManager : : instance ( ) - > resolveOpenAliasAsync ( alias ) ;
2020-10-07 10:36:04 +00:00
}
void SendWidget : : clearClicked ( ) {
ui - > lineAddress - > clear ( ) ;
ui - > lineAmount - > clear ( ) ;
ui - > lineDescription - > clear ( ) ;
}
void SendWidget : : btnMaxClicked ( ) {
ui - > lineAmount - > setText ( " all " ) ;
2020-12-31 03:26:03 +00:00
this - > updateConversionLabel ( ) ;
2020-10-07 10:36:04 +00:00
}
void SendWidget : : updateConversionLabel ( ) {
2020-12-31 03:26:03 +00:00
auto amount = this - > amountDouble ( ) ;
2020-10-15 02:17:57 +00:00
ui - > label_conversionAmount - > setText ( " " ) ;
2020-12-31 03:26:03 +00:00
if ( amount < = 0 ) {
2020-10-15 02:17:57 +00:00
ui - > label_conversionAmount - > hide ( ) ;
2020-10-07 10:36:04 +00:00
return ;
}
2023-09-12 14:15:40 +00:00
if ( conf ( ) - > get ( Config : : disableWebsocket ) . toBool ( ) ) {
2023-02-13 09:41:07 +00:00
return ;
}
2020-10-15 02:17:57 +00:00
QString conversionAmountStr = [ this ] {
QString currency = ui - > comboCurrencySelection - > currentText ( ) ;
if ( currency ! = " XMR " ) {
return QString ( " ~%1 XMR " ) . arg ( QString : : number ( this - > conversionAmount ( ) , ' f ' ) ) ;
} else {
2023-09-12 14:15:40 +00:00
auto preferredFiatCurrency = conf ( ) - > get ( Config : : preferredFiatCurrency ) . toString ( ) ;
2021-05-02 18:22:38 +00:00
double conversionAmount = appData ( ) - > prices . convert ( " XMR " , preferredFiatCurrency , this - > amountDouble ( ) ) ;
2020-10-15 02:17:57 +00:00
return QString ( " ~%1 %2 " ) . arg ( QString : : number ( conversionAmount , ' f ' , 2 ) , preferredFiatCurrency ) ;
2020-12-28 04:39:20 +00:00
}
2020-10-15 02:17:57 +00:00
} ( ) ;
ui - > label_conversionAmount - > setText ( conversionAmountStr ) ;
ui - > label_conversionAmount - > show ( ) ;
2020-10-07 10:36:04 +00:00
}
double SendWidget : : conversionAmount ( ) {
QString currency = ui - > comboCurrencySelection - > currentText ( ) ;
2021-05-02 18:22:38 +00:00
return appData ( ) - > prices . convert ( currency , " XMR " , this - > amountDouble ( ) ) ;
2020-10-07 10:36:04 +00:00
}
2020-12-31 03:26:03 +00:00
quint64 SendWidget : : amount ( ) {
2020-10-07 10:36:04 +00:00
// grab amount from "amount" text box
QString amount = ui - > lineAmount - > text ( ) ;
2022-05-22 17:13:19 +00:00
if ( amount = = " all " ) {
return 0 ;
}
2020-12-31 03:26:03 +00:00
2020-10-07 10:36:04 +00:00
amount . replace ( ' , ' , ' . ' ) ;
2022-05-22 17:13:19 +00:00
if ( amount . isEmpty ( ) ) {
return 0 ;
}
2020-12-31 03:26:03 +00:00
return WalletManager : : amountFromString ( amount ) ;
}
double SendWidget : : amountDouble ( ) {
quint64 amount = this - > amount ( ) ;
2021-05-18 15:59:18 +00:00
return amount / constants : : cdiv ;
2020-10-07 10:36:04 +00:00
}
2021-10-22 22:14:34 +00:00
void SendWidget : : onOpenAliasResolved ( const QString & openAlias , const QString & address , bool dnssecValid ) {
2021-10-22 23:46:38 +00:00
ui - > btn_openAlias - > setEnabled ( true ) ;
2021-10-22 22:14:34 +00:00
if ( address . isEmpty ( ) ) {
2023-09-12 14:15:40 +00:00
Utils : : showError ( this , " Unable to resolve OpenAlias " , " Address empty. " ) ;
2021-10-22 22:14:34 +00:00
return ;
}
if ( ! dnssecValid ) {
2023-09-12 14:15:40 +00:00
Utils : : showError ( this , " Unable to resolve OpenAlias " , " Address found, but the DNSSEC signatures could not be verified, so this address may be spoofed. " ) ;
2021-10-22 22:14:34 +00:00
return ;
}
bool valid = WalletManager : : addressValid ( address , constants : : networkType ) ;
if ( ! valid ) {
2023-09-12 14:15:40 +00:00
Utils : : showError ( this , " Unable to resolve OpenAlias " , QString ( " Address validation failed. \n \n OpenAlias: %1 \n Address: %2 " ) . arg ( openAlias , address ) ) ;
2021-10-22 22:14:34 +00:00
return ;
}
2020-10-07 10:36:04 +00:00
this - > fill ( address , openAlias ) ;
ui - > btn_openAlias - > hide ( ) ;
}
void SendWidget : : clearFields ( ) {
ui - > lineAddress - > clear ( ) ;
ui - > lineAmount - > clear ( ) ;
ui - > lineDescription - > clear ( ) ;
2020-10-15 02:17:57 +00:00
ui - > label_conversionAmount - > clear ( ) ;
2020-10-07 10:36:04 +00:00
}
2021-01-26 23:55:27 +00:00
void SendWidget : : payToMany ( ) {
ui - > lineAddress - > payToMany ( ) ;
}
2023-12-15 13:10:55 +00:00
void SendWidget : : disableSendButton ( ) {
2020-10-07 10:36:04 +00:00
ui - > btnSend - > setEnabled ( false ) ;
}
2023-12-15 13:10:55 +00:00
void SendWidget : : enableSendButton ( ) {
if ( m_disallowSending ) {
return ;
2022-03-12 12:53:46 +00:00
}
2023-12-15 13:10:55 +00:00
ui - > btnSend - > setEnabled ( true ) ;
2022-03-12 12:53:46 +00:00
}
2023-12-15 13:10:55 +00:00
void SendWidget : : disallowSending ( ) {
m_disallowSending = true ;
2022-03-12 12:53:46 +00:00
ui - > btnSend - > setEnabled ( false ) ;
2020-10-07 10:36:04 +00:00
}
2023-02-13 09:41:07 +00:00
void SendWidget : : setWebsocketEnabled ( bool enabled ) {
this - > updateConversionLabel ( ) ;
if ( enabled ) {
this - > setupComboBox ( ) ;
} else {
ui - > comboCurrencySelection - > clear ( ) ;
ui - > comboCurrencySelection - > insertItem ( 0 , " XMR " ) ;
}
}
2024-04-28 19:26:54 +00:00
void SendWidget : : setManualFeeSelectionEnabled ( bool enabled ) {
ui - > label_feeTarget - > setVisible ( enabled ) ;
ui - > combo_feePriority - > setVisible ( enabled ) ;
}
void SendWidget : : setSubtractFeeFromAmountEnabled ( bool enabled ) {
ui - > check_subtractFeeFromAmount - > setVisible ( enabled ) ;
}
2021-07-07 22:48:17 +00:00
void SendWidget : : onDataPasted ( const QString & data ) {
if ( ! data . isEmpty ( ) ) {
2023-03-01 02:05:56 +00:00
QVariantMap uriData = m_wallet - > parse_uri_to_object ( data ) ;
2021-07-07 22:48:17 +00:00
if ( ! uriData . contains ( " error " ) ) {
2021-07-09 21:43:59 +00:00
ui - > lineAddress - > setText ( uriData . value ( " address " ) . toString ( ) ) ;
ui - > lineDescription - > setText ( uriData . value ( " tx_description " ) . toString ( ) ) ;
ui - > lineAmount - > setText ( uriData . value ( " amount " ) . toString ( ) ) ;
2021-07-07 22:48:17 +00:00
} else {
ui - > lineAddress - > setText ( data ) ;
}
}
else {
2023-09-12 14:15:40 +00:00
Utils : : showError ( this , " Unable to decode QR code " , " No QR code found. " ) ;
2021-07-07 22:48:17 +00:00
}
}
2020-11-24 21:16:24 +00:00
void SendWidget : : setupComboBox ( ) {
ui - > comboCurrencySelection - > clear ( ) ;
QStringList defaultCurrencies = { " XMR " , " USD " , " EUR " , " CNY " , " JPY " , " GBP " } ;
2023-09-12 14:15:40 +00:00
QString preferredCurrency = conf ( ) - > get ( Config : : preferredFiatCurrency ) . toString ( ) ;
2020-11-24 21:16:24 +00:00
if ( defaultCurrencies . contains ( preferredCurrency ) ) {
defaultCurrencies . removeOne ( preferredCurrency ) ;
}
ui - > comboCurrencySelection - > insertItems ( 0 , defaultCurrencies ) ;
ui - > comboCurrencySelection - > insertItem ( 1 , preferredCurrency ) ;
}
2020-10-15 02:17:57 +00:00
void SendWidget : : onPreferredFiatCurrencyChanged ( ) {
this - > updateConversionLabel ( ) ;
2020-11-24 21:16:24 +00:00
this - > setupComboBox ( ) ;
2020-10-15 02:17:57 +00:00
}
2021-06-25 14:14:49 +00:00
void SendWidget : : skinChanged ( ) {
if ( ColorScheme : : hasDarkBackground ( this ) ) {
ui - > btnScan - > setIcon ( icons ( ) - > icon ( " camera_white.png " ) ) ;
} else {
ui - > btnScan - > setIcon ( icons ( ) - > icon ( " camera_dark.png " ) ) ;
}
}
2021-06-27 12:13:05 +00:00
SendWidget : : ~ SendWidget ( ) = default ;