From 2ca33b1777045fd81259b698728e44f9b94cbedc Mon Sep 17 00:00:00 2001 From: "littletux89@gmail.com" <littletux89@gmail.com> Date: Fri, 31 May 2019 01:00:47 +0300 Subject: [PATCH] [*] Temporary edits. --- KelvinDashboardGUI/DapChainWalletsModel.cpp | 17 ++- KelvinDashboardGUI/DapChainWalletsModel.h | 7 +- KelvinDashboardGUI/DapCommandController.cpp | 22 +++ KelvinDashboardGUI/DapCommandController.h | 6 + KelvinDashboardGUI/DapServiceController.cpp | 17 ++- KelvinDashboardGUI/DapServiceController.h | 4 + .../DapUiQmlScreenDashboard.qml | 2 + .../DapUiQmlWidgetChainNodeLogs.qml | 5 + ...=> DapUiQmlWidgetChainNodeLogsForm.ui.qml} | 102 +++++-------- .../DapUiQmlWidgetChainWallet.qml | 26 +++- .../DapUiQmlWidgetChainWalletForm.ui.qml | 144 +++++++++--------- KelvinDashboardGUI/DapUiQmlWidgetModel.cpp | 2 +- KelvinDashboardGUI/main.qml | 94 +++++++----- KelvinDashboardGUI/qml.qrc | 3 +- .../DapChainDashboardService.cpp | 7 +- .../DapChainDashboardService.h | 2 + KelvinDashboardService/DapChainLogHandler.h | 6 +- .../DapChainWalletHandler.cpp | 28 ++++ .../DapChainWalletHandler.h | 1 + libKelvinDashboardCommon/DapChainWallet.cpp | 20 ++- libKelvinDashboardCommon/DapChainWallet.h | 10 +- libKelvinDashboardCommon/DapLogModel.cpp | 18 +-- 22 files changed, 339 insertions(+), 204 deletions(-) create mode 100644 KelvinDashboardGUI/DapUiQmlWidgetChainNodeLogs.qml rename KelvinDashboardGUI/{DapUiQmlWidgetChainNodeLogs.ui.qml => DapUiQmlWidgetChainNodeLogsForm.ui.qml} (80%) diff --git a/KelvinDashboardGUI/DapChainWalletsModel.cpp b/KelvinDashboardGUI/DapChainWalletsModel.cpp index 0c5a32221..7d46e1686 100644 --- a/KelvinDashboardGUI/DapChainWalletsModel.cpp +++ b/KelvinDashboardGUI/DapChainWalletsModel.cpp @@ -23,6 +23,7 @@ QVariant DapChainWalletsModel::data(const QModelIndex &index, int role) const case IconWalletRole: return m_dapChainWallets.at(index.row())->getIconPath(); case NameWalletRole: return m_dapChainWallets.at(index.row())->getName(); case AddressWalletRole: return m_dapChainWallets.at(index.row())->getAddress(); + case BalanceWalletRole: return m_dapChainWallets.at(index.row())->getBalance(); default: return QVariant(); } @@ -34,7 +35,8 @@ QHash<int, QByteArray> DapChainWalletsModel::roleNames() const static const QHash<int, QByteArray> roles { { IconWalletRole, "iconPath" }, { NameWalletRole, "name" }, - { AddressWalletRole, "address" } + { AddressWalletRole, "address" }, + { BalanceWalletRole, "balance" } }; return roles; @@ -43,25 +45,25 @@ QHash<int, QByteArray> DapChainWalletsModel::roleNames() const QVariantMap DapChainWalletsModel::get(int row) const { const DapChainWallet *wallet = m_dapChainWallets.value(row); - return { {"iconPath", wallet->getIconPath()}, {"name", wallet->getName()}, {"address", wallet->getAddress()} }; + return { {"iconPath", wallet->getIconPath()}, {"name", wallet->getName()}, {"address", wallet->getAddress()}, {"balance", wallet->getBalance()} }; } void DapChainWalletsModel::append(const DapChainWallet &arWallet) { - this->append(arWallet.getIconPath(), arWallet.getName(), arWallet.getAddress()); + this->append(arWallet.getIconPath(), arWallet.getName(), arWallet.getAddress(), arWallet.getBalance()); } -void DapChainWalletsModel::append(const QString& asIconPath, const QString &asName, const QString &asAddress) +void DapChainWalletsModel::append(const QString& asIconPath, const QString &asName, const QString &asAddress, const QString& aBalance) { int row = 0; while (row < m_dapChainWallets.count()) ++row; beginInsertRows(QModelIndex(), row, row); - m_dapChainWallets.insert(row, new DapChainWallet(asIconPath, asName, asAddress)); + m_dapChainWallets.insert(row, new DapChainWallet(asIconPath, asName, asAddress, aBalance)); endInsertRows(); } -void DapChainWalletsModel::set(int row, const QString& asIconPath, const QString &asName, const QString &asAddresss) +void DapChainWalletsModel::set(int row, const QString& asIconPath, const QString &asName, const QString &asAddresss, const QString& aBalance) { if (row < 0 || row >= m_dapChainWallets.count()) return; @@ -70,7 +72,8 @@ void DapChainWalletsModel::set(int row, const QString& asIconPath, const QString wallet->setIconPath(asIconPath); wallet->setName(asName); wallet->setAddress(asAddresss); - dataChanged(index(row, 0), index(row, 0), { IconWalletRole, NameWalletRole, AddressWalletRole }); + wallet->setBalance(aBalance); + dataChanged(index(row, 0), index(row, 0), { IconWalletRole, NameWalletRole, AddressWalletRole, BalanceWalletRole }); } void DapChainWalletsModel::remove(int row) diff --git a/KelvinDashboardGUI/DapChainWalletsModel.h b/KelvinDashboardGUI/DapChainWalletsModel.h index 2013196b8..5c8afb5ee 100644 --- a/KelvinDashboardGUI/DapChainWalletsModel.h +++ b/KelvinDashboardGUI/DapChainWalletsModel.h @@ -15,7 +15,8 @@ enum DapChainWalletRole { IconWalletRole = Qt::DisplayRole, NameWalletRole = Qt::UserRole, - AddressWalletRole + AddressWalletRole, + BalanceWalletRole }; class DapChainWalletsModel : public QAbstractListModel @@ -36,8 +37,8 @@ public: Q_INVOKABLE QVariantMap get(int row) const; Q_INVOKABLE void append(const DapChainWallet &arWallet); - Q_INVOKABLE void append(const QString& asIconPath, const QString &asName, const QString &asAddress); - Q_INVOKABLE void set(int row, const QString& asIconPath, const QString &asName, const QString &asAddresss); + Q_INVOKABLE void append(const QString& asIconPath, const QString &asName, const QString &asAddress, const QString &aBalance); + Q_INVOKABLE void set(int row, const QString& asIconPath, const QString &asName, const QString &asAddresss, const QString &aBalance); Q_INVOKABLE void remove(int row); Q_INVOKABLE void clear(); diff --git a/KelvinDashboardGUI/DapCommandController.cpp b/KelvinDashboardGUI/DapCommandController.cpp index 5e63b1e13..06792c1e4 100644 --- a/KelvinDashboardGUI/DapCommandController.cpp +++ b/KelvinDashboardGUI/DapCommandController.cpp @@ -79,6 +79,21 @@ void DapCommandController::processGetWallets() emit sigWalletsReceived(reply->response().result().toVariant().toMap()); } +void DapCommandController::processGetWalletInfo() +{ + qInfo() << "processGetWalletInfo()"; + DapRpcServiceReply *reply = static_cast<DapRpcServiceReply *>(sender()); + if (!reply) { + qWarning() << "Invalid response received"; + return; + } + emit sigCommandResult(reply->response().result()); + QString name = reply->response().result().toVariant().toStringList().at(0); + QString address = reply->response().result().toVariant().toStringList().at(1); + QString balance = reply->response().result().toVariant().toStringList().at(2); + emit sigWalletInfoChanged(name, address, balance); +} + /// Show or hide GUI client by clicking on the tray icon. /// @param aIsActivated Accepts true - when requesting to /// display a client, falso - when requesting to hide a client. @@ -115,3 +130,10 @@ void DapCommandController::getWallets() DapRpcServiceReply *reply = m_DAPRpcSocket->invokeRemoteMethod("RPCServer.getWallets"); connect(reply, SIGNAL(finished()), this, SLOT(processGetWallets())); } + +void DapCommandController::getWalletInfo(const QString& asWalletName) +{ + qInfo() << QString("getWalletInfo(%1)").arg(asWalletName); + DapRpcServiceReply *reply = m_DAPRpcSocket->invokeRemoteMethod("RPCServer.getWalletInfo", asWalletName); + connect(reply, SIGNAL(finished()), this, SLOT(processGetWalletInfo())); +} diff --git a/KelvinDashboardGUI/DapCommandController.h b/KelvinDashboardGUI/DapCommandController.h index 6b4abdfbc..d8e79a61c 100644 --- a/KelvinDashboardGUI/DapCommandController.h +++ b/KelvinDashboardGUI/DapCommandController.h @@ -33,6 +33,8 @@ signals: void onClientActivate(bool aIsActivated); void onClientClose(); + + void sigWalletInfoChanged(const QString& asWalletName, const QString& asWalletAddress, const QString& aBalance); public: /// Overloaded constructor. @@ -52,6 +54,8 @@ private slots: void processAddWallet(); void processGetWallets(); + + void processGetWalletInfo(); public slots: /// Show or hide GUI client by clicking on the tray icon. @@ -68,6 +72,8 @@ public slots: void addWallet(const QString& asWalletName); void getWallets(); + + void getWalletInfo(const QString& asWalletName); }; #endif // COMMANDCONTROLLER_H diff --git a/KelvinDashboardGUI/DapServiceController.cpp b/KelvinDashboardGUI/DapServiceController.cpp index e1c01a2ed..91c330c05 100644 --- a/KelvinDashboardGUI/DapServiceController.cpp +++ b/KelvinDashboardGUI/DapServiceController.cpp @@ -43,6 +43,8 @@ void DapServiceController::init(DapServiceClient *apDapServiceClient) connect(m_pDapCommandController, SIGNAL(sigWalletAdded(QString, QString)), SLOT(processAddWallet(QString, QString))); connect(m_pDapCommandController, SIGNAL(sigWalletsReceived(QMap<QString,QVariant>)), SLOT(processGetWallets(QMap<QString,QVariant>))); + + connect(m_pDapCommandController, SIGNAL(sigWalletInfoChanged(QString,QString,QString)), SLOT(processGetWalletInfo(QString,QString,QString))); } QString DapServiceController::getBrand() const @@ -116,6 +118,12 @@ void DapServiceController::addWallet(const QString &asWalletName) m_pDapCommandController->addWallet(asWalletName); } +void DapServiceController::getWalletInfo(const QString &asWalletName) +{ + qInfo() << QString("getWalletInfo(%1)").arg(asWalletName); + m_pDapCommandController->getWalletInfo(asWalletName); +} + void DapServiceController::processAddWallet(const QString& asWalletName, const QString& asWalletAddress) { qInfo() << QString("processAddWallet(%1, %2)").arg(asWalletName).arg(asWalletAddress);; @@ -129,10 +137,17 @@ void DapServiceController::processGetWallets(const QMap<QString, QVariant> &aWal for(QString w : aWallets.keys()) { DapChainWallet wallet("", w, aWallets.value(w).toString()); - DapChainWalletsModel::getInstance().append(wallet); + getWalletInfo(w); } } +void DapServiceController::processGetWalletInfo(const QString &asWalletName, const QString &asWalletAddress, const QString &aBalance) +{ + qInfo() << QString("processGetWalletInfo(%1, %2, %3)").arg(asWalletName).arg(asWalletAddress).arg(aBalance); + DapChainWallet wallet("", asWalletName, asWalletAddress, aBalance); + DapChainWalletsModel::getInstance().append(wallet); +} + /// Get an instance of a class. /// @return Instance of a class. DapServiceController &DapServiceController::getInstance() diff --git a/KelvinDashboardGUI/DapServiceController.h b/KelvinDashboardGUI/DapServiceController.h index fe9a03f65..1edafae66 100644 --- a/KelvinDashboardGUI/DapServiceController.h +++ b/KelvinDashboardGUI/DapServiceController.h @@ -68,6 +68,8 @@ public: Q_INVOKABLE void addWallet(const QString& asWalletName); + void getWalletInfo(const QString& asWalletName); + signals: /// The signal is emitted when the Brand company property changes. void brandChanged(const QString &brand); @@ -87,6 +89,8 @@ private slots: void processGetWallets(const QMap<QString, QVariant>& aWallets); + void processGetWalletInfo(const QString& asWalletName, const QString& asWalletAddress, const QString& aBalance); + public slots: /// Show or hide GUI client by clicking on the tray icon. /// @param aIsActivated Accepts true - when requesting to diff --git a/KelvinDashboardGUI/DapUiQmlScreenDashboard.qml b/KelvinDashboardGUI/DapUiQmlScreenDashboard.qml index 881e48384..1f5d35b34 100755 --- a/KelvinDashboardGUI/DapUiQmlScreenDashboard.qml +++ b/KelvinDashboardGUI/DapUiQmlScreenDashboard.qml @@ -64,6 +64,8 @@ Page { text: qsTr(name) color: "#BBBEBF" anchors.horizontalCenter: parent.horizontalCenter + font.weight: Font.Light + font.family: "Roboto" } } diff --git a/KelvinDashboardGUI/DapUiQmlWidgetChainNodeLogs.qml b/KelvinDashboardGUI/DapUiQmlWidgetChainNodeLogs.qml new file mode 100644 index 000000000..19155c797 --- /dev/null +++ b/KelvinDashboardGUI/DapUiQmlWidgetChainNodeLogs.qml @@ -0,0 +1,5 @@ +import QtQuick 2.4 + +DapUiQmlWidgetChainNodeLogsForm { + +} diff --git a/KelvinDashboardGUI/DapUiQmlWidgetChainNodeLogs.ui.qml b/KelvinDashboardGUI/DapUiQmlWidgetChainNodeLogsForm.ui.qml similarity index 80% rename from KelvinDashboardGUI/DapUiQmlWidgetChainNodeLogs.ui.qml rename to KelvinDashboardGUI/DapUiQmlWidgetChainNodeLogsForm.ui.qml index c1719d28d..00bca0056 100644 --- a/KelvinDashboardGUI/DapUiQmlWidgetChainNodeLogs.ui.qml +++ b/KelvinDashboardGUI/DapUiQmlWidgetChainNodeLogsForm.ui.qml @@ -6,71 +6,47 @@ import KelvinDashboard 1.0 Page { id: dapUiQmlWidgetChainNodeLogs title: "Logs" - - ListModel - { - id: nodeModel - ListElement - { - name: "Node 1" - } - -// ListElement +// TabView // { -// name: "Node 2" -// } +// id: tabViewLogs +// anchors.top: parent.top +// anchors.bottom: parent.bottom +// anchors.left: parent.left +// anchors.right: parent.right +// Repeater { +// anchors.fill: parent +// model: nodeModel +// delegate: +// Tab{ + + + +// title: qsTr(name) -// ListElement -// { -// name: "Node 3" -// } - } - - TabView - { - id: tabViewLogs - anchors.top: parent.top - anchors.bottom: parent.bottom - anchors.left: parent.left - anchors.right: parent.right - Repeater { - anchors.fill: parent - model: nodeModel - delegate: - Tab{ - - - - title: qsTr(name) - TableView { id: tableViewLogs -// anchors.top: parent.top -// anchors.bottom: parent.bottom -// anchors.left: parent.left -// anchors.right: parent.right + anchors.top: parent.top + anchors.bottom: parent.bottom + anchors.left: parent.left + anchors.right: parent.right model: dapLogModel clip: true - + TableViewColumn { id: columnType role: "type" title: "Type" - + delegate: Item{ - Text { - anchors.centerIn: parent - renderType: Text.NativeRendering - text: styleData.value - } -// Image { -// anchors.centerIn: parent -// source: styleData.value -// width: 14 -// height: 14 -// } + Image { + id: img + anchors.centerIn: parent + source: styleData.value + width: 14 + height: 14 + } } } TableViewColumn { @@ -113,7 +89,7 @@ Page { headerDelegate: Rectangle { height: 20 color: "orange" - + Text { text: styleData.value color: "#FFF" @@ -129,8 +105,8 @@ Page { } } - } - +// } + // TabView // { // id: tabViewLogs @@ -143,16 +119,16 @@ Page { // model: dapUiQmlWidgetModel // delegate: // Tab{ - - - + + + // title: qsTr(name) - + // TableView { // id: tableViewLogs // model: dataModel // clip: true - + // TableViewColumn { // id: columnType // role: "type" @@ -205,7 +181,7 @@ Page { // headerDelegate: Rectangle { // height: 20 // color: "#29333f" - + // Text { // text: styleData.value // color: "#FFF" @@ -224,5 +200,5 @@ Page { // } // } // } - } -} +// } +//} diff --git a/KelvinDashboardGUI/DapUiQmlWidgetChainWallet.qml b/KelvinDashboardGUI/DapUiQmlWidgetChainWallet.qml index 9767571a9..018ef4719 100644 --- a/KelvinDashboardGUI/DapUiQmlWidgetChainWallet.qml +++ b/KelvinDashboardGUI/DapUiQmlWidgetChainWallet.qml @@ -1,9 +1,31 @@ -import QtQuick 2.4 +import QtQuick 2.9 +import QtQuick.Controls 1.4 +import QtQuick.Controls 2.4 +import QtQuick.Window 2.0 +import QtQuick.Controls.Styles 1.3 +import QtQuick.Controls.Styles 1.4 +import Qt.labs.platform 1.0 +import KelvinDashboard 1.0 DapUiQmlWidgetChainWalletForm { id: dapQmlWidgetChainWallet + listViewWallet.highlight: + Component + { + Rectangle { + id: rectangleMenu + color: "#121B28" + Rectangle + { + height: rectangleMenu.height + width: 4 + color: "green" + } + } + } - + listViewWallet.onCurrentItemChanged: + console.log(listViewWallet.currentIndex) save.onClicked: { dialogAddWallet.show() diff --git a/KelvinDashboardGUI/DapUiQmlWidgetChainWalletForm.ui.qml b/KelvinDashboardGUI/DapUiQmlWidgetChainWalletForm.ui.qml index 1bdc39b1d..6d5dd626d 100644 --- a/KelvinDashboardGUI/DapUiQmlWidgetChainWalletForm.ui.qml +++ b/KelvinDashboardGUI/DapUiQmlWidgetChainWalletForm.ui.qml @@ -11,88 +11,92 @@ Page { property alias save: save property alias dialogAddWallet: dialogAddWallet - ListView { - id: listViewWallet - anchors.fill: parent - anchors.margins: 10 - spacing: 10 - model: dapChainWalletsModel - - delegate: Item { - width: parent.width - height: 150 - - Rectangle { - id: rectangleWallet - anchors.fill: parent - color: "lightgray" - opacity: 0.5 - radius: 5 - border.color: "gray" - clip: true - - Rectangle - { - id: iconWallet - height: 140 - width: 140 - border.color: "gray" - anchors.left: parent.left - anchors.leftMargin: 5 - anchors.verticalCenter: parent.verticalCenter - radius: 3.5 - - Image + Rectangle + { + anchors.left: parent.left + anchors.top: parent.top + anchors.bottom: parent.bottom + color: "#353841" + width: 100 + ListView { + id: listViewWallet + anchors.fill: parent + keyNavigationEnabled: true + model: dapChainWalletsModel + + delegate: Item { + width: parent.width + height: 100 + + Column { - anchors.fill: parent - source: "qrc:/Resources/Icons/add.png" - } + anchors.centerIn: parent + spacing: 5 + + Text { + id: nameWallet + anchors.horizontalCenter: parent.horizontalCenter + text: qsTr(name) + font.pixelSize: 14 + color: "#BBBEBF" + font.family: "Roboto" + } + + Text { + id: lableBalance + anchors.horizontalCenter: parent.horizontalCenter + text: qsTr(balance) + font.pixelSize: 18 + color: "#BBBEBF" + font.family: "Roboto" + } + + Text { + id: lableCurrency + anchors.horizontalCenter: parent.horizontalCenter + text: "Dollars" + font.pixelSize: 14 + color: "#BBBEBF" + font.weight: Font.Light + font.family: "Roboto" + } + +// TextEdit { +// id: addressWallet +// text: address +// width: parent.width +// font.pixelSize: 16 +// wrapMode: Text.Wrap +// selectByMouse: true +// // clip: true +// // elide: Text.ElideRight +// } } - Column - { - anchors.verticalCenter: parent.verticalCenter - anchors.left: iconWallet.right - anchors.leftMargin: 10 - anchors.right: parent.right - anchors.rightMargin: 10 - spacing: 5 - - Text { - id: nameWallet - text: name - bottomPadding: 15 - font.bold: true - font.pixelSize: 20 - } - - Text { - id: lableAddress - text: "Address:" - font.pixelSize: 18 - color: "gray" - } - - TextEdit { - id: addressWallet - text: address - width: parent.width - font.pixelSize: 16 - wrapMode: Text.Wrap - selectByMouse: true - // clip: true - // elide: Text.ElideRight - } + MouseArea { + anchors.fill: parent + onClicked: listViewWallet.currentIndex = index } } + + focus: true } + } - } DapUiQmlScreenDialogAddWallet { id: dialogAddWallet } + RoundButton { + id: deleteWallet + text: qsTr("-") + highlighted: true + anchors.margins: 10 + anchors.right: parent.right + anchors.bottom: save.top + } + RoundButton { id: save text: qsTr("+") diff --git a/KelvinDashboardGUI/DapUiQmlWidgetModel.cpp b/KelvinDashboardGUI/DapUiQmlWidgetModel.cpp index 11ff0ae6f..828d2d78e 100755 --- a/KelvinDashboardGUI/DapUiQmlWidgetModel.cpp +++ b/KelvinDashboardGUI/DapUiQmlWidgetModel.cpp @@ -8,7 +8,7 @@ DapUiQmlWidgetModel::DapUiQmlWidgetModel(QObject *parent) : QAbstractListModel(p m_dapUiQmlWidgets.append(new DapUiQmlWidget( "Services share control", "DapUiQmlWidgetChainServicesShareControl.ui.qml", "qrc:/Resources/Icons/add.png")); m_dapUiQmlWidgets.append(new DapUiQmlWidget( "Settings", "DapUiQmlWidgetChainSettings.ui.qml", "qrc:/Resources/Icons/add.png")); m_dapUiQmlWidgets.append(new DapUiQmlWidget( "Wallet", "DapUiQmlWidgetChainWallet.qml", "qrc:/Resources/Icons/add.png")); - m_dapUiQmlWidgets.append(new DapUiQmlWidget( "Logs", "DapUiQmlWidgetChainNodeLogs.ui.qml", "qrc:/Resources/Icons/add.png")); + m_dapUiQmlWidgets.append(new DapUiQmlWidget( "Logs", "DapUiQmlWidgetChainNodeLogsForm.ui.qml", "qrc:/Resources/Icons/add.png")); } DapUiQmlWidgetModel &DapUiQmlWidgetModel::getInstance() diff --git a/KelvinDashboardGUI/main.qml b/KelvinDashboardGUI/main.qml index 46dc72f93..1f58d9190 100755 --- a/KelvinDashboardGUI/main.qml +++ b/KelvinDashboardGUI/main.qml @@ -128,48 +128,70 @@ ApplicationWindow { Drawer { id: drawerMenu - width: window.width * 0.25 + width: window.width * 0.3 height: window.height - - ListView { - id: listViewMenu + Rectangle + { anchors.fill: parent - model: dapUiQmlWidgetModel - - delegate: - Component { - id: listViewItemMenu - Item { - id: itemMenu - - width: listViewMenu.width - height: textItemMenu.height + 10 - - Row { - anchors.margins: 5 - anchors.fill: parent - - Text - { - id: textItemMenu - text: qsTr(name) + color: "#353841" + + ListView { + id: listViewMenu + anchors.fill: parent + model: dapUiQmlWidgetModel + + delegate: + Component { + id: listViewItemMenu + Item { + id: itemMenu + + width: listViewMenu.width + height: textItemMenu.height + 10 + + Row { + anchors.margins: 5 + anchors.fill: parent + + Text + { + id: textItemMenu + text: qsTr(name) + color: "#BBBEBF" + font.pointSize: 12 + font.weight: Font.Light + font.family: "Roboto" + } } - } - - MouseArea { - anchors.fill: parent - onClicked: - { - listViewMenu.currentIndex = index - stackView.push(Qt.resolvedUrl(URLpage), StackView.Immediate) - drawerMenu.close() + + MouseArea { + anchors.fill: parent + onClicked: + { + listViewMenu.currentIndex = index + stackView.push(Qt.resolvedUrl(URLpage), StackView.Immediate) + drawerMenu.close() + } } - } + } + } + + highlight: + Component + { + Rectangle { + id: rectangleMenu + color: "#121B28" + Rectangle + { + height: rectangleMenu.height + width: 4 + color: "green" + } } } - - highlight: Rectangle { color: "aliceblue"; radius: 5 } - focus: true + focus: true + } } } diff --git a/KelvinDashboardGUI/qml.qrc b/KelvinDashboardGUI/qml.qrc index eedcc5cd7..ce09fd17c 100755 --- a/KelvinDashboardGUI/qml.qrc +++ b/KelvinDashboardGUI/qml.qrc @@ -18,7 +18,6 @@ <file>DapUiQmlWidgetDelegate.qml</file> <file>DapUiQmlWidgetDelegateForm.ui.qml</file> <file>DapUiQmlScreenChangeWidget.qml</file> - <file>DapUiQmlWidgetChainNodeLogs.ui.qml</file> <file>Resources/Icons/add.png</file> <file>Resources/Icons/icon.ico</file> <file>Resources/Icons/about.png</file> @@ -32,5 +31,7 @@ <file>Resources/Icons/dialog-information.png</file> <file>Resources/Icons/dialog-question.png</file> <file>Resources/Icons/dialog-warning.png</file> + <file>DapUiQmlWidgetChainNodeLogs.qml</file> + <file>DapUiQmlWidgetChainNodeLogsForm.ui.qml</file> </qresource> </RCC> diff --git a/KelvinDashboardService/DapChainDashboardService.cpp b/KelvinDashboardService/DapChainDashboardService.cpp index f1d558c5b..cf5466d8f 100755 --- a/KelvinDashboardService/DapChainDashboardService.cpp +++ b/KelvinDashboardService/DapChainDashboardService.cpp @@ -6,7 +6,6 @@ DapChainDashboardService::DapChainDashboardService() : DapRpcService(nullptr) m_pDapChainLogHandler = new DapChainLogHandler(this); m_pDapChainWalletHandler = new DapChainWalletHandler(this); - connect(this, &DapChainDashboardService::onNewClientConnected, [=] { qDebug() << "New client"; }); @@ -54,6 +53,12 @@ QMap<QString, QVariant> DapChainDashboardService::getWallets() return m_pDapChainWalletHandler->getWallets(); } +QStringList DapChainDashboardService::getWalletInfo(const QString &asWalletName) +{ + qInfo() << QString("getWalletInfo(%1)").arg(asWalletName); + return m_pDapChainWalletHandler->getWalletInfo(asWalletName); +} + /// Activate the main client window by double-clicking the application icon in the system tray. /// @param reason Type of action on the icon in the system tray. diff --git a/KelvinDashboardService/DapChainDashboardService.h b/KelvinDashboardService/DapChainDashboardService.h index 1e4f2663e..6510559e6 100755 --- a/KelvinDashboardService/DapChainDashboardService.h +++ b/KelvinDashboardService/DapChainDashboardService.h @@ -71,6 +71,8 @@ public slots: QStringList addWallet(const QString &asWalletName); QMap<QString, QVariant> getWallets(); + + QStringList getWalletInfo(const QString &asWalletName); }; diff --git a/KelvinDashboardService/DapChainLogHandler.h b/KelvinDashboardService/DapChainLogHandler.h index ed50921ab..eb4bc127a 100644 --- a/KelvinDashboardService/DapChainLogHandler.h +++ b/KelvinDashboardService/DapChainLogHandler.h @@ -1,5 +1,5 @@ -#ifndef DAPLOGREADER_H -#define DAPLOGREADER_H +#ifndef DAPCHAINLOGHANDLER_H +#define DAPCHAINLOGHANDLER_H #include <QObject> #include <QString> @@ -23,4 +23,4 @@ public slots: QStringList request(int aiTimeStamp, int aiRowCount); }; -#endif // DAPLOGREADER_H +#endif // DAPCHAINLOGHANDLER_H diff --git a/KelvinDashboardService/DapChainWalletHandler.cpp b/KelvinDashboardService/DapChainWalletHandler.cpp index b02cb255f..1277f6a6d 100644 --- a/KelvinDashboardService/DapChainWalletHandler.cpp +++ b/KelvinDashboardService/DapChainWalletHandler.cpp @@ -53,3 +53,31 @@ QMap<QString, QVariant> DapChainWalletHandler::getWallets() return map; } + +QStringList DapChainWalletHandler::getWalletInfo(const QString &asNameWallet) +{ + QProcess process; + process.start(QString("%1 wallet info -w %2 -net kelvin-testnet").arg("/home/andrey/Project/build-kelvin-node/kelvin-node-cli").arg(asNameWallet)); + process.waitForFinished(-1); + QStringList list; + QString str = QString::fromLatin1(process.readAll()).remove(" "); + QRegExp rx( "(\\\\n|:)([A-Z0-9]{1,1}[\\w\\S]+)\\\\n" ); + rx.setMinimal(true); + int pos = 0; + list = str.split(":"); + QStringList res; + for(QString s : list) + { + qDebug() << s; + if(!s.contains(":")) + res.append(s.remove(s.indexOf('\n'), s.size())); + } +qDebug() << str; +// while ((pos = rx.indexIn(str, pos)) != -1) +// { +// list.append(rx.cap(2)); +// pos += rx.matchedLength(); +// } + qDebug() << list; + return res; +} diff --git a/KelvinDashboardService/DapChainWalletHandler.h b/KelvinDashboardService/DapChainWalletHandler.h index 652890f26..53aba3763 100644 --- a/KelvinDashboardService/DapChainWalletHandler.h +++ b/KelvinDashboardService/DapChainWalletHandler.h @@ -21,6 +21,7 @@ signals: public slots: QStringList createWallet(const QString& asNameWallet); QMap<QString, QVariant> getWallets(); + QStringList getWalletInfo(const QString& asNameWallet); }; #endif // DAPCHAINWALLETHANDLER_H diff --git a/libKelvinDashboardCommon/DapChainWallet.cpp b/libKelvinDashboardCommon/DapChainWallet.cpp index 7a311014f..e3e8ce891 100644 --- a/libKelvinDashboardCommon/DapChainWallet.cpp +++ b/libKelvinDashboardCommon/DapChainWallet.cpp @@ -1,7 +1,13 @@ #include "DapChainWallet.h" +DapChainWallet::DapChainWallet(const QString &asIconPath, const QString &asName, const QString &asAddresss, const QString &aBalance, QObject *parent) + : QObject(parent), m_sIconPath(asIconPath), m_sName(asName), m_sAddress(asAddresss), m_balance(aBalance) +{ + +} + DapChainWallet::DapChainWallet(const QString &asIconPath, const QString &asName, const QString &asAddresss, QObject *parent) - : QObject(parent), m_sIconPath(asIconPath), m_sName(asName), m_sAddress(asAddresss) + : DapChainWallet(asIconPath, asName, asAddresss, 0, parent) { } @@ -41,3 +47,15 @@ void DapChainWallet::setAddress(const QString &asAddress) emit addressChanged(m_sAddress); } + +QString DapChainWallet::getBalance() const +{ + return m_balance; +} + +void DapChainWallet::setBalance(const QString &aBalance) +{ + m_balance = aBalance; + + emit balanceChanged(m_balance); +} diff --git a/libKelvinDashboardCommon/DapChainWallet.h b/libKelvinDashboardCommon/DapChainWallet.h index 11f0d0cb2..152a7c1b0 100644 --- a/libKelvinDashboardCommon/DapChainWallet.h +++ b/libKelvinDashboardCommon/DapChainWallet.h @@ -11,14 +11,18 @@ class DapChainWallet : public QObject QString m_sIconPath; QString m_sName; QString m_sAddress; + QString m_balance; public: - DapChainWallet(QObject *parent = nullptr) {} + DapChainWallet(QObject *parent = nullptr) { Q_UNUSED(parent)} + DapChainWallet(const QString& asIconPath, const QString &asName, const QString &asAddresss, const QString &aBalance, QObject * parent = nullptr); DapChainWallet(const QString& asIconPath, const QString &asName, const QString &asAddresss, QObject * parent = nullptr); + Q_PROPERTY(QString iconPath MEMBER m_sIconPath READ getIconPath WRITE setIconPath NOTIFY iconPathChanged) Q_PROPERTY(QString name MEMBER m_sName READ getName WRITE setName NOTIFY nameChanged) Q_PROPERTY(QString address MEMBER m_sAddress READ getAddress WRITE setAddress NOTIFY addressChanged) + Q_PROPERTY(QString balance MEMBER m_balance READ getBalance WRITE setBalance NOTIFY balanceChanged) QString getName() const; void setName(const QString &asName); @@ -28,10 +32,14 @@ public: QString getIconPath() const; void setIconPath(const QString &asIconPath); + QString getBalance() const; + void setBalance(const QString& aBalance); + signals: void iconPathChanged(const QString& asIconPath); void nameChanged(const QString& asName); void addressChanged(const QString& asAddress); + void balanceChanged(const QString& aBalance); }; diff --git a/libKelvinDashboardCommon/DapLogModel.cpp b/libKelvinDashboardCommon/DapLogModel.cpp index 653c0a070..1921eea71 100644 --- a/libKelvinDashboardCommon/DapLogModel.cpp +++ b/libKelvinDashboardCommon/DapLogModel.cpp @@ -23,25 +23,15 @@ QVariant DapLogModel::data(const QModelIndex &index, int role) const case TypeRole: switch (m_dapLogMessage.at(index.row())->getType()) { case Type::Info: - return "INF"; + return "qrc:/Resources/Icons/dialog-information.png"; case Type::Warning: - return "WRG"; + return "qrc:/Resources/Icons/dialog-warning.png"; case Type::Error: - return "ERR"; + return "qrc:/Resources/Icons/dialog-error.png"; case Type::Debug: - return "DBG"; + return "qrc:/Resources/Icons/dialog-question.png"; default: break; -// case Type::Info: -// return "qrc:/Resources/Icons/dialog-information.png"; -// case Type::Warning: -// return "qrc:/Resources/Icons/dialog-warning.png"; -// case Type::Error: -// return "qrc:/Resources/Icons/dialog-error.png"; -// case Type::Debug: -// return "qrc:/Resources/Icons/dialog-question.png"; -// default: -// break; } case TimeStampRole: return m_dapLogMessage.at(index.row())->getTimeStamp(); -- GitLab