Skip to content
Snippets Groups Projects
Commit 03ddc94d authored by user's avatar user
Browse files

Ayupov Roman(test task)

parent 00e420c4
No related branches found
No related tags found
No related merge requests found
......@@ -124,6 +124,22 @@ void DapCommandController::processGetWalletInfo()
emit sigWalletInfoChanged(name, address, balance, tokens);
}
void DapCommandController::processExecuteCommand()
{
qInfo() << "processGetWalletInfo()";
DapRpcServiceReply *reply = static_cast<DapRpcServiceReply *>(sender());
if (!reply || reply->response().result().toVariant().toStringList().isEmpty()) {
QString result = "Invalid response received";
qWarning() << result;
emit executeCommandChanged(result);
return;
}
emit sigCommandResult(reply->response().result());
QString result = reply->response().result().toVariant().toStringList().at(0);
emit executeCommandChanged(result);
}
/// 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.
......@@ -180,3 +196,10 @@ void DapCommandController::getWalletInfo(const QString& asWalletName)
DapRpcServiceReply *reply = m_DAPRpcSocket->invokeRemoteMethod("RPCServer.getWalletInfo", asWalletName);
connect(reply, SIGNAL(finished()), this, SLOT(processGetWalletInfo()));
}
void DapCommandController::executeCommand(const QString &command)
{
qInfo() << QString("rpc executeCommand(%1)").arg(command);
DapRpcServiceReply *reply = m_DAPRpcSocket->invokeRemoteMethod("RPCServer.executeCommand", command);
connect(reply, SIGNAL(finished()), this, SLOT(processExecuteCommand()));
}
......@@ -37,6 +37,7 @@ signals:
void sigWalletInfoChanged(const QString& asWalletName, const QString& asWalletAddress, const QStringList& aBalance, const QStringList& aTokens);
void executeCommandChanged(const QString& result);
public:
/// Overloaded constructor.
/// @param apIODevice Data transfer device.
......@@ -58,6 +59,7 @@ private slots:
void processGetWalletInfo();
void processExecuteCommand();
public slots:
/// Show or hide GUI client by clicking on the tray icon.
/// @param aIsActivated Accepts true - when requesting to
......@@ -77,6 +79,8 @@ public slots:
void getWallets();
void getWalletInfo(const QString& asWalletName);
void executeCommand(const QString& command);
};
#endif // COMMANDCONTROLLER_H
......@@ -47,6 +47,9 @@ void DapServiceController::init(DapServiceClient *apDapServiceClient)
connect(m_pDapCommandController, SIGNAL(sigWalletInfoChanged(QString,QString, QStringList, QStringList)), SLOT(processGetWalletInfo(QString,QString, QStringList, QStringList)));
connect(m_pDapCommandController, SIGNAL(onTokenSended(QString)), SLOT(processSendToken(QString)));
connect(m_pDapCommandController, SIGNAL(executeCommandChanged(QString)), SLOT(processExecuteCommandInfo(QString)));
}
QString DapServiceController::getBrand() const
......@@ -61,6 +64,11 @@ QString DapServiceController::getVersion() const
return m_sVersion;
}
QString DapServiceController::getResult()
{
return m_sResult;
}
/// Get node logs.
/// @param aiTimeStamp Timestamp start reading logging.
/// @param aiRowCount Number of lines displayed.
......@@ -122,10 +130,9 @@ void DapServiceController::addWallet(const QString &asWalletName)
void DapServiceController::removeWallet(int index, const QString &asWalletName)
{
qInfo() << QString("removeWallet(%1)").arg(index);
qInfo() << QString("removeWallet(%1)").arg(asWalletName);
m_pDapCommandController->removeWallet(asWalletName.trimmed());
DapChainWalletsModel::getInstance().remove(index);
qInfo() << QString("removeWallet(%1)").arg(asWalletName);
m_pDapCommandController->removeWallet(asWalletName.trimmed());
DapChainWalletsModel::getInstance().remove(index);
}
void DapServiceController::sendToken(const QString &asSendWallet, const QString &asAddressReceiver, const QString &asToken, const QString &aAmount)
......@@ -134,6 +141,13 @@ void DapServiceController::sendToken(const QString &asSendWallet, const QString
m_pDapCommandController->sendToken(asSendWallet.trimmed(), asAddressReceiver.trimmed(), asToken.trimmed(), aAmount);
}
void DapServiceController::executeCommand(const QString& command)
{
qInfo() << QString("executeCommand (%1)").arg(command);
m_pDapCommandController->executeCommand(command);
}
void DapServiceController::getWalletInfo(const QString &asWalletName)
{
qInfo() << QString("getWalletInfo(%1)").arg(asWalletName);
......@@ -172,6 +186,13 @@ void DapServiceController::processGetWalletInfo(const QString &asWalletName, con
}
}
void DapServiceController::processExecuteCommandInfo(const QString &result)
{
qInfo() << QString("processExecuteCommandInfo(%1)").arg(result);
m_sResult = result;
emit resultChanged();
}
/// Get an instance of a class.
/// @return Instance of a class.
DapServiceController &DapServiceController::getInstance()
......
......@@ -22,7 +22,9 @@ class DapServiceController : public QObject
QString m_sBrand {DAP_BRAND};
/// Application version.
QString m_sVersion {DAP_VERSION};
/// Result execute.
QString m_sResult;
/// Service connection management service.
DapServiceClient *m_pDapServiceClient {nullptr};
/// RPC protocol controller.
......@@ -45,7 +47,9 @@ 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)
/// Result execute command.
Q_PROPERTY(QString Result MEMBER m_sVersion READ getResult NOTIFY resultChanged)
///********************************************
/// Interface
/// *******************************************
......@@ -56,6 +60,9 @@ public:
/// Get app version.
/// @return Application version.
QString getVersion() const;
/// Get result command execute.
/// @return Result execute.
QString getResult();
/// Get node logs.
/// @param aiTimeStamp Timestamp start reading logging.
/// @param aiRowCount Number of lines displayed.
......@@ -69,6 +76,7 @@ public:
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);
......@@ -77,11 +85,13 @@ signals:
void brandChanged(const QString &brand);
/// The signal is emitted when the Application version property changes.
void versionChanged(const QString &version);
/// The signal is emitted when the result execute property changes.
void resultChanged();
/// The signal is emitted when the main application window is activated.
void activateWindow();
/// The signal is emitted when checking the existence of an already running copy of the application.
void isExistenceClient(bool isExistenceClient);
void sendToQML(QString);
private slots:
/// Handling service response for receiving node logs.
/// @param aNodeLogs List of node logs.
......@@ -95,6 +105,8 @@ private slots:
void processGetWalletInfo(const QString& asWalletName, const QString& asWalletAddress, const QStringList &aBalance, const QStringList& aTokens);
void processExecuteCommandInfo(const QString& result);
public slots:
/// Show or hide GUI client by clicking on the tray icon.
/// @param aIsActivated Accepts true - when requesting to
......
import QtQuick 2.9
import QtQuick.Controls 1.4
import QtQuick.Controls 2.2
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
DapUiQmlWidgetConsoleForm {
id: dapQmlWidgetConsole
execute.onClicked: {
dapServiceController.executeCommand(command.text)
execute.enabled = false;
}
Connections {
target: dapServiceController
onResultChanged: {
command.clear()
result.text = dapServiceController.Result
execute.enabled = true
}
}
}
import QtQuick 2.9
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.1
Page {
id: dapUiQmlWidgetConsole
property alias result: result
property alias command: command
property alias execute: execute
Rectangle {
id: rectangle
y: 0
width: 640
height: 480
color: "#ffffff"
anchors.left: parent.left
anchors.leftMargin: 0
anchors.verticalCenter: parent.verticalCenter
border.width: 0
Button {
id: execute
x: 250
y: 366
text: qsTr("Execute")
anchors.horizontalCenterOffset: 0
anchors.bottom: parent.bottom
anchors.bottomMargin: 74
anchors.horizontalCenter: parent.horizontalCenter
}
TextEdit {
id: command
x: 290
y: 50
width: 606
height: 208
anchors.horizontalCenterOffset: 4
anchors.horizontalCenter: parent.horizontalCenter
font.pixelSize: 12
}
Label {
id: result
y: 422
width: 606
height: 50
text: qsTr("")
anchors.left: parent.left
anchors.leftMargin: 21
anchors.bottom: parent.bottom
anchors.bottomMargin: 8
}
Label {
id: commandText
x: 21
y: 24
width: 82
height: 14
text: qsTr("Command:")
anchors.left: parent.left
anchors.leftMargin: 21
}
Label {
id: resultText
x: 21
y: 409
text: qsTr("Result:")
}
}
}
/*##^## Designer {
D{i:0;autoSize:true;height:480;width:640}
}
##^##*/
......@@ -9,6 +9,7 @@ DapUiQmlWidgetModel::DapUiQmlWidgetModel(QObject *parent) : QAbstractListModel(p
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", "DapUiQmlWidgetChainNodeLogsForm.ui.qml", "qrc:/Resources/Icons/add.png"));
m_dapUiQmlWidgets.append(new DapUiQmlWidget( "Console cli", "DapUiQmlWidgetConsole.qml", "qrc:/Resources/Icons/add.png"));
}
DapUiQmlWidgetModel &DapUiQmlWidgetModel::getInstance()
......
......@@ -35,5 +35,7 @@
<file>DapUiQmlWidgetChainNodeLogsForm.ui.qml</file>
<file>DapUiQmlScreenDialogSendToken.qml</file>
<file>DapUiQmlScreenDialogRemoveWallet.qml</file>
<file>DapUiQmlWidgetConsoleForm.ui.qml</file>
<file>DapUiQmlWidgetConsole.qml</file>
</qresource>
</RCC>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment