Skip to content
Snippets Groups Projects
Commit b35a8af9 authored by jonymt's avatar jonymt
Browse files

[+] added handler

parent bd834faa
No related branches found
No related tags found
1 merge request!11Cellframe clone
Showing
with 136 additions and 116 deletions
import QtQuick 2.9
import QtQml 2.12
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.12
Page {
TextEdit {
id: txtCommands
property int positionLine: 2
anchors.fill: parent
text: "> "
wrapMode: TextEdit.WordWrap
onTextChanged: {
if(txtCommands.cursorPosition === txtCommands.positionLine)
{
txtCommands.text += " ";
txtCommands.cursorPosition = txtCommands.text.length
}
}
function acceptedResopose(responce)
{
txtCommands.readOnly = false;
txtCommands.append(responce);
txtCommands.append("> ");
console.debug(txtCommands.positionLine);
console.debug(txtCommands.cursorPosition);
txtCommands.positionLine = txtCommands.cursorPosition + 1;
}
Keys.onPressed: {
switch(event.key)
{
case Qt.Key_Up: console.debug("UP"); break;
case Qt.Key_Down: console.debug("Down"); break;
default: break;
}
}
Keys.onReturnPressed: {
console.debug("ENTER");
txtCommands.readOnly = true;
acceptedResopose("New resp");
}
}
}
......@@ -51,6 +51,13 @@ Page {
page: "DapUiQmlScreenHistory.qml"
source: "qrc:/Resources/Icons/defaul_icon.png"
}
ListElement {
name: qsTr("Console")
page: "DapUiQmlScreenConsoleForm.qml"
source: "qrc:/Resources/Icons/defaul_icon.png"
}
ListElement {
name: qsTr("About")
page: "DapQmlScreenAbout.qml"
......
#include "DapUiQmlWidgetConsole.h"
DapUiQmlWidgetConsole::DapUiQmlWidgetConsole(QObject *parent) : QObject(parent)
{
}
#ifndef DAPUIQMLSCREENCONSOLEFORM_H
#define DAPUIQMLSCREENCONSOLEFORM_H
#include <QObject>
#include <QPlainTextEdit>
class DapUiQmlWidgetConsole : public QObject
{
Q_OBJECT
public:
explicit DapUiQmlWidgetConsole(QObject *parent = nullptr);
public slots:
signals:
};
#endif // DAPUIQMLSCREENCONSOLEFORM_H
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}
}
##^##*/
......@@ -45,6 +45,7 @@ SOURCES += \
DapScreenHistoryFilterModel.cpp \
DapScreenHistoryModel.cpp \
DapUiQmlWidgetChainTransactions.cpp \
DapUiQmlWidgetConsole.cpp \
main.cpp \
DapUiQmlWidgetChainBallance.cpp \
DapUiQmlWidgetChainBlockExplorer.cpp \
......@@ -86,6 +87,7 @@ HEADERS += \
DapUiQmlScreenDashboard.h \
DapUiQmlWidgetChainOperations.h \
DapUiQmlWidgetChainTransactions.h \
DapUiQmlWidgetConsole.h \
DapUiQmlWidgetModel.h \
DapUiQmlWidget.h \
DapScreenDialog.h \
......
......@@ -23,7 +23,7 @@
#include "DapChainNodeNetworkModel.h"
#include "DapChainNodeNetworkExplorer.h"
#include "DapScreenHistoryFilterModel.h"
#include "DapUiQmlWidgetConsole.h"
#include <QRegExp>
......@@ -66,6 +66,7 @@ int main(int argc, char *argv[])
// qmlRegisterType<DapScreenHistoryModel>("")
qmlRegisterSingletonType<DapUiQmlWidgetModel>("KelvinDashboard", 1, 0, "DapUiQmlWidgetModel", DapUiQmlWidgetModel::singletonProvider);
qmlRegisterType<DapScreenHistoryModel>("DapTransactionHistory", 1, 0, "DapTransactionModel");
qmlRegisterType<DapUiQmlWidgetConsole>("QmlWidgetConsole", 1, 0, "DapUiQmlWidgetConsole");
QQmlApplicationEngine engine;
// qreal dpi = QGuiApplication::primaryScreen()->physicalDotsPerInch();
......
......@@ -24,10 +24,9 @@
<file>DapUiQmlWidgetChainNodeLogsForm.ui.qml</file>
<file>DapUiQmlScreenDialogSendToken.qml</file>
<file>DapUiQmlScreenDialogRemoveWallet.qml</file>
<file>DapUiQmlWidgetConsoleForm.ui.qml</file>
<file>DapUiQmlWidgetConsole.qml</file>
<file>DapUiQmlWidgetNodeNetworkExplorer.qml</file>
<file>DapUiQmlScreenHistory.qml</file>
<file>Resources/Icons/defaul_icon.png</file>
<file>Resources/Icons/defaul_icon.png</file>
<file>DapUiQmlScreenConsoleForm.qml</file>
</qresource>
</RCC>
#include "DapChainConsoleHandler.h"
DapChainConsoleHandler::DapChainConsoleHandler(QObject *parent) : QObject(parent)
{
}
QString DapChainConsoleHandler::getResult(const QString& aQuery) const
{
QProcess process;
process.start(QString(CLI_PATH) + " " + aQuery);
process.waitForFinished(-1);
return QString::fromStdString(process.readAll().toStdString());
}
#ifndef DAPCHAINCONSOLEHANDLER_H
#define DAPCHAINCONSOLEHANDLER_H
#include <QObject>
#include <QProcess>
class DapChainConsoleHandler : public QObject
{
Q_OBJECT
public:
explicit DapChainConsoleHandler(QObject *parent = nullptr);
QString getResult(const QString& aQuery) const;
};
#endif // DAPCHAINCONSOLEHANDLER_H
......@@ -16,6 +16,9 @@ DapChainDashboardService::DapChainDashboardService() : DapRpcService(nullptr)
m_pDapChainHistoryHandler = new DapChainHistoryHandler {this};
QObject::connect(m_pDapChainHistoryHandler, &DapChainHistoryHandler::requsetWallets, this, &DapChainDashboardService::doRequestWallets);
QObject::connect(m_pDapChainHistoryHandler, &DapChainHistoryHandler::changeHistory, this, &DapChainDashboardService::doSendNewHistory);
m_pDapChainConsoleHandler = new DapChainConsoleHandler(this);
}
bool DapChainDashboardService::start()
......@@ -89,6 +92,11 @@ QVariant DapChainDashboardService::getHistory() const
return m_pDapChainHistoryHandler->getHistory();
}
QString DapChainDashboardService::getQueryResult(const QString& aQuery) const
{
return m_pDapChainConsoleHandler->getResult(aQuery);
}
void DapChainDashboardService::doRequestWallets()
{
m_pDapChainHistoryHandler->onRequestNewHistory(m_pDapChainWalletHandler->getWallets());
......
......@@ -27,6 +27,7 @@
#include "DapChainWalletHandler.h"
#include "DapChainNodeNetworkHandler.h"
#include "DapChainHistoryHandler.h"
#include "DapChainConsoleHandler.h"
#include <QLocalServer>
typedef class DapRpcLocalServer DapUiService;
......@@ -49,6 +50,8 @@ class DapChainDashboardService : public DapRpcService
DapChainHistoryHandler* m_pDapChainHistoryHandler {nullptr};
DapChainConsoleHandler* m_pDapChainConsoleHandler {nullptr};
public:
/// Standard сonstructor.
explicit DapChainDashboardService();
......@@ -92,6 +95,8 @@ public slots:
QVariant getHistory() const;
QString getQueryResult(const QString& aQuery) const;
private slots:
void doRequestWallets();
void doSendNewHistory(const QVariant& aData);
......
......@@ -48,7 +48,8 @@ SOURCES += \
$$PWD/DapChainNode.cpp \
$$PWD/DapChainNodeCache.cpp \
$$PWD/DapChainWalletHandler.cpp \
$$PWD/DapChainLogHandler.cpp
$$PWD/DapChainLogHandler.cpp \
DapChainConsoleHandler.cpp
HEADERS += \
$$PWD/DapChainDashboardService.h \
......@@ -57,7 +58,8 @@ HEADERS += \
$$PWD/DapChainNodeCache.h \
$$PWD/DapChainNodeNetworkHandler.h \
$$PWD/DapChainWalletHandler.h \
$$PWD/DapChainLogHandler.h
$$PWD/DapChainLogHandler.h \
DapChainConsoleHandler.h
include (../libdap/libdap.pri)
include (../libdap-crypto/libdap-crypto.pri)
......
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