Show $ values next to ZEC amounts
This commit is contained in:
parent
1b2335c0d4
commit
02432338cd
|
@ -81,7 +81,7 @@ QVariant BalancesTableModel::data(const QModelIndex &index, int role) const
|
|||
case 0: return std::get<0>(modeldata->at(index.row()));
|
||||
case 1: {
|
||||
auto bal = std::get<1>(modeldata->at(index.row())).toDouble();
|
||||
return "$ " + QString::number(bal * Settings::getInstance()->getZECPrice(), 'f', 2); // Use 'f' notation to get 2 decimal places
|
||||
return Settings::getInstance()->getUSDFormat(bal);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
18
src/rpc.cpp
18
src/rpc.cpp
|
@ -45,7 +45,7 @@ RPC::RPC(QNetworkAccessManager* client, MainWindow* main) {
|
|||
QObject::connect(timer, &QTimer::timeout, [=]() {
|
||||
refreshZECPrice();
|
||||
});
|
||||
priceTimer->start(1 * 60 * 60 * 1000); // Every hour
|
||||
priceTimer->start(60 * 60 * 60 * 1000); // Every hour
|
||||
}
|
||||
|
||||
RPC::~RPC() {
|
||||
|
@ -571,19 +571,3 @@ void RPC::refreshZECPrice() {
|
|||
Settings::getInstance()->setZECPrice(0);
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
.url("https://api.coinmarketcap.com/v1/ticker/")
|
||||
.withHeaders("Accept" -> "application/json")
|
||||
.get()
|
||||
.map {
|
||||
response => {
|
||||
val prices = response.json.as[JsArray].value
|
||||
.map(x => ((x \ "symbol").as[String], (x \ "price_usd").as[BigDecimal].setScale(2, RoundingMode.HALF_UP)))
|
||||
.toMap
|
||||
|
||||
coinCodes.map { coinCode =>
|
||||
CoinPrice(coinCode, prices.get(coinCode), Some(System.currentTimeMillis() / 1000))
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
|
|
@ -322,7 +322,7 @@ void MainWindow::sendButton() {
|
|||
|
||||
auto Amt = new QLabel(confirm.sendToAddrs);
|
||||
Amt->setObjectName(QString("Amt") % QString::number(i + 1));
|
||||
Amt->setText(QString::number(toAddr.amount, 'g', 8) % " " % Utils::getTokenName());
|
||||
Amt->setText(Settings::getInstance()->getZECDisplayFormat(toAddr.amount));
|
||||
Amt->setAlignment(Qt::AlignRight | Qt::AlignTrailing | Qt::AlignVCenter);
|
||||
confirm.gridLayout->addWidget(Amt, i*2, 1, 1, 1);
|
||||
|
||||
|
@ -350,11 +350,11 @@ void MainWindow::sendButton() {
|
|||
// Add two rows for fees
|
||||
{
|
||||
confirm.labelMinerFee->setText("Miner Fee");
|
||||
confirm.minerFee->setText(QString::number(Utils::getMinerFee(), 'g', 8) % " " % Utils::getTokenName());
|
||||
confirm.minerFee->setText(Settings::getInstance()->getZECDisplayFormat(Utils::getMinerFee()));
|
||||
|
||||
if (!devAddress.isEmpty() && Utils::getDevFee() > 0) {
|
||||
confirm.labelDevFee->setText("Dev Fee");
|
||||
confirm.devFee->setText(QString::number(Utils::getMinerFee(), 'g', 8) % " " % Utils::getTokenName());
|
||||
confirm.devFee->setText(Settings::getInstance()->getZECDisplayFormat(Utils::getDevFee()));
|
||||
} else {
|
||||
confirm.labelDevFee->setText("");
|
||||
confirm.devFee->setText("");
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "precompiled.h"
|
||||
|
||||
#include "utils.h"
|
||||
#include "settings.h"
|
||||
|
||||
Settings* Settings::instance = nullptr;
|
||||
|
@ -145,3 +146,26 @@ bool Settings::isSyncing() {
|
|||
void Settings::setSyncing(bool syncing) {
|
||||
this->_isSyncing = syncing;
|
||||
}
|
||||
|
||||
double Settings::getZECPrice() {
|
||||
//if (isTestnet())
|
||||
// return 0;
|
||||
//else
|
||||
return zecPrice;
|
||||
}
|
||||
|
||||
QString Settings::getUSDFormat(double bal) {
|
||||
if (getZECPrice() > 0)
|
||||
return "$" + QString::number(bal * getZECPrice(), 'f', 2);
|
||||
else
|
||||
return QString();
|
||||
}
|
||||
|
||||
QString Settings::getZECDisplayFormat(double bal) {
|
||||
auto usdFormat = getUSDFormat(bal);
|
||||
if (!usdFormat.isEmpty())
|
||||
return QString::number(bal, 'g', 8) % " " % Utils::getTokenName() %
|
||||
" (" % getUSDFormat(bal) % ")";
|
||||
else
|
||||
return QString::number(bal, 'g', 8) % " " % Utils::getTokenName();
|
||||
}
|
|
@ -31,8 +31,10 @@ public:
|
|||
|
||||
const QString& getZcashdConfLocation() { return confLocation; }
|
||||
|
||||
void setZECPrice(double p) { zecPrice = p; }
|
||||
double getZECPrice() { return zecPrice; }
|
||||
void setZECPrice(double p) { zecPrice = p; }
|
||||
double getZECPrice();
|
||||
QString getUSDFormat(double bal);
|
||||
QString getZECDisplayFormat(double bal);
|
||||
|
||||
private:
|
||||
// This class can only be accessed through Settings::getInstance()
|
||||
|
|
|
@ -58,7 +58,7 @@ void TxTableModel::setNewData(QList<TransactionItem>* data) {
|
|||
if (role == Qt::DisplayRole)
|
||||
return QVariant(QString::number(modeldata->at(index.row()).amount, 'g', 8) % " " % Utils::getTokenName());
|
||||
else {
|
||||
return "$ " + QString::number(Settings::getInstance()->getZECPrice() * modeldata->at(index.row()).amount, 'f', 2);
|
||||
return Settings::getInstance()->getUSDFormat(modeldata->at(index.row()).amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue