From df82a9e0c72938ee0da403b06409a5d495d6f5c9 Mon Sep 17 00:00:00 2001 From: Andre Jochems Date: Fri, 11 Dec 2015 23:16:37 +0100 Subject: [PATCH] Fixes #8 --- src/qt/bitcoingui.cpp | 2 +- src/qt/currencies.cpp | 10 +++++++--- src/qt/currencies.h | 2 +- src/qt/forms/infopage.ui | 36 ++++++++++++++++++++++++++++-------- src/qt/infopage.cpp | 12 ++++++++---- src/qt/infopage.h | 2 ++ src/qt/overviewpage.cpp | 8 +++++++- src/qt/overviewpage.h | 1 + src/qt/walletview.cpp | 3 ++- 9 files changed, 57 insertions(+), 19 deletions(-) diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index 9891334..fab5fa8 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -473,7 +473,7 @@ void BitcoinGUI::restoreWindowGeometry() { QSettings settings; QPoint pos = settings.value("nWindowPos").toPoint(); - QSize size = settings.value("nWindowSize", QSize(850, 550)).toSize(); + QSize size = settings.value("nWindowSize", QSize(900, 650)).toSize(); if (!pos.x() && !pos.y()) { QRect screen = QApplication::desktop()->screenGeometry(); diff --git a/src/qt/currencies.cpp b/src/qt/currencies.cpp index e524afd..1aad32a 100644 --- a/src/qt/currencies.cpp +++ b/src/qt/currencies.cpp @@ -73,10 +73,14 @@ QString Currencies::symbol(int currency) } } -QString Currencies::format(int currency, double value, bool useSymbol) +QString Currencies::format(int currency, double value, bool useSymbol, int decimals, bool isSatoshi) { // divide by satoshi - double fiatValue = value * 0.00000001; + double fiatValue = value; + if(isSatoshi) + { + fiatValue *= 0.00000001; + } QString formattedValue = ""; if(useSymbol) { @@ -84,7 +88,7 @@ QString Currencies::format(int currency, double value, bool useSymbol) } // apply format QLocale::setDefault( QLocale(QLocale::English, QLocale::UnitedStates) ); - formattedValue.append(QString("%L1").arg(fiatValue, 0, 'f', 2)).append(" ").append(name(currency)); + formattedValue.append(QString("%L1").arg(fiatValue, 0, 'f', decimals)).append(" ").append(name(currency)); return formattedValue; } diff --git a/src/qt/currencies.h b/src/qt/currencies.h index ee9300b..60309e7 100644 --- a/src/qt/currencies.h +++ b/src/qt/currencies.h @@ -29,7 +29,7 @@ public: //! symbol static QString symbol(int currency); //! Format value - static QString format(int currency, double value, bool symbol); + static QString format(int currency, double value, bool symbol, int decimals, bool isSatoshi); //! @name AbstractListModel implementation //! List model for currency drop-down selection box. diff --git a/src/qt/forms/infopage.ui b/src/qt/forms/infopage.ui index a7a890b..3bb4872 100644 --- a/src/qt/forms/infopage.ui +++ b/src/qt/forms/infopage.ui @@ -410,7 +410,7 @@ - + @@ -423,7 +423,7 @@ - + @@ -442,7 +442,7 @@ - + @@ -455,7 +455,7 @@ - + @@ -474,7 +474,7 @@ - + @@ -487,7 +487,7 @@ - + @@ -506,7 +506,7 @@ - + @@ -519,7 +519,7 @@ - + @@ -538,6 +538,26 @@ + + + + Coin Fiat Value + + + + + + + + 75 + true + + + + - + + + diff --git a/src/qt/infopage.cpp b/src/qt/infopage.cpp index 08ee4e6..c71c47a 100644 --- a/src/qt/infopage.cpp +++ b/src/qt/infopage.cpp @@ -6,7 +6,7 @@ #include #include "bitcoinunits.h" #include "main.h" - +#include "overviewpage.h" #include "qtquick_controls/cpp/guiexchangeswidget.h" using namespace std; @@ -17,9 +17,8 @@ InfoPage::InfoPage(QWidget *parent) : exchangesWidget( 0 ) { ui->setupUi(this); -// ui->casinoInfoBox->setVisible(false); -// ui->newsItemsBox->setVisible(false); - + ui->coinInfoBox->setMinimumHeight(250); + ui->exchangeInfoBox->setMinimumHeight(250); createExchangesWidget(); } @@ -119,3 +118,8 @@ void InfoPage::createExchangesWidget() exchangesWidget->slotPopulateExchangesFromWeb(); ui->verticalLayoutExchanges->addWidget( exchangesWidget->dockQmlToWidget() ); } + +void InfoPage::setCoinFiatValue(QString coinValue) +{ + ui->txtCoinFiatValue->setText(coinValue); +} diff --git a/src/qt/infopage.h b/src/qt/infopage.h index ae59aab..4061968 100644 --- a/src/qt/infopage.h +++ b/src/qt/infopage.h @@ -22,6 +22,8 @@ public slots: void setNumBlocks(int count, int countOfPeers); /** Set number of transactions shown in the UI */ void setNumTransactions(int count); + /** Set Fiat coin value */ + void setCoinFiatValue(const QString coinValue); public: explicit InfoPage(QWidget *parent = 0); diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index 7eae9d3..d64b2fd 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -125,6 +125,7 @@ OverviewPage::OverviewPage(QWidget *parent) : ui->listTransactions->setItemDelegate(txdelegate); ui->listTransactions->setIconSize(QSize(DECORATION_SIZE, DECORATION_SIZE)); ui->listTransactions->setMinimumHeight(NUM_ITEMS * (DECORATION_SIZE + 2)); + ui->listTransactions->setMinimumWidth(350); ui->listTransactions->setAttribute(Qt::WA_MacShowFocusRect, false); connect(ui->listTransactions, SIGNAL(clicked(QModelIndex)), this, SLOT(handleTransactionClicked(QModelIndex))); @@ -277,8 +278,13 @@ void OverviewPage::updateFiatBalance(int currency) { QString conversionCurrency = QString("Price").append(Currencies::name(currency)); double currencyValue = coinInformation.find(conversionCurrency).value().toDouble(); + // emit signal for change value + QString coinValue = Currencies::format(currency, currencyValue, true, 4, false); + emit coinFiatValueChanged(coinValue); + // calculate and set fiat balance double fiatBalance = currentBalance * currencyValue; - ui->labelBalanceFiat->setText(Currencies::format(currency,fiatBalance,true)); + QString fiatBalanceString = Currencies::format(currency,fiatBalance,true, 2, true); + ui->labelBalanceFiat->setText(fiatBalanceString); } } diff --git a/src/qt/overviewpage.h b/src/qt/overviewpage.h index e2f9d05..b351c95 100644 --- a/src/qt/overviewpage.h +++ b/src/qt/overviewpage.h @@ -39,6 +39,7 @@ public slots: signals: void transactionClicked(const QModelIndex &index); + void coinFiatValueChanged(const QString formattedCoinFiatValue); private: Ui::OverviewPage *ui; diff --git a/src/qt/walletview.cpp b/src/qt/walletview.cpp index f18327f..ec35c06 100644 --- a/src/qt/walletview.cpp +++ b/src/qt/walletview.cpp @@ -91,7 +91,8 @@ WalletView::WalletView(QWidget *parent, BitcoinGUI *_gui): connect(receiveCoinsPage, SIGNAL(signMessage(QString)), this, SLOT(gotoSignMessageTab(QString))); // Clicking on "Export" allows to export the transaction list connect(exportButton, SIGNAL(clicked()), transactionView, SLOT(exportClicked())); - + // subscribe to coin value changes + connect(overviewPage, SIGNAL(coinFiatValueChanged(const QString)), infoPage, SLOT(setCoinFiatValue(const QString))); gotoOverviewPage(); }