add the option to choose between usd,eur,btc as currency for mainwindow Pricecheck

This commit is contained in:
Denio
2019-11-17 22:41:37 +01:00
parent 740e713281
commit b0c12948c7
6 changed files with 299 additions and 106 deletions

View File

@@ -36,6 +36,7 @@ MainWindow::MainWindow(QWidget *parent) :
this->slot_change_theme(theme_name);
ui->setupUi(this);
logger = new Logger(this, QDir(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)).filePath("silentdragonlite-wallet.log"));
@@ -393,6 +394,21 @@ void MainWindow::setupSettingsModal() {
Ui_Settings settings;
settings.setupUi(&settingsDialog);
Settings::saveRestore(&settingsDialog);
// Include currencies
QString currency_name;
try
{
currency_name = Settings::getInstance()->get_currency_name();
}
catch (...)
{
currency_name = "USD";
}
this->slot_change_currency(currency_name);
// Setup theme combo
int theme_index = settings.comboBoxTheme->findText(Settings::getInstance()->get_theme_name(), Qt::MatchExactly);
@@ -404,6 +420,19 @@ void MainWindow::setupSettingsModal() {
QMessageBox::information(this, tr("Restart"), tr("Please restart Silentdragonlite to have the theme apply"), QMessageBox::Ok);
});
// Get Currency Data
int currency_index = settings.comboBoxCurrency->findText(Settings::getInstance()->get_currency_name(), Qt::MatchExactly);
settings.comboBoxCurrency->setCurrentIndex(currency_index);
QObject::connect(settings.comboBoxCurrency, &QComboBox::currentTextChanged, [=] (QString currency_name) {
this->slot_change_currency(currency_name);
});
// Check for updates
settings.chkCheckUpdates->setChecked(Settings::getInstance()->getCheckForUpdates());
@@ -1235,9 +1264,41 @@ void MainWindow::updateLabels() {
updateLabelsAutoComplete();
}
void MainWindow::slot_change_currency(const QString& currency_name)
{
Settings::getInstance()->set_currency_name(currency_name);
// Include currency
QString saved_currency_name;
try
{
saved_currency_name = Settings::getInstance()->get_currency_name();
}
catch (...)
{
saved_currency_name = "USD";
}
}
void MainWindow::slot_change_theme(const QString& theme_name)
{
Settings::getInstance()->set_theme_name(theme_name);
// Include css
QString saved_theme_name;