[GUI] Fix CMake error, add README.md
This commit is contained in:
parent
72f5284e49
commit
f57205a2e6
6 changed files with 42 additions and 28 deletions
|
|
@ -16,6 +16,8 @@ file(GLOB QML qml/*)
|
||||||
qt5_add_resources(QML_QRC qml/qml.qrc)
|
qt5_add_resources(QML_QRC qml/qml.qrc)
|
||||||
|
|
||||||
add_executable(light_client ClientDataModel.cpp ClientDataModel.hpp main.cpp ${QML_QRC} ${QML})
|
add_executable(light_client ClientDataModel.cpp ClientDataModel.hpp main.cpp ${QML_QRC} ${QML})
|
||||||
add_dependencies(light_client gen_qrc)
|
if (CMAKE_VERSION VERSION_LESS 3.0)
|
||||||
|
add_dependencies(light_client gen_qrc)
|
||||||
|
endif()
|
||||||
|
|
||||||
target_link_libraries(light_client PRIVATE Qt5::Core Qt5::Widgets Qt5::Quick graphene_chain graphene_utilities fc graphene_app )
|
target_link_libraries(light_client PRIVATE Qt5::Core Qt5::Widgets Qt5::Quick graphene_chain graphene_utilities fc graphene_app )
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ using namespace graphene::app;
|
||||||
ChainDataModel::ChainDataModel( fc::thread& t, QObject* parent )
|
ChainDataModel::ChainDataModel( fc::thread& t, QObject* parent )
|
||||||
:QObject(parent),m_thread(&t){}
|
:QObject(parent),m_thread(&t){}
|
||||||
|
|
||||||
Account* ChainDataModel::getAccount(qint64 id)
|
Account* ChainDataModel::getAccount(ObjectId id)
|
||||||
{
|
{
|
||||||
auto& by_id_idx = m_accounts.get<::by_id>();
|
auto& by_id_idx = m_accounts.get<::by_id>();
|
||||||
auto itr = by_id_idx.find(id);
|
auto itr = by_id_idx.find(id);
|
||||||
|
|
@ -94,7 +94,7 @@ Account* ChainDataModel::getAccount(QString name)
|
||||||
{
|
{
|
||||||
by_name_idx.modify( itr,
|
by_name_idx.modify( itr,
|
||||||
[=]( Account* a ){
|
[=]( Account* a ){
|
||||||
a->setProperty("id", qint64(result.front()->id.instance()));
|
a->setProperty("id", ObjectId(result.front()->id.instance()));
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,24 +11,36 @@
|
||||||
#include <fc/thread/thread.hpp>
|
#include <fc/thread/thread.hpp>
|
||||||
#include <graphene/app/api.hpp>
|
#include <graphene/app/api.hpp>
|
||||||
|
|
||||||
|
#include <QtQml>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QQmlListProperty>
|
#include <QQmlListProperty>
|
||||||
|
|
||||||
using boost::multi_index_container;
|
using boost::multi_index_container;
|
||||||
using namespace boost::multi_index;
|
using namespace boost::multi_index;
|
||||||
|
|
||||||
|
using ObjectId = qint64;
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(std::function<void()>)
|
Q_DECLARE_METATYPE(std::function<void()>)
|
||||||
|
|
||||||
|
class Crypto {
|
||||||
|
Q_GADGET
|
||||||
|
|
||||||
|
public:
|
||||||
|
Q_INVOKABLE QString sha256(QByteArray data) {
|
||||||
|
return QCryptographicHash::hash(data, QCryptographicHash::Sha256).toHex();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
QML_DECLARE_TYPE(Crypto)
|
||||||
|
|
||||||
class Asset : public QObject {
|
class Asset : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
Q_PROPERTY(QString symbol MEMBER symbol)
|
Q_PROPERTY(QString symbol MEMBER symbol)
|
||||||
Q_PROPERTY(qint64 id MEMBER id)
|
Q_PROPERTY(ObjectId id MEMBER id)
|
||||||
Q_PROPERTY(quint8 precision MEMBER precision)
|
Q_PROPERTY(quint8 precision MEMBER precision)
|
||||||
|
|
||||||
QString symbol;
|
QString symbol;
|
||||||
qint64 id;
|
ObjectId id;
|
||||||
quint8 precision;
|
quint8 precision;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -37,33 +49,30 @@ class Balance : public QObject {
|
||||||
|
|
||||||
Q_PROPERTY(Asset* type MEMBER type)
|
Q_PROPERTY(Asset* type MEMBER type)
|
||||||
Q_PROPERTY(qint64 amount MEMBER amount)
|
Q_PROPERTY(qint64 amount MEMBER amount)
|
||||||
Q_PROPERTY(qint64 id MEMBER id)
|
Q_PROPERTY(ObjectId id MEMBER id)
|
||||||
|
|
||||||
Asset* type;
|
Asset* type;
|
||||||
qint64 amount;
|
qint64 amount;
|
||||||
qint64 id;
|
ObjectId id;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Account : public QObject {
|
class Account : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
Q_PROPERTY(QString name MEMBER name NOTIFY nameChanged)
|
Q_PROPERTY(QString name MEMBER name NOTIFY nameChanged)
|
||||||
Q_PROPERTY(qint64 id MEMBER id NOTIFY idChanged)
|
Q_PROPERTY(ObjectId id MEMBER id NOTIFY idChanged)
|
||||||
Q_PROPERTY(QQmlListProperty<Balance> balances READ balances)
|
Q_PROPERTY(QQmlListProperty<Balance> balances READ balances)
|
||||||
|
|
||||||
QList<Balance*> m_balances;
|
QList<Balance*> m_balances;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Account(QObject* parent = nullptr)
|
|
||||||
// : QObject(parent){}
|
|
||||||
|
|
||||||
const QString& getName()const { return name; }
|
const QString& getName()const { return name; }
|
||||||
qint64 getId()const { return id; }
|
ObjectId getId()const { return id; }
|
||||||
|
|
||||||
QQmlListProperty<Balance> balances();
|
QQmlListProperty<Balance> balances();
|
||||||
|
|
||||||
QString name;
|
QString name;
|
||||||
qint64 id;
|
ObjectId id;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void nameChanged();
|
void nameChanged();
|
||||||
|
|
@ -75,22 +84,19 @@ struct by_account_name;
|
||||||
/**
|
/**
|
||||||
* @ingroup object_index
|
* @ingroup object_index
|
||||||
*/
|
*/
|
||||||
typedef multi_index_container<
|
using account_multi_index_type = multi_index_container<
|
||||||
Account*,
|
Account*,
|
||||||
indexed_by<
|
indexed_by<
|
||||||
hashed_unique< tag<by_id>, const_mem_fun<Account, qint64, &Account::getId > >,
|
hashed_unique< tag<by_id>, const_mem_fun<Account, ObjectId, &Account::getId > >,
|
||||||
ordered_unique< tag<by_account_name>, const_mem_fun<Account, const QString&, &Account::getName> >
|
ordered_unique< tag<by_account_name>, const_mem_fun<Account, const QString&, &Account::getName> >
|
||||||
>
|
>
|
||||||
> account_multi_index_type;
|
>;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class ChainDataModel : public QObject {
|
class ChainDataModel : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Q_INVOKABLE Account* getAccount(qint64 id);
|
Q_INVOKABLE Account* getAccount(ObjectId id);
|
||||||
Q_INVOKABLE Account* getAccount(QString name);
|
Q_INVOKABLE Account* getAccount(QString name);
|
||||||
|
|
||||||
ChainDataModel(){}
|
ChainDataModel(){}
|
||||||
|
|
@ -107,14 +113,10 @@ private:
|
||||||
std::string m_api_url;
|
std::string m_api_url;
|
||||||
fc::api<graphene::app::database_api> m_db_api;
|
fc::api<graphene::app::database_api> m_db_api;
|
||||||
|
|
||||||
qint64 m_account_query_num = -1;
|
ObjectId m_account_query_num = -1;
|
||||||
account_multi_index_type m_accounts;
|
account_multi_index_type m_accounts;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class GrapheneApplication : public QObject {
|
class GrapheneApplication : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
|
|
||||||
11
programs/light_client/README.md
Normal file
11
programs/light_client/README.md
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
== Graphene Client GUI ==
|
||||||
|
|
||||||
|
This is a Qt-based native GUI client for Graphene blockchains.
|
||||||
|
|
||||||
|
To build this GUI, run cmake with -DBUILD_QT_GUI=ON
|
||||||
|
|
||||||
|
This GUI depends on Qt 5.5 or later. If you do not have Qt 5.5 installed
|
||||||
|
in the canonical location on your OS (or if your OS does not have a
|
||||||
|
canonical location for libraries), you can specify the Qt path by running
|
||||||
|
cmake with -DCMAKE_PREFIX_PATH=/path/to/Qt/5.5/gcc_64 as appropriate for
|
||||||
|
your environment.
|
||||||
|
|
@ -21,11 +21,9 @@ int main(int argc, char *argv[])
|
||||||
qmlRegisterType<GrapheneApplication>("Graphene.Client", 0, 1, "GrapheneApplication");
|
qmlRegisterType<GrapheneApplication>("Graphene.Client", 0, 1, "GrapheneApplication");
|
||||||
|
|
||||||
QQmlApplicationEngine engine;
|
QQmlApplicationEngine engine;
|
||||||
/*
|
|
||||||
QVariant crypto;
|
QVariant crypto;
|
||||||
crypto.setValue(Crypto());
|
crypto.setValue(Crypto());
|
||||||
engine.rootContext()->setContextProperty("Crypto", crypto);
|
engine.rootContext()->setContextProperty("Crypto", crypto);
|
||||||
*/
|
|
||||||
#ifdef NDEBUG
|
#ifdef NDEBUG
|
||||||
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
|
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
|
||||||
#else
|
#else
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ ApplicationWindow {
|
||||||
MenuItem {
|
MenuItem {
|
||||||
text: qsTr("Exit")
|
text: qsTr("Exit")
|
||||||
onTriggered: Qt.quit();
|
onTriggered: Qt.quit();
|
||||||
|
shortcut: "Ctrl+Q"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue