mirror of
https://github.com/AskDavis/Casinotest.git
synced 2026-01-01 05:05:57 -08:00
Currency format updated
This commit is contained in:
@@ -6,8 +6,8 @@
|
||||
//
|
||||
|
||||
// These need to be macros, as version.cpp's and bitcoin-qt.rc's voodoo requires it
|
||||
#define CLIENT_VERSION_MAJOR 1
|
||||
#define CLIENT_VERSION_MINOR 3
|
||||
#define CLIENT_VERSION_MAJOR 2
|
||||
#define CLIENT_VERSION_MINOR 0
|
||||
#define CLIENT_VERSION_REVISION 0
|
||||
#define CLIENT_VERSION_BUILD 0
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
// Copyright year (2009-this)
|
||||
// Todo: update this when changing our copyright comments in the source
|
||||
#define COPYRIGHT_YEAR 2014
|
||||
#define COPYRIGHT_YEAR 2015
|
||||
|
||||
// Converts the parameter X to a string after macro replacement on X has been performed.
|
||||
// Don't merge these into one macro!
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "currencies.h"
|
||||
#include <QStringList>
|
||||
#include <QLocale>
|
||||
|
||||
Currencies::Currencies(QObject *parent):
|
||||
QAbstractListModel(parent),
|
||||
@@ -59,6 +60,34 @@ QString Currencies::description(int currency)
|
||||
}
|
||||
}
|
||||
|
||||
QString Currencies::symbol(int currency)
|
||||
{
|
||||
switch(currency)
|
||||
{
|
||||
case USD: return QString("$");
|
||||
case EUR: return QString("€");
|
||||
case CNY: return QString("¥");
|
||||
case JPY: return QString("¥");
|
||||
case RUB: return QString("₽");
|
||||
default: return QString("$");
|
||||
}
|
||||
}
|
||||
|
||||
QString Currencies::format(int currency, double value, bool useSymbol)
|
||||
{
|
||||
// divide by satoshi
|
||||
double fiatValue = value * 0.00000001;
|
||||
QString formattedValue = "";
|
||||
if(useSymbol)
|
||||
{
|
||||
formattedValue.append(symbol(currency)).append(" ");
|
||||
}
|
||||
// apply format
|
||||
QLocale::setDefault( QLocale(QLocale::English, QLocale::UnitedStates) );
|
||||
formattedValue.append(QString("%L1").arg(fiatValue, 0, 'f', 2)).append(" ").append(name(currency));
|
||||
return formattedValue;
|
||||
}
|
||||
|
||||
int Currencies::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
Q_UNUSED(parent);
|
||||
|
||||
@@ -26,6 +26,10 @@ public:
|
||||
static QString name(int currency);
|
||||
//! Longer description
|
||||
static QString description(int unit);
|
||||
//! symbol
|
||||
static QString symbol(int currency);
|
||||
//! Format value
|
||||
static QString format(int currency, double value, bool symbol);
|
||||
|
||||
//! @name AbstractListModel implementation
|
||||
//! List model for currency drop-down selection box.
|
||||
|
||||
@@ -309,7 +309,7 @@
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>100</y>
|
||||
<width>230</width>
|
||||
<width>491</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
@@ -324,8 +324,8 @@
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>127</y>
|
||||
<width>275</width>
|
||||
<y>130</y>
|
||||
<width>491</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
@@ -345,7 +345,7 @@
|
||||
<height>24</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2_Display_Currency">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_display_Currency">
|
||||
<item>
|
||||
<widget class="QLabel" name="currencyLabel">
|
||||
<property name="text">
|
||||
@@ -377,7 +377,7 @@
|
||||
<height>24</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_1_Display">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_display_Language">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetMaximumSize</enum>
|
||||
</property>
|
||||
@@ -412,7 +412,7 @@
|
||||
<height>24</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2_Display">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_display_Units">
|
||||
<item>
|
||||
<widget class="QLabel" name="unitLabel">
|
||||
<property name="text">
|
||||
@@ -435,6 +435,22 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="displayPromotions">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>160</y>
|
||||
<width>491</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Whether to show casino promotions on the overview page or not.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Display casino promotions</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
@@ -204,51 +204,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0" colspan="2">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="8" column="0" colspan="2">
|
||||
<layout class="QVBoxLayout" name="verticalLayoutAdvertWidget"/>
|
||||
</item>
|
||||
<item row="7" column="0" colspan="2">
|
||||
<widget class="QPushButton" name="pushButtonToggleAdverts">
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Hide all advertisements</string>
|
||||
</property>
|
||||
<property name="autoDefault">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="default">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0" colspan="2">
|
||||
<widget class="QWidget" name="widgetBuyCSCButton" native="true">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>30</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="labelBalanceFiatText">
|
||||
<property name="text">
|
||||
@@ -278,6 +233,22 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0" colspan="2">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>100</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="6" column="0" colspan="2">
|
||||
<layout class="QVBoxLayout" name="verticalLayoutAdvertWidget"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
|
||||
@@ -108,7 +108,6 @@ void OptionsDialog::setModel(OptionsModel *model)
|
||||
if(model)
|
||||
{
|
||||
connect(model, SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit()));
|
||||
|
||||
mapper->setModel(model);
|
||||
setMapper();
|
||||
mapper->toFirst();
|
||||
@@ -150,6 +149,7 @@ void OptionsDialog::setMapper()
|
||||
mapper->addMapping(ui->currency, OptionsModel::DisplayFiatCurrency);
|
||||
mapper->addMapping(ui->displayAddresses, OptionsModel::DisplayAddresses);
|
||||
mapper->addMapping(ui->coinControlFeatures, OptionsModel::CoinControlFeatures);
|
||||
mapper->addMapping(ui->displayPromotions, OptionsModel::DisplayPromotions);
|
||||
}
|
||||
|
||||
void OptionsDialog::enableApplyButton()
|
||||
|
||||
@@ -51,6 +51,7 @@ void OptionsModel::Init()
|
||||
language = settings.value("language", "").toString();
|
||||
fCoinControlFeatures = settings.value("fCoinControlFeatures", false).toBool();
|
||||
nDisplayFiatCurrency = settings.value("nDisplayFiatCurrency", Currencies::USD).toInt();
|
||||
fDisplayPromotions = settings.value("fDisplayPromotions", true).toBool();
|
||||
|
||||
// These are shared with core Bitcoin; we want
|
||||
// command-line options to override the GUI settings:
|
||||
@@ -203,6 +204,8 @@ QVariant OptionsModel::data(const QModelIndex & index, int role) const
|
||||
return QVariant(fCoinControlFeatures);
|
||||
case DisplayFiatCurrency:
|
||||
return QVariant(nDisplayFiatCurrency);
|
||||
case DisplayPromotions:
|
||||
return QVariant(fDisplayPromotions);
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
@@ -281,6 +284,7 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
|
||||
case DisplayFiatCurrency:
|
||||
nDisplayFiatCurrency = value.toInt();
|
||||
settings.setValue("nDisplayFiatCurrency", nDisplayFiatCurrency);
|
||||
emit displayCurrencyChanged(nDisplayFiatCurrency);
|
||||
break;
|
||||
case DisplayAddresses:
|
||||
bDisplayAddresses = value.toBool();
|
||||
@@ -295,6 +299,12 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
|
||||
emit coinControlFeaturesChanged(fCoinControlFeatures);
|
||||
}
|
||||
break;
|
||||
case DisplayPromotions: {
|
||||
fDisplayPromotions = value.toBool();
|
||||
settings.setValue("fDisplayPromotions", fDisplayPromotions);
|
||||
emit displayPromotionsChanged(fDisplayPromotions);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ public:
|
||||
DisplayAddresses, // bool
|
||||
Language, // QString
|
||||
CoinControlFeatures, // bool
|
||||
DisplayPromotions, // bool
|
||||
OptionIDRowCount,
|
||||
};
|
||||
|
||||
@@ -53,6 +54,7 @@ public:
|
||||
QString getLanguage() { return language; }
|
||||
bool getCoinControlFeatures();
|
||||
int getDisplayFiatCurrency() { return nDisplayFiatCurrency; }
|
||||
bool getDisplayPromotions() { return fDisplayPromotions; }
|
||||
|
||||
private:
|
||||
int nDisplayUnit;
|
||||
@@ -62,11 +64,14 @@ private:
|
||||
QString language;
|
||||
bool fCoinControlFeatures;
|
||||
int nDisplayFiatCurrency;
|
||||
bool fDisplayPromotions;
|
||||
|
||||
signals:
|
||||
void displayUnitChanged(int unit);
|
||||
void transactionFeeChanged(qint64);
|
||||
void coinControlFeaturesChanged(bool);
|
||||
void displayCurrencyChanged(int currency);
|
||||
void displayPromotionsChanged(bool);
|
||||
};
|
||||
|
||||
#endif // OPTIONSMODEL_H
|
||||
|
||||
@@ -163,7 +163,7 @@ void OverviewPage::setBalance(qint64 balance, qint64 unconfirmedBalance, qint64
|
||||
ui->labelImmature->setVisible(showImmature);
|
||||
ui->labelImmatureText->setVisible(showImmature);
|
||||
// set fiat balance
|
||||
updateFiatBalance();
|
||||
updateFiatBalance(walletModel->getOptionsModel()->getDisplayFiatCurrency());
|
||||
}
|
||||
|
||||
void OverviewPage::createAdvertsWidget()
|
||||
@@ -205,8 +205,9 @@ void OverviewPage::setWalletModel(WalletModel *model)
|
||||
// Keep up to date with wallet
|
||||
setBalance(model->getBalance(), model->getUnconfirmedBalance(), model->getImmatureBalance());
|
||||
connect(model, SIGNAL(balanceChanged(qint64, qint64, qint64)), this, SLOT(setBalance(qint64, qint64, qint64)));
|
||||
|
||||
connect(model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit()));
|
||||
connect(model->getOptionsModel(), SIGNAL(displayCurrencyChanged(int)), this, SLOT(updateFiatBalance(int)));
|
||||
connect(model->getOptionsModel(), SIGNAL(displayPromotionsChanged(bool)), this, SLOT(updateDisplayPromotions(bool)));
|
||||
}
|
||||
|
||||
// update the display unit, to not use the default ("BTC")
|
||||
@@ -239,27 +240,6 @@ void OverviewPage::showOutOfSyncWarning(bool fShow)
|
||||
ui->labelTransactionsStatus->setVisible(fShow);
|
||||
}
|
||||
|
||||
|
||||
void OverviewPage::on_pushButtonToggleAdverts_clicked()
|
||||
{
|
||||
if ( ui->verticalLayoutAdvertWidget->itemAt( 0 ) )
|
||||
{
|
||||
QWidget* pAdvertWidget = ui->verticalLayoutAdvertWidget->itemAt( 0 )->widget();
|
||||
if ( pAdvertWidget )
|
||||
{
|
||||
pAdvertWidget->setVisible( !pAdvertWidget->isVisible() );
|
||||
if ( pAdvertWidget->isVisible() )
|
||||
{
|
||||
ui->pushButtonToggleAdverts->setText( tr( "Hide all advertisements" ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->pushButtonToggleAdverts->setText( tr( "Show advertisements" ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OverviewPage::getCoinInfo()
|
||||
{
|
||||
if ( cscWebApi )
|
||||
@@ -275,18 +255,30 @@ void OverviewPage::updateCoinInfoFromWeb( JsonCoinInfoParser* coinInfoParser )
|
||||
// save the coin information
|
||||
coinInformation = coinInfoParser->getCoinInfo();
|
||||
// calculate and set the estimated fiat balance
|
||||
updateFiatBalance();
|
||||
updateFiatBalance(walletModel->getOptionsModel()->getDisplayFiatCurrency());
|
||||
}
|
||||
|
||||
void OverviewPage::updateFiatBalance()
|
||||
void OverviewPage::updateFiatBalance(int currency)
|
||||
{
|
||||
if(!coinInformation.isEmpty())
|
||||
{
|
||||
int currency = walletModel->getOptionsModel()->getDisplayFiatCurrency();
|
||||
QString conversionCurrency = QString("Price").append(Currencies::name(currency));
|
||||
double currencyValue = coinInformation.find(conversionCurrency).value().toDouble();
|
||||
double fiatBalance = currentBalance * currencyValue * 0.00000001;
|
||||
double fiatBalance = currentBalance * currencyValue;
|
||||
qDebug() << "updateFiatBalance: " << QString::number(fiatBalance,'f',2);
|
||||
ui->labelBalanceFiat->setText(QString::number(fiatBalance,'f',2).append(" ").append(Currencies::name(currency)));
|
||||
ui->labelBalanceFiat->setText(Currencies::format(currency,fiatBalance,true));
|
||||
}
|
||||
}
|
||||
|
||||
void OverviewPage::updateDisplayPromotions(bool checked)
|
||||
{
|
||||
qDebug() << "updateDisplayPromotions: " << checked;
|
||||
if ( ui->verticalLayoutAdvertWidget->itemAt( 0 ) )
|
||||
{
|
||||
QWidget* pAdvertWidget = ui->verticalLayoutAdvertWidget->itemAt( 0 )->widget();
|
||||
if ( pAdvertWidget )
|
||||
{
|
||||
pAdvertWidget->setVisible( checked );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,14 +58,14 @@ private:
|
||||
CasinoCoinWebAPI* cscWebApi;
|
||||
void getCoinInfo();
|
||||
QJsonObject coinInformation;
|
||||
void updateFiatBalance();
|
||||
|
||||
private slots:
|
||||
void updateDisplayUnit();
|
||||
void handleTransactionClicked(const QModelIndex &index);
|
||||
void updateAlerts(const QString &warnings);
|
||||
void on_pushButtonToggleAdverts_clicked();
|
||||
void updateCoinInfoFromWeb( JsonCoinInfoParser* coinInfoParser );
|
||||
void updateFiatBalance(int currency);
|
||||
void updateDisplayPromotions(bool checked);
|
||||
};
|
||||
|
||||
#endif // OVERVIEWPAGE_H
|
||||
|
||||
@@ -41,7 +41,7 @@ const std::string CLIENT_NAME("digishield");
|
||||
#endif
|
||||
|
||||
#define BUILD_DESC_FROM_COMMIT(maj,min,rev,build,commit) \
|
||||
"v" DO_STRINGIZE(maj) "." DO_STRINGIZE(min) "." DO_STRINGIZE(rev) "." DO_STRINGIZE(build) "-g" commit
|
||||
"v" DO_STRINGIZE(maj) "." DO_STRINGIZE(min) "." DO_STRINGIZE(rev) "." DO_STRINGIZE(build) "-Qt" commit
|
||||
|
||||
#define BUILD_DESC_FROM_UNKNOWN(maj,min,rev,build) \
|
||||
"v" DO_STRINGIZE(maj) "." DO_STRINGIZE(min) "." DO_STRINGIZE(rev) "." DO_STRINGIZE(build) "-unk"
|
||||
|
||||
Reference in New Issue
Block a user