[GUI] Fix CMake error, add README.md

This commit is contained in:
Nathan Hourt 2015-07-14 13:06:32 -04:00
parent 72f5284e49
commit f57205a2e6
6 changed files with 42 additions and 28 deletions

View file

@ -16,6 +16,8 @@ file(GLOB QML qml/*)
qt5_add_resources(QML_QRC qml/qml.qrc)
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 )

View file

@ -10,7 +10,7 @@ using namespace graphene::app;
ChainDataModel::ChainDataModel( fc::thread& t, QObject* parent )
: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 itr = by_id_idx.find(id);
@ -94,7 +94,7 @@ Account* ChainDataModel::getAccount(QString name)
{
by_name_idx.modify( itr,
[=]( Account* a ){
a->setProperty("id", qint64(result.front()->id.instance()));
a->setProperty("id", ObjectId(result.front()->id.instance()));
}
);
}

View file

@ -11,24 +11,36 @@
#include <fc/thread/thread.hpp>
#include <graphene/app/api.hpp>
#include <QtQml>
#include <QObject>
#include <QQmlListProperty>
using boost::multi_index_container;
using namespace boost::multi_index;
using ObjectId = qint64;
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 {
Q_OBJECT
Q_PROPERTY(QString symbol MEMBER symbol)
Q_PROPERTY(qint64 id MEMBER id)
Q_PROPERTY(ObjectId id MEMBER id)
Q_PROPERTY(quint8 precision MEMBER precision)
QString symbol;
qint64 id;
ObjectId id;
quint8 precision;
};
@ -37,33 +49,30 @@ class Balance : public QObject {
Q_PROPERTY(Asset* type MEMBER type)
Q_PROPERTY(qint64 amount MEMBER amount)
Q_PROPERTY(qint64 id MEMBER id)
Q_PROPERTY(ObjectId id MEMBER id)
Asset* type;
qint64 amount;
qint64 id;
ObjectId id;
};
class Account : public QObject {
Q_OBJECT
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)
QList<Balance*> m_balances;
public:
// Account(QObject* parent = nullptr)
// : QObject(parent){}
const QString& getName()const { return name; }
qint64 getId()const { return id; }
ObjectId getId()const { return id; }
QQmlListProperty<Balance> balances();
QString name;
qint64 id;
ObjectId id;
signals:
void nameChanged();
@ -75,22 +84,19 @@ struct by_account_name;
/**
* @ingroup object_index
*/
typedef multi_index_container<
using account_multi_index_type = multi_index_container<
Account*,
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> >
>
> account_multi_index_type;
>;
class ChainDataModel : public QObject {
Q_OBJECT
public:
Q_INVOKABLE Account* getAccount(qint64 id);
Q_INVOKABLE Account* getAccount(ObjectId id);
Q_INVOKABLE Account* getAccount(QString name);
ChainDataModel(){}
@ -107,14 +113,10 @@ private:
std::string m_api_url;
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;
};
class GrapheneApplication : public QObject {
Q_OBJECT

View 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.

View file

@ -21,11 +21,9 @@ int main(int argc, char *argv[])
qmlRegisterType<GrapheneApplication>("Graphene.Client", 0, 1, "GrapheneApplication");
QQmlApplicationEngine engine;
/*
QVariant crypto;
crypto.setValue(Crypto());
engine.rootContext()->setContextProperty("Crypto", crypto);
*/
#ifdef NDEBUG
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
#else

View file

@ -28,6 +28,7 @@ ApplicationWindow {
MenuItem {
text: qsTr("Exit")
onTriggered: Qt.quit();
shortcut: "Ctrl+Q"
}
}
}
@ -112,7 +113,7 @@ ApplicationWindow {
}
}
}
}