diff --git a/src/clientversion.h b/src/clientversion.h index 6b23a4c..954197b 100644 --- a/src/clientversion.h +++ b/src/clientversion.h @@ -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! diff --git a/src/qt/currencies.cpp b/src/qt/currencies.cpp index ac4e79f..e524afd 100644 --- a/src/qt/currencies.cpp +++ b/src/qt/currencies.cpp @@ -1,5 +1,6 @@ #include "currencies.h" #include +#include 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); diff --git a/src/qt/currencies.h b/src/qt/currencies.h index 4e2d4c1..ee9300b 100644 --- a/src/qt/currencies.h +++ b/src/qt/currencies.h @@ -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. diff --git a/src/qt/forms/optionsdialog.ui b/src/qt/forms/optionsdialog.ui index e6d2036..6c0d1f6 100644 --- a/src/qt/forms/optionsdialog.ui +++ b/src/qt/forms/optionsdialog.ui @@ -309,7 +309,7 @@ 10 100 - 230 + 491 20 @@ -324,8 +324,8 @@ 10 - 127 - 275 + 130 + 491 20 @@ -345,7 +345,7 @@ 24 - + @@ -377,7 +377,7 @@ 24 - + QLayout::SetMaximumSize @@ -412,7 +412,7 @@ 24 - + @@ -435,6 +435,22 @@ + + + + 10 + 160 + 491 + 20 + + + + Whether to show casino promotions on the overview page or not. + + + Display casino promotions + + diff --git a/src/qt/forms/overviewpage.ui b/src/qt/forms/overviewpage.ui index b9c0de2..58f21a0 100644 --- a/src/qt/forms/overviewpage.ui +++ b/src/qt/forms/overviewpage.ui @@ -204,51 +204,6 @@ - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - - - Hide all advertisements - - - false - - - false - - - true - - - - - - - - 150 - 30 - - - - @@ -278,6 +233,22 @@ + + + + Qt::Vertical + + + + 20 + 100 + + + + + + + diff --git a/src/qt/optionsdialog.cpp b/src/qt/optionsdialog.cpp index 25c0dde..6e75e48 100644 --- a/src/qt/optionsdialog.cpp +++ b/src/qt/optionsdialog.cpp @@ -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() diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp index db0c377..be79269 100644 --- a/src/qt/optionsmodel.cpp +++ b/src/qt/optionsmodel.cpp @@ -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; } diff --git a/src/qt/optionsmodel.h b/src/qt/optionsmodel.h index 69e7fac..2b74ed1 100644 --- a/src/qt/optionsmodel.h +++ b/src/qt/optionsmodel.h @@ -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 diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index 852eaec..e3124f7 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -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 ); + } } } diff --git a/src/qt/overviewpage.h b/src/qt/overviewpage.h index bcfb37c..c60f1f4 100644 --- a/src/qt/overviewpage.h +++ b/src/qt/overviewpage.h @@ -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 diff --git a/src/version.cpp b/src/version.cpp index 75b73bd..3b297a2 100644 --- a/src/version.cpp +++ b/src/version.cpp @@ -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"