mirror of
https://github.com/AskDavis/Casinotest.git
synced 2026-01-04 04:29:46 -08:00
Coin Information API integrated
This commit is contained in:
@@ -31,6 +31,11 @@ void CasinoCoinWebAPI::GetActiveExchanges()
|
||||
Get( s_strServerAddress + s_strServerEndpoint + "/ActiveExchanges" );
|
||||
}
|
||||
|
||||
void CasinoCoinWebAPI::GetCoinInfo()
|
||||
{
|
||||
Get( s_strServerAddress + s_strServerEndpoint + "/CoinInfo" );
|
||||
}
|
||||
|
||||
void CasinoCoinWebAPI::Get( const QString& a_rUrl )
|
||||
{
|
||||
QUrl oUrl ( a_rUrl );
|
||||
@@ -43,7 +48,7 @@ void CasinoCoinWebAPI::slotParseNetworkResponse( QNetworkReply *finished )
|
||||
if ( finished->error() != QNetworkReply::NoError )
|
||||
{
|
||||
// A communication error has occurred
|
||||
qDebug() << finished->request().url();
|
||||
qDebug() << "API Network Error: " << finished->errorString();
|
||||
emit signalNetworkError( finished->error(), finished->request().url() );
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ public:
|
||||
void GetActiveCasinos();
|
||||
void GetActiveNewsItems();
|
||||
void GetActiveExchanges();
|
||||
void GetCoinInfo();
|
||||
|
||||
static const QString s_strServerAddress;
|
||||
static const QString s_strServerEndpoint;
|
||||
|
||||
@@ -48,8 +48,21 @@ void CasinoCoinWebAPIParser::slotParseAnswer( const QByteArray& a_rJsonFile )
|
||||
StoreFile( "ActiveExchanges", a_rJsonFile );
|
||||
ParseExchanges( docAsObject );
|
||||
}
|
||||
}
|
||||
else if ( jsonObjectResult.find( "CoinInfo" ).value().isObject() )
|
||||
{
|
||||
StoreFile( "CoinInfo", a_rJsonFile );
|
||||
ParseCoinInfo( docAsObject );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "CasinoCoinWebAPIParser -> No Result object found: " << docAsObject.begin().key();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "CasinoCoinWebAPIParser -> Parse Error: " << oError.errorString();
|
||||
}
|
||||
}
|
||||
|
||||
void CasinoCoinWebAPIParser::slotNetworkError( QNetworkReply::NetworkError a_eError
|
||||
@@ -85,6 +98,12 @@ void CasinoCoinWebAPIParser::ParseNewsItems( const QJsonObject& a_rJsonNewsItems
|
||||
qDebug() << a_rJsonNewsItems;
|
||||
}
|
||||
|
||||
void CasinoCoinWebAPIParser::ParseCoinInfo( const QJsonObject& a_rJsonCoinInfo )
|
||||
{
|
||||
qDebug() << "ParseCoinInfo";
|
||||
emit signalCoinInfoParsed( new JsonCoinInfoParser( a_rJsonCoinInfo ) );
|
||||
}
|
||||
|
||||
QByteArray CasinoCoinWebAPIParser::ReadFile( QString a_strSourcePath )
|
||||
{
|
||||
QByteArray strAnswer;
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
#include "jsonactivepromotionsparser.h"
|
||||
#include "jsonsingleactivepromotion.h"
|
||||
#include "jsoncoininfoparser.h"
|
||||
|
||||
#include <QNetworkReply>
|
||||
|
||||
@@ -17,6 +18,7 @@ public:
|
||||
|
||||
signals:
|
||||
void signalActivePromotionsParsed( JsonActivePromotionsParser* a_pActivePromotions );
|
||||
void signalCoinInfoParsed( JsonCoinInfoParser* a_pCoinInfo );
|
||||
// void signalActiveCasinosParsed( JsonActiveCasinosParser* a_pActivePromotions );
|
||||
// void signalActiveExchangesParsed( JsonActiveExchangesParser* a_pActivePromotions );
|
||||
// void signalActiveNewsItemsParsed( JsonActiveNewsItemsParser* a_pActivePromotions );
|
||||
@@ -32,6 +34,7 @@ private:
|
||||
void ParseCasinos ( const QJsonObject& a_rJsonCasinos );
|
||||
void ParseExchanges ( const QJsonObject& a_rJsonExchanges );
|
||||
void ParseNewsItems ( const QJsonObject& a_rJsonNewsItems );
|
||||
void ParseCoinInfo ( const QJsonObject& a_rJsonCoinInfo );
|
||||
|
||||
QByteArray ReadFile( QString a_strSourcePath );
|
||||
void StoreFile( QString a_strDestinationPath, const QByteArray& a_rJsonFile );
|
||||
|
||||
29
src/qt/CSCPublicAPI/jsoncoininfoparser.cpp
Normal file
29
src/qt/CSCPublicAPI/jsoncoininfoparser.cpp
Normal file
@@ -0,0 +1,29 @@
|
||||
#include "jsoncoininfoparser.h"
|
||||
#include <QDebug>
|
||||
|
||||
JsonCoinInfoParser::JsonCoinInfoParser()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
JsonCoinInfoParser::JsonCoinInfoParser( const QJsonObject& apiResult )
|
||||
: QJsonObject( apiResult )
|
||||
{
|
||||
qDebug() << "JsonCoinInfoParser: " << apiResult.begin().key();
|
||||
if ( apiResult.find( "Result" ).value().isObject() )
|
||||
{
|
||||
if ( apiResult.find( "Result" ).value().toObject().find( "CoinInfo" ).value().isObject() )
|
||||
{
|
||||
coinInfoObject = apiResult.find( "Result" ).value().toObject().find( "CoinInfo" ).value().toObject();
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug()<<"JsonCoinInfoParser first key: " << apiResult.find( "Result" ).value().toObject().begin().key();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const QJsonObject& JsonCoinInfoParser::getCoinInfo() const
|
||||
{
|
||||
return coinInfoObject;
|
||||
}
|
||||
20
src/qt/CSCPublicAPI/jsoncoininfoparser.h
Normal file
20
src/qt/CSCPublicAPI/jsoncoininfoparser.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#ifndef JSONCOININFOPARSER_H
|
||||
#define JSONCOININFOPARSER_H
|
||||
|
||||
#include <QJsonObject>
|
||||
#include <QJsonValue>
|
||||
|
||||
class JsonCoinInfoParser : public QJsonObject
|
||||
{
|
||||
public:
|
||||
JsonCoinInfoParser();
|
||||
JsonCoinInfoParser( const QJsonObject& a_rOther );
|
||||
virtual ~JsonCoinInfoParser(){}
|
||||
|
||||
const QJsonObject& getCoinInfo() const;
|
||||
|
||||
private:
|
||||
QJsonObject coinInfoObject;
|
||||
};
|
||||
|
||||
#endif // JSONCOININFOPARSER_H
|
||||
87
src/qt/currencies.cpp
Normal file
87
src/qt/currencies.cpp
Normal file
@@ -0,0 +1,87 @@
|
||||
#include "currencies.h"
|
||||
#include <QStringList>
|
||||
|
||||
Currencies::Currencies(QObject *parent):
|
||||
QAbstractListModel(parent),
|
||||
currencylist(availableCurrencies())
|
||||
{
|
||||
}
|
||||
|
||||
QList<Currencies::FiatCurrencyID> Currencies::availableCurrencies()
|
||||
{
|
||||
QList<Currencies::FiatCurrencyID> currencylist;
|
||||
currencylist.append(USD);
|
||||
currencylist.append(EUR);
|
||||
currencylist.append(CNY);
|
||||
currencylist.append(JPY);
|
||||
currencylist.append(RUB);
|
||||
return currencylist;
|
||||
}
|
||||
|
||||
bool Currencies::valid(int currency)
|
||||
{
|
||||
switch(currency)
|
||||
{
|
||||
case USD:
|
||||
case EUR:
|
||||
case CNY:
|
||||
case JPY:
|
||||
case RUB:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
QString Currencies::name(int currency)
|
||||
{
|
||||
switch(currency)
|
||||
{
|
||||
case USD: return QString("USD");
|
||||
case EUR: return QString("EUR");
|
||||
case CNY: return QString("CNY");
|
||||
case JPY: return QString("JPY");
|
||||
case RUB: return QString("RUB");
|
||||
default: return QString("???");
|
||||
}
|
||||
}
|
||||
|
||||
QString Currencies::description(int currency)
|
||||
{
|
||||
switch(currency)
|
||||
{
|
||||
case USD: return QString("US Dollars");
|
||||
case EUR: return QString("European Euro");
|
||||
case CNY: return QString("Chinese Yuan");
|
||||
case JPY: return QString("Japanese Yen");
|
||||
case RUB: return QString("Russian Ruble");
|
||||
default: return QString("???");
|
||||
}
|
||||
}
|
||||
|
||||
int Currencies::rowCount(const QModelIndex &parent) const
|
||||
{
|
||||
Q_UNUSED(parent);
|
||||
return currencylist.size();
|
||||
}
|
||||
|
||||
QVariant Currencies::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
int row = index.row();
|
||||
if(row >= 0 && row < currencylist.size())
|
||||
{
|
||||
FiatCurrencyID currency = currencylist.at(row);
|
||||
switch(role)
|
||||
{
|
||||
case Qt::EditRole:
|
||||
case Qt::DisplayRole:
|
||||
return QVariant(name(currency));
|
||||
case Qt::ToolTipRole:
|
||||
return QVariant(description(currency));
|
||||
case CurrencyRole:
|
||||
return QVariant(static_cast<int>(currency));
|
||||
}
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
46
src/qt/currencies.h
Normal file
46
src/qt/currencies.h
Normal file
@@ -0,0 +1,46 @@
|
||||
#ifndef CURRENCIES_H
|
||||
#define CURRENCIES_H
|
||||
|
||||
#include <QAbstractListModel>
|
||||
|
||||
class Currencies : public QAbstractListModel
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit Currencies(QObject *parent);
|
||||
|
||||
enum FiatCurrencyID {
|
||||
USD,
|
||||
EUR,
|
||||
CNY,
|
||||
JPY,
|
||||
RUB,
|
||||
};
|
||||
|
||||
//! Get list of currencies, for drop-down box
|
||||
static QList<FiatCurrencyID> availableCurrencies();
|
||||
//! Is currency ID valid?
|
||||
static bool valid(int currency);
|
||||
//! Short name
|
||||
static QString name(int currency);
|
||||
//! Longer description
|
||||
static QString description(int unit);
|
||||
|
||||
//! @name AbstractListModel implementation
|
||||
//! List model for currency drop-down selection box.
|
||||
///@{
|
||||
enum RoleIndex {
|
||||
/** Currency identifier */
|
||||
CurrencyRole = Qt::UserRole
|
||||
};
|
||||
int rowCount(const QModelIndex &parent) const;
|
||||
QVariant data(const QModelIndex &index, int role) const;
|
||||
///@}
|
||||
|
||||
private:
|
||||
QList<Currencies::FiatCurrencyID> currencylist;
|
||||
};
|
||||
typedef Currencies::FiatCurrencyID Currency;
|
||||
|
||||
#endif // CURRENCIES_H
|
||||
@@ -23,7 +23,7 @@
|
||||
<enum>QTabWidget::North</enum>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<number>3</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tabMain">
|
||||
<attribute name="title">
|
||||
@@ -304,89 +304,137 @@
|
||||
<attribute name="title">
|
||||
<string>&Display</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_Display">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_1_Display">
|
||||
<item>
|
||||
<widget class="QLabel" name="langLabel">
|
||||
<property name="text">
|
||||
<string>User Interface &language:</string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::PlainText</enum>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>lang</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QValueComboBox" name="lang">
|
||||
<property name="toolTip">
|
||||
<string>The user interface language can be set here. This setting will take effect after restarting CasinoCoin.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2_Display">
|
||||
<item>
|
||||
<widget class="QLabel" name="unitLabel">
|
||||
<property name="text">
|
||||
<string>&Unit to show amounts in:</string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::PlainText</enum>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>unit</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QValueComboBox" name="unit">
|
||||
<property name="toolTip">
|
||||
<string>Choose the default subdivision unit to show in the interface and when sending coins.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="displayAddresses">
|
||||
<property name="toolTip">
|
||||
<string>Whether to show CasinoCoin addresses in the transaction list or not.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Display addresses in transaction list</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="coinControlFeatures">
|
||||
<property name="toolTip">
|
||||
<string>Whether to show coin control features or not.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Display coin &control features (experts only!)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_Display">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
<widget class="QCheckBox" name="displayAddresses">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>100</y>
|
||||
<width>230</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Whether to show CasinoCoin addresses in the transaction list or not.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&Display addresses in transaction list</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="coinControlFeatures">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>127</y>
|
||||
<width>275</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Whether to show coin control features or not.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Display coin &control features (experts only!)</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>10</x>
|
||||
<y>70</y>
|
||||
<width>491</width>
|
||||
<height>24</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2_Display_Currency">
|
||||
<item>
|
||||
<widget class="QLabel" name="currencyLabel">
|
||||
<property name="text">
|
||||
<string>Currency to show amounts in:</string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::PlainText</enum>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>currency</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QValueComboBox" name="currency">
|
||||
<property name="toolTip">
|
||||
<string>Choose the default currency in which to show your total coin value.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>11</x>
|
||||
<y>11</y>
|
||||
<width>491</width>
|
||||
<height>24</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_1_Display">
|
||||
<property name="sizeConstraint">
|
||||
<enum>QLayout::SetMaximumSize</enum>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLabel" name="langLabel">
|
||||
<property name="text">
|
||||
<string>User Interface &language:</string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::PlainText</enum>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>lang</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QValueComboBox" name="lang">
|
||||
<property name="toolTip">
|
||||
<string>The user interface language can be set here. This setting will take effect after restarting CasinoCoin.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="layoutWidget">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>11</x>
|
||||
<y>42</y>
|
||||
<width>491</width>
|
||||
<height>24</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2_Display">
|
||||
<item>
|
||||
<widget class="QLabel" name="unitLabel">
|
||||
<property name="text">
|
||||
<string>&Unit to show amounts in:</string>
|
||||
</property>
|
||||
<property name="textFormat">
|
||||
<enum>Qt::PlainText</enum>
|
||||
</property>
|
||||
<property name="buddy">
|
||||
<cstring>unit</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QValueComboBox" name="unit">
|
||||
<property name="toolTip">
|
||||
<string>Choose the default subdivision unit to show in the interface and when sending coins.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
@@ -60,6 +60,56 @@
|
||||
<property name="verticalSpacing">
|
||||
<number>12</number>
|
||||
</property>
|
||||
<item row="0" column="0" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>14</pointsize>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">color: rgb(166, 27, 31);</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Wallet</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="labelWalletStatus">
|
||||
<property name="toolTip">
|
||||
<string>The displayed information may be out of date. Your wallet automatically synchronizes with the CasinoCoin network after a connection is established, but this process has not completed yet.</string>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">color: rgb(166, 27, 31);</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">(out of sync)</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="labelBalanceText">
|
||||
<property name="text">
|
||||
@@ -154,17 +204,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" 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="5" column="0" colspan="2">
|
||||
<item row="6" column="0" colspan="2">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
@@ -177,7 +217,10 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="6" column="0" colspan="2">
|
||||
<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"/>
|
||||
@@ -196,58 +239,44 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0" colspan="2">
|
||||
<layout class="QVBoxLayout" name="verticalLayoutAdvertWidget"/>
|
||||
<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="0" column="0" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>14</pointsize>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">color: rgb(166, 27, 31);</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Wallet</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="labelWalletStatus">
|
||||
<property name="toolTip">
|
||||
<string>The displayed information may be out of date. Your wallet automatically synchronizes with the CasinoCoin network after a connection is established, but this process has not completed yet.</string>
|
||||
</property>
|
||||
<property name="styleSheet">
|
||||
<string notr="true">color: rgb(166, 27, 31);</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">(out of sync)</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="labelBalanceFiatText">
|
||||
<property name="text">
|
||||
<string>Estimated Fiat Balance:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QLabel" name="labelBalanceFiat">
|
||||
<property name="font">
|
||||
<font>
|
||||
<weight>75</weight>
|
||||
<bold>true</bold>
|
||||
</font>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Estimated Fiat balance calculated against current market value</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string notr="true">0</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "ui_optionsdialog.h"
|
||||
|
||||
#include "bitcoinunits.h"
|
||||
#include "currencies.h"
|
||||
#include "monitoreddatamapper.h"
|
||||
#include "netbase.h"
|
||||
#include "optionsmodel.h"
|
||||
@@ -80,6 +81,7 @@ OptionsDialog::OptionsDialog(QWidget *parent) :
|
||||
}
|
||||
|
||||
ui->unit->setModel(new BitcoinUnits(this));
|
||||
ui->currency->setModel(new Currencies(this));
|
||||
|
||||
/* Widget-to-option mapper */
|
||||
mapper = new MonitoredDataMapper(this);
|
||||
@@ -145,6 +147,7 @@ void OptionsDialog::setMapper()
|
||||
/* Display */
|
||||
mapper->addMapping(ui->lang, OptionsModel::Language);
|
||||
mapper->addMapping(ui->unit, OptionsModel::DisplayUnit);
|
||||
mapper->addMapping(ui->currency, OptionsModel::DisplayFiatCurrency);
|
||||
mapper->addMapping(ui->displayAddresses, OptionsModel::DisplayAddresses);
|
||||
mapper->addMapping(ui->coinControlFeatures, OptionsModel::CoinControlFeatures);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "optionsmodel.h"
|
||||
|
||||
#include "bitcoinunits.h"
|
||||
#include "currencies.h"
|
||||
#include "init.h"
|
||||
#include "walletdb.h"
|
||||
#include "guiutil.h"
|
||||
@@ -49,6 +50,7 @@ void OptionsModel::Init()
|
||||
nTransactionFee = settings.value("nTransactionFee").toLongLong();
|
||||
language = settings.value("language", "").toString();
|
||||
fCoinControlFeatures = settings.value("fCoinControlFeatures", false).toBool();
|
||||
nDisplayFiatCurrency = settings.value("nDisplayFiatCurrency", Currencies::USD).toInt();
|
||||
|
||||
// These are shared with core Bitcoin; we want
|
||||
// command-line options to override the GUI settings:
|
||||
@@ -199,6 +201,8 @@ QVariant OptionsModel::data(const QModelIndex & index, int role) const
|
||||
return settings.value("language", "");
|
||||
case CoinControlFeatures:
|
||||
return QVariant(fCoinControlFeatures);
|
||||
case DisplayFiatCurrency:
|
||||
return QVariant(nDisplayFiatCurrency);
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
@@ -274,6 +278,10 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in
|
||||
settings.setValue("nDisplayUnit", nDisplayUnit);
|
||||
emit displayUnitChanged(nDisplayUnit);
|
||||
break;
|
||||
case DisplayFiatCurrency:
|
||||
nDisplayFiatCurrency = value.toInt();
|
||||
settings.setValue("nDisplayFiatCurrency", nDisplayFiatCurrency);
|
||||
break;
|
||||
case DisplayAddresses:
|
||||
bDisplayAddresses = value.toBool();
|
||||
settings.setValue("bDisplayAddresses", bDisplayAddresses);
|
||||
|
||||
@@ -27,6 +27,7 @@ public:
|
||||
ProxySocksVersion, // int
|
||||
Fee, // qint64
|
||||
DisplayUnit, // BitcoinUnits::Unit
|
||||
DisplayFiatCurrency, // Currencies::FiatCurrencyID
|
||||
DisplayAddresses, // bool
|
||||
Language, // QString
|
||||
CoinControlFeatures, // bool
|
||||
@@ -51,6 +52,7 @@ public:
|
||||
bool getDisplayAddresses() { return bDisplayAddresses; }
|
||||
QString getLanguage() { return language; }
|
||||
bool getCoinControlFeatures();
|
||||
int getDisplayFiatCurrency() { return nDisplayFiatCurrency; }
|
||||
|
||||
private:
|
||||
int nDisplayUnit;
|
||||
@@ -59,6 +61,7 @@ private:
|
||||
bool fMinimizeOnClose;
|
||||
QString language;
|
||||
bool fCoinControlFeatures;
|
||||
int nDisplayFiatCurrency;
|
||||
|
||||
signals:
|
||||
void displayUnitChanged(int unit);
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "clientmodel.h"
|
||||
#include "walletmodel.h"
|
||||
#include "bitcoinunits.h"
|
||||
#include "currencies.h"
|
||||
#include "optionsmodel.h"
|
||||
#include "transactiontablemodel.h"
|
||||
#include "transactionfilterproxy.h"
|
||||
@@ -11,8 +12,12 @@
|
||||
#include "guiconstants.h"
|
||||
#include "qtquick_controls/cpp/guibannerwidget.h"
|
||||
|
||||
#include "CSCPublicAPI/casinocoinwebapi.h"
|
||||
#include "CSCPublicAPI/casinocoinwebapiparser.h"
|
||||
|
||||
#include <QAbstractItemDelegate>
|
||||
#include <QPainter>
|
||||
#include <QDebug>
|
||||
|
||||
#define DECORATION_SIZE 64
|
||||
#define NUM_ITEMS 3
|
||||
@@ -102,7 +107,9 @@ OverviewPage::OverviewPage(QWidget *parent) :
|
||||
currentImmatureBalance(-1),
|
||||
txdelegate(new TxViewDelegate()),
|
||||
filter(0),
|
||||
advertsWidget(0)
|
||||
advertsWidget(0),
|
||||
cscWebApiParser( new CasinoCoinWebAPIParser( this ) ),
|
||||
cscWebApi( new CasinoCoinWebAPI( this ) )
|
||||
{
|
||||
ui->setupUi(this);
|
||||
createAdvertsWidget();
|
||||
@@ -114,6 +121,9 @@ OverviewPage::OverviewPage(QWidget *parent) :
|
||||
ui->listTransactions->setAttribute(Qt::WA_MacShowFocusRect, false);
|
||||
|
||||
connect(ui->listTransactions, SIGNAL(clicked(QModelIndex)), this, SLOT(handleTransactionClicked(QModelIndex)));
|
||||
connect( cscWebApi, SIGNAL( signalResponseReady(const QByteArray&)), cscWebApiParser, SLOT( slotParseAnswer(const QByteArray&)), Qt::UniqueConnection );
|
||||
connect( cscWebApi, SIGNAL( signalNetworkError(QNetworkReply::NetworkError,const QUrl)), cscWebApiParser, SLOT( slotNetworkError(QNetworkReply::NetworkError,const QUrl)), Qt::UniqueConnection );
|
||||
connect( cscWebApiParser, SIGNAL( signalCoinInfoParsed(JsonCoinInfoParser*)), this, SLOT( updateCoinInfoFromWeb(JsonCoinInfoParser*)), Qt::UniqueConnection );
|
||||
|
||||
// init "out of sync" warning labels
|
||||
ui->labelWalletStatus->setText("(" + tr("out of sync") + ")");
|
||||
@@ -121,6 +131,9 @@ OverviewPage::OverviewPage(QWidget *parent) :
|
||||
|
||||
// start with displaying the "out of sync" warnings
|
||||
showOutOfSyncWarning(true);
|
||||
|
||||
// get CoinInfo from the web
|
||||
getCoinInfo();
|
||||
}
|
||||
|
||||
void OverviewPage::handleTransactionClicked(const QModelIndex &index)
|
||||
@@ -149,6 +162,8 @@ void OverviewPage::setBalance(qint64 balance, qint64 unconfirmedBalance, qint64
|
||||
bool showImmature = immatureBalance != 0;
|
||||
ui->labelImmature->setVisible(showImmature);
|
||||
ui->labelImmatureText->setVisible(showImmature);
|
||||
// set fiat balance
|
||||
updateFiatBalance();
|
||||
}
|
||||
|
||||
void OverviewPage::createAdvertsWidget()
|
||||
@@ -244,3 +259,34 @@ void OverviewPage::on_pushButtonToggleAdverts_clicked()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OverviewPage::getCoinInfo()
|
||||
{
|
||||
if ( cscWebApi )
|
||||
{
|
||||
cscWebApi->GetCoinInfo();
|
||||
}
|
||||
}
|
||||
|
||||
void OverviewPage::updateCoinInfoFromWeb( JsonCoinInfoParser* coinInfoParser )
|
||||
{
|
||||
qDebug() << "CoinInfo ID: " << coinInfoParser->getCoinInfo().find("ID").value().toDouble();
|
||||
qDebug() << "CoinInfo InfoTime: " <<coinInfoParser->getCoinInfo().find("InfoTime").value().toString();
|
||||
// save the coin information
|
||||
coinInformation = coinInfoParser->getCoinInfo();
|
||||
// calculate and set the estimated fiat balance
|
||||
updateFiatBalance();
|
||||
}
|
||||
|
||||
void OverviewPage::updateFiatBalance()
|
||||
{
|
||||
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;
|
||||
qDebug() << "updateFiatBalance: " << QString::number(fiatBalance,'f',2);
|
||||
ui->labelBalanceFiat->setText(QString::number(fiatBalance,'f',2).append(" ").append(Currencies::name(currency)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define OVERVIEWPAGE_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QJsonObject>
|
||||
|
||||
namespace Ui {
|
||||
class OverviewPage;
|
||||
@@ -11,6 +12,9 @@ class WalletModel;
|
||||
class TxViewDelegate;
|
||||
class TransactionFilterProxy;
|
||||
class GUIBannerWidget;
|
||||
class CasinoCoinWebAPIParser;
|
||||
class CasinoCoinWebAPI;
|
||||
class JsonCoinInfoParser;
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QModelIndex;
|
||||
@@ -49,12 +53,19 @@ private:
|
||||
GUIBannerWidget* advertsWidget;
|
||||
/** Create widget to populate adverts */
|
||||
void createAdvertsWidget();
|
||||
/** Get the CoinInfo from REST service */
|
||||
CasinoCoinWebAPIParser* cscWebApiParser;
|
||||
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 );
|
||||
};
|
||||
|
||||
#endif // OVERVIEWPAGE_H
|
||||
|
||||
@@ -16,7 +16,7 @@ PryptoPage::PryptoPage(QWidget *parent) :
|
||||
ui->setupUi(this);
|
||||
connect( &networkAccessManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(parseAPINetworkResponse(QNetworkReply*)) );
|
||||
connect( this, SIGNAL(apiResponseReady(QByteArray)), this, SLOT(showAPIResult(QByteArray)) );
|
||||
connect( this, SIGNAL(apiNetworkError(QNetworkReply::NetworkError*)), this, SLOT(showAPINetworkError(QNetworkReply*)) );
|
||||
connect( this, SIGNAL(apiNetworkError(QNetworkReply::NetworkError)), this, SLOT(showAPINetworkError(QNetworkReply::NetworkError)) );
|
||||
}
|
||||
|
||||
void PryptoPage::setWalletModel(WalletModel *model)
|
||||
@@ -81,10 +81,11 @@ void PryptoPage::parseAPINetworkResponse( QNetworkReply *finished )
|
||||
emit apiResponseReady( data );
|
||||
}
|
||||
|
||||
void PryptoPage::showAPINetworkError(QNetworkReply *reply)
|
||||
void PryptoPage::showAPINetworkError(QNetworkReply::NetworkError error)
|
||||
{
|
||||
qDebug() << "PryptoPage::showAPINetworkError: " << error;
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText("Error redeeming Prypto Card: " + reply->errorString());
|
||||
msgBox.setText("Error redeeming Prypto Card.");
|
||||
msgBox.exec();
|
||||
}
|
||||
|
||||
|
||||
@@ -24,13 +24,13 @@ public:
|
||||
|
||||
signals:
|
||||
void apiResponseReady( const QByteArray& content );
|
||||
void apiNetworkError( QNetworkReply::NetworkError error );
|
||||
void apiNetworkError( const QNetworkReply::NetworkError& error );
|
||||
|
||||
private slots:
|
||||
void on_butRedeem_clicked();
|
||||
void parseAPINetworkResponse( QNetworkReply *finished );
|
||||
void showAPIResult(QByteArray data);
|
||||
void showAPINetworkError(QNetworkReply *reply);
|
||||
void showAPINetworkError(QNetworkReply::NetworkError error);
|
||||
|
||||
private:
|
||||
static const QString strAPIEndpoint;
|
||||
|
||||
Reference in New Issue
Block a user