diff --git a/DapRPCProtocol/DapRpcService.cpp b/DapRPCProtocol/DapRpcService.cpp index f52ce29db5812e3c3cddcffca0c209ec93c5e480..7159d4acc52112f43e4bf40e61e473511ea995bd 100644 --- a/DapRPCProtocol/DapRpcService.cpp +++ b/DapRPCProtocol/DapRpcService.cpp @@ -252,6 +252,7 @@ DapRpcMessage DapRpcService::dispatch(const DapRpcMessage &aRequest) } const QByteArray &method(methodName(aRequest)); + qDebug() << method; if (!m_invokableMethodHash.contains(method)) { return aRequest.createErrorResponse(DapErrorCode::MethodNotFound, "invalid method called"); } diff --git a/KelvinDashboard.pro b/KelvinDashboard.pro index 8cfdee374c6f7d6c8852ef105f3dc7def3ba89ce..26f9013c37ae7121ea4565db0ab9715179bc35e9 100755 --- a/KelvinDashboard.pro +++ b/KelvinDashboard.pro @@ -9,3 +9,9 @@ KelvinDashboardGUI.depends = KelvinDashboardService { BRAND = KelvinDashboard } + +unix: !mac : !android { + share_target.files = debian/share/* + share_target.path = /opt/KelvinDashboard/share/ + INSTALLS += share_target +} diff --git a/KelvinDashboardGUI/DapChainWalletsModel.cpp b/KelvinDashboardGUI/DapChainWalletsModel.cpp old mode 100644 new mode 100755 index 7d46e1686e74e08ca61b3014e0ed6131cfbe9583..1abadc1e093f711da67041f961bc0ce7accd8793 --- a/KelvinDashboardGUI/DapChainWalletsModel.cpp +++ b/KelvinDashboardGUI/DapChainWalletsModel.cpp @@ -1,5 +1,6 @@ #include "DapChainWalletsModel.h" + DapChainWalletsModel::DapChainWalletsModel(QObject *parent) { @@ -24,6 +25,7 @@ QVariant DapChainWalletsModel::data(const QModelIndex &index, int role) const 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(); + case TokensWalletRole: return m_dapChainWallets.at(index.row())->getTokens(); default: return QVariant(); } @@ -36,7 +38,8 @@ QHash<int, QByteArray> DapChainWalletsModel::roleNames() const { IconWalletRole, "iconPath" }, { NameWalletRole, "name" }, { AddressWalletRole, "address" }, - { BalanceWalletRole, "balance" } + { BalanceWalletRole, "balance" }, + { TokensWalletRole, "tokens" } }; return roles; @@ -44,26 +47,29 @@ QHash<int, QByteArray> DapChainWalletsModel::roleNames() const QVariantMap DapChainWalletsModel::get(int row) const { + if (m_dapChainWallets.count() == 0) { + return { {"iconPath", ""}, {"name", ""}, {"address", ""}, {"balance", ""}, {"tokens", QStringList()} }; + } const DapChainWallet *wallet = m_dapChainWallets.value(row); - return { {"iconPath", wallet->getIconPath()}, {"name", wallet->getName()}, {"address", wallet->getAddress()}, {"balance", wallet->getBalance()} }; + return { {"iconPath", wallet->getIconPath()}, {"name", wallet->getName()}, {"address", wallet->getAddress()}, {"balance", wallet->getBalance()}, {"tokens", wallet->getTokens()} }; } void DapChainWalletsModel::append(const DapChainWallet &arWallet) { - this->append(arWallet.getIconPath(), arWallet.getName(), arWallet.getAddress(), arWallet.getBalance()); + this->append(arWallet.getIconPath(), arWallet.getName(), arWallet.getAddress(), arWallet.getBalance(), arWallet.getTokens()); } -void DapChainWalletsModel::append(const QString& asIconPath, const QString &asName, const QString &asAddress, const QString& aBalance) +void DapChainWalletsModel::append(const QString& asIconPath, const QString &asName, const QString &asAddress, const QStringList& aBalance, const QStringList& aTokens) { int row = 0; while (row < m_dapChainWallets.count()) ++row; beginInsertRows(QModelIndex(), row, row); - m_dapChainWallets.insert(row, new DapChainWallet(asIconPath, asName, asAddress, aBalance)); + m_dapChainWallets.insert(row, new DapChainWallet(asIconPath, asName, asAddress, aBalance, aTokens)); endInsertRows(); } -void DapChainWalletsModel::set(int row, const QString& asIconPath, const QString &asName, const QString &asAddresss, const QString& aBalance) +void DapChainWalletsModel::set(int row, const QString& asIconPath, const QString &asName, const QString &asAddresss, const QStringList& aBalance, const QStringList& aTokens) { if (row < 0 || row >= m_dapChainWallets.count()) return; @@ -73,6 +79,7 @@ void DapChainWalletsModel::set(int row, const QString& asIconPath, const QString wallet->setName(asName); wallet->setAddress(asAddresss); wallet->setBalance(aBalance); + wallet->setTokens(aTokens); dataChanged(index(row, 0), index(row, 0), { IconWalletRole, NameWalletRole, AddressWalletRole, BalanceWalletRole }); } @@ -88,8 +95,12 @@ void DapChainWalletsModel::remove(int row) void DapChainWalletsModel::clear() { - if(m_dapChainWallets.count() > 0) + beginResetModel(); + if(m_dapChainWallets.count() > 0) { + qDeleteAll(m_dapChainWallets); m_dapChainWallets.clear(); + } + endResetModel(); } QObject *DapChainWalletsModel::singletonProvider(QQmlEngine *engine, QJSEngine *scriptEngine) diff --git a/KelvinDashboardGUI/DapChainWalletsModel.h b/KelvinDashboardGUI/DapChainWalletsModel.h old mode 100644 new mode 100755 index 5c8afb5eeb039cc9bfc5f8ef25fd68645937d9f6..fe59c4adac99aab061f815949863c5dee46e25d5 --- a/KelvinDashboardGUI/DapChainWalletsModel.h +++ b/KelvinDashboardGUI/DapChainWalletsModel.h @@ -16,7 +16,8 @@ enum DapChainWalletRole { IconWalletRole = Qt::DisplayRole, NameWalletRole = Qt::UserRole, AddressWalletRole, - BalanceWalletRole + BalanceWalletRole, + TokensWalletRole }; class DapChainWalletsModel : public QAbstractListModel @@ -37,8 +38,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, const QString &aBalance); - Q_INVOKABLE void set(int row, const QString& asIconPath, const QString &asName, const QString &asAddresss, const QString &aBalance); + Q_INVOKABLE void append(const QString& asIconPath, const QString &asName, const QString &asAddress, const QStringList &aBalance, const QStringList &aTokens); + Q_INVOKABLE void set(int row, const QString& asIconPath, const QString &asName, const QString &asAddresss, const QStringList &aBalance, const QStringList &aTokens); Q_INVOKABLE void remove(int row); Q_INVOKABLE void clear(); diff --git a/KelvinDashboardGUI/DapCommandController.cpp b/KelvinDashboardGUI/DapCommandController.cpp old mode 100644 new mode 100755 index 06792c1e4d2ab6ccb5e6db1aec14b809afc041af..1bfc3ce29616e6fdd6b8db44fcc75bd62a9a3cdf --- a/KelvinDashboardGUI/DapCommandController.cpp +++ b/KelvinDashboardGUI/DapCommandController.cpp @@ -67,6 +67,20 @@ void DapCommandController::processAddWallet() emit sigWalletAdded(name, address); } +void DapCommandController::processSendToken() +{ + qInfo() << "processSendToken()"; + DapRpcServiceReply *reply = static_cast<DapRpcServiceReply *>(sender()); + if (!reply) { + qWarning() << "Invalid response received"; + return; + } + qInfo() << reply->response(); + emit sigCommandResult(reply->response().result()); + auto answer = reply->response().result().toVariant().toString(); + emit onTokenSended(answer); +} + void DapCommandController::processGetWallets() { qInfo() << "processGetWallets()"; @@ -90,8 +104,24 @@ void DapCommandController::processGetWalletInfo() 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); + QStringList temp = reply->response().result().toVariant().toStringList(); + QStringList tokens; + QStringList balance; + for(int x{2}; x < temp.count(); x++) + { + if(x%2) + { + tokens.append(temp[x]); + qDebug() << "TOKKEN " << temp[x]; + } + else + { + balance.append(temp[x]); + qDebug() << "BALANCE " << temp[x]; + } + } + + emit sigWalletInfoChanged(name, address, balance, tokens); } /// Show or hide GUI client by clicking on the tray icon. @@ -125,6 +155,13 @@ void DapCommandController::addWallet(const QString &asWalletName) connect(reply, SIGNAL(finished()), this, SLOT(processAddWallet())); } +void DapCommandController::sendToken(const QString &asSendWallet, const QString &asAddressReceiver, const QString &asToken, const QString &aAmount) +{ + qInfo() << QString("sendToken(%1, %2, %3, %4)").arg(asSendWallet).arg(asAddressReceiver).arg(asToken).arg(aAmount); + DapRpcServiceReply *reply = m_DAPRpcSocket->invokeRemoteMethod("RPCServer.sendToken", asSendWallet, asAddressReceiver, asToken, aAmount); + connect(reply, SIGNAL(finished()), this, SLOT(processSendToken())); +} + void DapCommandController::getWallets() { DapRpcServiceReply *reply = m_DAPRpcSocket->invokeRemoteMethod("RPCServer.getWallets"); diff --git a/KelvinDashboardGUI/DapCommandController.h b/KelvinDashboardGUI/DapCommandController.h old mode 100644 new mode 100755 index d8e79a61c737e0cd0df80fc4e8544ffb17f203cd..b07c37447d2d7b9e4dbe2e130e449278f9b99579 --- a/KelvinDashboardGUI/DapCommandController.h +++ b/KelvinDashboardGUI/DapCommandController.h @@ -27,6 +27,7 @@ signals: void sigNodeLogsReceived(const QStringList& aNodeLogs); void sigWalletAdded(const QString& asWalletName, const QString& asWalletAddress); + void onTokenSended(const QString& asAnswer); void sigWalletsReceived(const QMap<QString, QVariant>& aWallets); /// The signal is emitted when the main application window is activated. @@ -34,7 +35,7 @@ signals: void onClientClose(); - void sigWalletInfoChanged(const QString& asWalletName, const QString& asWalletAddress, const QString& aBalance); + void sigWalletInfoChanged(const QString& asWalletName, const QString& asWalletAddress, const QStringList& aBalance, const QStringList& aTokens); public: /// Overloaded constructor. @@ -52,7 +53,7 @@ private slots: void processGetNodeLogs(); void processAddWallet(); - + void processSendToken(); void processGetWallets(); void processGetWalletInfo(); @@ -70,6 +71,7 @@ public slots: void getNodeLogs(int aiTimeStamp, int aiRowCount); void addWallet(const QString& asWalletName); + void sendToken(const QString &asSendWallet, const QString& asAddressReceiver, const QString& asToken, const QString& aAmount); void getWallets(); diff --git a/KelvinDashboardGUI/DapQmlScreenAbout.qml b/KelvinDashboardGUI/DapQmlScreenAbout.qml index da8d3cd2915cd57c254a86ede9637e2122eb3bc4..5e97667eb1d885d7ec4767f90f4d9825b559dc8c 100755 --- a/KelvinDashboardGUI/DapQmlScreenAbout.qml +++ b/KelvinDashboardGUI/DapQmlScreenAbout.qml @@ -1,5 +1,5 @@ import QtQuick 2.9 -import QtQml 2.11 +import QtQml 2.3 import QtQuick.Controls 2.2 import KelvinDashboard 1.0 diff --git a/KelvinDashboardGUI/DapServiceController.cpp b/KelvinDashboardGUI/DapServiceController.cpp old mode 100644 new mode 100755 index 91c330c05b116d85f9353d60ee5cda9498f3b8b0..528a574ad3e2769b3d72f0c73e1ad4f0d90c72e3 --- a/KelvinDashboardGUI/DapServiceController.cpp +++ b/KelvinDashboardGUI/DapServiceController.cpp @@ -44,7 +44,9 @@ void DapServiceController::init(DapServiceClient *apDapServiceClient) 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))); + connect(m_pDapCommandController, SIGNAL(sigWalletInfoChanged(QString,QString, QStringList, QStringList)), SLOT(processGetWalletInfo(QString,QString, QStringList, QStringList))); + + connect(m_pDapCommandController, SIGNAL(onTokenSended(QString)), SLOT(processSendToken(QString))); } QString DapServiceController::getBrand() const @@ -118,6 +120,12 @@ void DapServiceController::addWallet(const QString &asWalletName) m_pDapCommandController->addWallet(asWalletName); } +void DapServiceController::sendToken(const QString &asSendWallet, const QString &asAddressReceiver, const QString &asToken, const QString &aAmount) +{ + qInfo() << QString("sendToken(%1, %2, %3, %4)").arg(asSendWallet).arg(asAddressReceiver).arg(asToken).arg(aAmount); + m_pDapCommandController->sendToken(asSendWallet.trimmed(), asAddressReceiver.trimmed(), asToken.trimmed(), aAmount); +} + void DapServiceController::getWalletInfo(const QString &asWalletName) { qInfo() << QString("getWalletInfo(%1)").arg(asWalletName); @@ -126,26 +134,34 @@ void DapServiceController::getWalletInfo(const QString &asWalletName) void DapServiceController::processAddWallet(const QString& asWalletName, const QString& asWalletAddress) { - qInfo() << QString("processAddWallet(%1, %2)").arg(asWalletName).arg(asWalletAddress);; + qInfo() << QString("processAddWallet(%1, %2)").arg(asWalletName).arg(asWalletAddress); DapChainWallet wallet("", asWalletName, asWalletAddress); DapChainWalletsModel::getInstance().append(wallet); } +void DapServiceController::processSendToken(const QString &asAnswer) +{ + qInfo() << QString("processSendToken(%1)").arg(asAnswer); +} + void DapServiceController::processGetWallets(const QMap<QString, QVariant> &aWallets) { qInfo() << QString("processGetWallets()") << aWallets.size(); for(QString w : aWallets.keys()) { - DapChainWallet wallet("", w, aWallets.value(w).toString()); getWalletInfo(w); } } -void DapServiceController::processGetWalletInfo(const QString &asWalletName, const QString &asWalletAddress, const QString &aBalance) +void DapServiceController::processGetWalletInfo(const QString &asWalletName, const QString &asWalletAddress, const QStringList& aBalance, const QStringList &aTokens) { - qInfo() << QString("processGetWalletInfo(%1, %2, %3)").arg(asWalletName).arg(asWalletAddress).arg(aBalance); - DapChainWallet wallet("", asWalletName, asWalletAddress, aBalance); + qInfo() << QString("processGetWalletInfo(%1, %2)").arg(asWalletName).arg(asWalletAddress); + DapChainWallet wallet("", asWalletName, asWalletAddress, aBalance, aTokens); DapChainWalletsModel::getInstance().append(wallet); + + for (QString s : aBalance) { + qDebug() << s; + } } /// Get an instance of a class. diff --git a/KelvinDashboardGUI/DapServiceController.h b/KelvinDashboardGUI/DapServiceController.h old mode 100644 new mode 100755 index 1edafae669200fbab9c6f7fc3bd1fe23e4f5e362..52e6683f4b0f42d4555d7c93b176d7c40d9154c3 --- a/KelvinDashboardGUI/DapServiceController.h +++ b/KelvinDashboardGUI/DapServiceController.h @@ -61,12 +61,13 @@ public: /// @param aiRowCount Number of lines displayed. void getNodeLogs(int aiTimeStamp, int aiRowCount) const; - void getWallets() const; + Q_INVOKABLE void getWallets() const; DapLogModel getLogModel() const; void setLogModel(const DapLogModel &dapLogModel); Q_INVOKABLE void addWallet(const QString& asWalletName); + Q_INVOKABLE void sendToken(const QString &asSendWallet, const QString& asAddressReceiver, const QString& asToken, const QString& aAmount); void getWalletInfo(const QString& asWalletName); @@ -87,9 +88,11 @@ private slots: void processAddWallet(const QString& asWalletName, const QString& asWalletAddress); + void processSendToken(const QString& asAnswer); + void processGetWallets(const QMap<QString, QVariant>& aWallets); - void processGetWalletInfo(const QString& asWalletName, const QString& asWalletAddress, const QString& aBalance); + void processGetWalletInfo(const QString& asWalletName, const QString& asWalletAddress, const QStringList &aBalance, const QStringList& aTokens); public slots: /// Show or hide GUI client by clicking on the tray icon. diff --git a/KelvinDashboardGUI/DapUiQmlScreenChangeWidget.qml b/KelvinDashboardGUI/DapUiQmlScreenChangeWidget.qml index 4ff8f4e2fdf9d14124c70534ba37e5334733a914..8eed111a00b6511ae3db287541ba255a1ca3dd0b 100755 --- a/KelvinDashboardGUI/DapUiQmlScreenChangeWidget.qml +++ b/KelvinDashboardGUI/DapUiQmlScreenChangeWidget.qml @@ -1,7 +1,7 @@ import QtQuick 2.9 -import QtQml 2.11 +import QtQml 2.3 import QtQuick.Controls 1.4 -import QtQuick.Controls 2.4 +import QtQuick.Controls 2.2 import QtQuick.Layouts 1.2 import QtQml.Models 2.2 import KelvinDashboard 1.0 diff --git a/KelvinDashboardGUI/DapUiQmlScreenDialog.qml b/KelvinDashboardGUI/DapUiQmlScreenDialog.qml index 15b1490d1116cac6050aee79bb10e8df4c541bfa..98b903eb12867843898e4c09555d6018915d510a 100644 --- a/KelvinDashboardGUI/DapUiQmlScreenDialog.qml +++ b/KelvinDashboardGUI/DapUiQmlScreenDialog.qml @@ -1,5 +1,5 @@ -import QtQuick 2.11 -import QtQuick.Controls 2.4 +import QtQuick 2.9 +import QtQuick.Controls 2.2 import KelvinDashboard 1.0 Page { diff --git a/KelvinDashboardGUI/DapUiQmlScreenDialogAddWallet.qml b/KelvinDashboardGUI/DapUiQmlScreenDialogAddWallet.qml index 54517ffacb6d17132da87496daab3046486e2af4..4b0a360de89d2f0d13e5aaf8972eab432c962e74 100644 --- a/KelvinDashboardGUI/DapUiQmlScreenDialogAddWallet.qml +++ b/KelvinDashboardGUI/DapUiQmlScreenDialogAddWallet.qml @@ -1,5 +1,5 @@ import QtQuick 2.9 -import QtQuick.Controls 2.4 +import QtQuick.Controls 2.2 import KelvinDashboard 1.0 Dialog { diff --git a/KelvinDashboardGUI/DapUiQmlScreenDialogSendToken.qml b/KelvinDashboardGUI/DapUiQmlScreenDialogSendToken.qml new file mode 100755 index 0000000000000000000000000000000000000000..960c3f397e1163346be83596556845157880b2db --- /dev/null +++ b/KelvinDashboardGUI/DapUiQmlScreenDialogSendToken.qml @@ -0,0 +1,182 @@ +import QtQuick 2.9 +import QtQuick.Controls 1.4 +import QtQuick.Controls 2.2 +//import QtQuick.Controls 2.5 +import KelvinDashboard 1.0 + +Dialog { + id: dialogSendToken + focus: true + modal: true + title: qsTr("Send token...") + + width: parent.width/1.5 + height: 280 + + x: parent.width / 2 - width / 2 + y: parent.height / 2 - height / 2 + + function show() { + dialogSendToken.open(); + } + + contentItem: + + Rectangle + { + anchors.fill: parent + + // TextField + // { + // background: Rectangle { + // radius: 2 + // border.color: "gray" + // border.width: 1 + // } + + // id: textFieldNameWallet + // selectByMouse: true + // height: 35 + // anchors.bottom: buttonOk.top + // anchors.bottomMargin: 20 + // anchors.right: parent.right + // anchors.rightMargin: 10 + // anchors.left: parent.left + // anchors.leftMargin: 10 + // font.pixelSize: 20 + // clip: true + + + // } + + ComboBox { + id: comboBoxToken + anchors { bottom: comboBoxAddressWallet.top; bottomMargin: 20; right: parent.right; rightMargin: 10; + left: parent.left; leftMargin: 10 } + model: listViewTokens.model + delegate: ItemDelegate { + width: comboBoxToken.width + contentItem: Text { + text: modelData + font: comboBoxToken.font + elide: Text.ElideRight + verticalAlignment: Text.AlignVCenter + } + highlighted: comboBoxToken.highlightedIndex !== index + } + } + + ComboBox { + id: comboBoxAddressWallet + anchors.bottom: textFieldAmount.top + anchors.bottomMargin: 20 + anchors.right: parent.right + anchors.rightMargin: 10 + anchors.left: parent.left + anchors.leftMargin: 10 + editable: true + textRole: "text" + onAccepted: { + if (find(currentText) === -1) { + model.append({text: editText}) + // currentIndex = find(editText) + // fnameField.insert(currentIndex) + + } + } + } + + TextField { + property real realValue: parseFloat(textFieldAmount.text.replace(',', '.')) * 1e12; + + id: textFieldAmount + anchors.bottom: buttonOk.top + anchors.bottomMargin: 20 + anchors.right: parent.right + anchors.rightMargin: 10 + placeholderText: "Amount (Ex. 2,9103)" + validator: DoubleValidator{} + } + + Button + { + id: buttonCancel + text: qsTr("Cancel") + anchors.right: buttonOk.left + anchors.rightMargin: 10 + anchors.bottom: parent.bottom + anchors.bottomMargin: 10 + + contentItem: Text { + text: buttonCancel.text + font: buttonCancel.font + opacity: enabled ? 1.0 : 0.3 + color: buttonCancel.down ? "#353841" : "white" + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + elide: Text.ElideRight + } + + background: Rectangle { + implicitWidth: 100 + implicitHeight: 30 + opacity: enabled ? 1 : 0.3 + color: buttonCancel.down ? "white" : "#353841" + radius: 4 + } + + onClicked: + { + close() + } + } + + Button + { + id: buttonOk + text: "OK" + anchors.right: parent.right + anchors.rightMargin: 10 + anchors.bottom: parent.bottom + anchors.bottomMargin: 10 + contentItem: Text { + text: buttonOk.text + font: buttonOk.font + opacity: enabled ? 1.0 : 0.3 + color: buttonOk.down ? "#353841" : "white" + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + elide: Text.ElideRight + } + + background: Rectangle { + implicitWidth: 100 + implicitHeight: 30 + opacity: enabled ? 1 : 0.3 + color: buttonOk.down ? "white" : "#353841" + radius: 4 + } + + onClicked: + { + var wallet = listViewWallet.model.get(listViewWallet.currentIndex).name; + var token = comboBoxToken.currentText; + var amount = textFieldAmount.realValue.toString(); + var receiver = comboBoxAddressWallet.editText; + + if (wallet && token && amount && receiver) { + console.log("Send " + token + "(" + amount + ") to address " + receiver + " from wallet " + wallet ); + dapServiceController.sendToken(wallet, receiver, token, amount); + dapChainWalletsModel.clear(); + dapServiceController.getWallets(); + } else { + console.log("There's error!"); + console.log(amount); + } + + close() + } + } + } + +} diff --git a/KelvinDashboardGUI/DapUiQmlScreenMainWindow.ui.qml b/KelvinDashboardGUI/DapUiQmlScreenMainWindow.ui.qml index edc520024fe0c426c223257aabc8d72763a3dc28..4f6d67ec1377c3aaf98d75915fa1422af5ff32fd 100644 --- a/KelvinDashboardGUI/DapUiQmlScreenMainWindow.ui.qml +++ b/KelvinDashboardGUI/DapUiQmlScreenMainWindow.ui.qml @@ -1,6 +1,6 @@ import QtQuick 2.9 import QtQuick.Controls 1.4 -import QtQuick.Controls 2.4 +import QtQuick.Controls 2.2 Page { diff --git a/KelvinDashboardGUI/DapUiQmlWidgetChainTransactions.cpp b/KelvinDashboardGUI/DapUiQmlWidgetChainTransactions.cpp new file mode 100644 index 0000000000000000000000000000000000000000..3231a0962a50c95c6edc4f1fca86493e11f87996 --- /dev/null +++ b/KelvinDashboardGUI/DapUiQmlWidgetChainTransactions.cpp @@ -0,0 +1,6 @@ +#include "DapUiQmlWidgetChainTransactions.h" + +DapUiQmlWidgetChainTransactions::DapUiQmlWidgetChainTransactions(const QString &name, const QString &URLpage, const QString &image) : DapUiQmlWidget(name, URLpage, image) +{ + +} diff --git a/KelvinDashboardGUI/DapUiQmlWidgetChainTransactions.h b/KelvinDashboardGUI/DapUiQmlWidgetChainTransactions.h new file mode 100644 index 0000000000000000000000000000000000000000..d68fb2d08e1a9647e33b563d82dee892ee669458 --- /dev/null +++ b/KelvinDashboardGUI/DapUiQmlWidgetChainTransactions.h @@ -0,0 +1,12 @@ +#ifndef DAPUIQMLWIDGETCHAINTRANSCTIONS_H +#define DAPUIQMLWIDGETCHAINTRANSCTIONS_H + +#include "DapUiQmlWidget.h" + +class DapUiQmlWidgetChainTransactions : public DapUiQmlWidget +{ +public: + explicit DapUiQmlWidgetChainTransactions(const QString &name, const QString &URLpage, const QString &image); +}; + +#endif // DAPUIQMLWIDGETCHAINTRANSCTIONS_H diff --git a/KelvinDashboardGUI/DapUiQmlWidgetChainTransctions.cpp b/KelvinDashboardGUI/DapUiQmlWidgetChainTransctions.cpp deleted file mode 100644 index df9441b200c3591a16804430750e74c08af174b4..0000000000000000000000000000000000000000 --- a/KelvinDashboardGUI/DapUiQmlWidgetChainTransctions.cpp +++ /dev/null @@ -1,6 +0,0 @@ -#include "DapUiQmlWidgetChainTransctions.h" - -DapUiQmlWidgetChainTransctions::DapUiQmlWidgetChainTransctions(const QString &name, const QString &URLpage, const QString &image) : DapUiQmlWidget(name, URLpage, image) -{ - -} diff --git a/KelvinDashboardGUI/DapUiQmlWidgetChainTransctions.h b/KelvinDashboardGUI/DapUiQmlWidgetChainTransctions.h deleted file mode 100644 index 3fe4c1a73e4753334b2fd01ae243c06fc29263d9..0000000000000000000000000000000000000000 --- a/KelvinDashboardGUI/DapUiQmlWidgetChainTransctions.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef DAPUIQMLWIDGETCHAINTRANSCTIONS_H -#define DAPUIQMLWIDGETCHAINTRANSCTIONS_H - -#include "DapUiQmlWidget.h" - -class DapUiQmlWidgetChainTransctions : public DapUiQmlWidget -{ -public: - explicit DapUiQmlWidgetChainTransctions(const QString &name, const QString &URLpage, const QString &image); -}; - -#endif // DAPUIQMLWIDGETCHAINTRANSCTIONS_H diff --git a/KelvinDashboardGUI/DapUiQmlWidgetChainWallet.qml b/KelvinDashboardGUI/DapUiQmlWidgetChainWallet.qml old mode 100644 new mode 100755 index 018ef4719b6e7358c1295751519021688828cee2..313d385dff6f41b465ce6286fa627db98326c1ab --- a/KelvinDashboardGUI/DapUiQmlWidgetChainWallet.qml +++ b/KelvinDashboardGUI/DapUiQmlWidgetChainWallet.qml @@ -1,6 +1,6 @@ import QtQuick 2.9 import QtQuick.Controls 1.4 -import QtQuick.Controls 2.4 +import QtQuick.Controls 2.2 import QtQuick.Window 2.0 import QtQuick.Controls.Styles 1.3 import QtQuick.Controls.Styles 1.4 @@ -25,11 +25,33 @@ DapUiQmlWidgetChainWalletForm { } listViewWallet.onCurrentItemChanged: - console.log(listViewWallet.currentIndex) + { + listViewTokens.model = listViewWallet.model.get(listViewWallet.currentIndex).tokens + updateBalanceText(); + addressWallet.text = listViewWallet.model.get(listViewWallet.currentIndex).address + } + + listViewTokens.onCurrentItemChanged: + { + updateBalanceText(); + console.log(textBalance.text); + } - save.onClicked: { + buttonSaveWallet.onClicked: { dialogAddWallet.show() -} - + } + buttonSendToken.onClicked: { + dialogSendToken.show() + } + function updateBalanceText() { + var value = ""; + if (listViewTokens.currentIndex > -1) { + value = listViewWallet.model.get(listViewWallet.currentIndex).balance[listViewTokens.currentIndex]; + } + if (value) + textBalance.text = value.replace(/[^\d.-]/g, ''); + else + textBalance.text = ''; + } } diff --git a/KelvinDashboardGUI/DapUiQmlWidgetChainWalletForm.ui.qml b/KelvinDashboardGUI/DapUiQmlWidgetChainWalletForm.ui.qml old mode 100644 new mode 100755 index 6d5dd626dad1ab09bd4a0155a94a948bbc655c50..54b51460d4df1b12f669c472245ba55510444298 --- a/KelvinDashboardGUI/DapUiQmlWidgetChainWalletForm.ui.qml +++ b/KelvinDashboardGUI/DapUiQmlWidgetChainWalletForm.ui.qml @@ -1,6 +1,8 @@ -import QtQuick 2.11 +import QtQuick 2.9 import QtGraphicalEffects 1.0 import QtQuick.Controls 2.2 +import QtQuick.Controls.Styles 1.4 +import KelvinDashboard 1.0 Page { id: dapUiQmlWidgetChainWallet @@ -8,11 +10,17 @@ Page { title: qsTr("Wallet") property alias listViewWallet: listViewWallet - property alias save: save + property alias buttonSaveWallet: buttonSaveWallet property alias dialogAddWallet: dialogAddWallet + property alias dialogSendToken: dialogSendToken + property alias addressWallet: addressWallet + property alias textBalance: textBalance + property alias listViewTokens: listViewTokens + property alias buttonSendToken: buttonSendToken Rectangle { + id: rectanglePanel anchors.left: parent.left anchors.top: parent.top anchors.bottom: parent.bottom @@ -25,6 +33,7 @@ Page { model: dapChainWalletsModel delegate: Item { + id: delegateWallet width: parent.width height: 100 @@ -33,44 +42,17 @@ Page { anchors.centerIn: parent spacing: 5 - Text { + Label { id: nameWallet anchors.horizontalCenter: parent.horizontalCenter text: qsTr(name) font.pixelSize: 14 color: "#BBBEBF" font.family: "Roboto" + width: delegateWallet.width + elide: Text.ElideRight + leftPadding: 5 } - - 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 -// } } MouseArea { @@ -83,27 +65,134 @@ Page { } } + Rectangle + { + anchors.left: rectanglePanel.right + anchors.right: parent.right + anchors.top: parent.top + anchors.bottom: parent.bottom + + TextEdit { + id: addressWallet + font.pixelSize: 11 + wrapMode: Text.Wrap + selectByMouse: true + color: "black" + selectionColor: "#008080" + clip: true + anchors.top: parent.top + anchors.horizontalCenter: parent.horizontalCenter + anchors.left: parent.left + readOnly: true + } + + ListView { + id: listViewTokens + orientation: ListView.Vertical + anchors.top: addressWallet.bottom + anchors.left: parent.left + anchors.bottom: parent.bottom + width: parent.width*2/3 + flickableDirection: Flickable.VerticalFlick + delegate: Item { + width: 200; height: 50 + Text { id: nameField; text: modelData; color: listViewTokens.currentIndex === index ? 'green' : 'black'; } + MouseArea { + anchors.fill: parent + onClicked: listViewTokens.currentIndex = index + } + } + + focus: true + } + + Text + { + id: textBalance + wrapMode: Text.NoWrap + textFormat: Text.PlainText + clip: false + anchors.top: addressWallet.bottom + anchors.left: listViewTokens.right + anchors.bottom: parent.bottom + anchors.right: parent.right + + font.pixelSize: 30 + font.bold: true + } + } DapUiQmlScreenDialogAddWallet { id: dialogAddWallet } + DapUiQmlScreenDialogSendToken { + id: dialogSendToken + } RoundButton { - id: deleteWallet - text: qsTr("-") + id: buttonDeleteWallet highlighted: true anchors.margins: 10 - anchors.right: parent.right - anchors.bottom: save.top + anchors.left: parent.left + anchors.bottom: buttonSaveWallet.top + height: 40 + width: 40 + contentItem: Text { + text: qsTr("-") + color: "#121B28" + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + elide: Text.ElideRight + + } + background: Rectangle { + color: "white" + border.color: "#121B28" + radius: 20 + } } RoundButton { - id: save - text: qsTr("+") + id: buttonSaveWallet + contentItem: Text { + text: qsTr("+") + color: "#121B28" + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + elide: Text.ElideRight + + } + background: Rectangle { + id: inSave + color: "white" + border.color: "#121B28" + radius: 20 + } + + highlighted: true + anchors.margins: 10 + anchors.left: parent.left + anchors.bottom: parent.bottom + height: 40 + width: 40 + } + + RoundButton { + id: buttonSendToken + text: qsTr("->") highlighted: true anchors.margins: 10 anchors.right: parent.right anchors.bottom: parent.bottom } + + RoundButton { + id: buttonAddToken + text: qsTr("+") + highlighted: true + anchors.margins: 10 + anchors.right: parent.right + anchors.bottom: buttonSendToken.top + } } diff --git a/KelvinDashboardGUI/DapUiQmlWidgetDelegate.qml b/KelvinDashboardGUI/DapUiQmlWidgetDelegate.qml index 607a49ad604901c412cf8142dd676b18e3af0d20..d8ccef85e08a2b8492302b1663e199591e020f40 100644 --- a/KelvinDashboardGUI/DapUiQmlWidgetDelegate.qml +++ b/KelvinDashboardGUI/DapUiQmlWidgetDelegate.qml @@ -1,4 +1,4 @@ -import QtQuick 2.4 +import QtQuick 2.2 DapUiQmlWidgetDelegateForm { } diff --git a/KelvinDashboardGUI/KelvinDashboardGUI.pro b/KelvinDashboardGUI/KelvinDashboardGUI.pro index a067d00a6b8153bcb47e1665a39e1990acad5c28..0e5a7c2d17031717a0f0d6001f12b3e48ed6f66e 100755 --- a/KelvinDashboardGUI/KelvinDashboardGUI.pro +++ b/KelvinDashboardGUI/KelvinDashboardGUI.pro @@ -38,11 +38,11 @@ ICON = icon.ico #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 SOURCES += \ + DapUiQmlWidgetChainTransactions.cpp \ main.cpp \ DapUiQmlWidgetChainBallance.cpp \ DapUiQmlWidgetChainBlockExplorer.cpp \ DapUiQmlWidgetChainNodeLogs.cpp \ - DapUiQmlWidgetChainTransctions.cpp \ DapUiQmlWidgetChainOperations.cpp \ DapUiQmlWidgetModel.cpp \ DapUiQmlWidget.cpp \ @@ -72,9 +72,9 @@ HEADERS += \ DapUiQmlWidgetChainBallance.h \ DapUiQmlWidgetChainBlockExplorer.h \ DapUiQmlWidgetChainNodeLogs.h \ - DapUiQmlWidgetChainTransctions.h \ DapUiQmlScreenDashboard.h \ DapUiQmlWidgetChainOperations.h \ + DapUiQmlWidgetChainTransactions.h \ DapUiQmlWidgetModel.h \ DapUiQmlWidget.h \ DapScreenDialog.h \ @@ -96,4 +96,11 @@ include (../DapRPCProtocol/DapRPCProtocol.pri) INCLUDEPATH += $$_PRO_FILE_PWD_/../libKelvinDashboardCommon/ $$_PRO_FILE_PWD_/../DapRPCProtocol/ + +unix: !mac : !android { + gui_target.files = $${BRAND} + gui_target.path = /opt/$$BRAND/bin/ + INSTALLS += gui_target +} + DISTFILES += diff --git a/KelvinDashboardGUI/main.qml b/KelvinDashboardGUI/main.qml index 1f58d9190aa1e7a060b6545894c504e31dafe1d4..01c5752c530bbf26f2c93a0e8d76a5bef67730aa 100755 --- a/KelvinDashboardGUI/main.qml +++ b/KelvinDashboardGUI/main.qml @@ -1,6 +1,6 @@ import QtQuick 2.9 import QtQuick.Controls 1.4 -import QtQuick.Controls 2.4 +import QtQuick.Controls 2.2 import QtQuick.Window 2.0 import QtQuick.Controls.Styles 1.3 import QtQuick.Controls.Styles 1.4 diff --git a/KelvinDashboardGUI/qml.qrc b/KelvinDashboardGUI/qml.qrc index ce09fd17cca72a53bd5d1760905f3ffa3b2aecbc..9de95561440b9170571e89abd20950df93bde74f 100755 --- a/KelvinDashboardGUI/qml.qrc +++ b/KelvinDashboardGUI/qml.qrc @@ -33,5 +33,6 @@ <file>Resources/Icons/dialog-warning.png</file> <file>DapUiQmlWidgetChainNodeLogs.qml</file> <file>DapUiQmlWidgetChainNodeLogsForm.ui.qml</file> + <file>DapUiQmlScreenDialogSendToken.qml</file> </qresource> </RCC> diff --git a/KelvinDashboardService/DapChainDashboardService.cpp b/KelvinDashboardService/DapChainDashboardService.cpp index cf5466d8fa13f1a99d86e01a61d9172d0f087606..14cb9fd65c6718bebdfbf691c56cba61d149b4e8 100755 --- a/KelvinDashboardService/DapChainDashboardService.cpp +++ b/KelvinDashboardService/DapChainDashboardService.cpp @@ -25,6 +25,7 @@ bool DapChainDashboardService::start() else { qCritical() << QString("Can't listen on %1").arg(DAP_BRAND); + qCritical() << m_pServer->errorString(); return false; } return true; @@ -59,25 +60,31 @@ QStringList DapChainDashboardService::getWalletInfo(const QString &asWalletName) return m_pDapChainWalletHandler->getWalletInfo(asWalletName); } +QString DapChainDashboardService::sendToken(const QString &asWalletName, const QString &asReceiverAddr, const QString &asToken, const QString &asAmount) +{ + qInfo() << QString("sendToken(%1;%2;%3;%4)").arg(asWalletName).arg(asReceiverAddr).arg(asToken).arg(asAmount); + return m_pDapChainWalletHandler->sendToken(asWalletName, asReceiverAddr, asToken, asAmount); +} + /// 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. -void DapChainDashboardService::activateClient(const QSystemTrayIcon::ActivationReason& reason) -{ - qInfo() << "DapChainDashboardService::activateClient()"; - switch (reason) - { - case QSystemTrayIcon::Trigger: - { - QJsonArray arguments; - arguments.append(true); - m_pServer->notifyConnectedClients("RPCClient.activateClient", arguments); - } - break; - default: - break; - } -} +//void DapChainDashboardService::activateClient(const QSystemTrayIcon::ActivationReason& reason) +//{ +// qInfo() << "DapChainDashboardService::activateClient()"; +// switch (reason) +// { +// case QSystemTrayIcon::Trigger: +// { +// QJsonArray arguments; +// arguments.append(true); +// m_pServer->notifyConnectedClients("RPCClient.activateClient", arguments); +// } +// break; +// default: +// break; +// } +//} /// Shut down client. void DapChainDashboardService::closeClient() @@ -90,26 +97,26 @@ void DapChainDashboardService::closeClient() } /// System tray initialization. -void DapChainDashboardService::initTray() -{ - QSystemTrayIcon *trayIconKelvinDashboard = new QSystemTrayIcon(); - trayIconKelvinDashboard->setIcon(QIcon(":/Resources/Icons/icon.ico")); - trayIconKelvinDashboard->setToolTip("KelvinDashboard"); - QMenu * menuKelvinDashboardService = new QMenu(); - QAction * quitAction = new QAction("Выход"); - menuKelvinDashboardService->addAction(quitAction); - trayIconKelvinDashboard->setContextMenu(menuKelvinDashboardService); - trayIconKelvinDashboard->show(); +//void DapChainDashboardService::initTray() +//{ +// QSystemTrayIcon *trayIconKelvinDashboard = new QSystemTrayIcon(); +// trayIconKelvinDashboard->setIcon(QIcon(":/Resources/Icons/icon.ico")); +// trayIconKelvinDashboard->setToolTip("KelvinDashboard"); +// QMenu * menuKelvinDashboardService = new QMenu(); +// QAction * quitAction = new QAction("Выход"); +// menuKelvinDashboardService->addAction(quitAction); +// trayIconKelvinDashboard->setContextMenu(menuKelvinDashboardService); +// trayIconKelvinDashboard->show(); - // If the "Exit" menu item is selected, then we shut down the service, - // and also send a command to shut down the client. - connect(quitAction, &QAction::triggered, this, [=] - { - closeClient(); - }); +// // If the "Exit" menu item is selected, then we shut down the service, +// // and also send a command to shut down the client. +// connect(quitAction, &QAction::triggered, this, [=] +// { +// closeClient(); +// }); - // With a double click on the icon in the system tray, - // we send a command to the client to activate the main window - connect(trayIconKelvinDashboard, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), - this, SLOT(activateClient(QSystemTrayIcon::ActivationReason))); -} +// // With a double click on the icon in the system tray, +// // we send a command to the client to activate the main window +// connect(trayIconKelvinDashboard, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), +// this, SLOT(activateClient(QSystemTrayIcon::ActivationReason))); +//} diff --git a/KelvinDashboardService/DapChainDashboardService.h b/KelvinDashboardService/DapChainDashboardService.h index 6510559e6e5350cbd99df9b4728634a9746ab7cd..ef26bf157f1b2cb6db66852bd416f6cc5cef2adb 100755 --- a/KelvinDashboardService/DapChainDashboardService.h +++ b/KelvinDashboardService/DapChainDashboardService.h @@ -13,10 +13,10 @@ #define DAPCHAINDASHBOARDSERVICE_H #include <QObject> -#include <QSystemTrayIcon> -#include <QMenu> -#include <QAction> -#include <QApplication> +//#include <QSystemTrayIcon> +//#include <QMenu> +//#include <QAction> +#include <QCoreApplication> #include "DapRpcAbstractServer.h" #include "DapRpcLocalServer.h" @@ -57,11 +57,11 @@ signals: public slots: /// 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. - void activateClient(const QSystemTrayIcon::ActivationReason& reason); +// void activateClient(const QSystemTrayIcon::ActivationReason& reason); /// Shut down client. void closeClient(); /// System tray initialization. - void initTray(); + //void initTray(); /// Get node logs. /// @param aiTimeStamp Timestamp start reading logging. /// @param aiRowCount Number of lines displayed. @@ -73,6 +73,8 @@ public slots: QMap<QString, QVariant> getWallets(); QStringList getWalletInfo(const QString &asWalletName); + + QString sendToken(const QString &asWalletName, const QString &asReceiverAddr, const QString &asToken, const QString &asAmount); }; diff --git a/KelvinDashboardService/DapChainLogHandler.cpp b/KelvinDashboardService/DapChainLogHandler.cpp old mode 100644 new mode 100755 index de6211b918f1dd4ffebc454eb9782fbe5a3e9aa0..645053a420ccd3650f38e9be06e55b98f6b76a64 --- a/KelvinDashboardService/DapChainLogHandler.cpp +++ b/KelvinDashboardService/DapChainLogHandler.cpp @@ -26,7 +26,7 @@ QStringList DapChainLogHandler::request(int aiTimeStamp, int aiRowCount) { QByteArray result; QProcess process; - process.start(QString("%1 print_log ts_after %2 limit %3").arg("/home/andrey/Project/build-kelvin-node/kelvin-node-cli").arg(aiTimeStamp).arg(aiRowCount)); + process.start(QString("%1 print_log ts_after %2 limit %3").arg("/opt/kelvin-node/bin/kelvin-node-cli").arg(aiTimeStamp).arg(aiRowCount)); process.waitForFinished(-1); result = process.readAll(); diff --git a/KelvinDashboardService/DapChainWalletHandler.cpp b/KelvinDashboardService/DapChainWalletHandler.cpp old mode 100644 new mode 100755 index 1277f6a6d81549bb119ab17b18332615ba512787..86dd61d20d0ebfd9cad2aa1f8130796abc3f0e8e --- a/KelvinDashboardService/DapChainWalletHandler.cpp +++ b/KelvinDashboardService/DapChainWalletHandler.cpp @@ -1,4 +1,5 @@ #include "DapChainWalletHandler.h" +#include <QDebug> DapChainWalletHandler::DapChainWalletHandler(QObject *parent) : QObject(parent) { @@ -16,7 +17,7 @@ QStringList DapChainWalletHandler::createWallet(const QString &asNameWallet) { QByteArray result; QProcess process; - process.start(QString("%1 wallet new -w %2").arg("/home/andrey/Project/build-kelvin-node/kelvin-node-cli").arg(asNameWallet)); + process.start(QString("%1 wallet new -w %2").arg("/opt/kelvin-node/bin/kelvin-node-cli").arg(asNameWallet)); process.waitForFinished(-1); result = process.readAll(); QStringList list; @@ -29,10 +30,12 @@ QMap<QString, QVariant> DapChainWalletHandler::getWallets() { QMap<QString, QVariant> map; QProcess process; - process.start(QString("%1 wallet list").arg("/home/andrey/Project/build-kelvin-node/kelvin-node-cli")); + process.start(QString("%1 wallet list").arg("/opt/kelvin-node/bin/kelvin-node-cli")); process.waitForFinished(-1); - QString str = QString::fromLatin1(process.readAll()).remove(" "); - QRegExp rx( ":\\b([a-zA-Z0-9]+)\\n" ); + QString str = QString::fromLatin1(process.readAll()); + qDebug() << "ZDES`" << str; + QRegExp rx(":{1,1}([\\s\\w\\W]+)(\\n|\\r){1,1}" ); + rx.setMinimal(true); int pos = 0; int x {0}; QString tempName; @@ -57,27 +60,45 @@ QMap<QString, QVariant> DapChainWalletHandler::getWallets() 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.start(QString("%1 wallet info -w %2 -net private").arg("/opt/kelvin-node/bin/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" ); + QString str = QString::fromLatin1(process.readAll()).replace("\\", "\\\\"); + + QRegExp rx("[(:\\)\\t]{1,1}([^\\\\\\n\\t]+)[\\\\(|\\n|\\r]{1,1}"); rx.setMinimal(true); - int pos = 0; - list = str.split(":"); - QStringList res; - for(QString s : list) + + int pos{0}; + while((pos = rx.indexIn(str, pos)) != -1) { - qDebug() << s; - if(!s.contains(":")) - res.append(s.remove(s.indexOf('\n'), s.size())); + list.append(rx.cap(1)); + pos += rx.matchedLength(); } -qDebug() << str; -// while ((pos = rx.indexIn(str, pos)) != -1) -// { -// list.append(rx.cap(2)); -// pos += rx.matchedLength(); -// } qDebug() << list; - return res; + return list; +} + +QString DapChainWalletHandler::sendToken(const QString &asSendWallet, const QString &asAddressReceiver, const QString &asToken, const QString &aAmount) +{ + QString answer; + qInfo() << QString("sendTokenTest(%1, %2, %3, %4)").arg(asSendWallet).arg(asAddressReceiver).arg(asToken).arg(aAmount); + QProcess processCreate; + processCreate.start(QString("%1 tx_create -net private -chain gdb -from_wallet %2 -to_addr %3 -token %4 -value %5") + .arg("/opt/kelvin-node/bin/kelvin-node-cli") + .arg(asSendWallet) + .arg(asAddressReceiver) + .arg(asToken) + .arg(aAmount)); + processCreate.waitForFinished(-1); + QString resultCreate = QString::fromLatin1(processCreate.readAll()); + qDebug() << resultCreate; + if(!(resultCreate.isEmpty() || resultCreate.isNull())) + { + QProcess processMempool; + processMempool.start(QString("%1 mempool_proc -net private -chain gdb").arg("/opt/kelvin-node/bin/kelvin-node-cli")); + processMempool.waitForFinished(-1); + answer = QString::fromLatin1(processMempool.readAll()); + qDebug() << answer; + } + return answer; } diff --git a/KelvinDashboardService/DapChainWalletHandler.h b/KelvinDashboardService/DapChainWalletHandler.h old mode 100644 new mode 100755 index 53aba37636fbf46179534a4d715f2b86b7696f56..a365abdf1f1e53fe773718abe9fe2365dcb20c2c --- a/KelvinDashboardService/DapChainWalletHandler.h +++ b/KelvinDashboardService/DapChainWalletHandler.h @@ -22,6 +22,7 @@ public slots: QStringList createWallet(const QString& asNameWallet); QMap<QString, QVariant> getWallets(); QStringList getWalletInfo(const QString& asNameWallet); + QString sendToken(const QString &asSendWallet, const QString& asAddressReceiver, const QString& asToken, const QString& aAmount); }; #endif // DAPCHAINWALLETHANDLER_H diff --git a/KelvinDashboardService/KelvinDashboardService.pro b/KelvinDashboardService/KelvinDashboardService.pro index 52458e45e6a29c1abfcf858b7ae9e6bb10a98388..7d40ebc9edcb5268a2a51c98cdd65eeccc1bb2bc 100755 --- a/KelvinDashboardService/KelvinDashboardService.pro +++ b/KelvinDashboardService/KelvinDashboardService.pro @@ -1,7 +1,7 @@ -QT += core network widgets -QT += gui +QT += core network +QT -= gui -CONFIG += c++11 +CONFIG += c++11 console CONFIG -= app_bundle !defined(BRAND,var){ @@ -61,5 +61,11 @@ INCLUDEPATH += $$_PRO_FILE_PWD_/../libKelvinDashboardCommon/ $$_PRO_FILE_PWD_/../DapRPCProtocol/ $$_PRO_FILE_PWD_/../kelvin-node/ +unix: !mac : !android { + service_target.files = $${BRAND}Service + service_target.path = /opt/$$BRAND/bin/ + INSTALLS += service_target +} + RESOURCES += \ KelvinDashboardService.qrc diff --git a/KelvinDashboardService/main.cpp b/KelvinDashboardService/main.cpp index 9c4130e8aa6dd636ac24723797bd5b6b30df375f..82ed77b9453543136d8a8b59f6abe379ea5c6cd7 100755 --- a/KelvinDashboardService/main.cpp +++ b/KelvinDashboardService/main.cpp @@ -1,12 +1,17 @@ -#include <QApplication> +#include <QCoreApplication> #include <QSystemSemaphore> #include <QSharedMemory> +#include <QCommandLineParser> + +#include <unistd.h> #include "DapHalper.h" #include "DapChainDashboardService.h" #include "DapLogger.h" #include "DapChainLogHandler.h" +void processArgs(); + int main(int argc, char *argv[]) { // Creating a semaphore for locking external resources, as well as initializing an external resource-memory @@ -22,8 +27,8 @@ int main(int argc, char *argv[]) { return 1; } - - QApplication a(argc, argv); + + QCoreApplication a(argc, argv); a.setOrganizationName("DEMLABS"); a.setOrganizationDomain("demlabs.com"); a.setApplicationName("KelvinDashboardService"); @@ -36,10 +41,29 @@ int main(int argc, char *argv[]) #endif //#endif // Creating the main application object + processArgs(); DapChainDashboardService service; service.start(); // Initialization of the application in the system tray - service.initTray(); +// service.initTray(); + return a.exec(); } + +void processArgs() +{ +#ifdef Q_OS_LINUX + QCommandLineParser clParser; + clParser.parse(QCoreApplication::arguments()); + auto options = clParser.unknownOptionNames(); + if (options.contains("D")) { + daemon(1, 0); + } + else if (options.contains("stop")) { + qint64 pid = QCoreApplication::applicationPid(); + QProcess::startDetached("kill -9 " + QString::number(pid)); + exit(0); + } +#endif +} diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000000000000000000000000000000000000..8aa80ceca52e0238ed961d193fb2373fd5d62c2b --- /dev/null +++ b/debian/changelog @@ -0,0 +1,6 @@ +kelvindashboard (1.0) unstable; urgency=medium + + * created + - created transactions + +-- vladislav.cholak vlad.hoc10@gmail.com 01.07.2019 diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000000000000000000000000000000000000..ec635144f60048986bc560c5576355344005e6e7 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +9 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000000000000000000000000000000000000..5394e5333b07f37bff30482bdd76c4db7c8408b0 --- /dev/null +++ b/debian/control @@ -0,0 +1,17 @@ +Source: kelvindashboard +Section: unknown +Priority: optional +Maintainer: support <support@ncodedcommunications.com> +Build-Depends: debhelper (>= 9) +Standards-Version: 5.8-4 +Homepage: https://ncodedcommunications.com + +Package: kelvindashboard +Architecture: any +Depends: psmisc, menu, ${shlibs:Depends}, ${misc:Depends} +Replaces: KelvinDashboard +Description: KelvinDashboard + KelvinDashboard + + + diff --git a/debian/postinst b/debian/postinst new file mode 100755 index 0000000000000000000000000000000000000000..54c99385eb7b5d26facf1525aa7ed1da5689f7fd --- /dev/null +++ b/debian/postinst @@ -0,0 +1,23 @@ +#!/bin/bash - + +case "$1" in + configure) + + ln -sf /opt/KelvinDashboard/share/init.d/KelvinDashboardService.service /etc/systemd/user/KelvinDashboardService.service + systemctl --system enable /opt/KelvinDashboard/share/init.d/KelvinDashboardService.service + ln -s /opt/KelvinDashboard/bin/KelvinDashboard /usr/local/bin/ + cp -f /opt/KelvinDashboard/share/kelvindashboard.desktop /usr/share/applications/kelvindashboard.desktop + cp -f /opt/KelvinDashboard/share/kelvindashboard.ico /usr/share/pixmaps/kelvindashboard.ico + update-menus + echo "For start Kelvin Dashboard Service - run 'systemctl start KelvinDashboardService'" +;; + abort-upgrade|abort-remove|abort-deconfigure) + ;; + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 2 + ;; +esac +exit 0 + + diff --git a/debian/preinst.ex b/debian/preinst.ex new file mode 100644 index 0000000000000000000000000000000000000000..f9179c878704f3e74a352698ae2963827583eec8 --- /dev/null +++ b/debian/preinst.ex @@ -0,0 +1,35 @@ +#!/bin/sh +# preinst script for dapvpngui +# +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +# * <new-preinst> `install' +# * <new-preinst> `install' <old-version> +# * <new-preinst> `upgrade' <old-version> +# * <old-preinst> `abort-upgrade' <new-version> +# for details, see https://www.debian.org/doc/debian-policy/ or +# the debian-policy package + + +case "$1" in + install|upgrade) + ;; + + abort-upgrade) + ;; + + *) + echo "preinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 diff --git a/debian/prerm b/debian/prerm new file mode 100755 index 0000000000000000000000000000000000000000..2df4d479d456d5a1903f5eb15d8868206f8d7a73 --- /dev/null +++ b/debian/prerm @@ -0,0 +1,19 @@ +#!/bin/bash + +case "$1" in + purge|remove|abort-upgrade|failed-upgrade|upgrade) + [ -f /etc/init.d/kelvindashboardservice ] && service kelvindashboardservice stop + [ -d /opt/KelvinDashboard ] && rm -rf /opt/KelvinDashboard/ + [ -f /usr/local/bin/KelvinDashboard ] && rm /usr/local/bin/KelvinDashboard + [ -f /etc/init.d/kelvindashboardservice ] && rm /etc/init.d/kelvindashboardservice + systemctl daemon-reload + [ -f /usr/share/applications/kelvindashboard.desktop ] && rm /usr/share/applications/kelvindashboard.desktop + [ -f /usr/share/pixmaps/kelvindashboard.ico ] && rm /usr/share/pixmaps/kelvindashboard.ico + ;; + *) + echo "postrm called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +exit 0 diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000000000000000000000000000000000000..4609cdd81b5ace8dbe51ceee27b4af9e63dedddd --- /dev/null +++ b/debian/rules @@ -0,0 +1,4 @@ +#!/usr/bin/make -f + +include /usr/share/cdbs/1/rules/debhelper.mk +include /usr/share/cdbs/1/class/qmake.mk diff --git a/debian/share/init.d/KelvinDashboardService.service b/debian/share/init.d/KelvinDashboardService.service new file mode 100644 index 0000000000000000000000000000000000000000..75597dac213de2b188ea34e13e976812543e797a --- /dev/null +++ b/debian/share/init.d/KelvinDashboardService.service @@ -0,0 +1,15 @@ +[Unit] +Description=Kelvin Dashboard Service +After=network.target + +[Service] +Type=forking +OOMScoreAdjust=-1000 +PIDFile=/opt/KelvinDashboard/kelvindashboardservice.pid +WorkingDirectory=/opt/KelvinDashboard/ +ExecStart=/opt/KelvinDashboard/bin/KelvinDashboardService -D +ExecStop=/opt/KelvinDashboard/bin/KelvinDashboardService --stop +Restart=always + +[Install] +WantedBy=multi-user.target diff --git a/debian/share/kelvindashboard.desktop b/debian/share/kelvindashboard.desktop new file mode 100644 index 0000000000000000000000000000000000000000..ecaf9281f670947f6398134e9abf18171a1092df --- /dev/null +++ b/debian/share/kelvindashboard.desktop @@ -0,0 +1,9 @@ +[Desktop Entry] +Name=Kelvin Dashboard +Exec=/opt/KelvinDashboard/bin/KelvinDashboard +Icon=/opt/sap/ultrapad/share/kelvindashboard.ico +Terminal=false +Type=Application +Encoding=UTF-8 +Categories=Network;Application; +Name[en_US]=Kelvin Dashboard diff --git a/debian/share/kelvindashboard.ico b/debian/share/kelvindashboard.ico new file mode 100644 index 0000000000000000000000000000000000000000..41230db92cb8101b8f24cf6f861082c6dfb827e1 Binary files /dev/null and b/debian/share/kelvindashboard.ico differ diff --git a/debian/stamp-makefile-build b/debian/stamp-makefile-build new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/debian/stamp-makefile-install b/debian/stamp-makefile-install new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/libKelvinDashboardCommon/DapChainWallet.cpp b/libKelvinDashboardCommon/DapChainWallet.cpp old mode 100644 new mode 100755 index e3e8ce891fcbc9c2cdad2fa03e59f0a2823726b7..1ef76c80b4b531e11736d85201cd5c9438970e20 --- a/libKelvinDashboardCommon/DapChainWallet.cpp +++ b/libKelvinDashboardCommon/DapChainWallet.cpp @@ -1,13 +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, const QStringList &aBalance, const QStringList &aTokens, QObject *parent) + : QObject(parent), m_sIconPath(asIconPath), m_sName(asName), m_sAddress(asAddresss), m_balance(aBalance), m_tokens(aTokens) { } DapChainWallet::DapChainWallet(const QString &asIconPath, const QString &asName, const QString &asAddresss, QObject *parent) - : DapChainWallet(asIconPath, asName, asAddresss, 0, parent) + : DapChainWallet(asIconPath, asName, asAddresss, QStringList(), QStringList(), parent) { } @@ -48,14 +48,26 @@ void DapChainWallet::setAddress(const QString &asAddress) emit addressChanged(m_sAddress); } -QString DapChainWallet::getBalance() const +QStringList DapChainWallet::getBalance() const { return m_balance; } -void DapChainWallet::setBalance(const QString &aBalance) +void DapChainWallet::setBalance(const QStringList &aBalance) { m_balance = aBalance; emit balanceChanged(m_balance); } + +QStringList DapChainWallet::getTokens() const +{ + return m_tokens; +} + +void DapChainWallet::setTokens(const QStringList &aTokens) +{ + m_tokens = aTokens; + + emit tokensChanged(m_tokens); +} diff --git a/libKelvinDashboardCommon/DapChainWallet.h b/libKelvinDashboardCommon/DapChainWallet.h old mode 100644 new mode 100755 index 152a7c1b065a8bee13a6d4d9183b47329a347478..1537b883d8c6dd5cbffcc236379f799c354bf22d --- a/libKelvinDashboardCommon/DapChainWallet.h +++ b/libKelvinDashboardCommon/DapChainWallet.h @@ -11,18 +11,20 @@ class DapChainWallet : public QObject QString m_sIconPath; QString m_sName; QString m_sAddress; - QString m_balance; + QStringList m_balance; + QStringList m_tokens; public: 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, const QStringList &aBalance, const QStringList& aTokens, 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) + Q_PROPERTY(QStringList balance MEMBER m_balance READ getBalance WRITE setBalance NOTIFY balanceChanged) + Q_PROPERTY(QStringList tokens MEMBER m_tokens READ getTokens WRITE setTokens NOTIFY tokensChanged) QString getName() const; void setName(const QString &asName); @@ -32,14 +34,18 @@ public: QString getIconPath() const; void setIconPath(const QString &asIconPath); - QString getBalance() const; - void setBalance(const QString& aBalance); + QStringList getBalance() const; + void setBalance(const QStringList& aBalance); + + QStringList getTokens() const; + void setTokens(const QStringList& aTokens); signals: void iconPathChanged(const QString& asIconPath); void nameChanged(const QString& asName); void addressChanged(const QString& asAddress); - void balanceChanged(const QString& aBalance); + void balanceChanged(const QStringList& aBalance); + void tokensChanged(const QStringList& aTokens); };