Skip to content
Snippets Groups Projects
Commit 74899aef authored by Evgenii Tagiltsev's avatar Evgenii Tagiltsev
Browse files

Merge branch 'master' into bugs-2546

parents 405babd5 63450f56
No related branches found
No related tags found
1 merge request!11Cellframe clone
Showing
with 302 additions and 7 deletions
......@@ -45,6 +45,7 @@ SOURCES += \
DapConsoleModel.cpp \
DapScreenHistoryFilterModel.cpp \
DapScreenHistoryModel.cpp \
DapSettingsNetworkModel.cpp \
DapUiQmlWidgetChainTransactions.cpp \
main.cpp \
DapUiQmlWidgetChainBallance.cpp \
......@@ -82,6 +83,7 @@ HEADERS += \
DapConsoleModel.h \
DapScreenHistoryFilterModel.h \
DapScreenHistoryModel.h \
DapSettingsNetworkModel.h \
DapUiQmlWidgetChainBallance.h \
DapUiQmlWidgetChainBlockExplorer.h \
DapUiQmlWidgetChainNodeLogs.h \
......@@ -117,4 +119,6 @@ unix: !mac : !android {
INSTALLS += gui_target
}
DISTFILES +=
#DISTFILES += \
# DapUiQmlScreenSettings.qml \
# DapUiQmlScreenSettingsForm.ui.qml
......@@ -70,6 +70,11 @@ void DapCommandController::getCmdHistory()
connect(reply, SIGNAL(finished()), this, SLOT(processGetCmdHistory()));
}
void DapCommandController::changeCurrentNetwork(const QString& aNetwork)
{
m_DAPRpcSocket->invokeRemoteMethod("RPCServer.changeCurrentNetwork", aNetwork);
}
void DapCommandController::processChangedLog()
{
// QStringList tempLogModel;
......@@ -193,7 +198,6 @@ void DapCommandController::processExecuteCommand()
void DapCommandController::processGetHistory()
{
qDebug() << "processGetHistory()";
DapRpcServiceReply *reply = static_cast<DapRpcServiceReply *>(sender());
QVariant result = reply->response().result().toArray().toVariantList();
emit sendHistory(result);
......@@ -213,6 +217,13 @@ void DapCommandController::processGetCmdHistory()
emit sigCmdHistory(result);
}
void DapCommandController::processGetNetworkList()
{
DapRpcServiceReply *reply = static_cast<DapRpcServiceReply *>(sender());
QStringList result = reply->response().result().toVariant().toStringList();
emit sendNetworkList(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.
......@@ -266,6 +277,12 @@ void DapCommandController::getNodeNetwork()
connect(reply, SIGNAL(finished()), this, SLOT(processGetNodeNetwork()));
}
void DapCommandController::getNetworkList()
{
DapRpcServiceReply *reply = m_DAPRpcSocket->invokeRemoteMethod("RPCServer.getNetworkList");
connect(reply, SIGNAL(finished()), this, SLOT(processGetNetworkList()));
}
void DapCommandController::setNodeStatus(const bool aIsOnline)
{
/*DapRpcServiceReply *reply =*/ m_DAPRpcSocket->invokeRemoteMethod("RPCServer.setNodeStatus", aIsOnline);
......
......@@ -51,6 +51,8 @@ signals:
/// Signal about changing history of commands
void sigCmdHistory(const QString& aHistory);
void sendNetworkList(const QStringList& aList);
public:
/// Overloaded constructor.
/// @param apIODevice Data transfer device.
......@@ -80,6 +82,8 @@ private slots:
void processGetHistory();
void processGetNetworkList();
void processResponseConsole();
void processGetCmdHistory();
......@@ -104,6 +108,8 @@ public slots:
void getNodeNetwork();
void getNetworkList();
void setNodeStatus(const bool aIsOnline);
void executeCommand(const QString& command);
......@@ -119,6 +125,8 @@ public slots:
void requestConsole(const QString& aQueue);
/// Get command history
void getCmdHistory();
void changeCurrentNetwork(const QString& aNetwork);
};
#endif // COMMANDCONTROLLER_H
......@@ -50,7 +50,6 @@ void DapScreenHistoryModel::receiveNewData(const QVariant& aData)
return;
}
qDebug() << aData;
beginResetModel();
QList<QVariant> dataList = aData.toList();
m_elementList.clear();
......
......@@ -67,6 +67,9 @@ void DapServiceController::init(DapServiceClient *apDapServiceClient)
connect(&DapConsoleModel::getInstance(), &DapConsoleModel::sendRequest, m_pDapCommandController, &DapCommandController::requestConsole);
connect(m_pDapCommandController, &DapCommandController::responseConsole, &DapConsoleModel::getInstance(), &DapConsoleModel::receiveResponse);
connect(m_pDapCommandController, &DapCommandController::sigCmdHistory, &DapConsoleModel::getInstance(), &DapConsoleModel::receiveCmdHistory);
connect(m_pDapCommandController, &DapCommandController::sendNetworkList, &DapSettingsNetworkModel::getInstance(), &DapSettingsNetworkModel::setNetworkList);
connect(&DapSettingsNetworkModel::getInstance(), &DapSettingsNetworkModel::currentNetworkChanged, m_pDapCommandController, &DapCommandController::changeCurrentNetwork);
}
QString DapServiceController::getBrand() const
......@@ -230,6 +233,11 @@ void DapServiceController::processGetHistory(const QVariant& aData)
DapScreenHistoryModel::getInstance().receiveNewData(aData);
}
void DapServiceController::getNetworkList()
{
m_pDapCommandController->getNetworkList();
}
/// Get an instance of a class.
/// @return Instance of a class.
......
......@@ -15,6 +15,7 @@
#include "DapChainWalletsModel.h"
#include "DapChainNodeNetworkModel.h"
#include "DapScreenHistoryModel.h"
#include "DapSettingsNetworkModel.h"
#include "DapConsoleModel.h"
class DapServiceController : public QObject
......@@ -81,6 +82,8 @@ public:
Q_INVOKABLE void executeCommand(const QString& command);
void getWalletInfo(const QString& asWalletName);
/// Request about new netowrk list
void getNetworkList();
/// Get history of commands
void getCmdHistory();
......
#include "DapSettingsNetworkModel.h"
DapSettingsNetworkModel::DapSettingsNetworkModel(QObject *parent) : QAbstractListModel(parent),
m_CurrentIndex(-1)
{
}
DapSettingsNetworkModel& DapSettingsNetworkModel::getInstance()
{
static DapSettingsNetworkModel instance;
return instance;
}
int DapSettingsNetworkModel::rowCount(const QModelIndex& parent) const
{
Q_UNUSED(parent)
return m_NetworkList.count();
}
QVariant DapSettingsNetworkModel::data(const QModelIndex& index, int role) const
{
if(!index.isValid()) return QVariant();
if(role == DisplayName)
return m_NetworkList.at(index.row());
return QVariant();
}
QHash<int, QByteArray> DapSettingsNetworkModel::roleNames() const
{
QHash<int, QByteArray> roles;
roles[DisplayName] = "network";
return roles;
}
QString DapSettingsNetworkModel::getCurrentNetwork() const
{
return m_CurrentNetwork;
}
int DapSettingsNetworkModel::getCurrentIndex() const
{
return m_CurrentIndex;
}
void DapSettingsNetworkModel::setNetworkList(const QStringList& aNetworkList)
{
if(m_NetworkList == aNetworkList) return;
beginResetModel();
m_NetworkList = aNetworkList;
endResetModel();
}
void DapSettingsNetworkModel::setCurrentNetwork(QString CurrentNetwork, int CurrentIndex)
{
if (m_CurrentNetwork == CurrentNetwork)
return;
m_CurrentNetwork = CurrentNetwork;
m_CurrentIndex = CurrentIndex;
emit currentNetworkChanged(m_CurrentNetwork);
}
#ifndef DAPSETTINGSNETWORKMODEL_H
#define DAPSETTINGSNETWORKMODEL_H
#include <QAbstractListModel>
#include <QStringList>
#include <QDebug>
class DapSettingsNetworkModel : public QAbstractListModel
{
Q_OBJECT
public:
/// Enumeration display role
enum DisplayRole {
DisplayName = Qt::UserRole
};
private:
QStringList m_NetworkList;
QString m_CurrentNetwork;
int m_CurrentIndex;
public:
explicit DapSettingsNetworkModel(QObject *parent = nullptr);
/// Get instance of this object
/// @return instance
static DapSettingsNetworkModel &getInstance();
/// Overload methods
int rowCount(const QModelIndex& parent) const;
QVariant data(const QModelIndex& index, int role) const;
QHash<int, QByteArray> roleNames() const;
/// Get current network which was selected
/// @return name of current network
Q_INVOKABLE QString getCurrentNetwork() const;
/// Get current index which was selected
/// @return index of current network
Q_INVOKABLE int getCurrentIndex() const;
public slots:
/// Set new network list
/// @param List of network
void setNetworkList(const QStringList& aNetworkList);
/// Set current network which was selected in combobox
/// @param name of network
/// @param index of network
void setCurrentNetwork(QString CurrentNetwork, int CurrentIndex);
signals:
/// Signal about changing current network
/// @param name of network which was selected
void currentNetworkChanged(QString currentNetwork);
};
#endif // DAPSETTINGSNETWORKMODEL_H
......@@ -49,7 +49,9 @@ Page {
}
ListElement {
name: qsTr("Settings")
page: "DapQmlScreenAbout.qml"
// page: "DapQmlScreenAbout.qml"
page: "DapUiQmlScreenSettings.qml"
// page: "DapUiQmlWidgetSettingsNetwork.qml"
source: "qrc:/Resources/Icons/defaul_icon.png"
}
ListElement {
......
import QtQuick 2.4
import QtQuick.Controls 2.12
DapUiQmlScreenSettingsForm {
anchors.fill: parent
ListModel {
id: dapListModelSettings
ListElement {
name: qsTr("Network")
element: "DapUiQmlWidgetSettingsNetwork.qml"
}
}
ListView {
id: dapListViewSettings
anchors.fill: parent
model: dapListModelSettings
delegate: Component {
Item {
width: parent.width
height: loaderSettings.height
Loader {
id: loaderSettings
source: element
}
}
}
section.property: "name"
section.criteria: ViewSection.FullString
section.delegate: DapUiQmlScreenSettingsSection {}
}
}
import QtQuick 2.4
Item {
anchors.fill: parent
}
import QtQuick 2.0
Component {
Rectangle {
width: parent.width
height: 30 * pt
color: "#DFE1E6"
Text {
anchors.fill: parent
anchors.leftMargin: 18 * pt
verticalAlignment: Qt.AlignVCenter
text: section
font.family: "Roboto"
font.pixelSize: 12 * pt
color: "#5F5F63"
}
}
}
import QtQuick 2.4
import QtQuick.Controls 2.12
DapUiQmlWidgetSettingsNetworkForm {
width: parent.width
height: childrenRect.height
ComboBox {
width: 150
height: 50
anchors.left: parent.left
anchors.top: parent.top
anchors.leftMargin: 18 * pt
anchors.topMargin: 13 * pt
model: dapSettingsNetworkModel
textRole: "network"
currentIndex: dapSettingsNetworkModel.getCurrentIndex()
onCurrentTextChanged: {
if(dapSettingsNetworkModel.getCurrentIndex() !== currentIndex) {
dapSettingsNetworkModel.setCurrentNetwork(currentText, currentIndex);
}
}
}
}
import QtQuick 2.4
Item {
width: 400
height: 400
}
......@@ -23,6 +23,7 @@
#include "DapChainNodeNetworkModel.h"
#include "DapChainNodeNetworkExplorer.h"
#include "DapScreenHistoryFilterModel.h"
#include "DapSettingsNetworkModel.h"
#include "DapConsoleModel.h"
#include <QRegExp>
......@@ -54,6 +55,7 @@ int main(int argc, char *argv[])
controller.getWallets();
controller.getHistory();
controller.getCmdHistory();
controller.getNetworkList();
DapScreenHistoryFilterModel::getInstance()
.setSourceModel(&DapScreenHistoryModel::getInstance());
......@@ -75,9 +77,10 @@ int main(int argc, char *argv[])
engine.rootContext()->setContextProperty("dapNodeNetworkModel", &DapChainNodeNetworkModel::getInstance());
engine.rootContext()->setContextProperty("dapConsoleModel", &DapConsoleModel::getInstance());
engine.rootContext()->setContextProperty("dapHistoryModel", &DapScreenHistoryFilterModel::getInstance());
engine.rootContext()->setContextProperty("dapSettingsNetworkModel", &DapSettingsNetworkModel::getInstance());
engine.rootContext()->setContextProperty("pt", 1.3);
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
if (engine.rootObjects().isEmpty())
return -1;
......
......@@ -61,5 +61,10 @@
<file>DapUiQmlWidgetConsoleLastActionsDelegateForm.qml</file>
<file>DapUiQmlWidgetConsole.qml</file>
<file>DapUiQmlWidgetConsoleForm.ui.qml</file>
<file>DapUiQmlWidgetSettingsNetwork.qml</file>
<file>DapUiQmlWidgetSettingsNetworkForm.ui.qml</file>
<file>DapUiQmlScreenSettings.qml</file>
<file>DapUiQmlScreenSettingsForm.ui.qml</file>
<file>DapUiQmlScreenSettingsSection.qml</file>
</qresource>
</RCC>
......@@ -51,6 +51,7 @@ SOURCES += \
$$PWD/DapChainNodeCache.cpp \
$$PWD/DapChainWalletHandler.cpp \
$$PWD/DapChainLogHandler.cpp \
$$PWD/DapChainNetworkHandler.cpp \
$$PWD/DapChainConsoleHandler.cpp
HEADERS += \
......@@ -61,6 +62,7 @@ HEADERS += \
$$PWD/DapChainNodeNetworkHandler.h \
$$PWD/DapChainWalletHandler.h \
$$PWD/DapChainLogHandler.h \
$$PWD/DapChainNetworkHandler.h \
$$PWD/DapChainConsoleHandler.h
include (../libdap/libdap.pri)
......
......@@ -12,10 +12,12 @@ DapChainDashboardService::DapChainDashboardService() : DapRpcService(nullptr)
m_pDapChainNodeHandler = new DapChainNodeNetworkHandler(this);
m_pDapChainHistoryHandler = new DapChainHistoryHandler {this};
m_pDapChainHistoryHandler = new DapChainHistoryHandler(this);
QObject::connect(m_pDapChainHistoryHandler, &DapChainHistoryHandler::requsetWallets, this, &DapChainDashboardService::doRequestWallets);
QObject::connect(m_pDapChainHistoryHandler, &DapChainHistoryHandler::changeHistory, this, &DapChainDashboardService::doSendNewHistory);
m_pDapChainNetworkHandler = new DapChainNetworkHandler(this);
m_pDapChainConsoleHandler = new DapChainConsoleHandler(this);
}
......@@ -100,6 +102,18 @@ QString DapChainDashboardService::getCmdHistory() const
return m_pDapChainConsoleHandler->getHistory();
}
QStringList DapChainDashboardService::getNetworkList() const
{
return m_pDapChainNetworkHandler->getNetworkList();
}
void DapChainDashboardService::changeCurrentNetwork(const QString& aNetwork)
{
m_pDapChainHistoryHandler->setCurrentNetwork(aNetwork);
m_pDapChainNodeHandler->setCurrentNetwork(aNetwork);
m_pDapChainWalletHandler->setCurrentNetwork(aNetwork);
}
void DapChainDashboardService::doRequestWallets()
{
m_pDapChainHistoryHandler->onRequestNewHistory(m_pDapChainWalletHandler->getWallets());
......
......@@ -27,6 +27,7 @@
#include "DapChainWalletHandler.h"
#include "DapChainNodeNetworkHandler.h"
#include "DapChainHistoryHandler.h"
#include "DapChainNetworkHandler.h"
#include "DapChainConsoleHandler.h"
#include <QLocalServer>
......@@ -52,6 +53,8 @@ class DapChainDashboardService : public DapRpcService
/// Recipient history of commands
DapChainConsoleHandler* m_pDapChainConsoleHandler {nullptr};
DapChainNetworkHandler* m_pDapChainNetworkHandler {nullptr};
public:
/// Standard сonstructor.
explicit DapChainDashboardService();
......@@ -103,6 +106,12 @@ public slots:
/// Get history
/// @return QList data history
QVariant getHistory() const;
/// Get network list
/// @return Network list
QStringList getNetworkList() const;
/// Change current network
/// @param name of network whcih was selected
void changeCurrentNetwork(const QString& aNetwork);
/// Get result for command
/// @param command
/// @return result
......
......@@ -22,7 +22,7 @@ void DapChainHistoryHandler::onRequestNewHistory(const QMap<QString, QVariant>&
for(int i = 0; i < wallets.count(); i++)
{
QProcess process;
process.start(QString(CLI_PATH) + " tx_history -net private -chain gdb -addr " + wallets.at(i).toString());
process.start(QString("%1 tx_history -net %2 -chain gdb -addr %3").arg(CLI_PATH).arg(m_CurrentNetwork).arg(wallets.at(i).toString()));
process.waitForFinished(-1);
QByteArray result = process.readAll();
......@@ -48,3 +48,10 @@ void DapChainHistoryHandler::onRequestNewHistory(const QMap<QString, QVariant>&
emit changeHistory(m_history);
}
}
void DapChainHistoryHandler::setCurrentNetwork(const QString& aNetwork)
{
if(aNetwork == m_CurrentNetwork)
return;
m_CurrentNetwork = aNetwork;
}
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