2015-10-12 17:02:59 +00:00
|
|
|
/*
|
2015-10-12 17:48:40 +00:00
|
|
|
* Copyright (c) 2015 Cryptonomex, Inc., and contributors.
|
|
|
|
|
*
|
2016-01-06 09:51:18 +00:00
|
|
|
* The MIT License
|
2015-10-12 17:48:40 +00:00
|
|
|
*
|
2016-01-06 09:51:18 +00:00
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
|
* furnished to do so, subject to the following conditions:
|
2015-10-12 17:48:40 +00:00
|
|
|
*
|
2016-01-06 09:51:18 +00:00
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
|
* all copies or substantial portions of the Software.
|
2015-10-12 17:02:59 +00:00
|
|
|
*
|
2016-01-06 09:51:18 +00:00
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
|
* THE SOFTWARE.
|
2015-10-12 17:02:59 +00:00
|
|
|
*/
|
2015-07-10 21:37:22 +00:00
|
|
|
#include <QApplication>
|
|
|
|
|
#include <QQmlApplicationEngine>
|
|
|
|
|
#include <QtQml>
|
|
|
|
|
|
2015-07-22 15:10:52 +00:00
|
|
|
#include "GrapheneApplication.hpp"
|
|
|
|
|
#include "ChainDataModel.hpp"
|
2015-07-22 21:38:44 +00:00
|
|
|
#include "Transaction.hpp"
|
2015-07-21 21:09:44 +00:00
|
|
|
#include "Operations.hpp"
|
2015-07-22 15:10:52 +00:00
|
|
|
#include "Balance.hpp"
|
2015-07-29 19:50:12 +00:00
|
|
|
#include "Wallet.hpp"
|
2015-07-22 15:10:52 +00:00
|
|
|
|
|
|
|
|
class Crypto {
|
|
|
|
|
Q_GADGET
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
Q_INVOKABLE QString sha256(QByteArray data) {
|
|
|
|
|
return QCryptographicHash::hash(data, QCryptographicHash::Sha256).toHex();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
QML_DECLARE_TYPE(Crypto)
|
2015-07-10 21:37:22 +00:00
|
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
|
{
|
2015-07-27 20:01:16 +00:00
|
|
|
#ifndef NDEBUG
|
|
|
|
|
QQmlDebuggingEnabler enabler;
|
|
|
|
|
#endif
|
|
|
|
|
fc::thread::current().set_name("main");
|
2015-07-10 21:37:22 +00:00
|
|
|
QApplication app(argc, argv);
|
2015-07-13 18:35:17 +00:00
|
|
|
app.setApplicationName("Graphene Client");
|
|
|
|
|
app.setOrganizationDomain("cryptonomex.org");
|
|
|
|
|
app.setOrganizationName("Cryptonomex, Inc.");
|
2015-07-10 21:37:22 +00:00
|
|
|
|
2015-07-13 18:14:58 +00:00
|
|
|
qRegisterMetaType<std::function<void()>>();
|
2015-07-14 19:06:00 +00:00
|
|
|
qRegisterMetaType<ObjectId>();
|
2015-07-27 20:01:16 +00:00
|
|
|
qRegisterMetaType<QList<OperationBase*>>();
|
2015-08-07 19:14:30 +00:00
|
|
|
qRegisterMetaType<Transaction::Status>();
|
2015-07-13 18:14:58 +00:00
|
|
|
|
2015-07-10 21:37:22 +00:00
|
|
|
qmlRegisterType<Asset>("Graphene.Client", 0, 1, "Asset");
|
|
|
|
|
qmlRegisterType<Balance>("Graphene.Client", 0, 1, "Balance");
|
|
|
|
|
qmlRegisterType<Account>("Graphene.Client", 0, 1, "Account");
|
2015-07-13 17:19:07 +00:00
|
|
|
qmlRegisterType<ChainDataModel>("Graphene.Client", 0, 1, "DataModel");
|
2015-07-29 19:50:12 +00:00
|
|
|
qmlRegisterType<Wallet>("Graphene.Client", 0, 1, "Wallet");
|
2015-07-13 17:19:07 +00:00
|
|
|
qmlRegisterType<GrapheneApplication>("Graphene.Client", 0, 1, "GrapheneApplication");
|
2015-07-22 21:38:44 +00:00
|
|
|
qmlRegisterType<Transaction>("Graphene.Client", 0, 1, "Transaction");
|
|
|
|
|
|
2015-08-05 20:03:09 +00:00
|
|
|
qmlRegisterUncreatableType<OperationBase>("Graphene.Client", 0, 1, "OperationBase",
|
|
|
|
|
"OperationBase is an abstract base class; cannot be created");
|
2015-07-22 21:38:44 +00:00
|
|
|
qmlRegisterType<TransferOperation>("Graphene.Client", 0, 1, "TransferOperation");
|
|
|
|
|
|
2015-07-21 21:09:44 +00:00
|
|
|
qmlRegisterUncreatableType<OperationBuilder>("Graphene.Client", 0, 1, "OperationBuilder",
|
|
|
|
|
QStringLiteral("OperationBuilder cannot be created from QML"));
|
2015-07-10 21:37:22 +00:00
|
|
|
|
|
|
|
|
QQmlApplicationEngine engine;
|
2015-07-13 21:22:06 +00:00
|
|
|
QVariant crypto;
|
|
|
|
|
crypto.setValue(Crypto());
|
|
|
|
|
engine.rootContext()->setContextProperty("Crypto", crypto);
|
2015-07-13 18:16:02 +00:00
|
|
|
#ifdef NDEBUG
|
2015-07-10 21:37:22 +00:00
|
|
|
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
|
2015-07-13 18:16:02 +00:00
|
|
|
#else
|
|
|
|
|
engine.load(QUrl(QStringLiteral("qml/main.qml")));
|
2015-08-03 15:59:02 +00:00
|
|
|
QFileSystemWatcher watcher;
|
|
|
|
|
qDebug() << watcher.addPath("qml/");
|
|
|
|
|
QObject::connect(&watcher, &QFileSystemWatcher::directoryChanged, &engine, [&](QString path) {
|
|
|
|
|
qDebug() << "Changed file" << path;
|
|
|
|
|
engine.clearComponentCache();
|
|
|
|
|
});
|
2015-07-13 18:16:02 +00:00
|
|
|
#endif
|
2015-07-10 21:37:22 +00:00
|
|
|
|
|
|
|
|
return app.exec();
|
|
|
|
|
}
|
2015-07-22 15:10:52 +00:00
|
|
|
|
|
|
|
|
#include "main.moc"
|