Send: Always include pref. currency in combobox

This commit is contained in:
tobtoht 2020-11-24 22:16:24 +01:00
parent 9d781d1b57
commit 1d001322cc
3 changed files with 20 additions and 42 deletions

View file

@ -29,6 +29,8 @@ SendWidget::SendWidget(QWidget *parent) :
ui->label_conversionAmount->setText("");
ui->label_conversionAmount->hide();
ui->btn_openAlias->hide();
this->setupComboBox();
}
void SendWidget::currencyComboChanged(int index) {
@ -185,8 +187,23 @@ void SendWidget::onEndTransaction() {
ui->btnSend->setEnabled(true);
}
void SendWidget::setupComboBox() {
ui->comboCurrencySelection->clear();
QStringList defaultCurrencies = {"XMR", "USD", "EUR", "CNY", "JPY", "GBP"};
QString preferredCurrency = config()->get(Config::preferredFiatCurrency).toString();
if (defaultCurrencies.contains(preferredCurrency)) {
defaultCurrencies.removeOne(preferredCurrency);
}
ui->comboCurrencySelection->insertItems(0, defaultCurrencies);
ui->comboCurrencySelection->insertItem(1, preferredCurrency);
}
void SendWidget::onPreferredFiatCurrencyChanged() {
this->updateConversionLabel();
this->setupComboBox();
}
SendWidget::~SendWidget() {

View file

@ -48,6 +48,8 @@ signals:
void createTransaction(const QString &address, double amount, const QString &description, bool all);
private:
void setupComboBox();
Ui::SendWidget *ui;
AppContext *m_ctx;
double amount();

View file

@ -105,48 +105,7 @@
</widget>
</item>
<item>
<widget class="QComboBox" name="comboCurrencySelection">
<item>
<property name="text">
<string>XMR</string>
</property>
</item>
<item>
<property name="text">
<string>EUR</string>
</property>
</item>
<item>
<property name="text">
<string>USD</string>
</property>
</item>
<item>
<property name="text">
<string>GBP</string>
</property>
</item>
<item>
<property name="text">
<string>AUD</string>
</property>
</item>
<item>
<property name="text">
<string>JPY</string>
</property>
</item>
<item>
<property name="text">
<string>NZD</string>
</property>
</item>
<item>
<property name="text">
<string>RMB</string>
</property>
</item>
</widget>
<widget class="QComboBox" name="comboCurrencySelection"/>
</item>
</layout>
</item>