From 8e4456b11b8ab9c8dd89bafb3464fbfcbe85a4ed Mon Sep 17 00:00:00 2001 From: "littletux89@gmail.com" <littletux89@gmail.com> Date: Mon, 3 Feb 2020 12:04:45 +0300 Subject: [PATCH] [+] New functionality added. --- .../CellFrameDashboardGUI.pro | 6 +- .../DapServiceController.cpp | 47 +++- CellFrameDashboardGUI/DapServiceController.h | 22 ++ CellFrameDashboardGUI/Factory.cpp | 38 --- CellFrameDashboardGUI/Factory.h | 18 -- CellFrameDashboardGUI/main.cpp | 3 - .../screen/DapMainApplicationWindow.qml | 74 ++++++ .../desktop/Dashboard/DapDashboardScreen.qml | 218 ++++++++++++++++ .../Dashboard/DapDashboardScreenForm.ui.qml | 243 +----------------- .../desktop/Dashboard/DapDashboardTab.qml | 68 +++-- .../Dashboard/DapDashboardTopPanel.qml | 42 --- .../Dashboard/DapDashboardTopPanelForm.ui.qml | 77 +----- .../RightPanel/DapDoneWalletRightPanel.qml | 8 + .../DapDoneWalletRightPanelForm.ui.qml | 5 + .../DapInputNewWalletNameRightPanel.qml | 31 +++ ...DapInputNewWalletNameRightPanelForm.ui.qml | 59 +++-- .../DapNewPaymentDoneRightPanel.qml | 10 +- .../DapNewPaymentDoneRightPanelForm.ui.qml | 3 + .../DapNewPaymentMainRightPanel.qml | 12 +- .../DapNewPaymentMainRightPanelForm.ui.qml | 33 ++- .../desktop/Settings/DapSettingsScreen.qml | 20 +- .../DapServiceController.cpp | 4 +- DapRPCProtocol/DapRpcService.cpp | 5 +- libCellFrameDashboardCommon/DapWallet.cpp | 58 +++-- libCellFrameDashboardCommon/DapWallet.h | 7 +- .../DapWalletToken.cpp | 19 +- .../Handlers/DapCreateTransactionCommand.cpp | 2 +- .../Handlers/DapGetListNetworksCommand.cpp | 12 +- .../Handlers/DapGetListNetworksCommand.h | 6 +- .../Handlers/DapGetListWalletsCommand.cpp | 228 ++++++++++------ .../Handlers/DapGetListWalletsCommand.h | 8 +- .../Handlers/DapGetWalletHistoryCommand.cpp | 55 ++++ .../Handlers/DapGetWalletHistoryCommand.h | 36 +++ .../libCellFrameDashboardCommon.pri | 2 + libdap-qt-ui-qml | 2 +- 35 files changed, 861 insertions(+), 620 deletions(-) delete mode 100644 CellFrameDashboardGUI/Factory.cpp delete mode 100644 CellFrameDashboardGUI/Factory.h create mode 100644 libCellFrameDashboardCommon/Handlers/DapGetWalletHistoryCommand.cpp create mode 100644 libCellFrameDashboardCommon/Handlers/DapGetWalletHistoryCommand.h diff --git a/CellFrameDashboardGUI/CellFrameDashboardGUI.pro b/CellFrameDashboardGUI/CellFrameDashboardGUI.pro index acf01a8..6027ab0 100755 --- a/CellFrameDashboardGUI/CellFrameDashboardGUI.pro +++ b/CellFrameDashboardGUI/CellFrameDashboardGUI.pro @@ -69,8 +69,7 @@ SOURCES += \ $$PWD/DapServiceClientNativeAbstract.cpp \ $$PWD/DapServiceClientNativeLinux.cpp \ $$PWD/DapServiceClientNativeWin.cpp \ - $$PWD/DapServiceClientNativeMacOS.cpp \ - $$PWD/Factory.cpp + $$PWD/DapServiceClientNativeMacOS.cpp RESOURCES += $$PWD/qml.qrc @@ -84,8 +83,7 @@ HEADERS += \ $$PWD/DapServiceController.h \ $$PWD/DapServiceClientNativeAbstract.h \ $$PWD/DapServiceClientNativeLinux.h \ - $$PWD/DapServiceClientNativeWin.h \ - $$PWD/Factory.h + $$PWD/DapServiceClientNativeWin.h include (../libdap/libdap.pri) include (../libdap-crypto/libdap-crypto.pri) diff --git a/CellFrameDashboardGUI/DapServiceController.cpp b/CellFrameDashboardGUI/DapServiceController.cpp index 287c699..5502b5a 100644 --- a/CellFrameDashboardGUI/DapServiceController.cpp +++ b/CellFrameDashboardGUI/DapServiceController.cpp @@ -33,6 +33,30 @@ QString DapServiceController::getVersion() const return m_sVersion; } +QString DapServiceController::getCurrentNetwork() const +{ + return m_sCurrentNetwork; +} + +void DapServiceController::setCurrentNetwork(const QString &sCurrentNetwork) +{ + m_sCurrentNetwork = sCurrentNetwork; + + emit currentNetworkChanged(m_sCurrentNetwork); +} + +int DapServiceController::getIndexCurrentNetwork() const +{ + return m_iIndexCurrentNetwork; +} + +void DapServiceController::setIndexCurrentNetwork(int iIndexCurrentNetwork) +{ + m_iIndexCurrentNetwork = iIndexCurrentNetwork; + + emit indexCurrentNetworkChanged(m_iIndexCurrentNetwork); +} + /// Get an instance of a class. /// @return Instance of a class. DapServiceController &DapServiceController::getInstance() @@ -98,6 +122,27 @@ void DapServiceController::registerCommand() // Transaction confirmation m_transceivers.append(qMakePair(dynamic_cast<DapAbstractCommand*>(m_DAPRpcSocket->addService(new DapMempoolProcessCommand("DapMempoolProcessCommand",m_DAPRpcSocket))), QString("mempoolProcessed"))); + connect(this, &DapServiceController::walletsListReceived, [=] (const QVariant& walletList) + { + QByteArray array = QByteArray::fromHex(walletList.toByteArray()); + QList<DapWallet> tempWallets; + + QDataStream in(&array, QIODevice::ReadOnly); + in >> tempWallets; + + QList<QObject*> wallets; + auto begin = tempWallets.begin(); + auto end = tempWallets.end(); + DapWallet * wallet = nullptr; + for(;begin != end; ++begin) + { + wallet = new DapWallet(*begin); + wallets.append(wallet); + } + + emit walletsReceived(wallets); + }); + registerEmmitedSignal(); } @@ -106,7 +151,7 @@ void DapServiceController::registerCommand() void DapServiceController::findEmittedSignal(const QVariant &aValue) { DapAbstractCommand * transceiver = dynamic_cast<DapAbstractCommand *>(sender()); - + disconnect(transceiver, SIGNAL(serviceResponded(QVariant)), this, SLOT(findEmittedSignal(QVariant))); Q_ASSERT(transceiver); auto service = std::find_if(m_transceivers.begin(), m_transceivers.end(), [=] (const QPair<DapAbstractCommand*, QString>& it) { diff --git a/CellFrameDashboardGUI/DapServiceController.h b/CellFrameDashboardGUI/DapServiceController.h index 5027091..93c7c97 100644 --- a/CellFrameDashboardGUI/DapServiceController.h +++ b/CellFrameDashboardGUI/DapServiceController.h @@ -33,6 +33,10 @@ class DapServiceController : public QObject QString m_sBrand {DAP_BRAND}; /// Application version. QString m_sVersion {DAP_VERSION}; + + QString m_sCurrentNetwork; + + int m_iIndexCurrentNetwork; /// Service connection management service. DapServiceClient *m_pDapServiceClient {nullptr}; /// Command manager. @@ -72,6 +76,10 @@ public: Q_PROPERTY(QString Brand MEMBER m_sBrand READ getBrand NOTIFY brandChanged) /// Application version. Q_PROPERTY(QString Version MEMBER m_sVersion READ getVersion NOTIFY versionChanged) + + Q_PROPERTY(QString CurrentNetwork MEMBER m_sVersion READ getCurrentNetwork WRITE setCurrentNetwork NOTIFY currentNetworkChanged) + + Q_PROPERTY(int IndexCurrentNetwork MEMBER m_iIndexCurrentNetwork READ getIndexCurrentNetwork WRITE setIndexCurrentNetwork NOTIFY indexCurrentNetworkChanged) /// Client controller initialization. /// @param apDapServiceClient Network connection controller. @@ -83,6 +91,14 @@ public: /// @return Application version. QString getVersion() const; + QString getCurrentNetwork() const; + + Q_INVOKABLE void setCurrentNetwork(const QString &sCurrentNetwork); + + int getIndexCurrentNetwork() const; + + Q_INVOKABLE void setIndexCurrentNetwork(int iIndexCurrentNetwork); + signals: /// The signal is emitted when the Brand company property changes. /// @param asBrand Brand @@ -90,6 +106,8 @@ signals: /// The signal is emitted when the Application version property changes. /// @param version Version void versionChanged(const QString &version); + + void currentNetworkChanged(const QString &asCurrentNetwork); /// The signal is emitted when a command to activate a client is received. void clientActivated(); ///This signal sends data about saving a file from the Logs tab @@ -109,11 +127,15 @@ signals: void walletsListReceived(const QVariant& walletList); + void walletsReceived(const QList<QObject*>& walletList); + void networksListReceived(const QVariant& networkList); void walletAddressesReceived(const QVariant& walletAddresses); void walletTokensReceived(const QVariant& walletTokens); + + void indexCurrentNetworkChanged(int iIndexCurrentNetwork); private slots: /// Register command. diff --git a/CellFrameDashboardGUI/Factory.cpp b/CellFrameDashboardGUI/Factory.cpp deleted file mode 100644 index 5a60f3d..0000000 --- a/CellFrameDashboardGUI/Factory.cpp +++ /dev/null @@ -1,38 +0,0 @@ -#include "Factory.h" - -Factory::Factory(QObject *parent) : QObject(parent) -{ - -} - -QObject *Factory::createStructure() -{ - DapWallet * wallet = new DapWallet(); - wallet->setName("MyWallet5"); - wallet->setBalance(1548745354574); - wallet->addNetwork("Kelvin-testnet"); - wallet->addNetwork("Private"); - wallet->addAddress("ar4th4t4j6tyj7utjk45u654kuj4kl6ui4l54k5lu5u4il5i34l35", "Kelvin-testnet"); - wallet->addAddress("ar4th4t4j6tyj7utjk45u654kuj4kl6ui4l54k5lu5u4il5i34l35", "Private"); - DapWalletToken * token1 = new DapWalletToken("KLV", wallet); - token1->setBalance(5.5); - token1->setNetwork("Kelvin-testnet"); - token1->setEmission(464645646546); - DapWalletToken * token3 = new DapWalletToken("NEW", wallet); - token3->setBalance(5); - token3->setNetwork("Kelvin-testnet"); - token3->setEmission(45465566987846); - DapWalletToken * token2 = new DapWalletToken("CELL", wallet); - token2->setBalance(100); - token2->setNetwork("Private"); - token2->setEmission(121212121); - DapWalletToken * token4 = new DapWalletToken("CRU", wallet); - token4->setBalance(1000); - token4->setNetwork("Private"); - token4->setEmission(121212121); - wallet->addToken(token1); - wallet->addToken(token2); - wallet->addToken(token3); - wallet->addToken(token4); - return wallet; -} diff --git a/CellFrameDashboardGUI/Factory.h b/CellFrameDashboardGUI/Factory.h deleted file mode 100644 index 3ac934b..0000000 --- a/CellFrameDashboardGUI/Factory.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef FACTORY_H -#define FACTORY_H - -#include <QObject> - -#include "DapWallet.h" - -class Factory : public QObject -{ - Q_OBJECT -public: - explicit Factory(QObject *parent = nullptr); - - Q_INVOKABLE QObject* createStructure(); // Ð”Ð»Ñ ÑÐ¾Ð·Ð´Ð°Ð½Ð¸Ñ Ñтруктур - -}; - -#endif // FACTORY_H diff --git a/CellFrameDashboardGUI/main.cpp b/CellFrameDashboardGUI/main.cpp index a4e8dff..c757d81 100644 --- a/CellFrameDashboardGUI/main.cpp +++ b/CellFrameDashboardGUI/main.cpp @@ -14,7 +14,6 @@ #include "DapLogger.h" #include "DapLogMessage.h" #include "DapWallet.h" -#include "Factory.h" #include <sys/stat.h> @@ -56,8 +55,6 @@ int main(int argc, char *argv[]) qRegisterMetaType<DapWallet>(); qRegisterMetaType<DapWalletToken>(); QQmlApplicationEngine engine; - Factory factory; - engine.rootContext()->setContextProperty("factory", &factory); engine.rootContext()->setContextProperty("dapServiceController", &DapServiceController::getInstance()); engine.rootContext()->setContextProperty("pt", 1); engine.load(QUrl("qrc:/main.qml")); diff --git a/CellFrameDashboardGUI/screen/DapMainApplicationWindow.qml b/CellFrameDashboardGUI/screen/DapMainApplicationWindow.qml index 73e879a..b17d786 100644 --- a/CellFrameDashboardGUI/screen/DapMainApplicationWindow.qml +++ b/CellFrameDashboardGUI/screen/DapMainApplicationWindow.qml @@ -2,6 +2,7 @@ import QtQuick 2.4 DapMainApplicationWindowForm { + id: dapMainWindow ///@detalis Path to the dashboard tab. readonly property string dashboardScreen: "qrc:/screen/" + device + "/Dashboard/DapDashboardTab.qml" ///@detalis Path to the exchange tab. @@ -15,8 +16,19 @@ DapMainApplicationWindowForm ///@detalis Path to the console tab. readonly property string consoleScreen: "qrc:/screen/" + device + "/Console/DapConsoleTab.qml" + property var dapWallets: [] + signal modelWalletsUpdated() + ListModel + { + id: dapNetworkModel + } + + ListModel + { + id: dapModelWallets + } // Menu bar tab model ListModel @@ -75,6 +87,68 @@ DapMainApplicationWindowForm { dapScreenLoader.setSource(Qt.resolvedUrl(dapMenuTabWidget.pathScreen)) } + + Component.onCompleted: + { + dapServiceController.requestToService("DapGetListNetworksCommand"); + dapServiceController.requestToService("DapGetListWalletsCommand"); + } + + Connections + { + target: dapServiceController + onNetworksListReceived: + { + for(var n=0; n < Object.keys(networkList).length; ++n) + { + dapServiceController.CurrentNetwork = networkList[0]; + dapServiceController.IndexCurrentNetwork = 0; + dapNetworkModel.append({name: networkList[n]}) + } + } + + onWalletsReceived: + { + console.log(walletList.length) + console.log(dapWallets.length) + console.log(dapModelWallets.count) + for (var q = 0; q < walletList.length; ++q) + { + dapWallets.push(walletList[q]) + } + for (var i = 0; i < dapWallets.length; ++i) + { + console.log(dapWallets[i].Name) + dapModelWallets.append({ "name" : dapWallets[i].Name, + "balance" : dapWallets[i].Balance, + "icon" : dapWallets[i].Icon, + "address" : dapWallets[i].Address, + "networks" : []}) + console.log(Object.keys(dapWallets[i].Networks).length) + for (var n = 0; n < Object.keys(dapWallets[i].Networks).length; ++n) + { + dapModelWallets.get(i).networks.append({"name": dapWallets[i].Networks[n], + "address": dapWallets[i].findAddress(dapWallets[i].Networks[n]), + "tokens": []}) + console.log(Object.keys(dapWallets[i].Tokens).length) + for (var t = 0; t < Object.keys(dapWallets[i].Tokens).length; ++t) + { + console.log(dapWallets[i].Tokens[t].Network + " === " + dapWallets[i].Networks[n]) + if(dapWallets[i].Tokens[t].Network === dapWallets[i].Networks[n]) + { + dapModelWallets.get(i).networks.get(n).tokens.append({"name": dapWallets[i].Tokens[t].Name, + "balance": dapWallets[i].Tokens[t].Balance, + "emission": dapWallets[i].Tokens[t].Emission, + "network": dapWallets[i].Tokens[t].Network}) + } + } + + } + + } + modelWalletsUpdated() + } + } } /*##^## Designer { diff --git a/CellFrameDashboardGUI/screen/desktop/Dashboard/DapDashboardScreen.qml b/CellFrameDashboardGUI/screen/desktop/Dashboard/DapDashboardScreen.qml index d38bc0e..35e2dc9 100644 --- a/CellFrameDashboardGUI/screen/desktop/Dashboard/DapDashboardScreen.qml +++ b/CellFrameDashboardGUI/screen/desktop/Dashboard/DapDashboardScreen.qml @@ -1,6 +1,224 @@ import QtQuick 2.4 +import QtQuick.Layouts 1.2 +import "qrc:/widgets" DapDashboardScreenForm { + Component + { + id: delegateTokenView + Column + { + width: parent.width + Rectangle + { + id: stockNameBlock + height: 30 * pt + width: parent.width + color: "#908D9D" + + Text + { + id: stockNameText + anchors.left: parent.left + anchors.leftMargin: 16 * pt + anchors.verticalCenter: parent.verticalCenter + font.pixelSize: 12 * pt + font.family: "Roboto" + font.styleName: "Normal" + font.weight: Font.Normal + color: "#FFFFFF" + verticalAlignment: Qt.AlignVCenter + text: name + } + } + + Row + { + id: networkAddressBlock + height: 40 * pt + width: parent.width + + Item + { + width: 16 * pt + height: parent.height + } + + Text + { + id: networkAddressLabel + anchors.verticalCenter: parent.verticalCenter + font.pixelSize: 12 * pt + font.family: "Roboto" + font.styleName: "Normal" + font.weight: Font.Normal + color: "#908D9D" + text: qsTr("Network address") + } + + Item + { + width: 36 * pt + height: parent.height + } + + DapText + { + id: textMetworkAddress + anchors.verticalCenter: parent.verticalCenter + width: 400 * pt + font.pixelSize: 10 * pt + font.family: "Roboto" + font.styleName: "Normal" + font.weight: Font.Normal + color: "#908D9D" + text: address + elide: Text.ElideRight + } + + + + MouseArea + { + id: networkAddressCopyButton + anchors.verticalCenter: parent.verticalCenter + width: 20 * pt + height: 20 * pt + hoverEnabled: true + + onClicked: textMetworkAddress.copy() + + + Image + { + id: networkAddressCopyButtonImage + anchors.fill: parent + source: parent.containsMouse ? "qrc:/res/icons/ic_copy_hover.png" : "qrc:/res/icons/ic_copy.png" + sourceSize.width: width + sourceSize.height: height + + } + } + } + + Repeater + { + width: parent.width + model: tokens + + Rectangle + { + anchors.left: parent.left + anchors.leftMargin: 16 * pt + anchors.right: parent.right + anchors.rightMargin: 16 * pt + height: 56 * pt + + Rectangle + { + anchors.top: parent.top + width: parent.width + height: 1 * pt + color: "#908D9D" + } + + RowLayout + { + anchors.fill: parent + + Image + { + id: currencyIcon + height: 40 * pt + width: 40 * pt + Layout.alignment: Qt.AlignLeft +// source: (type === "bitCoin") ? bitCoinImagePath : (type === "ether") ? ethereumImagePath : newGoldImagePath // Don't know how to deal with it yet + sourceSize.width: width + sourceSize.height: height + } + + Item + { + height: parent.height + width: 10 * pt + Layout.alignment: Qt.AlignLeft + } + + Text + { + id: currencyName + Layout.alignment: Qt.AlignLeft + font.pixelSize: 18 * pt + font.family: "Roboto" + font.styleName: "Normal" + font.weight: Font.Normal + color: "#070023" + text: name + } + // Delimiters - see design + Item + { + height: parent.height + width: 16 * pt + } + + + Item + { + Layout.fillWidth: true + } + + + Item + { + height: parent.height + width: 16 * pt + } + + Text + { + id: currencySum + Layout.alignment: Qt.AlignLeft + font.pixelSize: 12 * pt + font.family: "Roboto" + font.styleName: "Normal" + font.weight: Font.Normal + color: "#070023" + text: balance + } + + Text + { + id: currencyCode + font.pixelSize: 12 * pt + font.family: "Roboto" + font.styleName: "Normal" + font.weight: Font.Normal + color: "#070023" + text: name + } + + Item + { + Layout.fillWidth: true + } + + Text + { + id: currencyDollarEqv + Layout.alignment: Qt.AlignRight + font.pixelSize: 12 * pt + font.family: "Roboto" + font.styleName: "Normal" + font.weight: Font.Normal + color: "#070023" + text: "$" + emission + " USD" + } + } + } + } + } + } } diff --git a/CellFrameDashboardGUI/screen/desktop/Dashboard/DapDashboardScreenForm.ui.qml b/CellFrameDashboardGUI/screen/desktop/Dashboard/DapDashboardScreenForm.ui.qml index f3ffbb4..11a8cce 100644 --- a/CellFrameDashboardGUI/screen/desktop/Dashboard/DapDashboardScreenForm.ui.qml +++ b/CellFrameDashboardGUI/screen/desktop/Dashboard/DapDashboardScreenForm.ui.qml @@ -20,7 +20,7 @@ DapAbstractScreen ///@param dapButtonNewPayment Button to create a new payment. property alias dapButtonNewPayment: buttonNewPayment - property alias dapListViewWallets: listViewWallets + property alias dapListViewWallet: listViewWallet Rectangle { @@ -91,7 +91,7 @@ DapAbstractScreen ListView { - id: listViewWallets + id: listViewWallet anchors.top: titleBlock.bottom anchors.topMargin: 20 * pt anchors.bottom: parent.bottom @@ -99,243 +99,6 @@ DapAbstractScreen spacing: 5 * pt clip: true -// ListModel -// { -// ListElement -// { -// name: "Kelvin Testnet" -// address: "KLJHuhlkjshfausdh7865lksfahHKLUIHKJFHKLUESAHFILKUHEWKUAFHjkhfdkslusfkhgs" -// money: [ -// ListElement -// { -// type: "bitCoin" -// sum: 3487256 -// eq: "$ 3498750" -// }, -// ListElement -// { -// type: "ether" -// sum: 67896 -// eq: "$ 78687" -// }, -// ListElement -// { -// type: "newGold" -// sum: 675573 -// eq: "$ 987978" -// } -// ] -// } -// } - - delegate: - Column - { - width: parent.width - - Rectangle - { - id: stockNameBlock - height: 30 * pt - width: parent.width - color: "#908D9D" - - Text - { - id: stockNameText - anchors.left: parent.left - anchors.leftMargin: 16 * pt - anchors.verticalCenter: parent.verticalCenter - font.pixelSize: 12 * pt - font.family: "Roboto" - font.styleName: "Normal" - font.weight: Font.Normal - color: "#FFFFFF" - verticalAlignment: Qt.AlignVCenter - text: name - } - } - - Row - { - id: networkAddressBlock - height: 40 * pt - width: parent.width - - Item - { - width: 16 * pt - height: parent.height - } - - Text - { - id: networkAddressLabel - anchors.verticalCenter: parent.verticalCenter - font.pixelSize: 12 * pt - font.family: "Roboto" - font.styleName: "Normal" - font.weight: Font.Normal - color: "#908D9D" - text: qsTr("Network address") - } - - Item - { - width: 36 * pt - height: parent.height - } - - Text - { - id: networkAddressValue - anchors.verticalCenter: parent.verticalCenter - width: 200 * pt - font.pixelSize: 12 * pt - font.family: "Roboto" - font.styleName: "Normal" - font.weight: Font.Normal - color: "#908D9D" - text: address - elide: Text.ElideRight - } - - MouseArea - { - id: networkAddressCopyButton - anchors.verticalCenter: parent.verticalCenter - width: 20 * pt - height: 20 * pt - hoverEnabled: true - - Image - { - id: networkAddressCopyButtonImage - anchors.fill: parent - source: parent.containsMouse ? "qrc:/res/icons/ic_copy_hover.png" : "qrc:/res/icons/ic_copy.png" - sourceSize.width: width - sourceSize.height: height - - } - } - } - - Repeater - { - width: parent.width - model: tokens - - Rectangle - { - anchors.left: parent.left - anchors.leftMargin: 16 * pt - anchors.right: parent.right - anchors.rightMargin: 16 * pt - height: 56 * pt - - Rectangle - { - anchors.top: parent.top - width: parent.width - height: 1 * pt - color: "#908D9D" - } - - RowLayout - { - anchors.fill: parent - - Image - { - id: currencyIcon - height: 40 * pt - width: 40 * pt - Layout.alignment: Qt.AlignLeft - source: (type === "bitCoin") ? bitCoinImagePath : (type === "ether") ? ethereumImagePath : newGoldImagePath // Don't know how to deal with it yet - sourceSize.width: width - sourceSize.height: height - } - - Item - { - height: parent.height - width: 10 * pt - Layout.alignment: Qt.AlignLeft - } - - Text - { - id: currencyName - Layout.alignment: Qt.AlignLeft - font.pixelSize: 18 * pt - font.family: "Roboto" - font.styleName: "Normal" - font.weight: Font.Normal - color: "#070023" - text: name - } - // Delimiters - see design - Item - { - height: parent.height - width: 16 * pt - } - - - Item - { - Layout.fillWidth: true - } - - - Item - { - height: parent.height - width: 16 * pt - } - - Text - { - id: currencySum - Layout.alignment: Qt.AlignHCenter - font.pixelSize: 18 * pt - font.family: "Roboto" - font.styleName: "Normal" - font.weight: Font.Normal - color: "#070023" - text: balance - } - - Text - { - id: currencyCode - font.pixelSize: 18 * pt - font.family: "Roboto" - font.styleName: "Normal" - font.weight: Font.Normal - color: "#070023" - text: (type === "bitCoin") ? "BTC" : (type === "ether") ? "ETH" : (type === "newGold") ? "NGD" : "KLVN" - } - - Item - { - Layout.fillWidth: true - } - - Text - { - id: currencyDollarEqv - Layout.alignment: Qt.AlignRight - font.pixelSize: 18 * pt - font.family: "Roboto" - font.styleName: "Normal" - font.weight: Font.Normal - color: "#070023" - text: emission - } - } - } - } - } + delegate: delegateTokenView } } diff --git a/CellFrameDashboardGUI/screen/desktop/Dashboard/DapDashboardTab.qml b/CellFrameDashboardGUI/screen/desktop/Dashboard/DapDashboardTab.qml index 2099b80..e395398 100644 --- a/CellFrameDashboardGUI/screen/desktop/Dashboard/DapDashboardTab.qml +++ b/CellFrameDashboardGUI/screen/desktop/Dashboard/DapDashboardTab.qml @@ -19,19 +19,15 @@ DapDashboardTabForm ///@detalis Path to the right panel of new payment done. readonly property string newPaymentDone: "qrc:/screen/" + device + "/Dashboard/RightPanel/DapNewPaymentDoneRightPanel.qml" - dapDashboardTopPanel.dapComboboxWallet.onCurrentIndexChanged: - { - dapDashboardScreen.dapListViewWallets.model = modelWallets.get(dapDashboardTopPanel.dapComboboxWallet.currentIndex).networks - } - + // Setting the right pane by default + dapDashboardRightPanel.initialItem: Qt.resolvedUrl(lastActionsWallet); + property int dapIndexCurrentWallet: -1 - ListModel + dapDashboardTopPanel.dapComboboxWallet.onCurrentIndexChanged: { - id: modelWallets + dapDashboardScreen.dapListViewWallet.model = dapModelWallets.get(dapDashboardTopPanel.dapComboboxWallet.currentIndex).networks } - // Setting the right pane by default - dapDashboardRightPanel.initialItem: Qt.resolvedUrl(lastActionsWallet); // Signal-slot connection realizing panel switching depending on predefined rules Connections @@ -41,20 +37,58 @@ DapDashboardTabForm { currentRightPanel = dapDashboardRightPanel.push(currentRightPanel.dapNextRightPanel); } + onPreviousActivated: + { + currentRightPanel = dapDashboardRightPanel.push(currentRightPanel.dapPreviousRightPanel); + } } + Connections + { + target: dapMainWindow + onModelWalletsUpdated: + { + console.log(dapIndexCurrentWallet) + dapDashboardTopPanel.dapComboboxWallet.currentIndex = dapIndexCurrentWallet + } + } + Connections + { + target: dapServiceController + onMempoolProcessed: + { + update() + } + onWalletCreated: + { + if(wallet[0]) + { + update() + } + } + } + + dapDashboardTopPanel.dapAddWalletButton.onClicked: + { + currentRightPanel = dapDashboardRightPanel.push({item:Qt.resolvedUrl(inputNameWallet)}); + } // When you click on the button for creating a new payment, open the form to fill in the payment data dapDashboardScreen.dapButtonNewPayment.onClicked: { - if(dapDashboardRightPanel.currentItem !== currentRightPanel) - { - currentRightPanel = dapDashboardRightPanel.push({item:Qt.resolvedUrl(newPaymentMain), - properties: {dapCmboBoxToken: modelWallets.get(dapDashboardTopPanel.dapComboboxWallet.currentIndex).networks}}); - dapDashboardTopPanel.dapComboboxNetwork = mT -// console.log(dapDashboardTopPanel.dapComboboxWallet.currentIndex) -// console.log(modelWallets.get(dapDashboardTopPanel.dapComboboxWallet.currentIndex).networks) - } + currentRightPanel = dapDashboardRightPanel.push({item:Qt.resolvedUrl(newPaymentMain), + properties: {dapCmboBoxTokenModel: dapModelWallets.get(dapDashboardTopPanel.dapComboboxWallet.currentIndex).networks, + dapCurrentWallet: dapDashboardTopPanel.dapComboboxWallet.currentText, + dapCmboBoxTokenModel: dapModelWallets.get(dapDashboardTopPanel.dapComboboxWallet.currentIndex).networks.get(dapServiceController.IndexCurrentNetwork).tokens, + dapTextSenderWalletAddress: dapWallets[dapDashboardTopPanel.dapComboboxWallet.currentIndex].findAddress(dapServiceController.CurrentNetwork)}}); + } + + function update() + { + dapIndexCurrentWallet = dapDashboardTopPanel.dapComboboxWallet.currentIndex + dapWallets.length = 0 + dapModelWallets.clear() + dapServiceController.requestToService("DapGetListWalletsCommand"); } } diff --git a/CellFrameDashboardGUI/screen/desktop/Dashboard/DapDashboardTopPanel.qml b/CellFrameDashboardGUI/screen/desktop/Dashboard/DapDashboardTopPanel.qml index f7b86be..eda858d 100644 --- a/CellFrameDashboardGUI/screen/desktop/Dashboard/DapDashboardTopPanel.qml +++ b/CellFrameDashboardGUI/screen/desktop/Dashboard/DapDashboardTopPanel.qml @@ -3,10 +3,6 @@ import Demlabs 1.0 DapDashboardTopPanelForm { - - property var objectsArray: [] - - Connections { target: dapServiceController @@ -17,43 +13,5 @@ DapDashboardTopPanelForm else console.log(wallet[1]) } - onWalletsListReceived: - { - objectsArray.push(factory.createStructure()) - for (var i = 0; i < objectsArray.length; ++i) - { - modelWallets.append({ "name" : objectsArray[i].Name, - "balance" : objectsArray[i].Balance, - "icon" : objectsArray[i].Icon, - "address" : objectsArray[i].Address, - "networks" : []}) - for (var n = 0; n < Object.keys(objectsArray[i].Networks).length; ++n) - { - modelWallets.get(i).networks.append({"name": objectsArray[i].Networks[n], - "address": objectsArray[i].findAddress(objectsArray[i].Networks[n]), - "tokens": []}) -// console.log(Object.keys(objectsArray[i].Tokens).length) - for (var t = 0; t < Object.keys(objectsArray[i].Tokens).length; ++t) - { - console.log(objectsArray[i].Tokens[t].Network + " === " + objectsArray[i].Networks[n]) - if(objectsArray[i].Tokens[t].Network === objectsArray[i].Networks[n]) - { - modelWallets.get(i).networks.get(n).tokens.append({"name": objectsArray[i].Tokens[t].Name, - "balance": objectsArray[i].Tokens[t].Balance, - "emission": objectsArray[i].Tokens[t].Emission, - "network": objectsArray[i].Tokens[t].Network}) - } - } - - } - - } - } - } - - dapAddWalletButton.onClicked: - { -// dapServiceController.requestToService("DapAddWalletCommand", "MYNEWWALLET5", "sig_dil", "kelvin-testnet", "0xad12dec5ab4f"); - dapServiceController.requestToService("DapGetListWalletsCommand", "kelvin-testnet"); } } diff --git a/CellFrameDashboardGUI/screen/desktop/Dashboard/DapDashboardTopPanelForm.ui.qml b/CellFrameDashboardGUI/screen/desktop/Dashboard/DapDashboardTopPanelForm.ui.qml index 9fb4fa4..1536800 100644 --- a/CellFrameDashboardGUI/screen/desktop/Dashboard/DapDashboardTopPanelForm.ui.qml +++ b/CellFrameDashboardGUI/screen/desktop/Dashboard/DapDashboardTopPanelForm.ui.qml @@ -7,7 +7,7 @@ DapAbstractTopPanel { property alias dapAddWalletButton: addWalletButton property alias dapComboboxWallet: comboboxWallet - property alias dapComboboxNetwork: comboboxWalletNetwork.model + anchors.fill: parent // Static text "Wallet" @@ -18,7 +18,7 @@ DapAbstractTopPanel anchors.left: parent.left anchors.leftMargin: 24 * pt anchors.verticalCenter: parent.verticalCenter - font.family: DapMainApplicationWindow.dapFontRobotoRegular.name + font.family: dapFontRobotoRegular.name font.pixelSize: 12 * pt color: "#ACAAB5" } @@ -37,71 +37,8 @@ DapAbstractTopPanel DapComboBox { id: comboboxWallet - model: modelWallets - textRole: "name" - mainLineText: "all wallets" - indicatorImageNormal: "qrc:/res/icons/ic_arrow_drop_down.png" - indicatorImageActive: "qrc:/res/icons/ic_arrow_drop_up.png" - sidePaddingNormal: 0 * pt - sidePaddingActive: 16 * pt - normalColorText: "#070023" - hilightColorText: "#FFFFFF" - normalColorTopText: "#FFFFFF" - hilightColorTopText: "#070023" - hilightColor: "#330F54" - normalTopColor: "#070023" - widthPopupComboBoxNormal: 148 * pt - widthPopupComboBoxActive: 180 * pt - heightComboBoxNormal: 24 * pt - heightComboBoxActive: 44 * pt - bottomIntervalListElement: 8 * pt - topEffect: false - x: popup.visible ? sidePaddingActive * (-1) : sidePaddingNormal - normalColor: "#FFFFFF" - hilightTopColor: normalColor - paddingTopItemDelegate: 8 * pt - heightListElement: 32 * pt - intervalListElement: 10 * pt - indicatorWidth: 24 * pt - indicatorHeight: indicatorWidth - indicatorLeftInterval: 8 * pt - colorTopNormalDropShadow: "#00000000" - colorDropShadow: "#40ABABAB" - fontComboBox.pixelSize: 14 * pt - fontComboBox.family: "Roboto" - } - } - - Rectangle - { - id: frameComboBoxNetwork - - anchors.left: frameComboBoxWallet.right - anchors.verticalCenter: parent.verticalCenter - anchors.leftMargin: 30 * pt - width: 148 * pt - color: "transparent" - - ListModel - { - id: mT - ListElement - { - name: "Pr" - val: 1 - } - ListElement - { - name: "Kl" - val: 2 - } - } - - DapComboBox - { - id: comboboxWalletNetwork - model: mT - textRole: "name" + model: dapModelWallets + comboBoxTextRole: "name" mainLineText: "all wallets" indicatorImageNormal: "qrc:/res/icons/ic_arrow_drop_down.png" indicatorImageActive: "qrc:/res/icons/ic_arrow_drop_up.png" @@ -140,10 +77,10 @@ DapAbstractTopPanel { id: headerWalletBalance text: qsTr("Wallet balance") - anchors.left: frameComboBoxNetwork.right + anchors.left: frameComboBoxWallet.right anchors.leftMargin: 70 * pt anchors.verticalCenter: parent.verticalCenter - font.family: DapMainApplicationWindow.dapFontRobotoRegular.name + font.family: dapFontRobotoRegular.name font.pixelSize: 12 * pt color: "#ACAAB5" } @@ -156,7 +93,7 @@ DapAbstractTopPanel anchors.left: headerWalletBalance.right anchors.leftMargin: 18 * pt anchors.verticalCenter: parent.verticalCenter - font.family: DapMainApplicationWindow.dapFontRobotoRegular.name + font.family: dapFontRobotoRegular.name font.pixelSize: 16 * pt color: "#FFFFFF" } diff --git a/CellFrameDashboardGUI/screen/desktop/Dashboard/RightPanel/DapDoneWalletRightPanel.qml b/CellFrameDashboardGUI/screen/desktop/Dashboard/RightPanel/DapDoneWalletRightPanel.qml index 01b96ef..36ae060 100644 --- a/CellFrameDashboardGUI/screen/desktop/Dashboard/RightPanel/DapDoneWalletRightPanel.qml +++ b/CellFrameDashboardGUI/screen/desktop/Dashboard/RightPanel/DapDoneWalletRightPanel.qml @@ -2,5 +2,13 @@ import QtQuick 2.4 DapDoneWalletRightPanelForm { + dapButtonDone.onClicked: + { + nextActivated(lastActionsWallet) + } + dapButtonClose.onClicked: + { + previousActivated(lastActionsWallet) + } } diff --git a/CellFrameDashboardGUI/screen/desktop/Dashboard/RightPanel/DapDoneWalletRightPanelForm.ui.qml b/CellFrameDashboardGUI/screen/desktop/Dashboard/RightPanel/DapDoneWalletRightPanelForm.ui.qml index 0cb2560..7bc5a82 100644 --- a/CellFrameDashboardGUI/screen/desktop/Dashboard/RightPanel/DapDoneWalletRightPanelForm.ui.qml +++ b/CellFrameDashboardGUI/screen/desktop/Dashboard/RightPanel/DapDoneWalletRightPanelForm.ui.qml @@ -4,6 +4,11 @@ import "../../../" DapAbstractRightPanel { + dapNextRightPanel: lastActionsWallet + dapPreviousRightPanel: lastActionsWallet + + property alias dapButtonDone: buttonDone + dapButtonClose.height: 16 * pt dapButtonClose.width: 16 * pt dapButtonClose.heightImageButton: 16 * pt diff --git a/CellFrameDashboardGUI/screen/desktop/Dashboard/RightPanel/DapInputNewWalletNameRightPanel.qml b/CellFrameDashboardGUI/screen/desktop/Dashboard/RightPanel/DapInputNewWalletNameRightPanel.qml index 518af91..c09c1ca 100644 --- a/CellFrameDashboardGUI/screen/desktop/Dashboard/RightPanel/DapInputNewWalletNameRightPanel.qml +++ b/CellFrameDashboardGUI/screen/desktop/Dashboard/RightPanel/DapInputNewWalletNameRightPanel.qml @@ -2,5 +2,36 @@ import QtQuick 2.4 DapInputNewWalletNameRightPanelForm { + property string dapSignatureTypeWallet + + dapComboBoxSignatureTypeWallet.onCurrentIndexChanged: + { + dapSignatureTypeWallet = dapSignatureTypeWalletModel.get(dapComboBoxSignatureTypeWallet.currentIndex).sign + } + + dapButtonNext.onClicked: + { + console.log(dapTextInputNameWallet.text) + console.log(dapSignatureTypeWallet) + console.log(dapServiceController.CurrentNetwork) + dapServiceController.requestToService("DapAddWalletCommand", dapTextInputNameWallet.text, dapSignatureTypeWallet, dapServiceController.CurrentNetwork, "0xad12dec5ab4f"); + } + + dapButtonClose.onClicked: + { + previousActivated(lastActionsWallet) + } + + Connections + { + target: dapServiceController + onWalletCreated: + { + if(wallet[0]) + { + nextActivated("doneWallet") + } + } + } } diff --git a/CellFrameDashboardGUI/screen/desktop/Dashboard/RightPanel/DapInputNewWalletNameRightPanelForm.ui.qml b/CellFrameDashboardGUI/screen/desktop/Dashboard/RightPanel/DapInputNewWalletNameRightPanelForm.ui.qml index c691075..4a9ab6d 100644 --- a/CellFrameDashboardGUI/screen/desktop/Dashboard/RightPanel/DapInputNewWalletNameRightPanelForm.ui.qml +++ b/CellFrameDashboardGUI/screen/desktop/Dashboard/RightPanel/DapInputNewWalletNameRightPanelForm.ui.qml @@ -7,6 +7,39 @@ import "../../../" DapAbstractRightPanel { + property alias dapTextInputNameWallet: textInputNameWallet + property alias dapComboBoxSignatureTypeWallet: comboBoxSignatureTypeWallet + property alias dapButtonNext: buttonNext + property alias dapSignatureTypeWalletModel: signatureTypeWallet + + dapNextRightPanel: doneWallet + dapPreviousRightPanel: lastActionsWallet + + ListModel + { + id: signatureTypeWallet + ListElement + { + name: "Dilithium" + sign: "sig_dil" + } + ListElement + { + name: "Bliss" + sign: "sig_bliss" + } + ListElement + { + name: "Picnic" + sign: " sig_picnic" + } + ListElement + { + name: "Tesla" + sign: " sig_tesla" + } + } + dapHeaderData: Row { @@ -140,29 +173,9 @@ DapAbstractRightPanel anchors.rightMargin: 16 * pt DapComboBox { - property Label fieldBalance: Label {} - - model: - ListModel - { - id: signatureType - ListElement - { - signatureName: "Dilithium" - } - ListElement - { - signatureName: "Bliss" - } - ListElement - { - signatureName: "Picnic" - } - ListElement - { - signatureName: "Tesla" - } - } + id: comboBoxSignatureTypeWallet + model: signatureTypeWallet + comboBoxTextRole: "name" anchors.left: parent.left anchors.right: parent.right anchors.leftMargin: 20 * pt diff --git a/CellFrameDashboardGUI/screen/desktop/Dashboard/RightPanel/DapNewPaymentDoneRightPanel.qml b/CellFrameDashboardGUI/screen/desktop/Dashboard/RightPanel/DapNewPaymentDoneRightPanel.qml index 1f044c2..c1d9524 100644 --- a/CellFrameDashboardGUI/screen/desktop/Dashboard/RightPanel/DapNewPaymentDoneRightPanel.qml +++ b/CellFrameDashboardGUI/screen/desktop/Dashboard/RightPanel/DapNewPaymentDoneRightPanel.qml @@ -4,6 +4,14 @@ DapNewPaymentDoneRightPanelForm { dapButtonSend.onClicked: { - dapServiceController.requestToService("DapMempoolProcessCommand", "private", "gdb") + var chain = dapServiceController.CurrentNetwork === "private" ? "gdb": "plasma" + dapServiceController.requestToService("DapMempoolProcessCommand", dapServiceController.CurrentNetwork, chain) + + nextActivated("transaction done") + } + + dapButtonClose.onClicked: + { + previousActivated(lastActionsWallet) } } diff --git a/CellFrameDashboardGUI/screen/desktop/Dashboard/RightPanel/DapNewPaymentDoneRightPanelForm.ui.qml b/CellFrameDashboardGUI/screen/desktop/Dashboard/RightPanel/DapNewPaymentDoneRightPanelForm.ui.qml index 3330f13..5d2319e 100644 --- a/CellFrameDashboardGUI/screen/desktop/Dashboard/RightPanel/DapNewPaymentDoneRightPanelForm.ui.qml +++ b/CellFrameDashboardGUI/screen/desktop/Dashboard/RightPanel/DapNewPaymentDoneRightPanelForm.ui.qml @@ -9,6 +9,9 @@ DapAbstractRightPanel /// @param dapButtonSend Send button. property alias dapButtonSend: buttonSend + dapNextRightPanel: lastActionsWallet + dapPreviousRightPanel: lastActionsWallet + dapHeaderData: Row { diff --git a/CellFrameDashboardGUI/screen/desktop/Dashboard/RightPanel/DapNewPaymentMainRightPanel.qml b/CellFrameDashboardGUI/screen/desktop/Dashboard/RightPanel/DapNewPaymentMainRightPanel.qml index 7e49160..4ee51ff 100644 --- a/CellFrameDashboardGUI/screen/desktop/Dashboard/RightPanel/DapNewPaymentMainRightPanel.qml +++ b/CellFrameDashboardGUI/screen/desktop/Dashboard/RightPanel/DapNewPaymentMainRightPanel.qml @@ -4,10 +4,18 @@ DapNewPaymentMainRightPanelForm { // The form displayed after clicking on the "Send" button dapNextRightPanel: newPaymentDone + dapPreviousRightPanel: lastActionsWallet + + dapButtonClose.onClicked: + { + previousActivated(lastActionsWallet) + } dapButtonSend.onClicked: { - nextActivated() - dapServiceController.requestToService("DapCreateTransactionCommand", "private", "gdb", "MyWallet", dapTextInputRecipientWalletAddress.text, dapCmboBoxToken.currentText, dapTextInputAmountPayment.text) + var chain = dapServiceController.CurrentNetwork === "private" ? "gdb": "plasma" + dapServiceController.requestToService("DapCreateTransactionCommand", dapServiceController.CurrentNetwork, chain, dapCurrentWallet, dapTextInputRecipientWalletAddress.text, dapCmboBoxToken.currentText, dapTextInputAmountPayment.text) + + nextActivated("transaction created") } } diff --git a/CellFrameDashboardGUI/screen/desktop/Dashboard/RightPanel/DapNewPaymentMainRightPanelForm.ui.qml b/CellFrameDashboardGUI/screen/desktop/Dashboard/RightPanel/DapNewPaymentMainRightPanelForm.ui.qml index 38b6ce2..6956bea 100644 --- a/CellFrameDashboardGUI/screen/desktop/Dashboard/RightPanel/DapNewPaymentMainRightPanelForm.ui.qml +++ b/CellFrameDashboardGUI/screen/desktop/Dashboard/RightPanel/DapNewPaymentMainRightPanelForm.ui.qml @@ -10,8 +10,15 @@ DapAbstractRightPanel property alias dapButtonSend: buttonSend /// @param dapTextInputAmountPayment Input field for transfer amount. property alias dapTextInputAmountPayment: textInputAmountPayment - /// @param dapCmboBoxToken Token combobox. - property alias dapCmboBoxToken: comboBoxToken.model + /// @param dapCmboBoxTokenModel Token combobox model. + property alias dapCmboBoxTokenModel: comboboxToken.model + + property alias dapCmboBoxToken: comboboxToken + + + property string dapCurrentWallet + + property alias dapTextSenderWalletAddress: textSenderWalletAddress.text /// @param dapTextInputRecipientWalletAddress Recipient wallet address input field. property alias dapTextInputRecipientWalletAddress: textInputRecipientWalletAddress @@ -96,24 +103,23 @@ DapAbstractRightPanel anchors.topMargin: 20 * pt anchors.leftMargin: 16 * pt anchors.rightMargin: 16 * pt - height: 100 + height: 40 * pt DapComboBox { - id: comboBoxToken - textRole: "name" - anchors.top: parent.top + id: comboboxToken anchors.left: parent.left anchors.right: parent.right - indicatorImageNormal: "qrc:/res/icons/ic_arrow_drop_down_dark.png" + comboBoxTextRole: "name" + indicatorImageNormal: "qrc:/res/icons/ic_arrow_drop_down.png" indicatorImageActive: "qrc:/res/icons/ic_arrow_drop_up.png" sidePaddingNormal: 0 * pt - sidePaddingActive: 0 * pt + sidePaddingActive: 16 * pt normalColorText: "#070023" - hilightColorText: "#transparent" - normalColorTopText: "#070023" + hilightColorText: "#FFFFFF" + normalColorTopText: "#FFFFFF" hilightColorTopText: "#070023" hilightColor: "#330F54" - normalTopColor: "transparent" + normalTopColor: "#070023" widthPopupComboBoxNormal: 148 * pt widthPopupComboBoxActive: 180 * pt heightComboBoxNormal: 24 * pt @@ -126,12 +132,12 @@ DapAbstractRightPanel paddingTopItemDelegate: 8 * pt heightListElement: 32 * pt intervalListElement: 10 * pt - indicatorWidth: 20 * pt + indicatorWidth: 24 * pt indicatorHeight: indicatorWidth indicatorLeftInterval: 8 * pt colorTopNormalDropShadow: "#00000000" colorDropShadow: "#40ABABAB" - fontComboBox.pixelSize: 16 * pt + fontComboBox.pixelSize: 14 * pt fontComboBox.family: "Roboto" } } @@ -163,7 +169,6 @@ DapAbstractRightPanel font.styleName: "Normal" font.weight: Font.Normal color: "#757184" - text: "dsgfsghdfsht5y5wv546v76b67v66354c6565v576764657676767f5f46" elide: Text.ElideRight } } diff --git a/CellFrameDashboardGUI/screen/desktop/Settings/DapSettingsScreen.qml b/CellFrameDashboardGUI/screen/desktop/Settings/DapSettingsScreen.qml index 60f961b..e64d6f4 100644 --- a/CellFrameDashboardGUI/screen/desktop/Settings/DapSettingsScreen.qml +++ b/CellFrameDashboardGUI/screen/desktop/Settings/DapSettingsScreen.qml @@ -3,6 +3,7 @@ import QtQuick.Controls 2.0 DapSettingsScreenForm { + ///@detalis Settings item model. VisualItemModel { @@ -47,6 +48,7 @@ DapSettingsScreenForm height: 60 * pt ComboBox { + id: comboBoxNetwork width: 150 anchors.left: parent.left anchors.top: parent.top @@ -54,18 +56,12 @@ DapSettingsScreenForm anchors.leftMargin: 18 * pt anchors.topMargin: 10 * pt anchors.bottomMargin: 10 * pt - model: - ListModel - { - ListElement - { - text: "one" - } - ListElement - { - text: "two" - } - } + model: dapNetworkModel + onCurrentTextChanged: + { + dapServiceController.CurrentNetwork = currentText + dapServiceController.IndexCurrentNetwork = currentIndex + } } } } diff --git a/CellFrameDashboardService/DapServiceController.cpp b/CellFrameDashboardService/DapServiceController.cpp index 1cdf345..90901c3 100755 --- a/CellFrameDashboardService/DapServiceController.cpp +++ b/CellFrameDashboardService/DapServiceController.cpp @@ -53,9 +53,9 @@ void DapServiceController::registerCommand() // The team to create a new wallet on the Dashboard tab m_pServer->addService(new DapAddWalletCommand("DapAddWalletCommand", m_pServer)); // The command to get a list of available wallets - m_pServer->addService(new DapGetListWalletsCommand("DapGetListWalletsCommand", m_pServer)); + m_pServer->addService(new DapGetListWalletsCommand("DapGetListWalletsCommand", m_pServer, CLI_PATH)); // The command to get a list of available networks - m_pServer->addService(new DapGetListNetworksCommand("DapGetListNetworksCommand", m_pServer)); + m_pServer->addService(new DapGetListNetworksCommand("DapGetListNetworksCommand", m_pServer, CLI_PATH)); // Saving the file with the logs m_pServer->addService(new DapExportLogCommand("DapExportLogCommand", m_pServer)); diff --git a/DapRPCProtocol/DapRpcService.cpp b/DapRPCProtocol/DapRpcService.cpp index d4c2284..05826c0 100644 --- a/DapRPCProtocol/DapRpcService.cpp +++ b/DapRPCProtocol/DapRpcService.cpp @@ -235,7 +235,10 @@ QJsonValue DapRpcService::convertReturnValue(QVariant &aReturnValue) case QMetaType::QVariantMap: return QJsonValue::fromVariant(aReturnValue); case QMetaType::QByteArray: - return QJsonValue::fromVariant(aReturnValue.toByteArray().toHex()); + { + QJsonValue var = QJsonValue::fromVariant(aReturnValue); + return var; + } default: // if a conversion operator was registered it will be used if (aReturnValue.convert(QMetaType::QJsonValue)) diff --git a/libCellFrameDashboardCommon/DapWallet.cpp b/libCellFrameDashboardCommon/DapWallet.cpp index 3329938..305fb38 100644 --- a/libCellFrameDashboardCommon/DapWallet.cpp +++ b/libCellFrameDashboardCommon/DapWallet.cpp @@ -7,18 +7,18 @@ DapWallet::DapWallet(QObject * parent) } DapWallet::DapWallet(const DapWallet &aWallet) - : m_sName(aWallet.m_sName), m_aNetworks(aWallet.m_aNetworks), - m_aAddresses(aWallet.m_aAddresses), m_aTokens(aWallet.m_aTokens) + : m_sName(aWallet.m_sName), m_dBalance(aWallet.m_dBalance), m_sIcon(aWallet.m_sIcon), m_sAddress(aWallet.m_sAddress), + m_aNetworks(aWallet.m_aNetworks), m_aAddresses(aWallet.m_aAddresses), m_aTokens(aWallet.m_aTokens) { } DapWallet &DapWallet::operator=(const DapWallet &aWallet) { - QObject(parent()); m_sName = aWallet.m_sName; m_dBalance = aWallet.m_dBalance; m_sIcon = aWallet.m_sIcon; + m_sAddress = aWallet.m_sAddress; m_aNetworks = aWallet.m_aNetworks; m_aAddresses = aWallet.m_aAddresses; m_aTokens = aWallet.m_aTokens; @@ -93,7 +93,8 @@ void DapWallet::addAddress(const QString& aiAddress, const QString &asNetwork) QString DapWallet::findAddress(const QString &asNetwork) const { - return m_aAddresses.find(asNetwork).value(); + QString s=m_aAddresses.find(asNetwork).value(); + return m_aAddresses.find(asNetwork) != m_aAddresses.end() ? m_aAddresses.find(asNetwork).value() : QString(); } QMap<QString, QString> DapWallet::getAddresses() const @@ -156,39 +157,44 @@ DapWallet DapWallet::fromVariant(const QVariant &aWallet) QDataStream& operator << (QDataStream& aOut, const DapWallet& aWallet) { QList<DapWalletToken> tokens; - auto begin = aWallet.m_aTokens.begin(); - auto end = aWallet.m_aTokens.end(); - for(;begin != end; ++begin) - tokens.append(**begin); - - QString balance; - balance.setNum(aWallet.m_dBalance); - aOut << aWallet.m_sIcon - << aWallet.m_sAddress - << aWallet.m_aNetworks - << aWallet.m_aAddresses - << tokens; + for(int x{0}; x < aWallet.m_aTokens.size(); ++x) + { + tokens.append(*aWallet.m_aTokens.at(x)); + } + + aOut << aWallet.m_sName + << aWallet.m_dBalance + << aWallet.m_sIcon + << aWallet.m_sAddress + << aWallet.m_aNetworks + << aWallet.m_aAddresses + << tokens; + return aOut; } QDataStream& operator >> (QDataStream& aIn, DapWallet& aWallet) { - QString balance; QList<DapWalletToken> tokens; - aIn >> aWallet.m_sIcon - >> aWallet.m_sAddress - >> aWallet.m_aNetworks - >> aWallet.m_aAddresses - >> tokens; - aWallet.m_dBalance = balance.toDouble(); + + aIn >> aWallet.m_sName; + aIn.setFloatingPointPrecision(QDataStream::DoublePrecision); + aIn >> aWallet.m_dBalance + >> aWallet.m_sIcon + >> aWallet.m_sAddress + >> aWallet.m_aNetworks + >> aWallet.m_aAddresses + >> tokens; + + auto begin = tokens.begin(); auto end = tokens.end(); for(;begin != end; ++begin) - aWallet.addToken(&(*begin)); + aWallet.addToken(new DapWalletToken(*begin)); return aIn; } -bool operator ==(const DapWallet &aTokenFirst, const DapWallet &aTokenSecond) +bool operator ==(const DapWallet &aWalletFirst, const DapWallet &aWalletSecond) { - return aTokenFirst.m_sName == aTokenSecond.m_sName; + return aWalletFirst.m_sName == aWalletSecond.m_sName; } diff --git a/libCellFrameDashboardCommon/DapWallet.h b/libCellFrameDashboardCommon/DapWallet.h index 51c14b6..1cdcf71 100644 --- a/libCellFrameDashboardCommon/DapWallet.h +++ b/libCellFrameDashboardCommon/DapWallet.h @@ -13,9 +13,9 @@ class DapWallet : public QObject Q_OBJECT QString m_sName; - double m_dBalance; + double m_dBalance {0.0}; QString m_sIcon; - QString m_sAddress = "KLJHuhlkjshfausdh7865lksfahHKLUIHKJFHKLUESAHFILKUHEWKUAFHjkhfdkslusfkhgs"; + QString m_sAddress = "private"; QStringList m_aNetworks; QMap<QString, QString> m_aAddresses; mutable QList<DapWalletToken*> m_aTokens; @@ -36,7 +36,7 @@ public: friend QDataStream& operator << (QDataStream& aOut, const DapWallet& aToken); friend QDataStream& operator >> (QDataStream& aOut, DapWallet& aToken); - friend bool operator == (const DapWallet& aTokenFirst, const DapWallet& aTokenSecond); + friend bool operator == (const DapWallet &aWalletFirst, const DapWallet &aWalletSecond); static DapWallet fromVariant(const QVariant& aWallet); @@ -51,7 +51,6 @@ signals: void tokenAdded(const DapWalletToken& asNetwork); public slots: - QString getName() const; void setName(const QString &asName); double getBalance() const; diff --git a/libCellFrameDashboardCommon/DapWalletToken.cpp b/libCellFrameDashboardCommon/DapWalletToken.cpp index 58f3d99..49832e6 100644 --- a/libCellFrameDashboardCommon/DapWalletToken.cpp +++ b/libCellFrameDashboardCommon/DapWalletToken.cpp @@ -15,7 +15,6 @@ DapWalletToken::DapWalletToken(const DapWalletToken &aToken) DapWalletToken &DapWalletToken::operator=(const DapWalletToken &aToken) { - QObject(parent()); m_sName = aToken.m_sName; m_dBalance = aToken.m_dBalance; m_iEmission = aToken.m_iEmission; @@ -93,27 +92,23 @@ void DapWalletToken::setIcon(const QString &sIcon) QDataStream& operator << (QDataStream& aOut, const DapWalletToken& aToken) { - QString balance; - balance.setNum(aToken.m_dBalance); QString emission; emission.setNum(aToken.m_iEmission); aOut << aToken.m_sName - << balance - << emission + << aToken.m_dBalance + << aToken.m_iEmission << aToken.m_sNetwork; return aOut; } QDataStream& operator >> (QDataStream& aOut, DapWalletToken& aToken) { - QString balance; - QString emission; - aOut >> aToken.m_sName - >> balance - >> emission + aOut >> aToken.m_sName; + aOut.setFloatingPointPrecision(QDataStream::DoublePrecision); + aOut >> aToken.m_dBalance; + aOut.setFloatingPointPrecision(QDataStream::SinglePrecision); + aOut >> aToken.m_iEmission >> aToken.m_sNetwork; - aToken.m_dBalance = balance.toDouble(); - aToken.m_iEmission = emission.toULongLong(); return aOut; } diff --git a/libCellFrameDashboardCommon/Handlers/DapCreateTransactionCommand.cpp b/libCellFrameDashboardCommon/Handlers/DapCreateTransactionCommand.cpp index 88aacc4..9468e57 100644 --- a/libCellFrameDashboardCommon/Handlers/DapCreateTransactionCommand.cpp +++ b/libCellFrameDashboardCommon/Handlers/DapCreateTransactionCommand.cpp @@ -28,7 +28,7 @@ QVariant DapCreateTransactionCommand::respondToClient(const QVariant &arg1, cons Q_UNUSED(arg10) QProcess processCreate; - processCreate.start(QString("%1 tx_create -net %2 -chain %3 -from_wallet %3 -to_addr %4 -token %5 -value %6") + processCreate.start(QString("%1 tx_create -net %2 -chain %3 -from_wallet %4 -to_addr %5 -token %6 -value %7") .arg(m_sCliPath) .arg(arg1.toString()) .arg(arg2.toString()) diff --git a/libCellFrameDashboardCommon/Handlers/DapGetListNetworksCommand.cpp b/libCellFrameDashboardCommon/Handlers/DapGetListNetworksCommand.cpp index 8498b3a..1a7e5b0 100644 --- a/libCellFrameDashboardCommon/Handlers/DapGetListNetworksCommand.cpp +++ b/libCellFrameDashboardCommon/Handlers/DapGetListNetworksCommand.cpp @@ -4,8 +4,9 @@ /// @param asServiceName Service name. /// @param parent Parent. /// @details The parent must be either DapRPCSocket or DapRPCLocalServer. -DapGetListNetworksCommand::DapGetListNetworksCommand(const QString &asServicename, QObject *parent) - : DapAbstractCommand(asServicename, parent) +/// @param asCliPath The path to cli nodes. +DapGetListNetworksCommand::DapGetListNetworksCommand(const QString &asServicename, QObject *parent, const QString &asCliPath) + : DapAbstractCommand(asServicename, parent), m_sCliPath(asCliPath) { } @@ -29,13 +30,12 @@ QVariant DapGetListNetworksCommand::respondToClient(const QVariant &arg1, const QStringList networkList; QProcess process; - process.start(QString("%1 net list").arg(CLI_PATH)); + process.start(QString("%1 net list").arg(m_sCliPath)); process.waitForFinished(-1); QString result = QString::fromLatin1(process.readAll()); - result.remove(' '); - if(!(result.isEmpty() || result.isNull())) + if(!(result.isEmpty() || result.isNull() || result.contains('\''))) { - QStringList str = result.remove("\n").remove("\r").split(":").at(1).split(","); + QStringList str = result.remove(" ").remove("\n").remove("\r").split(":").at(1).split(","); return str; } return QString(); diff --git a/libCellFrameDashboardCommon/Handlers/DapGetListNetworksCommand.h b/libCellFrameDashboardCommon/Handlers/DapGetListNetworksCommand.h index b02d43f..fb16b49 100644 --- a/libCellFrameDashboardCommon/Handlers/DapGetListNetworksCommand.h +++ b/libCellFrameDashboardCommon/Handlers/DapGetListNetworksCommand.h @@ -7,12 +7,16 @@ class DapGetListNetworksCommand : public DapAbstractCommand { + /// The path to cli nodes. + QString m_sCliPath; + public: /// Overloaded constructor. /// @param asServiceName Service name. /// @param parent Parent. /// @details The parent must be either DapRPCSocket or DapRPCLocalServer. - DapGetListNetworksCommand(const QString &asServicename, QObject *parent = nullptr); + /// @param asCliPath The path to cli nodes. + DapGetListNetworksCommand(const QString &asServicename, QObject *parent = nullptr, const QString &asCliPath = QString()); public slots: /// Send a response to the client. diff --git a/libCellFrameDashboardCommon/Handlers/DapGetListWalletsCommand.cpp b/libCellFrameDashboardCommon/Handlers/DapGetListWalletsCommand.cpp index 737c03a..089ff09 100644 --- a/libCellFrameDashboardCommon/Handlers/DapGetListWalletsCommand.cpp +++ b/libCellFrameDashboardCommon/Handlers/DapGetListWalletsCommand.cpp @@ -4,8 +4,9 @@ /// @param asServiceName Service name. /// @param parent Parent. /// @details The parent must be either DapRPCSocket or DapRPCLocalServer. -DapGetListWalletsCommand::DapGetListWalletsCommand(const QString &asServicename, QObject *parent) - : DapAbstractCommand(asServicename, parent) +/// @param asCliPath The path to cli nodes. +DapGetListWalletsCommand::DapGetListWalletsCommand(const QString &asServicename, QObject *parent, const QString &asCliPath) + : DapAbstractCommand(asServicename, parent), m_sCliPath(asCliPath) { } @@ -30,26 +31,64 @@ QVariant DapGetListWalletsCommand::respondToClient(const QVariant &arg1, const Q Q_UNUSED(arg9) Q_UNUSED(arg10) - DapWallet wallet; - wallet.setName("MyWallet5"); - 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); +// 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"); - QByteArray datas; - QDataStream out(&datas, QIODevice::WriteOnly); - out << wallet; +// 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); @@ -58,63 +97,92 @@ QVariant DapGetListWalletsCommand::respondToClient(const QVariant &arg1, const Q // QDataStream in(&datas, QIODevice::ReadOnly); // in>>w; - return QVariant(QString::fromStdString(datas.toStdString())); -// QList<DapWallet> wallets; - -// QStringList list = arg1.toStringList(); -// QProcess process; -// process.start(QString("%1 wallet list").arg(CLI_PATH)); -// 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); - -// auto begin = list.begin(); -// auto end = list.end(); -// for(; begin != end; ++begin) -// { -// DapWallet wallet (walletName); -// wallet.addNetwork(*begin); - -// QProcess process_token; -// process_token.start(QString("%1 wallet info -w %2 -net %3") -// .arg(CLI_PATH) -// .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; -// while((pos = regex.indexIn(result_tokens, pos)) != -1) -// { -// DapWalletToken token; -// if(!regex.cap(2).isEmpty()) -// { -// wallet.setAddress(regex.cap(2), *begin); -// } -// else -// { - -// token.setName(regex.cap(6)); -// token.setBalance(regex.cap(4).toDouble()); -// token.setEmission(regex.cap(5).toUInt()); -// token.setNetwork(*begin); -// } -// pos += regex.matchedLength(); -// } -// wallets.append(wallet); -// } -// } -// if(m_walletList != walletList) -// { -// m_walletList = walletList; -// emit walletDataChanged(walletData()); -// } -// return QVariant(); + 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 DapGetListWalletsCommand::replyFromService() +{ + QObject * s = sender(); + DapRpcServiceReply *reply = static_cast<DapRpcServiceReply *>(sender()); + + emit serviceResponded(reply->response().toJsonValue().toVariant().toByteArray()); + + return reply->response().toJsonValue().toVariant(); } diff --git a/libCellFrameDashboardCommon/Handlers/DapGetListWalletsCommand.h b/libCellFrameDashboardCommon/Handlers/DapGetListWalletsCommand.h index e97d439..202f38e 100644 --- a/libCellFrameDashboardCommon/Handlers/DapGetListWalletsCommand.h +++ b/libCellFrameDashboardCommon/Handlers/DapGetListWalletsCommand.h @@ -7,18 +7,23 @@ #include <QByteArray> #include <QDataStream> #include <QBuffer> +#include <QTextCodec> #include "DapWallet.h" #include "DapAbstractCommand.h" class DapGetListWalletsCommand : public DapAbstractCommand { + /// The path to cli nodes. + QString m_sCliPath; + public: /// Overloaded constructor. /// @param asServiceName Service name. /// @param parent Parent. /// @details The parent must be either DapRPCSocket or DapRPCLocalServer. - DapGetListWalletsCommand(const QString &asServicename, QObject *parent = nullptr); + /// @param asCliPath The path to cli nodes. + DapGetListWalletsCommand(const QString &asServicename, QObject *parent = nullptr, const QString &asCliPath = QString()); public slots: /// Send a response to the client. @@ -30,6 +35,7 @@ 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/libCellFrameDashboardCommon/Handlers/DapGetWalletHistoryCommand.cpp b/libCellFrameDashboardCommon/Handlers/DapGetWalletHistoryCommand.cpp new file mode 100644 index 0000000..ae61be3 --- /dev/null +++ b/libCellFrameDashboardCommon/Handlers/DapGetWalletHistoryCommand.cpp @@ -0,0 +1,55 @@ +#include "DapGetWalletHistoryCommand.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. +DapGetWalletHistoryCommand::DapGetWalletHistoryCommand(const QString &asServicename, QObject *parent, const QString &asCliPath) + : DapAbstractCommand(asServicename, parent), m_sCliPath(asCliPath) +{ + +} + +/// Send a response to the client. +/// @details Performed on the service side. +/// @param arg1...arg10 Parameters. +/// @return Reply to client. +QVariant DapGetWalletHistoryCommand::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<QVariant> data; + QProcess process; + process.start(QString("%1 tx_history -net %2 -chain gdb -addr %3").arg(m_sCliPath).arg(arg1.toString()).arg(arg2.toString())); + process.waitForFinished(-1); + QByteArray result = process.readAll(); + if(!result.isEmpty()) + { + QRegularExpression regular("((\\w{3}\\s+){2}\\d{1,2}\\s+(\\d{1,2}:*){3}\\s+\\d{4})\\s+(\\w+)\\s+(\\d+)\\s(\\w+)\\s+\\w+\\s+([\\w\\d]+)", QRegularExpression::MultilineOption); + QRegularExpressionMatchIterator matchItr = regular.globalMatch(result); + while (matchItr.hasNext()) + { + if(data.count() >= 100) break; + QRegularExpressionMatch match = matchItr.next(); + QStringList dataItem = QStringList() + << match.captured(1) + << match.captured(4) + << match.captured(5) + << match.captured(6) + << match.captured(7); + data << dataItem; + } + } + + return data; +} diff --git a/libCellFrameDashboardCommon/Handlers/DapGetWalletHistoryCommand.h b/libCellFrameDashboardCommon/Handlers/DapGetWalletHistoryCommand.h new file mode 100644 index 0000000..d192e96 --- /dev/null +++ b/libCellFrameDashboardCommon/Handlers/DapGetWalletHistoryCommand.h @@ -0,0 +1,36 @@ +#ifndef DAPGETWALLETHISTORYCOMMAND_H +#define DAPGETWALLETHISTORYCOMMAND_H + +#include <QProcess> +#include <QRegExp> +#include <QRegularExpression> + +#include "DapWallet.h" +#include "DapAbstractCommand.h" + +class DapGetWalletHistoryCommand : public DapAbstractCommand +{ + /// The path to cli nodes. + QString m_sCliPath; + +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. + DapGetWalletHistoryCommand(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; +}; + +#endif // DAPGETWALLETHISTORYCOMMAND_H diff --git a/libCellFrameDashboardCommon/libCellFrameDashboardCommon.pri b/libCellFrameDashboardCommon/libCellFrameDashboardCommon.pri index 4edcecc..e4d854e 100755 --- a/libCellFrameDashboardCommon/libCellFrameDashboardCommon.pri +++ b/libCellFrameDashboardCommon/libCellFrameDashboardCommon.pri @@ -27,6 +27,7 @@ SOURCES +=\ $$PWD/Handlers/DapGetListWalletsCommand.cpp \ $$PWD/Handlers/DapExportLogCommand.cpp \ $$PWD/Handlers/DapGetWalletAddressesCommand.cpp \ + $$PWD/Handlers/DapGetWalletHistoryCommand.cpp \ $$PWD/Handlers/DapGetWalletTokenInfoCommand.cpp \ $$PWD/Handlers/DapCreateTransactionCommand.cpp \ $$PWD/Handlers/DapMempoolProcessCommand.cpp \ @@ -51,6 +52,7 @@ HEADERS +=\ $$PWD/Handlers/DapGetListWalletsCommand.h \ $$PWD/Handlers/DapExportLogCommand.h \ $$PWD/Handlers/DapGetWalletAddressesCommand.h \ + $$PWD/Handlers/DapGetWalletHistoryCommand.h \ $$PWD/Handlers/DapGetWalletTokenInfoCommand.h \ $$PWD/Handlers/DapCreateTransactionCommand.h \ $$PWD/Handlers/DapMempoolProcessCommand.h \ diff --git a/libdap-qt-ui-qml b/libdap-qt-ui-qml index 43d8780..103c3d1 160000 --- a/libdap-qt-ui-qml +++ b/libdap-qt-ui-qml @@ -1 +1 @@ -Subproject commit 43d8780f269cf47ed375e6c1e2b87f5fca8ec056 +Subproject commit 103c3d107cf730c8158368d20e339647cc568659 -- GitLab