diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 9524098..0c9c9bb 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -256,6 +256,7 @@ MainWindow::MainWindow(AppContext *ctx, QWidget *parent) :
connect(m_windowSettings, &Settings::preferredFiatCurrencyChanged, tickerWidget, &TickerWidget::init);
connect(m_windowSettings, &Settings::preferredFiatCurrencyChanged, m_balanceWidget, &TickerWidget::init);
connect(m_windowSettings, &Settings::preferredFiatCurrencyChanged, m_ctx, &AppContext::onPreferredFiatCurrencyChanged);
+ connect(m_windowSettings, &Settings::preferredFiatCurrencyChanged, ui->sendWidget, QOverload<>::of(&SendWidget::onPreferredFiatCurrencyChanged));
// CCS/Reddit widget
connect(m_windowSettings, &Settings::homeWidgetChanged, this, &MainWindow::homeWidgetChanged);
diff --git a/src/sendwidget.cpp b/src/sendwidget.cpp
index 32f93f6..d08454c 100644
--- a/src/sendwidget.cpp
+++ b/src/sendwidget.cpp
@@ -27,8 +27,8 @@ SendWidget::SendWidget(QWidget *parent) :
connect(ui->lineAmount, &QLineEdit::textEdited, this, &SendWidget::amountEdited);
connect(ui->lineAddress, &QLineEdit::textEdited, this, &SendWidget::addressEdited);
connect(ui->btn_openAlias, &QPushButton::clicked, this, &SendWidget::aliasClicked);
- ui->label_xmrAmount->setText("");
- ui->label_xmrAmount->hide();
+ ui->label_conversionAmount->setText("");
+ ui->label_conversionAmount->hide();
ui->btn_openAlias->hide();
}
@@ -120,18 +120,26 @@ void SendWidget::btnMaxClicked() {
void SendWidget::updateConversionLabel() {
auto amount = this->amount();
if(amount == -1) return;
- ui->label_xmrAmount->setText("");
+ ui->label_conversionAmount->setText("");
if(amount <= 0) {
- ui->label_xmrAmount->hide();
+ ui->label_conversionAmount->hide();
return;
}
- QString currency = ui->comboCurrencySelection->currentText();
- if (currency != "XMR") {
- QString xmr_str = QString("%1 XMR").arg(QString::number(this->conversionAmount()));
- ui->label_xmrAmount->setText(xmr_str);
- ui->label_xmrAmount->show();
- }
+ QString conversionAmountStr = [this]{
+ QString currency = ui->comboCurrencySelection->currentText();
+ if (currency != "XMR") {
+ return QString("~%1 XMR").arg(QString::number(this->conversionAmount(), 'f'));
+
+ } else {
+ auto preferredFiatCurrency = config()->get(Config::preferredFiatCurrency).toString();
+ double conversionAmount = AppContext::prices->convert("XMR", preferredFiatCurrency, this->amount());
+ return QString("~%1 %2").arg(QString::number(conversionAmount, 'f', 2), preferredFiatCurrency);
+ };
+ }();
+
+ ui->label_conversionAmount->setText(conversionAmountStr);
+ ui->label_conversionAmount->show();
}
double SendWidget::conversionAmount() {
@@ -163,7 +171,7 @@ void SendWidget::clearFields() {
ui->lineAddress->clear();
ui->lineAmount->clear();
ui->lineDescription->clear();
- ui->label_xmrAmount->clear();
+ ui->label_conversionAmount->clear();
}
void SendWidget::onWalletClosed() {
@@ -178,6 +186,10 @@ void SendWidget::onEndTransaction() {
ui->btnSend->setEnabled(true);
}
+void SendWidget::onPreferredFiatCurrencyChanged() {
+ this->updateConversionLabel();
+}
+
SendWidget::~SendWidget() {
delete ui;
}
diff --git a/src/sendwidget.h b/src/sendwidget.h
index fd6338c..7c45f78 100644
--- a/src/sendwidget.h
+++ b/src/sendwidget.h
@@ -38,6 +38,7 @@ public slots:
void onOpenAliasResolveError(const QString &err);
void onOpenAliasResolved(const QString &address, const QString &openAlias);
void onWalletClosed();
+ void onPreferredFiatCurrencyChanged();
void onInitiateTransaction();
void onEndTransaction();
diff --git a/src/sendwidget.ui b/src/sendwidget.ui
index 73b5711..de52361 100644
--- a/src/sendwidget.ui
+++ b/src/sendwidget.ui
@@ -6,8 +6,8 @@
0
0
- 500
- 148
+ 603
+ 175
@@ -153,12 +153,12 @@
-
-
+
true
- xmrAmount
+ conversionAmount