This commit is contained in:
Andre Jochems
2015-12-11 23:16:37 +01:00
parent d325409101
commit df82a9e0c7
9 changed files with 57 additions and 19 deletions

View File

@@ -473,7 +473,7 @@ void BitcoinGUI::restoreWindowGeometry()
{ {
QSettings settings; QSettings settings;
QPoint pos = settings.value("nWindowPos").toPoint(); 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()) if (!pos.x() && !pos.y())
{ {
QRect screen = QApplication::desktop()->screenGeometry(); QRect screen = QApplication::desktop()->screenGeometry();

View File

@@ -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 // divide by satoshi
double fiatValue = value * 0.00000001; double fiatValue = value;
if(isSatoshi)
{
fiatValue *= 0.00000001;
}
QString formattedValue = ""; QString formattedValue = "";
if(useSymbol) if(useSymbol)
{ {
@@ -84,7 +88,7 @@ QString Currencies::format(int currency, double value, bool useSymbol)
} }
// apply format // apply format
QLocale::setDefault( QLocale(QLocale::English, QLocale::UnitedStates) ); 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; return formattedValue;
} }

View File

@@ -29,7 +29,7 @@ public:
//! symbol //! symbol
static QString symbol(int currency); static QString symbol(int currency);
//! Format value //! 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 //! @name AbstractListModel implementation
//! List model for currency drop-down selection box. //! List model for currency drop-down selection box.

View File

@@ -410,7 +410,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="0"> <item row="4" column="0">
<widget class="QLabel" name="lblConnections"> <widget class="QLabel" name="lblConnections">
<property name="styleSheet"> <property name="styleSheet">
<string notr="true"/> <string notr="true"/>
@@ -423,7 +423,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="1"> <item row="4" column="1">
<widget class="QLabel" name="txtConnections"> <widget class="QLabel" name="txtConnections">
<property name="font"> <property name="font">
<font> <font>
@@ -442,7 +442,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="0"> <item row="5" column="0">
<widget class="QLabel" name="lblDifficulty"> <widget class="QLabel" name="lblDifficulty">
<property name="styleSheet"> <property name="styleSheet">
<string notr="true"/> <string notr="true"/>
@@ -455,7 +455,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="4" column="1"> <item row="5" column="1">
<widget class="QLabel" name="txtDifficulty"> <widget class="QLabel" name="txtDifficulty">
<property name="font"> <property name="font">
<font> <font>
@@ -474,7 +474,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="5" column="0"> <item row="6" column="0">
<widget class="QLabel" name="lblHashRate"> <widget class="QLabel" name="lblHashRate">
<property name="styleSheet"> <property name="styleSheet">
<string notr="true"/> <string notr="true"/>
@@ -487,7 +487,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="5" column="1"> <item row="6" column="1">
<widget class="QLabel" name="txtHashRate"> <widget class="QLabel" name="txtHashRate">
<property name="font"> <property name="font">
<font> <font>
@@ -506,7 +506,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="6" column="0"> <item row="7" column="0">
<widget class="QLabel" name="lblTransactionCount"> <widget class="QLabel" name="lblTransactionCount">
<property name="styleSheet"> <property name="styleSheet">
<string notr="true"/> <string notr="true"/>
@@ -519,7 +519,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="6" column="1"> <item row="7" column="1">
<widget class="QLabel" name="txtTransactionCount"> <widget class="QLabel" name="txtTransactionCount">
<property name="font"> <property name="font">
<font> <font>
@@ -538,6 +538,26 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="0">
<widget class="QLabel" name="lblCoinFiatValue">
<property name="text">
<string>Coin Fiat Value</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QLabel" name="txtCoinFiatValue">
<property name="font">
<font>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>-</string>
</property>
</widget>
</item>
</layout> </layout>
</item> </item>
</layout> </layout>

View File

@@ -6,7 +6,7 @@
#include <QDateTime> #include <QDateTime>
#include "bitcoinunits.h" #include "bitcoinunits.h"
#include "main.h" #include "main.h"
#include "overviewpage.h"
#include "qtquick_controls/cpp/guiexchangeswidget.h" #include "qtquick_controls/cpp/guiexchangeswidget.h"
using namespace std; using namespace std;
@@ -17,9 +17,8 @@ InfoPage::InfoPage(QWidget *parent) :
exchangesWidget( 0 ) exchangesWidget( 0 )
{ {
ui->setupUi(this); ui->setupUi(this);
// ui->casinoInfoBox->setVisible(false); ui->coinInfoBox->setMinimumHeight(250);
// ui->newsItemsBox->setVisible(false); ui->exchangeInfoBox->setMinimumHeight(250);
createExchangesWidget(); createExchangesWidget();
} }
@@ -119,3 +118,8 @@ void InfoPage::createExchangesWidget()
exchangesWidget->slotPopulateExchangesFromWeb(); exchangesWidget->slotPopulateExchangesFromWeb();
ui->verticalLayoutExchanges->addWidget( exchangesWidget->dockQmlToWidget() ); ui->verticalLayoutExchanges->addWidget( exchangesWidget->dockQmlToWidget() );
} }
void InfoPage::setCoinFiatValue(QString coinValue)
{
ui->txtCoinFiatValue->setText(coinValue);
}

View File

@@ -22,6 +22,8 @@ public slots:
void setNumBlocks(int count, int countOfPeers); void setNumBlocks(int count, int countOfPeers);
/** Set number of transactions shown in the UI */ /** Set number of transactions shown in the UI */
void setNumTransactions(int count); void setNumTransactions(int count);
/** Set Fiat coin value */
void setCoinFiatValue(const QString coinValue);
public: public:
explicit InfoPage(QWidget *parent = 0); explicit InfoPage(QWidget *parent = 0);

View File

@@ -125,6 +125,7 @@ OverviewPage::OverviewPage(QWidget *parent) :
ui->listTransactions->setItemDelegate(txdelegate); ui->listTransactions->setItemDelegate(txdelegate);
ui->listTransactions->setIconSize(QSize(DECORATION_SIZE, DECORATION_SIZE)); ui->listTransactions->setIconSize(QSize(DECORATION_SIZE, DECORATION_SIZE));
ui->listTransactions->setMinimumHeight(NUM_ITEMS * (DECORATION_SIZE + 2)); ui->listTransactions->setMinimumHeight(NUM_ITEMS * (DECORATION_SIZE + 2));
ui->listTransactions->setMinimumWidth(350);
ui->listTransactions->setAttribute(Qt::WA_MacShowFocusRect, false); ui->listTransactions->setAttribute(Qt::WA_MacShowFocusRect, false);
connect(ui->listTransactions, SIGNAL(clicked(QModelIndex)), this, SLOT(handleTransactionClicked(QModelIndex))); 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)); QString conversionCurrency = QString("Price").append(Currencies::name(currency));
double currencyValue = coinInformation.find(conversionCurrency).value().toDouble(); 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; 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);
} }
} }

View File

@@ -39,6 +39,7 @@ public slots:
signals: signals:
void transactionClicked(const QModelIndex &index); void transactionClicked(const QModelIndex &index);
void coinFiatValueChanged(const QString formattedCoinFiatValue);
private: private:
Ui::OverviewPage *ui; Ui::OverviewPage *ui;

View File

@@ -91,7 +91,8 @@ WalletView::WalletView(QWidget *parent, BitcoinGUI *_gui):
connect(receiveCoinsPage, SIGNAL(signMessage(QString)), this, SLOT(gotoSignMessageTab(QString))); connect(receiveCoinsPage, SIGNAL(signMessage(QString)), this, SLOT(gotoSignMessageTab(QString)));
// Clicking on "Export" allows to export the transaction list // Clicking on "Export" allows to export the transaction list
connect(exportButton, SIGNAL(clicked()), transactionView, SLOT(exportClicked())); connect(exportButton, SIGNAL(clicked()), transactionView, SLOT(exportClicked()));
// subscribe to coin value changes
connect(overviewPage, SIGNAL(coinFiatValueChanged(const QString)), infoPage, SLOT(setCoinFiatValue(const QString)));
gotoOverviewPage(); gotoOverviewPage();
} }