From 729301ecceb4f161c640e53832cfdd9d1e6bcb5a Mon Sep 17 00:00:00 2001 From: "andrey.daragan" <daragan.andrey@demlabs.net> Date: Thu, 27 Feb 2020 10:11:34 +0000 Subject: [PATCH 1/3] features-3161 --- resources/QML/DapFontRoboto.qml | 38 +++++++++++++++++---------------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/resources/QML/DapFontRoboto.qml b/resources/QML/DapFontRoboto.qml index a9f787f..42e0b2c 100644 --- a/resources/QML/DapFontRoboto.qml +++ b/resources/QML/DapFontRoboto.qml @@ -3,8 +3,10 @@ import "qrc:/" Item { - ///@details dapMainFontTheme ID of item with all project fonts + ///@details dapMainFontTheme ID of item with all project fonts. property alias dapMainFontTheme: dapFontsObjects + ///@details dapFactor Scaling factor. + property int dapFactor: 1 //Add Font Loader DapFont @@ -28,7 +30,7 @@ Item family: dapFonts.dapProjectFonts[0].name, bold: false, italic: false, - pixelSize: 14 + pixelSize: 14 * dapFactor }) ///@details dapFontRobotoBlackCustom Font of Roboto font family (black, without parameters) @@ -39,7 +41,7 @@ Item family: dapFonts.dapProjectFonts[0].name, bold: false, italic: true, - pixelSize: 14 + pixelSize: 14 * dapFactor }) ///@details dapFontRobotoBlackItalicCustom Font of Roboto font family (black-italic, without parameters) @@ -53,7 +55,7 @@ Item family: dapFonts.dapProjectFonts[3].name, bold: true, italic: false, - pixelSize: 14 + pixelSize: 14 * dapFactor }) ///@details dapFontRobotoBoldCustom Font of Roboto font family (bold, without parameters) @@ -67,7 +69,7 @@ Item family: dapFonts.dapProjectFonts[3].name, bold: true, italic: true, - pixelSize: 14 + pixelSize: 14 * dapFactor }) ///@details dapFontRobotoBoldItalicCustom Font of Roboto font family (bold-italic, without parameters) @@ -82,7 +84,7 @@ Item family: dapFonts.dapProjectFonts[1].name, bold: false, italic: false, - pixelSize: 14 + pixelSize: 14 * dapFactor }) ///@details dapFontRobotoLightCustom Font of Roboto font family (light, without parameters) @@ -93,7 +95,7 @@ Item family: dapFonts.dapProjectFonts[1].name, bold: false, italic: true, - pixelSize: 14 + pixelSize: 14 * dapFactor }) ///@details dapFontRobotoLightItalicCustom Font of Roboto font family (light-italic, without parameters) @@ -106,7 +108,7 @@ Item family: dapFonts.dapProjectFonts[2].name, bold: false, italic: false, - pixelSize: 14 + pixelSize: 14 * dapFactor }) ///@details dapFontRobotoMediumCustom Font of Roboto font family (medium, without parameters) @@ -117,7 +119,7 @@ Item family: dapFonts.dapProjectFonts[2].name, bold: false, italic: true, - pixelSize: 14 + pixelSize: 14 * dapFactor }) ///@details dapFontRobotoMediumItalicCustom Font of Roboto font family (medium-italic, without parameters) @@ -131,7 +133,7 @@ Item family: dapFonts.dapProjectFonts[3].name, bold: false, italic: true, - pixelSize: 14 + pixelSize: 14 * dapFactor }) ///@details dapFontRobotoItalicCustom Font of Roboto font family (italic, without parameters) @@ -145,7 +147,7 @@ Item family: dapFonts.dapProjectFonts[3].name, bold: false, italic: false, - pixelSize: 14 + pixelSize: 14 * dapFactor }) ///@details dapFontRobotoRegular12 Font of Roboto font family (regular, 12pt) @@ -153,7 +155,7 @@ Item family: dapFonts.dapProjectFonts[3].name, bold: false, italic: false, - pixelSize: 12 + pixelSize: 12 * dapFactor }) ///@details dapFontRobotoRegular16 Font of Roboto font family (regular, 16pt) @@ -161,7 +163,7 @@ Item family: dapFonts.dapProjectFonts[3].name, bold: false, italic: false, - pixelSize: 16 + pixelSize: 16 * dapFactor }) ///@details dapFontRobotoRegular18 Font of Roboto font family (regular, 18pt) @@ -169,7 +171,7 @@ Item family: dapFonts.dapProjectFonts[3].name, bold: false, italic: false, - pixelSize: 18 + pixelSize: 18 * dapFactor }) ///@details dapFontRobotoRegularCustom Font of Roboto font family (regular, without parameters) @@ -180,7 +182,7 @@ Item family: dapFonts.dapProjectFonts[4].name, bold: false, italic: false, - pixelSize: 14 + pixelSize: 14 * dapFactor }) ///@details dapFontRobotoThinCustom Font of Roboto font family (thin, without parameters) @@ -191,7 +193,7 @@ Item family: dapFonts.dapProjectFonts[4].name, bold: false, italic: true, - pixelSize: 14 + pixelSize: 14 * dapFactor }) ///@details dapFontRobotoThinItalicCustom Font of Roboto font family (thin-italic, without parameters) @@ -205,7 +207,7 @@ Item family: dapFonts.dapProjectFonts[3].name, bold: false, italic: false, - pixelSize: 11 + pixelSize: 11 * dapFactor }) ///@details dapFontRobotoRegular10 Font of Roboto font family (regular, 10pt) @@ -213,7 +215,7 @@ Item family: dapFonts.dapProjectFonts[3].name, bold: false, italic: false, - pixelSize: 10 + pixelSize: 10 * dapFactor }) } } -- GitLab From f06288c593cccfc8b32541fc9ea1f6821963561f Mon Sep 17 00:00:00 2001 From: "tatiana.novikova" <tatiana.novikova@demlabs.net> Date: Thu, 12 Mar 2020 15:26:40 +0000 Subject: [PATCH 2/3] Features 2989 --- DapHalper.h | 2 +- DapSettings.h | 2 +- handlers/DapAbstractCommand.h | 2 +- handlers/DapActivateClientCommand.h | 2 +- handlers/DapAddWalletCommand.h | 2 +- handlers/DapGetListWalletsCommand.cpp | 144 +------------------------- handlers/DapGetListWalletsCommand.h | 4 - handlers/DapGetWalletInfoCommand.cpp | 107 +++++++++++++++++++ handlers/DapGetWalletInfoCommand.h | 37 +++++++ handlers/DapGetWalletsInfoCommand.cpp | 121 ++++++++++++++++++++++ handlers/DapGetWalletsInfoCommand.h | 38 +++++++ handlers/DapQuitApplicationCommand.h | 2 +- libdap-qt-ui-chain-wallet.pri | 4 + libdap-qt-ui-chain-wallet.qrc | 1 + resources/JS/TimeFunctions.js | 60 +++++++++++ 15 files changed, 377 insertions(+), 151 deletions(-) create mode 100644 handlers/DapGetWalletInfoCommand.cpp create mode 100644 handlers/DapGetWalletInfoCommand.h create mode 100644 handlers/DapGetWalletsInfoCommand.cpp create mode 100644 handlers/DapGetWalletsInfoCommand.h create mode 100644 resources/JS/TimeFunctions.js diff --git a/DapHalper.h b/DapHalper.h index 1c96e87..fea5511 100644 --- a/DapHalper.h +++ b/DapHalper.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** This file is part of the libCellFrameDashboardClient library. +** This file is part of the libdap-qt-ui-chain-wallet library. ** ** The class provides common functionality. ** diff --git a/DapSettings.h b/DapSettings.h index 7469a25..dc52b3d 100644 --- a/DapSettings.h +++ b/DapSettings.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** This file is part of the CellFrameDashboardGUI application. +** This file is part of the libdap-qt-ui-chain-wallet application. ** ** The class provides an interface for managing application settings. ** Record format - Json. diff --git a/handlers/DapAbstractCommand.h b/handlers/DapAbstractCommand.h index f2fe31f..70b2d98 100644 --- a/handlers/DapAbstractCommand.h +++ b/handlers/DapAbstractCommand.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** This file is part of the libCellFrameDashboardClient library. +** This file is part of the libdap-qt-ui-chain-wallet library. ** ** The class implements the command interface. ** diff --git a/handlers/DapActivateClientCommand.h b/handlers/DapActivateClientCommand.h index 9ff2874..05e8f1c 100644 --- a/handlers/DapActivateClientCommand.h +++ b/handlers/DapActivateClientCommand.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** This file is part of the libCellFrameDashboardClient library. +** This file is part of the libdap-qt-ui-chain-wallet library. ** ** The class implements the command to activate the GUI client. That is, ** by clicking on the icon in the system tray, the main window of the GUI diff --git a/handlers/DapAddWalletCommand.h b/handlers/DapAddWalletCommand.h index ea649f5..f76cc0d 100644 --- a/handlers/DapAddWalletCommand.h +++ b/handlers/DapAddWalletCommand.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** This file is part of the libCellFrameDashboardClient library. +** This file is part of the libdap-qt-ui-chain-wallet library. ** ** The class implements the functionality of creating a new wallet. ** diff --git a/handlers/DapGetListWalletsCommand.cpp b/handlers/DapGetListWalletsCommand.cpp index 82c11e9..9da645d 100644 --- a/handlers/DapGetListWalletsCommand.cpp +++ b/handlers/DapGetListWalletsCommand.cpp @@ -31,84 +31,7 @@ QVariant DapGetListWalletsCommand::respondToClient(const QVariant &arg1, const Q Q_UNUSED(arg9) Q_UNUSED(arg10) -// DapWallet wallet; -// wallet.setName("VASY"); -// wallet.setBalance(25.5); -// wallet.setIcon("/fsghdhjghjufkigl"); -// wallet.addNetwork("Kelvin-testnet"); -// wallet.addNetwork("Private"); -// wallet.addAddress("ar4th4t4j6tyj7utjk45u654kuj4kl6ui4l54k5lu5u4il5i34l35", "Kelvin-testnet"); -// wallet.addAddress("ar4th4t4j6tyj7utjk45u654kuj4kl6ui4l54k5lu5u4il5i34l35", "Private"); - -// DapWalletToken token1("KLV", &wallet); -// token1.setBalance(5.5); -// token1.setNetwork("Kelvin-testnet"); -// token1.setEmission(464645646546); -// DapWalletToken token2("CELL", &wallet); -// token2.setBalance(100); -// token2.setNetwork("Private"); -// token2.setEmission(121212121); -// wallet.addToken(&token1); -// wallet.addToken(&token2); - -// QByteArray datas; -// QDataStream out(&datas, QIODevice::WriteOnly); -// out << wallet; - -// qDebug() << "balance after:\t" << wallet.getBalance(); -// qDebug() << "icon after:\t" << wallet.getIcon(); -// qDebug() << "networks after:\t" << wallet.getNetworks(); -// qDebug() << "m_aAddresses after:\t" << wallet.getAddresses(); -// qDebug() << "m_aTokens after:\t" << wallet.getTokens(); - - -// DapWallet wallet2; -// QByteArray d (datas); -// QDataStream in(&d, QIODevice::ReadOnly); -// in >> wallet2; - -// qDebug() << endl; -// qDebug() << "name before:\t" << wallet2.getName(); -// qDebug() << "balance before:\t" << wallet2.getBalance(); -// qDebug() << "icon before:\t" << wallet2.getIcon(); -// qDebug() << "networks before:\t" << wallet2.getNetworks(); -// qDebug() << "m_aAddresses before:\t" << wallet2.getAddresses(); -// // qDebug() << "m_aTokens before:\t" << wallet2.m_aTokens; - -// foreach (auto w, wallet2.getTokens()) { -// qDebug() << static_cast<DapWalletToken*>(w)->getName() << endl; -// qDebug() << static_cast<DapWalletToken*>(w)->getBalance() << endl; -// qDebug() << static_cast<DapWalletToken*>(w)->getEmission() << endl; -// qDebug() << static_cast<DapWalletToken*>(w)->getNetwork() << endl; - -// } - - -// QJsonValue str = QJsonValue::fromVariant(datas.toHex()); - - - -// QByteArray b = QByteArray::fromHex(str.toVariant().toByteArray()); -// std::string s = datas.toStdString(); -// QString str = QString::fromStdString(s); - -// DapWallet w; -// QByteArray d; -// QDataStream in(&datas, QIODevice::ReadOnly); -// in>>w; - - QList<DapWallet> wallets; - - QStringList list; - QProcess processN; - processN.start(QString("%1 net list").arg(m_sCliPath)); - processN.waitForFinished(-1); - QString result = QString::fromLatin1(processN.readAll()); - result.remove(' '); - if(!(result.isEmpty() || result.isNull() || result.contains('\''))) - { - list = result.remove("\n").remove("\r").split(":").at(1).split(","); - } + QStringList wallets; QProcess process; process.start(QString("%1 wallet list").arg(m_sCliPath)); @@ -119,69 +42,8 @@ QVariant DapGetListWalletsCommand::respondToClient(const QVariant &arg1, const Q while (itr.hasNext()) { QRegularExpressionMatch match = itr.next(); - QString walletName = match.captured(1); - DapWallet wallet; - wallet.setName(walletName); - auto begin = list.begin(); - auto end = list.end(); - for(; begin != end; ++begin) - { - - wallet.addNetwork(*begin); - - QProcess process_token; - process_token.start(QString("%1 wallet info -w %2 -net %3") - .arg(m_sCliPath) - .arg(walletName) - .arg(*begin)); - - process_token.waitForFinished(-1); - QByteArray result_tokens = process_token.readAll(); - QRegExp regex("wallet: (.+)\\s+addr:\\s+(.+)\\s+(balance)|(\\d+.\\d+)\\s\\((\\d+)\\)\\s(\\w+)"); - - int pos = 0; - DapWalletToken *token {nullptr}; - while((pos = regex.indexIn(result_tokens, pos)) != -1) - { - - if(!regex.cap(2).isEmpty()) - { - wallet.addAddress(regex.cap(2), *begin); - } - else - { - token = new DapWalletToken(); - token->setName(regex.cap(6).trimmed()); - token->setBalance(regex.cap(4).toDouble()); - QString str = regex.cap(5); - token->setEmission(regex.cap(5).toULongLong()); - token->setNetwork(*begin); - wallet.addToken(token); - } - - pos += regex.matchedLength(); - } - - } - wallets.append(wallet); + wallets.append(match.captured(1)); } - QByteArray datas; - QDataStream out(&datas, QIODevice::WriteOnly); - out << wallets; - - return QJsonValue::fromVariant(datas.toHex()); -} - - -/// Reply from service. -/// @details Performed on the service side. -/// @return Service reply. -QVariant DapGetListWalletsCommand::replyFromService() -{ - DapRpcServiceReply *reply = static_cast<DapRpcServiceReply *>(sender()); - - emit serviceResponded(reply->response().toJsonValue().toVariant().toByteArray()); - - return reply->response().toJsonValue().toVariant(); + return wallets; } diff --git a/handlers/DapGetListWalletsCommand.h b/handlers/DapGetListWalletsCommand.h index 6d7c228..9805de4 100644 --- a/handlers/DapGetListWalletsCommand.h +++ b/handlers/DapGetListWalletsCommand.h @@ -5,9 +5,6 @@ #include <QRegExp> #include <QRegularExpression> #include <QByteArray> -#include <QDataStream> -#include <QBuffer> -#include <QTextCodec> #include "DapWallet.h" #include "DapAbstractCommand.h" @@ -32,7 +29,6 @@ public slots: const QVariant &arg5 = QVariant(), const QVariant &arg6 = QVariant(), const QVariant &arg7 = QVariant(), const QVariant &arg8 = QVariant(), const QVariant &arg9 = QVariant(), const QVariant &arg10 = QVariant()) override; - QVariant replyFromService() override; }; #endif // DAPGETLISTWALLETSCOMMAND_H diff --git a/handlers/DapGetWalletInfoCommand.cpp b/handlers/DapGetWalletInfoCommand.cpp new file mode 100644 index 0000000..689a0bc --- /dev/null +++ b/handlers/DapGetWalletInfoCommand.cpp @@ -0,0 +1,107 @@ +#include "DapGetWalletInfoCommand.h" + +/// Overloaded constructor. +/// @param asServiceName Service name. +/// @param parent Parent. +/// @details The parent must be either DapRPCSocket or DapRPCLocalServer. +/// @param asCliPath The path to cli nodes. +DapGetWalletInfoCommand::DapGetWalletInfoCommand(const QString &asServicename, QObject *parent, const QString &asCliPath) + : DapAbstractCommand(asServicename, parent, asCliPath) +{ + +} + +/// Send a response to the client. +/// @details Performed on the service side. +/// @param arg1...arg10 Parameters. +/// @return Reply to client. +QVariant DapGetWalletInfoCommand::respondToClient(const QVariant &arg1, const QVariant &arg2, const QVariant &arg3, + const QVariant &arg4, const QVariant &arg5, const QVariant &arg6, + const QVariant &arg7, const QVariant &arg8, const QVariant &arg9, + const QVariant &arg10) +{ + Q_UNUSED(arg1) + Q_UNUSED(arg2) + Q_UNUSED(arg3) + Q_UNUSED(arg4) + Q_UNUSED(arg5) + Q_UNUSED(arg6) + Q_UNUSED(arg7) + Q_UNUSED(arg8) + Q_UNUSED(arg9) + Q_UNUSED(arg10) + + QStringList list; + QProcess processGetNetworks; + processGetNetworks.start(QString("%1 net list").arg(m_sCliPath)); + processGetNetworks.waitForFinished(-1); + QString result = QString::fromLatin1(processGetNetworks.readAll()); + result.remove(' '); + if(!(result.isEmpty() || result.isNull() || result.contains('\''))) + { + list = result.remove("\n").remove("\r").split(":").at(1).split(","); + } + + DapWallet wallet; + wallet.setName(arg1.toString()); + auto begin = list.begin(); + auto end = list.end(); + for(; begin != end; ++begin) + { + + wallet.addNetwork(*begin); + + QProcess processGetTokkens; + processGetTokkens.start(QString("%1 wallet info -w %2 -net %3") + .arg(m_sCliPath) + .arg(wallet.getName()) + .arg(*begin)); + + processGetTokkens.waitForFinished(-1); + QByteArray result_tokens = processGetTokkens.readAll(); + QRegExp regex("wallet: (.+)\\s+addr:\\s+(.+)\\s+(balance)|(\\d+.\\d+)\\s\\((\\d+)\\)\\s(\\w+)"); + + int pos = 0; + DapWalletToken *token {nullptr}; + while((pos = regex.indexIn(result_tokens, pos)) != -1) + { + + if(!regex.cap(2).isEmpty()) + { + wallet.addAddress(regex.cap(2), *begin); + } + else + { + token = new DapWalletToken(); + token->setName(regex.cap(6).trimmed()); + token->setBalance(regex.cap(4).toDouble()); + QString str = regex.cap(5); + token->setEmission(regex.cap(5).toULongLong()); + token->setNetwork(*begin); + wallet.addToken(token); + } + + pos += regex.matchedLength(); + } + } + + QByteArray datas; + QDataStream out(&datas, QIODevice::WriteOnly); + out << wallet; + + return QJsonValue::fromVariant(datas.toHex()); +} + + +/// Reply from service. +/// @details Performed on the service side. +/// @return Service reply. +QVariant DapGetWalletInfoCommand::replyFromService() +{ + DapRpcServiceReply *reply = static_cast<DapRpcServiceReply *>(sender()); + + emit serviceResponded(reply->response().toJsonValue().toVariant().toByteArray()); + + return reply->response().toJsonValue().toVariant(); +} + diff --git a/handlers/DapGetWalletInfoCommand.h b/handlers/DapGetWalletInfoCommand.h new file mode 100644 index 0000000..d92f5a0 --- /dev/null +++ b/handlers/DapGetWalletInfoCommand.h @@ -0,0 +1,37 @@ +#ifndef DAPGETWALLETINFOCOMMAND_H +#define DAPGETWALLETINFOCOMMAND_H + +#include <QProcess> +#include <QRegExp> +#include <QRegularExpression> +#include <QByteArray> +#include <QDataStream> +#include <QBuffer> +#include <QTextCodec> + +#include "DapWallet.h" +#include "DapAbstractCommand.h" + +class DapGetWalletInfoCommand : public DapAbstractCommand +{ +public: + /// Overloaded constructor. + /// @param asServiceName Service name. + /// @param parent Parent. + /// @details The parent must be either DapRPCSocket or DapRPCLocalServer. + /// @param asCliPath The path to cli nodes. + DapGetWalletInfoCommand(const QString &asServicename, QObject *parent = nullptr, const QString &asCliPath = QString()); +public slots: + /// Send a response to the client. + /// @details Performed on the service side. + /// @param arg1...arg10 Parameters. + /// @return Reply to client. + QVariant respondToClient(const QVariant &arg1 = QVariant(), const QVariant &arg2 = QVariant(), + const QVariant &arg3 = QVariant(), const QVariant &arg4 = QVariant(), + const QVariant &arg5 = QVariant(), const QVariant &arg6 = QVariant(), + const QVariant &arg7 = QVariant(), const QVariant &arg8 = QVariant(), + const QVariant &arg9 = QVariant(), const QVariant &arg10 = QVariant()) override; + QVariant replyFromService() override; +}; + +#endif // DAPGETWALLETINFOCOMMAND_H diff --git a/handlers/DapGetWalletsInfoCommand.cpp b/handlers/DapGetWalletsInfoCommand.cpp new file mode 100644 index 0000000..5a8b9d0 --- /dev/null +++ b/handlers/DapGetWalletsInfoCommand.cpp @@ -0,0 +1,121 @@ +#include "DapGetWalletsInfoCommand.h" + +/// Overloaded constructor. +/// @param asServiceName Service name. +/// @param parent Parent. +/// @details The parent must be either DapRPCSocket or DapRPCLocalServer. +/// @param asCliPath The path to cli nodes. +DapGetWalletsInfoCommand::DapGetWalletsInfoCommand(const QString &asServicename, QObject *parent, const QString &asCliPath) + : DapAbstractCommand(asServicename, parent, asCliPath) +{ + +} + +/// Send a response to the client. +/// @details Performed on the service side. +/// @param arg1...arg10 Parameters. +/// @return Reply to client. +QVariant DapGetWalletsInfoCommand::respondToClient(const QVariant &arg1, const QVariant &arg2, const QVariant &arg3, + const QVariant &arg4, const QVariant &arg5, const QVariant &arg6, + const QVariant &arg7, const QVariant &arg8, const QVariant &arg9, + const QVariant &arg10) +{ + Q_UNUSED(arg1) + Q_UNUSED(arg2) + Q_UNUSED(arg3) + Q_UNUSED(arg4) + Q_UNUSED(arg5) + Q_UNUSED(arg6) + Q_UNUSED(arg7) + Q_UNUSED(arg8) + Q_UNUSED(arg9) + Q_UNUSED(arg10) + + QList<DapWallet> wallets; + + QStringList list; + QProcess processN; + processN.start(QString("%1 net list").arg(m_sCliPath)); + processN.waitForFinished(-1); + QString result = QString::fromLatin1(processN.readAll()); + result.remove(' '); + if(!(result.isEmpty() || result.isNull() || result.contains('\''))) + { + list = result.remove("\n").remove("\r").split(":").at(1).split(","); + } + + QProcess process; + process.start(QString("%1 wallet list").arg(m_sCliPath)); + process.waitForFinished(-1); + QString res = QString::fromLatin1(process.readAll()); + QRegularExpression rx("wallet:\\s(.+)\\s", QRegularExpression::MultilineOption); + QRegularExpressionMatchIterator itr = rx.globalMatch(res); + while (itr.hasNext()) + { + QRegularExpressionMatch match = itr.next(); + QString walletName = match.captured(1); + DapWallet wallet; + wallet.setName(walletName); + auto begin = list.begin(); + auto end = list.end(); + for(; begin != end; ++begin) + { + + wallet.addNetwork(*begin); + + QProcess process_token; + process_token.start(QString("%1 wallet info -w %2 -net %3") + .arg(m_sCliPath) + .arg(walletName) + .arg(*begin)); + + process_token.waitForFinished(-1); + QByteArray result_tokens = process_token.readAll(); + QRegExp regex("wallet: (.+)\\s+addr:\\s+(.+)\\s+(balance)|(\\d+.\\d+)\\s\\((\\d+)\\)\\s(\\w+)"); + + int pos = 0; + DapWalletToken *token {nullptr}; + while((pos = regex.indexIn(result_tokens, pos)) != -1) + { + + if(!regex.cap(2).isEmpty()) + { + wallet.addAddress(regex.cap(2), *begin); + } + else + { + token = new DapWalletToken(); + token->setName(regex.cap(6).trimmed()); + token->setBalance(regex.cap(4).toDouble()); + QString str = regex.cap(5); + token->setEmission(regex.cap(5).toULongLong()); + token->setNetwork(*begin); + wallet.addToken(token); + } + + pos += regex.matchedLength(); + } + + } + wallets.append(wallet); + } + + QByteArray datas; + QDataStream out(&datas, QIODevice::WriteOnly); + out << wallets; + + return QJsonValue::fromVariant(datas.toHex()); +} + + +/// Reply from service. +/// @details Performed on the service side. +/// @return Service reply. +QVariant DapGetWalletsInfoCommand::replyFromService() +{ + DapRpcServiceReply *reply = static_cast<DapRpcServiceReply *>(sender()); + + emit serviceResponded(reply->response().toJsonValue().toVariant().toByteArray()); + + return reply->response().toJsonValue().toVariant(); +} diff --git a/handlers/DapGetWalletsInfoCommand.h b/handlers/DapGetWalletsInfoCommand.h new file mode 100644 index 0000000..75cdd97 --- /dev/null +++ b/handlers/DapGetWalletsInfoCommand.h @@ -0,0 +1,38 @@ +#ifndef DAPGETWALLETSINFOCOMMAND_H +#define DAPGETWALLETSINFOCOMMAND_H + +#include <QProcess> +#include <QRegExp> +#include <QRegularExpression> +#include <QByteArray> +#include <QDataStream> +#include <QBuffer> +#include <QTextCodec> + +#include "DapWallet.h" +#include "DapAbstractCommand.h" + +class DapGetWalletsInfoCommand : public DapAbstractCommand +{ +public: + /// Overloaded constructor. + /// @param asServiceName Service name. + /// @param parent Parent. + /// @details The parent must be either DapRPCSocket or DapRPCLocalServer. + /// @param asCliPath The path to cli nodes. + DapGetWalletsInfoCommand(const QString &asServicename, QObject *parent = nullptr, const QString &asCliPath = QString()); + +public slots: + /// Send a response to the client. + /// @details Performed on the service side. + /// @param arg1...arg10 Parameters. + /// @return Reply to client. + QVariant respondToClient(const QVariant &arg1 = QVariant(), const QVariant &arg2 = QVariant(), + const QVariant &arg3 = QVariant(), const QVariant &arg4 = QVariant(), + const QVariant &arg5 = QVariant(), const QVariant &arg6 = QVariant(), + const QVariant &arg7 = QVariant(), const QVariant &arg8 = QVariant(), + const QVariant &arg9 = QVariant(), const QVariant &arg10 = QVariant()) override; + QVariant replyFromService() override; +}; + +#endif // DAPGETWALLETSINFOCOMMAND_H diff --git a/handlers/DapQuitApplicationCommand.h b/handlers/DapQuitApplicationCommand.h index c40ae93..3eaa3a8 100644 --- a/handlers/DapQuitApplicationCommand.h +++ b/handlers/DapQuitApplicationCommand.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** This file is part of the libCellFrameDashboardClient library. +** This file is part of the libdap-qt-ui-chain-wallet library. ** ** The class implements the exit command of the application. Both the ** GUI client and the service complete the work. diff --git a/libdap-qt-ui-chain-wallet.pri b/libdap-qt-ui-chain-wallet.pri index 47ae284..4c66816 100644 --- a/libdap-qt-ui-chain-wallet.pri +++ b/libdap-qt-ui-chain-wallet.pri @@ -30,8 +30,10 @@ HEADERS += \ $$PWD/handlers/DapGetHistoryExecutedCmdCommand.h \ $$PWD/handlers/DapGetListNetworksCommand.h \ $$PWD/handlers/DapGetListWalletsCommand.h \ + $$PWD/handlers/DapGetWalletsInfoCommand.h \ $$PWD/handlers/DapGetWalletAddressesCommand.h \ $$PWD/handlers/DapGetWalletHistoryCommand.h \ + $$PWD/handlers/DapGetWalletInfoCommand.h \ $$PWD/handlers/DapGetWalletTokenInfoCommand.h \ $$PWD/handlers/DapMempoolProcessCommand.h \ $$PWD/handlers/DapQuitApplicationCommand.h \ @@ -63,8 +65,10 @@ SOURCES += \ $$PWD/handlers/DapGetHistoryExecutedCmdCommand.cpp \ $$PWD/handlers/DapGetListNetworksCommand.cpp \ $$PWD/handlers/DapGetListWalletsCommand.cpp \ + $$PWD/handlers/DapGetWalletsInfoCommand.cpp \ $$PWD/handlers/DapGetWalletAddressesCommand.cpp \ $$PWD/handlers/DapGetWalletHistoryCommand.cpp \ + $$PWD/handlers/DapGetWalletInfoCommand.cpp \ $$PWD/handlers/DapGetWalletTokenInfoCommand.cpp \ $$PWD/handlers/DapMempoolProcessCommand.cpp \ $$PWD/handlers/DapQuitApplicationCommand.cpp \ diff --git a/libdap-qt-ui-chain-wallet.qrc b/libdap-qt-ui-chain-wallet.qrc index 5aee059..b2b9c41 100644 --- a/libdap-qt-ui-chain-wallet.qrc +++ b/libdap-qt-ui-chain-wallet.qrc @@ -14,5 +14,6 @@ <file>resources/fonts/roboto_regular.ttf</file> <file>resources/fonts/roboto_thin_italic.ttf</file> <file>resources/fonts/roboto_thin.ttf</file> + <file>resources/JS/TimeFunctions.js</file> </qresource> </RCC> diff --git a/resources/JS/TimeFunctions.js b/resources/JS/TimeFunctions.js new file mode 100644 index 0000000..6084d72 --- /dev/null +++ b/resources/JS/TimeFunctions.js @@ -0,0 +1,60 @@ +//Splits a string from the log. +function parceStringFromLog(string) +{ + var split = string.split(/ \[|\] \[|\]|\[/); + return split; +} + + +//This function converts the string representation of time to the Date format +function parceTime(thisTime) +{ + var aDate = thisTime.split('-'); + var aDay = aDate[0].split('/'); + var aTime = aDate[1].split(':'); + return new Date(20+aDay[2], aDay[0] - 1, aDay[1], aTime[0], aTime[1], aTime[2]); +} + + +//Returns the time in the correct form +function getTime(thisTime) +{ + var tmpTime = new Date(thisTime) + var thisHour = tmpTime.getHours(); + var thisMinute = tmpTime.getMinutes(); + var thisSecond = tmpTime.getSeconds(); + if(thisMinute < 10) thisMinute = '0' + thisMinute; + if(thisSecond < 10) thisSecond = '0' + thisSecond; + return thisHour + ':' + thisMinute + ':' + thisSecond; +} + + +//Returns the time in the correct form for the header +function getDay(thisTime, privateDate) +{ + var monthArray = ["January", "February", "March", "April", "May", "June", "July", "August", "September", + "October", "November", "December"]; + var tmpDate = new Date(thisTime); + var thisMonth = tmpDate.getMonth(); + var thisDay = tmpDate.getDate(); + var thisYear = tmpDate.getFullYear(); + + if(thisYear === privateDate.todayYear) + { + if(thisMonth === privateDate.todayMonth) + { + switch(thisDay) + { + case(privateDate.todayDay): return"Today"; + case(privateDate.todayDay-1): return"Yesterday"; + default: return monthArray[thisMonth] + ', ' + thisDay; + } + } + else + return monthArray[thisMonth] + ', ' + thisDay; + } + else + return monthArray[thisMonth] + ', ' + thisDay + ', ' + thisYear; +} + + -- GitLab From 71b2d5680a44d1001635568c914f1ac7765bceb0 Mon Sep 17 00:00:00 2001 From: "daragan.andrey@demlabs.net" <daragan.andrey@demlabs.net> Date: Wed, 18 Mar 2020 21:29:15 +0300 Subject: [PATCH 3/3] [*] Added the ability to use Russian characters in the name of the wallet. --- handlers/DapGetWalletsInfoCommand.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/handlers/DapGetWalletsInfoCommand.cpp b/handlers/DapGetWalletsInfoCommand.cpp index 5a8b9d0..2b548e7 100644 --- a/handlers/DapGetWalletsInfoCommand.cpp +++ b/handlers/DapGetWalletsInfoCommand.cpp @@ -47,7 +47,7 @@ QVariant DapGetWalletsInfoCommand::respondToClient(const QVariant &arg1, const Q QProcess process; process.start(QString("%1 wallet list").arg(m_sCliPath)); process.waitForFinished(-1); - QString res = QString::fromLatin1(process.readAll()); + QString res = QString::fromLocal8Bit(process.readAll()); QRegularExpression rx("wallet:\\s(.+)\\s", QRegularExpression::MultilineOption); QRegularExpressionMatchIterator itr = rx.globalMatch(res); while (itr.hasNext()) -- GitLab