From fed17ba0ee235cf12fb85fe720e2c0a35ee4ade2 Mon Sep 17 00:00:00 2001 From: Aditya Kulkarni Date: Tue, 23 Oct 2018 22:35:21 -0700 Subject: [PATCH] small UI fixes --- src/rpc.cpp | 31 ++++++++++++++++++++----------- src/settings.cpp | 2 +- src/ui_mainwindow.h | 8 ++------ 3 files changed, 23 insertions(+), 18 deletions(-) diff --git a/src/rpc.cpp b/src/rpc.cpp index 7eee173..d601530 100644 --- a/src/rpc.cpp +++ b/src/rpc.cpp @@ -25,6 +25,13 @@ RPC::RPC(QNetworkAccessManager* client, MainWindow* main) { reloadConnectionInfo(); + // Set up timer to refresh Price + priceTimer = new QTimer(main); + QObject::connect(priceTimer, &QTimer::timeout, [=]() { + refreshZECPrice(); + }); + priceTimer->start(Utils::priceRefreshSpeed); // Every hour + // Set up a timer to refresh the UI every few seconds timer = new QTimer(main); QObject::connect(timer, &QTimer::timeout, [=]() { @@ -39,13 +46,6 @@ RPC::RPC(QNetworkAccessManager* client, MainWindow* main) { }); // Start at every 10s. When an operation is pending, this will change to every second txTimer->start(Utils::updateSpeed); - - // Set up timer to refresh Price - priceTimer = new QTimer(main); - QObject::connect(priceTimer, &QTimer::timeout, [=]() { - refreshZECPrice(); - }); - priceTimer->start(Utils::priceRefreshSpeed); // Every hour } RPC::~RPC() { @@ -543,10 +543,18 @@ bool RPC::processUnspent(const json& reply) { void RPC::refreshBalances() { // 1. Get the Balances - getBalance([=] (json reply) { - ui->balSheilded ->setText(QString::fromStdString(reply["private"]) % " " % Utils::getTokenName()); - ui->balTransparent ->setText(QString::fromStdString(reply["transparent"]) % " " % Utils::getTokenName()); - ui->balTotal ->setText(QString::fromStdString(reply["total"]) % " " % Utils::getTokenName()); + getBalance([=] (json reply) { + auto balT = QString::fromStdString(reply["transparent"]).toDouble(); + auto balZ = QString::fromStdString(reply["private"]).toDouble(); + auto tot = QString::fromStdString(reply["total"]).toDouble(); + + ui->balSheilded ->setText(Settings::getInstance()->getZECDisplayFormat(balZ)); + ui->balTransparent->setText(Settings::getInstance()->getZECDisplayFormat(balT)); + ui->balTotal ->setText(Settings::getInstance()->getZECDisplayFormat(tot)); + + ui->balSheilded ->setToolTip(Settings::getInstance()->getUSDFormat(balZ)); + ui->balTransparent->setToolTip(Settings::getInstance()->getUSDFormat(balT)); + ui->balTotal ->setToolTip(Settings::getInstance()->getUSDFormat(tot)); }); // 2. Get the UTXOs @@ -744,6 +752,7 @@ void RPC::refreshZECPrice() { QString price = QString::fromStdString(item["price_usd"].get()); qDebug() << "ZEC Price=" << price; Settings::getInstance()->setZECPrice(price.toDouble()); + return; } } diff --git a/src/settings.cpp b/src/settings.cpp index 5e2481a..637b892 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -193,7 +193,7 @@ double Settings::getZECPrice() { QString Settings::getUSDFormat(double bal) { if (!isTestnet() && getZECPrice() > 0) - return "$" + QString::number(bal * getZECPrice(), 'f', 2); + return "$" + QLocale(QLocale::English).toString(bal * getZECPrice(), 'f', 2); else return QString(); } diff --git a/src/ui_mainwindow.h b/src/ui_mainwindow.h index 39fbd79..a0f8192 100644 --- a/src/ui_mainwindow.h +++ b/src/ui_mainwindow.h @@ -47,7 +47,6 @@ public: QAction *actionDonate; QAction *actionImport_Private_Keys; QAction *actionCheck_for_Updates; - QAction *actionDelete_Sent_History; QWidget *centralWidget; QGridLayout *gridLayout_3; QTabWidget *tabWidget; @@ -160,8 +159,6 @@ public: actionImport_Private_Keys->setVisible(false); actionCheck_for_Updates = new QAction(MainWindow); actionCheck_for_Updates->setObjectName(QStringLiteral("actionCheck_for_Updates")); - actionDelete_Sent_History = new QAction(MainWindow); - actionDelete_Sent_History->setObjectName(QStringLiteral("actionDelete_Sent_History")); centralWidget = new QWidget(MainWindow); centralWidget->setObjectName(QStringLiteral("centralWidget")); gridLayout_3 = new QGridLayout(centralWidget); @@ -368,7 +365,7 @@ public: sendToScrollArea->setWidgetResizable(true); sendToWidgets = new QWidget(); sendToWidgets->setObjectName(QStringLiteral("sendToWidgets")); - sendToWidgets->setGeometry(QRect(0, 0, 849, 369)); + sendToWidgets->setGeometry(QRect(0, 0, 841, 321)); sendToLayout = new QVBoxLayout(sendToWidgets); sendToLayout->setSpacing(6); sendToLayout->setContentsMargins(11, 11, 11, 11); @@ -640,7 +637,7 @@ public: MainWindow->setCentralWidget(centralWidget); menuBar = new QMenuBar(MainWindow); menuBar->setObjectName(QStringLiteral("menuBar")); - menuBar->setGeometry(QRect(0, 0, 889, 19)); + menuBar->setGeometry(QRect(0, 0, 889, 22)); menuBalance = new QMenu(menuBar); menuBalance->setObjectName(QStringLiteral("menuBalance")); menuHelp = new QMenu(menuBar); @@ -693,7 +690,6 @@ public: actionDonate->setText(QApplication::translate("MainWindow", "Donate", nullptr)); actionImport_Private_Keys->setText(QApplication::translate("MainWindow", "Import Private Keys", nullptr)); actionCheck_for_Updates->setText(QApplication::translate("MainWindow", "Check github.com for Updates", nullptr)); - actionDelete_Sent_History->setText(QApplication::translate("MainWindow", "Delete Sent History", nullptr)); groupBox->setTitle(QApplication::translate("MainWindow", "Summary", nullptr)); label->setText(QApplication::translate("MainWindow", "Shielded", nullptr)); balSheilded->setText(QString());