Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#include <QApplication>
#include <QGuiApplication>
#include <QtQml>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include <QIcon>
#include <QSystemSemaphore>
#include <QSharedMemory>
#include <QScreen>
#include "DapHalper.h"
#include "DapScreenDialog.h"
#include "DapScreenDialogChangeWidget.h"
#include "DapSettings.h"
#include "DapServiceClient.h"
#include "DapServiceController.h"
#include "DapLogger.h"
#include "DapLogMessage.h"
#include "DapLogModel.h"
#include "DapChainWalletsModel.h"
#include "DapChainNodeNetworkModel.h"
#include "DapChainNodeNetworkExplorer.h"
#include "DapScreenHistoryFilterModel.h"
#include "DapSettingsNetworkModel.h"
#include "DapConsoleModel.h"
#include "DapChainConvertor.h"
#include "DapClipboard.h"
#include "DapChainWalletModel.h"
#include "DapWalletFilterModel.h"
#include <QRegExp>
#include <sys/stat.h>
int main(int argc, char *argv[])
{
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication app(argc, argv);
app.setOrganizationName("DEMLABS");
app.setOrganizationDomain("demlabs.net");
app.setApplicationName("CellFrame Dashboard");
app.setWindowIcon(QIcon(":/res/icons/icon.ico"));
DapLogger dapLogger;
/// TODO: The code is commented out at the time of developing the logging strategy in the project
//#ifndef QT_DEBUG
#ifdef Q_OS_LINUX
dapLogger.setLogFile(QString("/opt/cellframe-dashboard/log/%1Gui.log").arg(DAP_BRAND));
#elif defined Q_OS_MACOS
mkdir("/tmp/cellframe-dashboard_log",0777);
dapLogger.setLogFile(QString("/tmp/cellframe-dashboard_log/%1Gui.log").arg(DAP_BRAND));
#elif defined Q_OS_WIN
dapLogger.setLogFile(QString("%Dashboard.log").arg(DAP_BRAND));
dapLogger.setLogLevel(L_DEBUG);
#endif
//#endif
/// Local client.
DapServiceClient dapServiceClient;
// Creating a service controller
DapServiceController &controller = DapServiceController::getInstance();
controller.init(&dapServiceClient);
dapServiceClient.init();
controller.getWallets();
controller.requestWalletData();
controller.getHistory();
controller.getCmdHistory();
controller.getNetworkList();
DapScreenHistoryFilterModel::getInstance()
.setSourceModel(&DapScreenHistoryModel::getInstance());
DapWalletFilterModel::instance()
.setSourceModel(&DapChainWalletModel::instance());
qmlRegisterType<DapScreenDialog>("CellFrameDashboard", 1, 0, "DapScreenDialog");
qmlRegisterType<DapScreenDialogChangeWidget>("CellFrameDashboard", 1, 0, "DapScreenDialogChangeWidget");
qmlRegisterType<DapLogMessage>("LogMessage", 1, 0, "DapLogMessage");
qmlRegisterType<DapChainNodeNetworkExplorer>("NodeNetworkExplorer", 1, 0, "DapUiQmlWidgetNodeNetwork");
qmlRegisterType<DapScreenHistoryModel>("DapTransactionHistory", 1, 0, "DapTransactionModel");
QQmlApplicationEngine engine;
/// TODO: this method for getting DPI screen can be useful in the future
// qreal dpi = QGuiApplication::primaryScreen()->physicalDotsPerInch();
engine.rootContext()->setContextProperty("dapServiceController", &DapServiceController::getInstance());
engine.rootContext()->setContextProperty("dapLogModel", &DapLogModel::getInstance());
engine.rootContext()->setContextProperty("dapChainWalletsModel", &DapChainWalletsModel::getInstance());
engine.rootContext()->setContextProperty("dapNodeNetworkModel", &DapChainNodeNetworkModel::getInstance());
engine.rootContext()->setContextProperty("dapConsoleModel", &DapConsoleModel::getInstance());
engine.rootContext()->setContextProperty("dapHistoryModel", &DapScreenHistoryFilterModel::getInstance());
engine.rootContext()->setContextProperty("dapSettingsNetworkModel", &DapSettingsNetworkModel::getInstance());
engine.rootContext()->setContextProperty("dapChainConvertor", &DapChainConvertor::getInstance());
engine.rootContext()->setContextProperty("dapWalletFilterModel", &DapWalletFilterModel::instance());
engine.rootContext()->setContextProperty("dapWalletModel", &DapChainWalletModel::instance());
engine.rootContext()->setContextProperty("clipboard", &DapClipboard::instance());
engine.rootContext()->setContextProperty("pt", 1.3);
engine.load(QUrl("qrc:/screen/main.qml"));
if (engine.rootObjects().isEmpty())
return -1;
return app.exec();
}