From 896e6035b80baea7f34a406e2ed74e6304ab881a Mon Sep 17 00:00:00 2001 From: jonymt <johanmt@yandex.ru> Date: Thu, 19 Sep 2019 11:39:52 +0200 Subject: [PATCH] [*] added comments and code refactoring --- KelvinDashboardGUI/DapCommandController.h | 8 ++-- KelvinDashboardGUI/DapConsoleModel.h | 9 +++-- KelvinDashboardGUI/DapServiceController.h | 7 ++-- ...m.qml => DapUiQmlScreenConsoleForm.ui.qml} | 0 .../DapUiQmlScreenMainWindowForm.ui.qml | 2 +- ...soleForm.qml => DapUiQmlWidgetConsole.qml} | 15 +++---- .../DapUiQmlWidgetConsoleForm.ui.qml | 12 ++++++ ...mlWidgetConsoleLastActionsDelegateForm.qml | 1 - .../DapUiQmlWidgetConsoleLastActionsForm.qml | 40 ------------------- KelvinDashboardGUI/qml.qrc | 5 ++- .../DapChainConsoleHandler.h | 5 +++ .../DapChainDashboardService.h | 9 +++-- 12 files changed, 47 insertions(+), 66 deletions(-) rename KelvinDashboardGUI/{DapUiQmlScreenConsoleForm.qml => DapUiQmlScreenConsoleForm.ui.qml} (100%) rename KelvinDashboardGUI/{DapUiQmlWidgetConsoleForm.qml => DapUiQmlWidgetConsole.qml} (87%) create mode 100644 KelvinDashboardGUI/DapUiQmlWidgetConsoleForm.ui.qml diff --git a/KelvinDashboardGUI/DapCommandController.h b/KelvinDashboardGUI/DapCommandController.h index 7596180dc..f04ea3f1a 100755 --- a/KelvinDashboardGUI/DapCommandController.h +++ b/KelvinDashboardGUI/DapCommandController.h @@ -48,9 +48,9 @@ signals: void onLogModel(); /// Signal for sending new transaction history void sendHistory(const QVariant& aData); - + /// Response from service about command request void responseConsole(const QString& aResponse); - + /// Signal about changing history of commands void sigCmdHistory(const QString& aHistory); public: @@ -118,9 +118,9 @@ public slots: void getHistory(); /// Send to model new history void setNewHistory(const QVariant& aData); - + /// Commands request void requestConsole(const QString& aQueue); - + /// Get command history void getCmdHistory(); }; diff --git a/KelvinDashboardGUI/DapConsoleModel.h b/KelvinDashboardGUI/DapConsoleModel.h index 428983a44..00bd228e4 100644 --- a/KelvinDashboardGUI/DapConsoleModel.h +++ b/KelvinDashboardGUI/DapConsoleModel.h @@ -47,9 +47,11 @@ public slots: /// Receive command requst for service /// @param command request Q_INVOKABLE void receiveRequest(const QString& aCommand); - + /// Get current history + /// @return history of commands Q_INVOKABLE QString getCmdHistory(); - + /// Receive new history of commands + /// @param last 50 commands void receiveCmdHistory(const QString& aHistory); signals: @@ -59,7 +61,8 @@ signals: /// Signal for getting response from service /// @param result of command void sendResponse(QString response); - + /// Signal for view about changing history + /// @param last 50 commands void cmdHistoryChanged(QString history); }; diff --git a/KelvinDashboardGUI/DapServiceController.h b/KelvinDashboardGUI/DapServiceController.h index 7dc055314..466336609 100755 --- a/KelvinDashboardGUI/DapServiceController.h +++ b/KelvinDashboardGUI/DapServiceController.h @@ -68,19 +68,20 @@ public: /// @param aiTimeStamp Timestamp start reading logging. /// @param aiRowCount Number of lines displayed. void getNodeLogs(int aiTimeStamp, int aiRowCount) const; - + /// Get wallets Q_INVOKABLE void getWallets() const; DapLogModel getLogModel() const; void setLogModel(const DapLogModel &dapLogModel); - + /// Add new wallet + /// @param wallet Q_INVOKABLE void addWallet(const QString& asWalletName); Q_INVOKABLE void removeWallet(int index, const QString& asWalletName); Q_INVOKABLE void sendToken(const QString &asSendWallet, const QString& asAddressReceiver, const QString& asToken, const QString& aAmount); Q_INVOKABLE void executeCommand(const QString& command); void getWalletInfo(const QString& asWalletName); - + /// Get history of commands void getCmdHistory(); signals: diff --git a/KelvinDashboardGUI/DapUiQmlScreenConsoleForm.qml b/KelvinDashboardGUI/DapUiQmlScreenConsoleForm.ui.qml similarity index 100% rename from KelvinDashboardGUI/DapUiQmlScreenConsoleForm.qml rename to KelvinDashboardGUI/DapUiQmlScreenConsoleForm.ui.qml diff --git a/KelvinDashboardGUI/DapUiQmlScreenMainWindowForm.ui.qml b/KelvinDashboardGUI/DapUiQmlScreenMainWindowForm.ui.qml index 2604654a6..da3b890a6 100644 --- a/KelvinDashboardGUI/DapUiQmlScreenMainWindowForm.ui.qml +++ b/KelvinDashboardGUI/DapUiQmlScreenMainWindowForm.ui.qml @@ -64,7 +64,7 @@ Page { } ListElement { name: qsTr("Console") - page: "DapUiQmlScreenConsoleForm.qml" + page: "DapUiQmlScreenConsoleForm.ui.qml" source: "qrc:/Resources/Icons/defaul_icon.png" } ListElement { diff --git a/KelvinDashboardGUI/DapUiQmlWidgetConsoleForm.qml b/KelvinDashboardGUI/DapUiQmlWidgetConsole.qml similarity index 87% rename from KelvinDashboardGUI/DapUiQmlWidgetConsoleForm.qml rename to KelvinDashboardGUI/DapUiQmlWidgetConsole.qml index 159660d82..7610a2b08 100644 --- a/KelvinDashboardGUI/DapUiQmlWidgetConsoleForm.qml +++ b/KelvinDashboardGUI/DapUiQmlWidgetConsole.qml @@ -5,6 +5,9 @@ import QtQuick.Layouts 1.13 Rectangle { + property alias textAreaCmdHistory: txtCommand + property alias textAreaCmd: consoleCmd + ColumnLayout { anchors.fill: parent @@ -20,9 +23,6 @@ Rectangle { text: dapConsoleModel.getCmdHistory(); selectByMouse: true wrapMode: TextArea.WordWrap - color: "#707070" - font.family: "Roboto" - font.pixelSize: 20 * pt Keys.onPressed: { switch(event.key) @@ -48,9 +48,9 @@ Rectangle { id: promt verticalAlignment: Qt.AlignVCenter text: ">" - color: "#707070" - font.family: "Roboto" - font.pixelSize: 20 * pt + color: consoleCmd.color + font.family: consoleCmd.font.family + font.pixelSize: consoleCmd.font.pixelSize } TextArea { @@ -59,9 +59,6 @@ Rectangle { Layout.fillWidth: true height: contentChildren.height wrapMode: TextArea.Wrap - color: "#707070" - font.family: "Roboto" - font.pixelSize: 20 * pt placeholderText: qsTr("Type here...") selectByMouse: true focus: true diff --git a/KelvinDashboardGUI/DapUiQmlWidgetConsoleForm.ui.qml b/KelvinDashboardGUI/DapUiQmlWidgetConsoleForm.ui.qml new file mode 100644 index 000000000..1b3ac691d --- /dev/null +++ b/KelvinDashboardGUI/DapUiQmlWidgetConsoleForm.ui.qml @@ -0,0 +1,12 @@ +import QtQuick 2.4 +import QtQuick.Controls 2.5 +import QtQuick.Layouts 1.13 + +DapUiQmlWidgetConsole { + textAreaCmdHistory.color: "#707070" + textAreaCmdHistory.font.family: "Roboto" + textAreaCmdHistory.font.pixelSize: 20 * pt + textAreaCmd.color: "#707070" + textAreaCmd.font.family: "Roboto" + textAreaCmd.font.pixelSize: 20 * pt +} diff --git a/KelvinDashboardGUI/DapUiQmlWidgetConsoleLastActionsDelegateForm.qml b/KelvinDashboardGUI/DapUiQmlWidgetConsoleLastActionsDelegateForm.qml index 5abde372b..3092bc5c1 100644 --- a/KelvinDashboardGUI/DapUiQmlWidgetConsoleLastActionsDelegateForm.qml +++ b/KelvinDashboardGUI/DapUiQmlWidgetConsoleLastActionsDelegateForm.qml @@ -28,5 +28,4 @@ Component { height: 18 * pt } } - } diff --git a/KelvinDashboardGUI/DapUiQmlWidgetConsoleLastActionsForm.qml b/KelvinDashboardGUI/DapUiQmlWidgetConsoleLastActionsForm.qml index 3b4752826..d2ffab088 100644 --- a/KelvinDashboardGUI/DapUiQmlWidgetConsoleLastActionsForm.qml +++ b/KelvinDashboardGUI/DapUiQmlWidgetConsoleLastActionsForm.qml @@ -5,44 +5,4 @@ DapUiQmlWidgetLastActions { id: lastActionsPanel viewModel: dapConsoleModel viewDelegate: DapUiQmlWidgetConsoleLastActionsDelegateForm {} -// width: lastActionsPanel.width -// height: 60 * pt -// anchors.left: parent.left -// anchors.right: parent.right -// anchors.leftMargin: 18 * pt -// anchors.rightMargin: 18 * pt -// } - -// viewDelegate: Component { - -// ColumnLayout { -// anchors.left: parent.left -// anchors.right: parent.right -// anchors.leftMargin: 18 * pt -// anchors.rightMargin: 18 * pt - -// Rectangle { -// height: 18 * pt -// } - -// Text { -// id: textLastCmd -// Layout.fillWidth: true -//// anchors.fill: parent -// verticalAlignment: Qt.AlignVCenter -// wrapMode: Text.Wrap -// text: lastCommand -// color: "#5F5F63" -// font.family: "Roboto Regular" -// font.pixelSize: 14 * pt -// clip: true -// } - -// Rectangle { -// height: 18 * pt -// } -// } - -// } - } diff --git a/KelvinDashboardGUI/qml.qrc b/KelvinDashboardGUI/qml.qrc index 908f54038..848c3ce91 100755 --- a/KelvinDashboardGUI/qml.qrc +++ b/KelvinDashboardGUI/qml.qrc @@ -56,9 +56,10 @@ <file>DapUiQmlWidgetLastActions.qml</file> <file>DapUiQmlWidgetLastActionsForm.ui.qml</file> <file>DapUiQmlScreenHistoryForm.ui.qml</file> - <file>DapUiQmlScreenConsoleForm.qml</file> - <file>DapUiQmlWidgetConsoleForm.qml</file> + <file>DapUiQmlScreenConsoleForm.ui.qml</file> <file>DapUiQmlWidgetConsoleLastActionsForm.qml</file> <file>DapUiQmlWidgetConsoleLastActionsDelegateForm.qml</file> + <file>DapUiQmlWidgetConsole.qml</file> + <file>DapUiQmlWidgetConsoleForm.ui.qml</file> </qresource> </RCC> diff --git a/KelvinDashboardService/DapChainConsoleHandler.h b/KelvinDashboardService/DapChainConsoleHandler.h index f64fe62cf..907c47e6b 100644 --- a/KelvinDashboardService/DapChainConsoleHandler.h +++ b/KelvinDashboardService/DapChainConsoleHandler.h @@ -16,7 +16,12 @@ private: public: explicit DapChainConsoleHandler(QObject *parent = nullptr); + /// Get history of commands + /// @return history QString getHistory() const; + /// Get result of command + /// @param command + /// @return command result QString getResult(const QString& aQuery) const; }; diff --git a/KelvinDashboardService/DapChainDashboardService.h b/KelvinDashboardService/DapChainDashboardService.h index 5f9837d0d..52fd3438c 100755 --- a/KelvinDashboardService/DapChainDashboardService.h +++ b/KelvinDashboardService/DapChainDashboardService.h @@ -49,7 +49,7 @@ class DapChainDashboardService : public DapRpcService DapChainNodeNetworkHandler * m_pDapChainNodeHandler {nullptr}; /// Recipient history of transactions DapChainHistoryHandler* m_pDapChainHistoryHandler {nullptr}; - + /// Recipient history of commands DapChainConsoleHandler* m_pDapChainConsoleHandler {nullptr}; public: @@ -105,9 +105,12 @@ public slots: /// Get history /// @return QList data history QVariant getHistory() const; - + /// Get result for command + /// @param command + /// @return result QString getQueryResult(const QString& aQuery) const; - + /// Get history of commands + /// @return history of last 50 commands QString getCmdHistory() const; private slots: -- GitLab