From 8635a3386101fb37fd6ff87eab9bbab7af1319ed Mon Sep 17 00:00:00 2001 From: Denio Date: Sun, 8 Dec 2019 15:26:55 +0100 Subject: [PATCH] improvements to render the price --- src/camount.cpp | 4 +-- src/controller.cpp | 66 ++++++++++++++++------------------------------ src/mainwindow.ui | 24 ++++++++--------- 3 files changed, 37 insertions(+), 57 deletions(-) diff --git a/src/camount.cpp b/src/camount.cpp index f811d1c..9e78381 100644 --- a/src/camount.cpp +++ b/src/camount.cpp @@ -44,7 +44,7 @@ QString CAmount::toDecimalEURString() const { double dblAmount = static_cast(this->amount) / COIN; double price = Settings::getInstance()->getEURPrice(); - return QLocale(QLocale::English).toString(dblAmount*price, 'f', 2) + " €"; + return QLocale(QLocale::German).toString(dblAmount*price, 'f', 2) + " €"; } QString CAmount::toDecimalBTCString() const { double dblAmount = static_cast(this->amount) / COIN; @@ -80,7 +80,7 @@ QString CAmount::toDecimalCHFString() const { double dblAmount = static_cast(this->amount) / COIN; double price = Settings::getInstance()->getCHFPrice(); - return "CHF " + QLocale(QLocale::English).toString(dblAmount*price, 'f', 2); + return "CHF " + QLocale(QLocale::German).toString(dblAmount*price, 'f', 2); } QString CAmount::toDecimalINRString() const { double dblAmount = static_cast(this->amount) / COIN; diff --git a/src/controller.cpp b/src/controller.cpp index 5f3b7ec..104f01e 100644 --- a/src/controller.cpp +++ b/src/controller.cpp @@ -166,37 +166,28 @@ void Controller::getInfoThenRefresh(bool force) { int notarized = reply["notarized"].get(); int difficulty = reply["difficulty"].get(); int blocks_until_halving= 340000 - curBlock; - char halving_days[8]; - sprintf(halving_days, "%.2f", (double) (blocks_until_halving * 150) / (60*60*24) ); + int halving_days = + (blocks_until_halving * 150) / (60*60*24) ; bool doUpdate = force || (model->getLatestBlock() != curBlock); model->setLatestBlock(curBlock); - if (Settings::getInstance()->get_currency_name() == "EUR") { - ui->blockHeight->setText(QLocale(QLocale::German).toString(curBlock)); - ui->last_notarized->setText(QLocale(QLocale::German).toString(notarized)); - ui->longestchain->setText(QLocale(QLocale::German).toString(longestchain)); - ui->difficulty->setText(QLocale(QLocale::German).toString(difficulty));} - - else if (Settings::getInstance()->get_currency_name() == "CHF") { - ui->blockHeight->setText(QLocale(QLocale::German).toString(curBlock)); - ui->last_notarized->setText(QLocale(QLocale::German).toString(notarized)); - ui->longestchain->setText(QLocale(QLocale::German).toString(longestchain)); - ui->difficulty->setText(QLocale(QLocale::German).toString(difficulty));} - - else if (Settings::getInstance()->get_currency_name() == "RUB") { - ui->blockHeight->setText(QLocale(QLocale::German).toString(curBlock)); - ui->last_notarized->setText(QLocale(QLocale::German).toString(notarized)); - ui->longestchain->setText(QLocale(QLocale::German).toString(longestchain)); - ui->difficulty->setText(QLocale(QLocale::German).toString(difficulty));} - + if (Settings::getInstance()->get_currency_name() == "EUR" || Settings::getInstance()->get_currency_name() == "CHF" || Settings::getInstance()->get_currency_name() == "RUB") { + ui->blockHeight->setText("Block: " + QLocale(QLocale::German).toString(curBlock)); + ui->last_notarized->setText("Block: " + QLocale(QLocale::German).toString(notarized)); + ui->longestchain->setText("Block: " + QLocale(QLocale::German).toString(longestchain)); + ui->difficulty->setText(QLocale(QLocale::German).toString(difficulty)); + ui->halvingTime->setText((QLocale(QLocale::German).toString(blocks_until_halving)) + " Blocks or , " + (QLocale(QLocale::German).toString(halving_days) + " days" )); + } else { - ui->blockHeight->setText(QLocale(QLocale::English).toString(curBlock)); - ui->last_notarized->setText(QLocale(QLocale::English).toString(notarized)); - ui->longestchain->setText(QLocale(QLocale::English).toString(longestchain)); - ui->difficulty->setText(QLocale(QLocale::English).toString(difficulty));} + ui->blockHeight->setText("Block: " + QLocale(QLocale::English).toString(curBlock)); + ui->last_notarized->setText("Block: " + QLocale(QLocale::English).toString(notarized)); + ui->longestchain->setText("Block: " + QLocale(QLocale::English).toString(longestchain)); + ui->difficulty->setText(QLocale(QLocale::English).toString(difficulty)); + ui->halvingTime->setText((QLocale(QLocale::English).toString(blocks_until_halving)) + " Blocks or , " + (QLocale(QLocale::English).toString(halving_days) + " days" )); + + } - ui->halvingTime->setText( QString::number(blocks_until_halving) % " blocks, " % QString::fromStdString(halving_days) % " days" ); ui->Version->setText(QString::fromStdString(reply["version"].get())); ui->Vendor->setText(QString::fromStdString(reply["vendor"].get())); @@ -325,25 +316,14 @@ void Controller::getInfoThenRefresh(bool force) { int zfunds = reply["zfunds"].get(); int total = reply["total"].get(); - if (Settings::getInstance()->get_currency_name() == "EUR") { - ui->supply_taddr->setText((QLocale(QLocale::German).toString(supply))); - ui->supply_zaddr->setText((QLocale(QLocale::German).toString(zfunds))); - ui->supply_total->setText((QLocale(QLocale::German).toString(total)));} - - else if (Settings::getInstance()->get_currency_name() == "CHF") { - ui->supply_taddr->setText((QLocale(QLocale::German).toString(supply))); - ui->supply_zaddr->setText((QLocale(QLocale::German).toString(zfunds))); - ui->supply_total->setText((QLocale(QLocale::German).toString(total)));} - - else if (Settings::getInstance()->get_currency_name() == "RUB") { - ui->supply_taddr->setText((QLocale(QLocale::German).toString(supply))); - ui->supply_zaddr->setText((QLocale(QLocale::German).toString(zfunds))); - ui->supply_total->setText((QLocale(QLocale::German).toString(total)));} - + if (Settings::getInstance()->get_currency_name() == "EUR" || Settings::getInstance()->get_currency_name() == "CHF" || Settings::getInstance()->get_currency_name() == "RUB") { + ui->supply_taddr->setText((QLocale(QLocale::German).toString(supply)+ " Hush")); + ui->supply_zaddr->setText((QLocale(QLocale::German).toString(zfunds)+ " Hush")); + ui->supply_total->setText((QLocale(QLocale::German).toString(total)+ " Hush"));} else{ - ui->supply_taddr->setText((QLocale(QLocale::English).toString(supply))); - ui->supply_zaddr->setText((QLocale(QLocale::English).toString(zfunds))); - ui->supply_total->setText((QLocale(QLocale::English).toString(total)));} + ui->supply_taddr->setText("Hush " + (QLocale(QLocale::English).toString(supply))); + ui->supply_zaddr->setText("Hush " +(QLocale(QLocale::English).toString(zfunds))); + ui->supply_total->setText("Hush " +(QLocale(QLocale::English).toString(total)));} }); diff --git a/src/mainwindow.ui b/src/mainwindow.ui index f8286a9..7edd54a 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -1010,7 +1010,7 @@ - | + <html><head/><body><p align="center">|</p></body></html> @@ -1024,7 +1024,7 @@ - | + <html><head/><body><p align="center">|</p></body></html> @@ -1045,7 +1045,7 @@ - | + <html><head/><body><p align="center">|</p></body></html> @@ -1094,14 +1094,14 @@ - | + <html><head/><body><p align="center">|</p></body></html> - | + <html><head/><body><p align="center">|</p></body></html> @@ -1115,7 +1115,7 @@ - | + <html><head/><body><p align="center">|</p></body></html> @@ -1136,7 +1136,7 @@ - | + <html><head/><body><p align="center">|</p></body></html> @@ -1150,7 +1150,7 @@ - | + <html><head/><body><p align="center">|</p></body></html> @@ -1164,7 +1164,7 @@ - | + <html><head/><body><p align="center">|</p></body></html> @@ -1192,7 +1192,7 @@ - | + <html><head/><body><p align="center">|</p></body></html> @@ -1264,7 +1264,7 @@ - | + <html><head/><body><p align="center">|</p></body></html> @@ -1285,7 +1285,7 @@ - | + <html><head/><body><p align="center">|</p></body></html>