mirror of
https://github.com/feather-wallet/feather.git
synced 2025-04-24 05:08:12 +00:00
Calc: configure crypto/fiat symbols
This commit is contained in:
parent
8e663d4a18
commit
bf533ddfaa
10 changed files with 515 additions and 151 deletions
|
@ -8,6 +8,7 @@
|
|||
#include "utils/ColorScheme.h"
|
||||
#include "utils/AppData.h"
|
||||
#include "utils/config.h"
|
||||
#include "dialog/CalcConfigDialog.h"
|
||||
|
||||
CalcWidget::CalcWidget(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
|
@ -29,14 +30,20 @@ CalcWidget::CalcWidget(QWidget *parent)
|
|||
ui->lineFrom->setValidator(dv);
|
||||
ui->lineTo->setValidator(dv);
|
||||
|
||||
connect(&appData()->prices, &Prices::fiatPricesUpdated, this, &CalcWidget::initComboBox);
|
||||
connect(&appData()->prices, &Prices::cryptoPricesUpdated, this, &CalcWidget::initComboBox);
|
||||
connect(&appData()->prices, &Prices::fiatPricesUpdated, this, &CalcWidget::onPricesReceived);
|
||||
connect(&appData()->prices, &Prices::cryptoPricesUpdated, this, &CalcWidget::onPricesReceived);
|
||||
|
||||
connect(ui->lineFrom, &QLineEdit::textEdited, this, [this]{this->convert(false);});
|
||||
connect(ui->lineTo, &QLineEdit::textEdited, this, [this]{this->convert(true);});
|
||||
|
||||
connect(ui->comboCalcFrom, QOverload<int>::of(&QComboBox::currentIndexChanged), [this]{this->convert(false);});
|
||||
connect(ui->comboCalcTo, QOverload<int>::of(&QComboBox::currentIndexChanged), [this]{this->convert(true);});
|
||||
connect(ui->comboCalcTo, QOverload<int>::of(&QComboBox::currentIndexChanged), [this]{this->convert(false);});
|
||||
|
||||
connect(ui->btn_configure, &QPushButton::clicked, this, &CalcWidget::showCalcConfigureDialog);
|
||||
|
||||
QTimer::singleShot(1, [this]{
|
||||
this->skinChanged();
|
||||
});
|
||||
}
|
||||
|
||||
void CalcWidget::convert(bool reverse) {
|
||||
|
@ -67,33 +74,76 @@ void CalcWidget::convert(bool reverse) {
|
|||
lineTo->setText(QString::number(result, 'f', precision));
|
||||
}
|
||||
|
||||
void CalcWidget::initComboBox() {
|
||||
void CalcWidget::onPricesReceived() {
|
||||
if (m_comboBoxInit)
|
||||
return;
|
||||
|
||||
QList<QString> marketsKeys = appData()->prices.markets.keys();
|
||||
QList<QString> ratesKeys = appData()->prices.rates.keys();
|
||||
if(marketsKeys.count() <= 0 || ratesKeys.count() <= 0) return;
|
||||
QList<QString> cryptoKeys = appData()->prices.markets.keys();
|
||||
QList<QString> fiatKeys = appData()->prices.rates.keys();
|
||||
if (cryptoKeys.empty() || fiatKeys.empty())
|
||||
return;
|
||||
|
||||
ui->comboCalcFrom->addItems(marketsKeys);
|
||||
ui->comboCalcFrom->insertSeparator(marketsKeys.count());
|
||||
ui->comboCalcFrom->addItems(ratesKeys);
|
||||
ui->comboCalcFrom->setCurrentIndex(marketsKeys.indexOf("XMR"));
|
||||
ui->btn_configure->setEnabled(true);
|
||||
this->initComboBox();
|
||||
m_comboBoxInit = true;
|
||||
}
|
||||
|
||||
ui->comboCalcTo->addItems(marketsKeys);
|
||||
ui->comboCalcTo->insertSeparator(marketsKeys.count());
|
||||
ui->comboCalcTo->addItems(ratesKeys);
|
||||
void CalcWidget::initComboBox() {
|
||||
QList<QString> cryptoKeys = appData()->prices.markets.keys();
|
||||
QList<QString> fiatKeys = appData()->prices.rates.keys();
|
||||
|
||||
QStringList enabledCrypto = config()->get(Config::cryptoSymbols).toStringList();
|
||||
QStringList filteredCryptoKeys;
|
||||
for (const auto& symbol : cryptoKeys) {
|
||||
if (enabledCrypto.contains(symbol)) {
|
||||
filteredCryptoKeys.append(symbol);
|
||||
}
|
||||
}
|
||||
|
||||
QStringList enabledFiat = config()->get(Config::fiatSymbols).toStringList();
|
||||
auto preferredFiat = config()->get(Config::preferredFiatCurrency).toString();
|
||||
ui->comboCalcTo->setCurrentText(preferredFiat);
|
||||
if (!enabledFiat.contains(preferredFiat) && fiatKeys.contains(preferredFiat)) {
|
||||
enabledFiat.append(preferredFiat);
|
||||
config()->set(Config::fiatSymbols, enabledFiat);
|
||||
}
|
||||
QStringList filteredFiatKeys;
|
||||
for (const auto &symbol : fiatKeys) {
|
||||
if (enabledFiat.contains(symbol)) {
|
||||
filteredFiatKeys.append(symbol);
|
||||
}
|
||||
}
|
||||
|
||||
this->m_comboBoxInit = true;
|
||||
this->setupComboBox(ui->comboCalcFrom, filteredCryptoKeys, filteredFiatKeys);
|
||||
this->setupComboBox(ui->comboCalcTo, filteredCryptoKeys, filteredFiatKeys);
|
||||
|
||||
ui->comboCalcFrom->setCurrentIndex(ui->comboCalcFrom->findText("XMR"));
|
||||
|
||||
if (!preferredFiat.isEmpty()) {
|
||||
ui->comboCalcTo->setCurrentIndex(ui->comboCalcTo->findText(preferredFiat));
|
||||
} else {
|
||||
ui->comboCalcTo->setCurrentIndex(ui->comboCalcTo->findText("USD"));
|
||||
}
|
||||
}
|
||||
|
||||
void CalcWidget::skinChanged() {
|
||||
ui->imageExchange->setMode(ColorScheme::hasDarkBackground(this));
|
||||
}
|
||||
|
||||
void CalcWidget::showCalcConfigureDialog() {
|
||||
CalcConfigDialog dialog{this};
|
||||
|
||||
if (dialog.exec() == QDialog::Accepted) {
|
||||
this->initComboBox();
|
||||
}
|
||||
}
|
||||
|
||||
void CalcWidget::setupComboBox(QComboBox *comboBox, const QStringList &crypto, const QStringList &fiat) {
|
||||
comboBox->clear();
|
||||
comboBox->addItems(crypto);
|
||||
comboBox->insertSeparator(comboBox->count());
|
||||
comboBox->addItems(fiat);
|
||||
}
|
||||
|
||||
CalcWidget::~CalcWidget() {
|
||||
delete ui;
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#define FEATHER_CALCWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QComboBox>
|
||||
|
||||
namespace Ui {
|
||||
class CalcWidget;
|
||||
|
@ -23,9 +24,12 @@ public slots:
|
|||
|
||||
private slots:
|
||||
void initComboBox();
|
||||
void showCalcConfigureDialog();
|
||||
void onPricesReceived();
|
||||
|
||||
private:
|
||||
void convert(bool reverse);
|
||||
void setupComboBox(QComboBox *comboBox, const QStringList &crypto, const QStringList &fiat);
|
||||
|
||||
Ui::CalcWidget *ui;
|
||||
bool m_comboBoxInit = false;
|
||||
|
|
|
@ -6,141 +6,22 @@
|
|||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>737</width>
|
||||
<height>153</height>
|
||||
<width>800</width>
|
||||
<height>132</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>MainWindow</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="spacing">
|
||||
<number>9</number>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Crypto/fiat and fiat/fiat calculator.</string>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Crypto/fiat and fiat/fiat calculator.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<property name="horizontalSpacing">
|
||||
<number>18</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineFrom">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="frame">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>From...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboCalcFrom"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="DoublePixmapLabel" name="imageExchange">
|
||||
<property name="text">
|
||||
<string>exchange image</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineTo">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>To...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboCalcTo"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="labelWarning">
|
||||
<property name="text">
|
||||
<string>Exchange rates are updated every 2 minutes.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>170</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
|
@ -155,8 +36,98 @@
|
|||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btn_configure">
|
||||
<property name="text">
|
||||
<string>Configure</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<property name="horizontalSpacing">
|
||||
<number>18</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineFrom">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="frame">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>From...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboCalcFrom"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="DoublePixmapLabel" name="imageExchange">
|
||||
<property name="text">
|
||||
<string>exchange image</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineTo">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Maximum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="placeholderText">
|
||||
<string>To...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="comboCalcTo"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="labelWarning">
|
||||
<property name="text">
|
||||
<string>Exchange rates are updated every 2 minutes.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
|
|
102
src/dialog/CalcConfigDialog.cpp
Normal file
102
src/dialog/CalcConfigDialog.cpp
Normal file
|
@ -0,0 +1,102 @@
|
|||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
// Copyright (c) 2020-2021, The Monero Project.
|
||||
|
||||
#include "CalcConfigDialog.h"
|
||||
#include "ui_CalcConfigDialog.h"
|
||||
#include "AppData.h"
|
||||
#include "utils/config.h"
|
||||
|
||||
CalcConfigDialog::CalcConfigDialog(QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, ui(new Ui::CalcConfigDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
this->fillListWidgets();
|
||||
|
||||
connect(ui->btn_selectAll, &QPushButton::clicked, this, &CalcConfigDialog::selectAll);
|
||||
connect(ui->btn_deselectAll, &QPushButton::clicked, this, &CalcConfigDialog::deselectAll);
|
||||
|
||||
connect(ui->buttonBox, &QDialogButtonBox::accepted, [this]{
|
||||
config()->set(Config::fiatSymbols, this->checkedFiat());
|
||||
config()->set(Config::cryptoSymbols, this->checkedCrypto());
|
||||
this->accept();
|
||||
});
|
||||
|
||||
this->adjustSize();
|
||||
}
|
||||
|
||||
QStringList CalcConfigDialog::checkedFiat() {
|
||||
return this->getChecked(ui->list_fiat);
|
||||
}
|
||||
|
||||
QStringList CalcConfigDialog::checkedCrypto() {
|
||||
return this->getChecked(ui->list_crypto);
|
||||
}
|
||||
|
||||
void CalcConfigDialog::selectAll() {
|
||||
this->setCheckState(this->getVisibleListWidget(), Qt::Checked);
|
||||
}
|
||||
|
||||
void CalcConfigDialog::deselectAll() {
|
||||
this->setCheckState(this->getVisibleListWidget(), Qt::Unchecked);
|
||||
}
|
||||
|
||||
void CalcConfigDialog::setCheckState(QListWidget *widget, Qt::CheckState checkState) {
|
||||
QListWidgetItem *item;
|
||||
for (int i=0; i < widget->count(); i++) {
|
||||
item = widget->item(i);
|
||||
item->setCheckState(checkState);
|
||||
}
|
||||
}
|
||||
|
||||
QStringList CalcConfigDialog::getChecked(QListWidget *widget) {
|
||||
QStringList checked;
|
||||
QListWidgetItem *item;
|
||||
for (int i=0; i < widget->count(); i++) {
|
||||
item = widget->item(i);
|
||||
if (item->checkState() == Qt::Checked) {
|
||||
checked.append(item->text());
|
||||
}
|
||||
}
|
||||
return checked;
|
||||
}
|
||||
|
||||
QListWidget* CalcConfigDialog::getVisibleListWidget() {
|
||||
if (ui->tabWidget->currentIndex() == 0) {
|
||||
return ui->list_fiat;
|
||||
} else {
|
||||
return ui->list_crypto;
|
||||
}
|
||||
}
|
||||
|
||||
void CalcConfigDialog::fillListWidgets() {
|
||||
QStringList cryptoCurrencies = appData()->prices.markets.keys();
|
||||
QStringList fiatCurrencies = appData()->prices.rates.keys();
|
||||
|
||||
QStringList checkedCryptoCurrencies = config()->get(Config::cryptoSymbols).toStringList();
|
||||
QStringList checkedFiatCurrencies = config()->get(Config::fiatSymbols).toStringList();
|
||||
|
||||
ui->list_crypto->addItems(cryptoCurrencies);
|
||||
ui->list_fiat->addItems(fiatCurrencies);
|
||||
|
||||
auto setChecked = [](QListWidget *widget, const QStringList &checked){
|
||||
QListWidgetItem *item;
|
||||
for (int i=0; i < widget->count(); i++) {
|
||||
item = widget->item(i);
|
||||
item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
|
||||
if (checked.contains(item->text())) {
|
||||
item->setCheckState(Qt::Checked);
|
||||
} else {
|
||||
item->setCheckState(Qt::Unchecked);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
setChecked(ui->list_crypto, checkedCryptoCurrencies);
|
||||
setChecked(ui->list_fiat, checkedFiatCurrencies);
|
||||
}
|
||||
|
||||
CalcConfigDialog::~CalcConfigDialog() {
|
||||
delete ui;
|
||||
}
|
39
src/dialog/CalcConfigDialog.h
Normal file
39
src/dialog/CalcConfigDialog.h
Normal file
|
@ -0,0 +1,39 @@
|
|||
// SPDX-License-Identifier: BSD-3-Clause
|
||||
// Copyright (c) 2020-2021, The Monero Project.
|
||||
|
||||
#ifndef FEATHER_CALCCONFIGDIALOG_H
|
||||
#define FEATHER_CALCCONFIGDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QListWidget>
|
||||
|
||||
namespace Ui {
|
||||
class CalcConfigDialog;
|
||||
}
|
||||
|
||||
class CalcConfigDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CalcConfigDialog(QWidget *parent = nullptr);
|
||||
~CalcConfigDialog() override;
|
||||
|
||||
QStringList checkedFiat();
|
||||
QStringList checkedCrypto();
|
||||
|
||||
private slots:
|
||||
void selectAll();
|
||||
void deselectAll();
|
||||
|
||||
private:
|
||||
void setCheckState(QListWidget *widget, Qt::CheckState checkState);
|
||||
QStringList getChecked(QListWidget *widget);
|
||||
void fillListWidgets();
|
||||
QListWidget* getVisibleListWidget();
|
||||
|
||||
Ui::CalcConfigDialog *ui;
|
||||
};
|
||||
|
||||
|
||||
#endif //FEATHER_CALCCONFIGDIALOG_H
|
153
src/dialog/CalcConfigDialog.ui
Normal file
153
src/dialog/CalcConfigDialog.ui
Normal file
|
@ -0,0 +1,153 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CalcConfigDialog</class>
|
||||
<widget class="QDialog" name="CalcConfigDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>509</width>
|
||||
<height>574</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Calc config</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab">
|
||||
<attribute name="title">
|
||||
<string>Fiat</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QListWidget" name="list_fiat"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_2">
|
||||
<attribute name="title">
|
||||
<string>Crypto</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QListWidget" name="list_crypto"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="line">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QPushButton" name="btn_selectAll">
|
||||
<property name="text">
|
||||
<string>Select all</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btn_deselectAll">
|
||||
<property name="text">
|
||||
<string>Deselect all</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>CalcConfigDialog</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>CalcConfigDialog</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
|
@ -249,8 +249,41 @@
|
|||
<string>Calc</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<item row="0" column="1">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Preferred</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="CalcWidget" name="conversionWidget" native="true"/>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="CalcWidget" name="conversionWidget" native="true"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
|
|
@ -68,6 +68,9 @@ static const QHash<Config::ConfigKey, ConfigDirective> configStrings = {
|
|||
{Config::redditFrontend, {QS("redditFrontend"), "old.reddit.com"}},
|
||||
{Config::localMoneroFrontend, {QS("localMoneroFrontend"), "https://localmonero.co"}},
|
||||
|
||||
{Config::fiatSymbols, {QS("fiatSymbols"), QStringList{"USD", "EUR", "GBP", "CAD", "AUD", "RUB"}}},
|
||||
{Config::cryptoSymbols, {QS("cryptoSymbols"), QStringList{"BTC", "ETH", "LTC", "XMR", "ZEC"}}},
|
||||
|
||||
// Tor
|
||||
{Config::torPrivacyLevel, {QS("torPrivacyLevel"), 1}},
|
||||
{Config::socks5Host, {QS("socks5Host"), "127.0.0.1"}},
|
||||
|
|
|
@ -20,6 +20,7 @@ public:
|
|||
|
||||
enum ConfigKey
|
||||
{
|
||||
// General
|
||||
firstRun,
|
||||
warnOnStagenet,
|
||||
warnOnTestnet,
|
||||
|
@ -33,14 +34,17 @@ public:
|
|||
windowState,
|
||||
GUI_HistoryViewState,
|
||||
|
||||
// Wallets
|
||||
walletDirectory, // Directory where wallet files are stored
|
||||
autoOpenWalletPath,
|
||||
recentlyOpenedWallets,
|
||||
|
||||
// Nodes
|
||||
nodes,
|
||||
nodeSource,
|
||||
useOnionNodes,
|
||||
|
||||
// Tabs
|
||||
showTabHome,
|
||||
showTabCoins,
|
||||
showTabExchange,
|
||||
|
@ -48,9 +52,11 @@ public:
|
|||
showTabXMRig,
|
||||
showSearchbar,
|
||||
|
||||
// Mining
|
||||
xmrigPath,
|
||||
xmrigPool,
|
||||
|
||||
// Settings
|
||||
preferredFiatCurrency,
|
||||
skin,
|
||||
amountPrecision,
|
||||
|
@ -66,6 +72,10 @@ public:
|
|||
redditFrontend,
|
||||
localMoneroFrontend,
|
||||
|
||||
fiatSymbols,
|
||||
cryptoSymbols,
|
||||
|
||||
// Tor
|
||||
torPrivacyLevel,
|
||||
socks5Host,
|
||||
socks5Port,
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
|
||||
#include "utils/prices.h"
|
||||
|
||||
Prices::Prices(QObject *parent) : QObject(parent) {
|
||||
this->rates = QMap<QString, double>();
|
||||
this->markets = QMap<QString, marketStruct>();
|
||||
Prices::Prices(QObject *parent)
|
||||
: QObject(parent)
|
||||
{
|
||||
}
|
||||
|
||||
void Prices::cryptoPricesReceived(const QJsonArray &data) {
|
||||
|
@ -30,9 +30,8 @@ void Prices::cryptoPricesReceived(const QJsonArray &data) {
|
|||
|
||||
void Prices::fiatPricesReceived(const QJsonObject &data) {
|
||||
QJsonObject ratesData = data.value("rates").toObject();
|
||||
for (const auto ¤cy : ratesData) {
|
||||
QString currencyStr = currency.toString();
|
||||
this->rates.insert(currencyStr, ratesData.value(currencyStr).toDouble());
|
||||
for (const auto ¤cy : ratesData.keys()) {
|
||||
this->rates.insert(currency, ratesData.value(currency).toDouble());
|
||||
}
|
||||
emit fiatPricesUpdated();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue