diff --git a/KelvinDashboardGUI/DapChainNodeNetworkExplorer.cpp b/KelvinDashboardGUI/DapChainNodeNetworkExplorer.cpp index bfaf920783e3e84864efcdda75c603bd0bd85394..53a988b055634675f1a6529f4dcfc9051ef27507 100644 --- a/KelvinDashboardGUI/DapChainNodeNetworkExplorer.cpp +++ b/KelvinDashboardGUI/DapChainNodeNetworkExplorer.cpp @@ -53,17 +53,14 @@ void DapChainNodeNetworkExplorer::mousePressEvent(QMouseEvent* event) void DapChainNodeNetworkExplorer::wheelEvent(QWheelEvent* event) { -// if(event->modifiers() == Qt::ControlModifier) -// { - if(event->delta() > 1) - { - if(scale() < 1.8) setScale(scale() + 0.1); - } - else - { - if(scale() > 0.5) setScale(scale() - 0.1); - } -// } + if(event->delta() > 1) + { + if(scale() < 1.8) setScale(scale() + 0.1); + } + else + { + if(scale() > 0.5) setScale(scale() - 0.1); + } } void DapChainNodeNetworkExplorer::hoverMoveEvent(QHoverEvent* event) diff --git a/KelvinDashboardGUI/DapChainNodeNetworkExplorer.h b/KelvinDashboardGUI/DapChainNodeNetworkExplorer.h index b0017d2fa184f2267c0127927962e54be6b7f815..5e348687556a393f1f9155c71ac8f21d2b41fe7a 100644 --- a/KelvinDashboardGUI/DapChainNodeNetworkExplorer.h +++ b/KelvinDashboardGUI/DapChainNodeNetworkExplorer.h @@ -9,12 +9,9 @@ #include "DapChainNodeNetworkModel.h" #include "DapNodeType.h" -/*! - * \brief The DapChainNodeNetworkExplorer class - * \details Class paiting DapKelvin map - * \warning To use this class it requers to send DapChainNodeNetworkModel model to slot setModel() - * \author Tagiltsev Evgenii - */ +/// The DapChainNodeNetworkExplorer class +/// details Class paiting DapKelvin map +/// @warning To use this class it requers to send DapChainNodeNetworkModel model to slot setModel() class DapChainNodeNetworkExplorer : public QQuickPaintedItem { Q_OBJECT @@ -44,13 +41,13 @@ private: QMap<QString /*Address*/, DapNodeGui /*NodeDataGui*/> m_nodeMap; // node map for gui QPair<QString /*Address*/, DapNodeGui* /*NodeDataGui*/> m_currentSelectedNode; // selected node - QColor m_colorOnline; // Property color for online status - QColor m_colorOffline; // Property color for offline status - QColor m_colorSelect; // Property color for selected state - QColor m_colorNormal; // Property color for normal state - QColor m_colorFocused; // Property color for focused state - int m_widthLine; // Property width line for borders - int m_sizeNode; // Property lenght of square's side + QColor m_colorOnline; + QColor m_colorOffline; + QColor m_colorSelect; + QColor m_colorNormal; + QColor m_colorFocused; + int m_widthLine; + int m_sizeNode; protected: void mousePressEvent(QMouseEvent* event); @@ -59,38 +56,85 @@ protected: public: explicit DapChainNodeNetworkExplorer(QQuickItem *parent = nullptr); - void paint(QPainter* painter); //!< Overload method for paiting - - QColor getColorOnline() const; //!< Get color for online nodes - QColor getColorOffline() const; //!< Get color for offline nodes - QColor getColorSelect() const; //!< Get color for selected node - QColor getColorNormal() const; //!< Get color for normal state for node - QColor getColorFocused() const; //!< Get color for focused node - int getWidthLine() const; //!< Get line width for borders - int getSizeNode() const; //!< Get lenght of square's side - - DapChainNodeNetworkModel* getModel() const; //!< Get model - - Q_INVOKABLE int getSelectedNodePosX() const; //!< Get X position for selected node - Q_INVOKABLE int getSelectedNodePosY() const; //!< Get Y position for selected node - Q_INVOKABLE QString getSelectedNodeAddress() const; //!< Get address for selected node - Q_INVOKABLE QString getSelectedNodeAlias() const; //!< Get alias for selected node - Q_INVOKABLE QString getSelectedNodeIpv4() const; //!< Get Ipv4 address for selected node - Q_INVOKABLE QString getAddressByPos(const int aX, const int aY); //!< Find node address by coordinate + /// Overload method for paiting + void paint(QPainter* painter); + + /// Get color for online nodes + /// @return color of online nodes + QColor getColorOnline() const; + /// Get color for offline nodes + /// @return color of offline nodes + QColor getColorOffline() const; + /// Get color for selected node + /// @return color of seletected node + QColor getColorSelect() const; + /// Get color for normal state for node + /// @return color of normal state + QColor getColorNormal() const; + /// Get color for focused node + /// @return color of focused node + QColor getColorFocused() const; + /// Get line width for borders + /// @return width of line + int getWidthLine() const; + /// Get lenght of square's side + /// @return diameter of node element + int getSizeNode() const; + + /// Get model + /// @return model for network explorer + DapChainNodeNetworkModel* getModel() const; + + /// Get X position for selected node + /// @return X position of selected node + Q_INVOKABLE int getSelectedNodePosX() const; + /// Get Y position for selected node + /// @return Y position of selected node + Q_INVOKABLE int getSelectedNodePosY() const; + /// Get address for selected node + /// @return address of selected node + Q_INVOKABLE QString getSelectedNodeAddress() const; + /// Get alias for selected node + /// @return alias of selected node + Q_INVOKABLE QString getSelectedNodeAlias() const; + /// Get Ipv4 address for selected node + /// @return Ipv4 address of selected node + Q_INVOKABLE QString getSelectedNodeIpv4() const; + /// Find node address by coordinate + /// @param X position + /// @param Y position + /// @return address of node + Q_INVOKABLE QString getAddressByPos(const int aX, const int aY); public slots: - void setColorSelect(const QColor& aColorSelect); //!< Set color for selected node - void setColorNormal(const QColor& aColorNormal); //!< Set color for normal state for node - void setColorFocused(const QColor& aColorActivated); //!< Set color for focused node - void setColorOnline(const QColor& aColorOnline); //!< Set color for online nodes - void setColorOffline(const QColor& aColorOffline); //!< Set color for offline nodes - void setWidthLine(const int widthLine); //!< Set line width for borders - void setSizeNode(const int sizeNode); //!< Set lenght of square's side - - void setModel(DapChainNodeNetworkModel* aModel); //!< Set model + /// Set color for selected node + /// @param color for selected node + void setColorSelect(const QColor& aColorSelect); + /// Set color for normal state for node + /// @param color for normal state of node + void setColorNormal(const QColor& aColorNormal); + /// Set color for focused node + /// @param color for focused node + void setColorFocused(const QColor& aColorActivated); + /// Set color for online nodes + /// @param color for online nodes + void setColorOnline(const QColor& aColorOnline); + /// Set color for offline nodes + /// @param color offline nodes + void setColorOffline(const QColor& aColorOffline); + /// Set line width for borders + /// @param width of line + void setWidthLine(const int widthLine); + /// Set lenght of square's side + /// @param diameter of node element + void setSizeNode(const int sizeNode); + + /// Set model + /// @param model for explorer + void setModel(DapChainNodeNetworkModel* aModel); private slots: - void proccessCreateGraph(); // Slot for repainting map if it was changed + void proccessCreateGraph(); signals: void colorSelectChanged(QColor colorSelect); @@ -102,8 +146,12 @@ signals: void sizeNodeChanged(int sizeNode); void modelChanged(DapChainNodeNetworkModel* model); - void selectNode(bool isCurrentNode); //!< Signal selected node - void selectNodeChanged(); //!< Signal deselect node + /// Signal selected node + /// @param status current selected node. It is true + /// if current node was selected + void selectNode(bool isCurrentNode); + /// Signal skip selected node to normal state + void selectNodeChanged(); }; #endif // DAPCHAINNODENETWORKEXPLORER_H diff --git a/KelvinDashboardGUI/DapChainNodeNetworkModel.h b/KelvinDashboardGUI/DapChainNodeNetworkModel.h index db19d6ca44f773930fe22595ffc52ab26bbe1626..261258e9dd1fc8fbefddaace48969b72aeb5e487 100644 --- a/KelvinDashboardGUI/DapChainNodeNetworkModel.h +++ b/KelvinDashboardGUI/DapChainNodeNetworkModel.h @@ -8,6 +8,7 @@ #include "DapNodeType.h" +/// Class model for Network Explorer class DapChainNodeNetworkModel : public QObject { Q_OBJECT @@ -21,27 +22,46 @@ protected: public: explicit DapChainNodeNetworkModel(QObject *parent = nullptr); + + Q_INVOKABLE static DapChainNodeNetworkModel &getInstance(); + /// Get data about whole network with nodes + /// @return QMap where key is address and value is structure about one node const DapNodeMap* getDataMap() const; + /// Get data about onde node by address + /// @return data's node structure const DapNodeData* getNodeData(const QString& aAddress) const; + /// Get current address of node + /// @return address of current node QString getCurrentAddress() const; - Q_INVOKABLE static DapChainNodeNetworkModel &getInstance(); + /// Get status of node + /// @return It is true if node is online Q_INVOKABLE bool isNodeOnline(const QString& aAddress) const; public slots: + /// Receive new network data and repaint the screen + /// @param QMap<QString, QStringList> data of node n void receiveNewNetwork(const QVariant& aData); + /// Receive changes status for nodes void receiveNodeStatus(const QVariant& aData); + /// Send request to service about changing status of node Q_INVOKABLE void sendRequestNodeStatus(const bool aIsOnline); + /// Start timer for request new data of network Q_INVOKABLE void startRequest(); + /// @param time in milliseconds for delay Q_INVOKABLE void startRequest(const int aTimeout); + /// Stop timer for request data of network Q_INVOKABLE void stopRequest(); signals: + /// Signal for changing network void changeNodeNetwork(); + /// Signal for request network void requestNodeNetwork(); + /// Signal for request status of node void requestNodeStatus(bool status); + /// SIgnal about changing status node void changeStatusNode(QString node, bool isOnline); - void appendNode(QMap<QString, QVariant>); }; diff --git a/KelvinDashboardGUI/DapChainWalletsModel.h b/KelvinDashboardGUI/DapChainWalletsModel.h index afcb2c57d144d63fd91782d133132cbd74145de7..74ff829394e80f2bd2782a5c7aaaa149f5402b62 100755 --- a/KelvinDashboardGUI/DapChainWalletsModel.h +++ b/KelvinDashboardGUI/DapChainWalletsModel.h @@ -21,6 +21,7 @@ enum DapChainWalletRole { CountWalletRole }; +/// Class model for wallets screen class DapChainWalletsModel : public QAbstractListModel { Q_OBJECT @@ -33,15 +34,21 @@ public: /// @return Instance of a class. Q_INVOKABLE static DapChainWalletsModel &getInstance(); + /// Overraid model's methods int rowCount(const QModelIndex & = QModelIndex()) const; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; QHash<int, QByteArray> roleNames() const; + /// Get data in a row Q_INVOKABLE QVariantMap get(int row) const; + /// Add new wallet Q_INVOKABLE void append(const DapChainWallet &arWallet); Q_INVOKABLE void append(const QString& asIconPath, const QString &asName, const QString &asAddress, const QStringList &aBalance, const QStringList &aTokens); + /// Change data for wallet in a row Q_INVOKABLE void set(int row, const QString& asIconPath, const QString &asName, const QString &asAddresss, const QStringList &aBalance, const QStringList &aTokens); + /// Remove row with wallet Q_INVOKABLE void remove(int row); + /// Clear screen Q_INVOKABLE void clear(); public slots: diff --git a/KelvinDashboardGUI/DapCommandController.cpp b/KelvinDashboardGUI/DapCommandController.cpp index f510a9e5165997751d56f28a444fb28054c8eb79..b02dfaa3116225819fe1d2ac87d8a7b5c65e09b3 100755 --- a/KelvinDashboardGUI/DapCommandController.cpp +++ b/KelvinDashboardGUI/DapCommandController.cpp @@ -60,7 +60,6 @@ void DapCommandController::getHistory() void DapCommandController::setNewHistory(const QVariant& aData) { - qDebug() << "new story" << aData; emit sendHistory(aData); } @@ -220,16 +219,6 @@ void DapCommandController::closeClient() emit onClientClose(); } -/// Get node logs. -/// @param aiTimeStamp Timestamp start reading logging. -/// @param aiRowCount Number of lines displayed. -void DapCommandController::getNodeLogs(int aiTimeStamp, int aiRowCount) -{ - qInfo() << QString("getNodeLogs(%1, %2)").arg(aiTimeStamp).arg(aiRowCount); - DapRpcServiceReply *reply = m_DAPRpcSocket->invokeRemoteMethod("RPCServer.getNodeLogs", aiTimeStamp, aiRowCount); - connect(reply, SIGNAL(finished()), this, SLOT(processGetNodeLogs())); -} - void DapCommandController::addWallet(const QString &asWalletName) { qInfo() << QString("addWallet(%1)").arg(asWalletName); @@ -240,7 +229,7 @@ void DapCommandController::addWallet(const QString &asWalletName) void DapCommandController::removeWallet(const QString &asWalletName) { qInfo() << QString("removeWallet(%1)").arg(asWalletName); - DapRpcServiceReply *reply = m_DAPRpcSocket->invokeRemoteMethod("RPCServer.removeWallet", asWalletName); + m_DAPRpcSocket->invokeRemoteMethod("RPCServer.removeWallet", asWalletName); } void DapCommandController::sendToken(const QString &asSendWallet, const QString &asAddressReceiver, const QString &asToken, const QString &aAmount) @@ -265,7 +254,6 @@ void DapCommandController::getWalletInfo(const QString& asWalletName) void DapCommandController::getNodeNetwork() { - qInfo() << QString("getNodeNetwork()"); DapRpcServiceReply *reply = m_DAPRpcSocket->invokeRemoteMethod("RPCServer.getNodeNetwork"); connect(reply, SIGNAL(finished()), this, SLOT(processGetNodeNetwork())); } diff --git a/KelvinDashboardGUI/DapCommandController.h b/KelvinDashboardGUI/DapCommandController.h index 59c6854f8f2164f27ad50c2158bb9b121ab1912c..1739ac95b4710fa1b46e0426b0ee954a373a5fa6 100755 --- a/KelvinDashboardGUI/DapCommandController.h +++ b/KelvinDashboardGUI/DapCommandController.h @@ -32,21 +32,21 @@ signals: void sigWalletsReceived(const QMap<QString, QVariant>& aWallets); /// The signal is emitted when the main application window is activated. void onClientActivate(bool aIsActivated); - + /// void onClientClose(); - + /// Signal for changing information of wallet void sigWalletInfoChanged(const QString& asWalletName, const QString& asWalletAddress, const QStringList& aBalance, const QStringList& aTokens); - + /// Signal for data network void sendNodeNetwork(const QVariant& aData); - + /// Signal for sending status of node void sendNodeStatus(const QVariant& aData); - + /// void executeCommandChanged(const QString& result); - + /// Signal for cleaning log void onClearLogModel(); - + /// void onLogModel(); - + /// Signal for sending new transaction history void sendHistory(const QVariant& aData); void responseConsole(const QString& aResponse); @@ -89,10 +89,6 @@ public slots: void activateClient(bool aIsActivated); /// Shut down client. void closeClient(); - /// Get node logs. - /// @param aiTimeStamp Timestamp start reading logging. - /// @param aiRowCount Number of lines displayed. - void getNodeLogs(int aiTimeStamp, int aiRowCount); void processChangedLog(); @@ -114,8 +110,9 @@ public slots: /// Get node logs. void getNodeLogs(); + /// Get transaction history void getHistory(); - + /// Send to model new history void setNewHistory(const QVariant& aData); void requestConsole(const QString& aQueue); diff --git a/KelvinDashboardGUI/DapUiQmlWidgetConsole.cpp b/KelvinDashboardGUI/DapConsoleModel.cpp similarity index 53% rename from KelvinDashboardGUI/DapUiQmlWidgetConsole.cpp rename to KelvinDashboardGUI/DapConsoleModel.cpp index 475072cfde4801a08c2f0c8b5a0ea9ae9e538465..04e4b89c236773f6b7a70edf0a3ccd21484e3f0d 100644 --- a/KelvinDashboardGUI/DapUiQmlWidgetConsole.cpp +++ b/KelvinDashboardGUI/DapConsoleModel.cpp @@ -1,57 +1,54 @@ -#include "DapUiQmlWidgetConsole.h" +#include "DapConsoleModel.h" -DapUiQmlWidgetConsoleModel::DapUiQmlWidgetConsoleModel(QObject *parent) : +DapConsoleModel::DapConsoleModel(QObject *parent) : QAbstractListModel(parent) { } -DapUiQmlWidgetConsoleModel& DapUiQmlWidgetConsoleModel::getInstance() +DapConsoleModel& DapConsoleModel::getInstance() { - static DapUiQmlWidgetConsoleModel instance; + static DapConsoleModel instance; return instance; } -void DapUiQmlWidgetConsoleModel::receiveResponse(const QString& aResponse) +void DapConsoleModel::receiveResponse(const QString& aResponse) { emit sendResponse(aResponse); } -int DapUiQmlWidgetConsoleModel::rowCount(const QModelIndex& parent) const +int DapConsoleModel::rowCount(const QModelIndex& parent) const { Q_UNUSED(parent) return m_CommandList.count(); } -QVariant DapUiQmlWidgetConsoleModel::data(const QModelIndex& index, int role) const +QVariant DapConsoleModel::data(const QModelIndex& index, int role) const { if (!index.isValid()) return QVariant(); if(role == LastCommand) - { - qDebug() << "data:" << m_CommandList.at(index.row()); return m_CommandList.at(index.row()); - } return QVariant(); } -QHash<int, QByteArray> DapUiQmlWidgetConsoleModel::roleNames() const +QHash<int, QByteArray> DapConsoleModel::roleNames() const { QHash<int, QByteArray> roles; roles[LastCommand] = "lastCommand"; return roles; } -QString DapUiQmlWidgetConsoleModel::getCommandUp() +QString DapConsoleModel::getCommandUp() { if(m_CommandList.isEmpty()) return QString(); if(m_CommandIndex > m_CommandList.begin()) m_CommandIndex--; return *m_CommandIndex; } -QString DapUiQmlWidgetConsoleModel::getCommandDown() +QString DapConsoleModel::getCommandDown() { if(m_CommandList.isEmpty()) return QString(); if(m_CommandIndex < m_CommandList.end() -1) m_CommandIndex++; @@ -59,7 +56,7 @@ QString DapUiQmlWidgetConsoleModel::getCommandDown() return *m_CommandIndex; } -void DapUiQmlWidgetConsoleModel::receiveRequest(const QString& aCommand) +void DapConsoleModel::receiveRequest(const QString& aCommand) { beginResetModel(); m_CommandList.append(aCommand); diff --git a/KelvinDashboardGUI/DapUiQmlWidgetConsole.h b/KelvinDashboardGUI/DapConsoleModel.h similarity index 50% rename from KelvinDashboardGUI/DapUiQmlWidgetConsole.h rename to KelvinDashboardGUI/DapConsoleModel.h index 232ec64d4a7b97a9dd82ff4b85738bf69b5138a9..cc2d5f64ea245de947b79c209baff51fa70229c1 100644 --- a/KelvinDashboardGUI/DapUiQmlWidgetConsole.h +++ b/KelvinDashboardGUI/DapConsoleModel.h @@ -5,11 +5,13 @@ #include <QAbstractListModel> #include <QStringList> -class DapUiQmlWidgetConsoleModel : public QAbstractListModel +/// Model for DAP console +class DapConsoleModel : public QAbstractListModel { Q_OBJECT public: + /// Enumeration for model roles enum ConsoleRole { LastCommand = Qt::DisplayRole }; @@ -19,24 +21,38 @@ private: QStringList::iterator m_CommandIndex; public: - explicit DapUiQmlWidgetConsoleModel(QObject *parent = nullptr); + explicit DapConsoleModel(QObject *parent = nullptr); public slots: + /// Receive response from service about command + /// @param result void receiveResponse(const QString& aResponse); + /// Override methods of abstract model int rowCount(const QModelIndex& parent) const override; QVariant data(const QModelIndex& index, int role) const override; QHash<int, QByteArray> roleNames() const override; - Q_INVOKABLE static DapUiQmlWidgetConsoleModel& getInstance(); + /// Getting instanse of this class + /// @return instanse of this class + Q_INVOKABLE static DapConsoleModel& getInstance(); + /// Get the latest commands + /// @return the latest commands Q_INVOKABLE QString getCommandUp(); + /// Get the earliest commands + /// @return the earliest commands. If it is last command in the list + /// it returns QString() Q_INVOKABLE QString getCommandDown(); + /// Receive command requst for service + /// @param command request Q_INVOKABLE void receiveRequest(const QString& aCommand); signals: + /// Signal to send request to the service + /// @param command void sendRequest(QString command); + /// Signal for getting response from service + /// @param result of command void sendResponse(QString response); - - }; #endif // DAPUIQMLSCREENCONSOLEFORM_H diff --git a/KelvinDashboardGUI/DapScreenHistoryFilterModel.h b/KelvinDashboardGUI/DapScreenHistoryFilterModel.h index 8c38e0f492f9c25ab0fc0e825c85df7a72c6475f..5753a5c030c96d87b9d9a36205a872e99ba1a0f8 100644 --- a/KelvinDashboardGUI/DapScreenHistoryFilterModel.h +++ b/KelvinDashboardGUI/DapScreenHistoryFilterModel.h @@ -16,16 +16,26 @@ private: int m_status; protected: + /// Overides methods bool lessThan(const QModelIndex& source_left, const QModelIndex& source_right) const; bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const; public: explicit DapScreenHistoryFilterModel(QObject *parent = nullptr); + /// Get instance of this class + /// @return instance of this class static DapScreenHistoryFilterModel &getInstance(); public slots: + /// Filter model with wallet + /// @param number of wallet void setFilterWallet(const QString& aWalletNumber); + /// Filter model with dates + /// @param Min date + /// @param Max date void setFilterDate(const QDate& aDateLeft, const QDate& aDateRight); + /// Filter with status of transacrion + /// @param status of transaction void setFilterStatus(const DapTransactionStatus aStatus); }; diff --git a/KelvinDashboardGUI/DapScreenHistoryModel.cpp b/KelvinDashboardGUI/DapScreenHistoryModel.cpp index 24656d6ef26e797c8a34d3729ebba18a6978e6fe..91754fae220b5828e8b552efadac766768a0db9c 100644 --- a/KelvinDashboardGUI/DapScreenHistoryModel.cpp +++ b/KelvinDashboardGUI/DapScreenHistoryModel.cpp @@ -26,9 +26,30 @@ QHash<int, QByteArray> DapScreenHistoryModel::roleNames() const return names; } +QString DapScreenHistoryModel::toConvertCurrency(const QString& aMoney) const +{ + QString money; + + QStringList major = aMoney.split("."); + if(!major.isEmpty()) money = major.at(0); + else money = aMoney; + + for (int i = money.size() - 3; i >= 1; i -= 3) + money.insert(i, ' '); + + if(major.count() > 1) money.append("." + major.at(1)); + + return money; +} + void DapScreenHistoryModel::receiveNewData(const QVariant& aData) { - if(!aData.isValid()) return; + if(!aData.isValid()) + { + qWarning() << "New history data is not valid"; + return; + } + beginResetModel(); QList<QVariant> dataList = aData.toList(); m_elementList.clear(); @@ -51,19 +72,29 @@ void DapScreenHistoryModel::receiveNewData(const QVariant& aData) item.Cryptocurrency = dataItem.at(2); item.TokenName = dataItem.at(3); item.WalletNumber = dataItem.at(5); - item.Currency = "$ 0 USD"; // TODO: + // TODO: Later we should convert currency + item.Currency = QString::number(dataItem.at(2).toDouble() * 0.98); switch (item.Status) { - case DapTransactionStatus::stSent: item.Cryptocurrency.prepend("- "); break; - case DapTransactionStatus::stReceived: item.Cryptocurrency.prepend("+ "); break; + case DapTransactionStatus::stSent: + item.Cryptocurrency.prepend("- "); + item.Currency.prepend("- $ "); + break; + case DapTransactionStatus::stReceived: + item.Cryptocurrency.prepend("+ "); + item.Currency.prepend("+ $ "); + break; default: break; } + item.Cryptocurrency = toConvertCurrency(item.Cryptocurrency); item.Cryptocurrency += " " + item.TokenName; + item.Currency.append(" USD"); m_elementList.append(item); } + endResetModel(); } diff --git a/KelvinDashboardGUI/DapScreenHistoryModel.h b/KelvinDashboardGUI/DapScreenHistoryModel.h index 4314fe2fb74fb20b37ad317ac7e24fac096b1cc0..0993e31181fa0844d71998d95b24ca952dbf4b89 100644 --- a/KelvinDashboardGUI/DapScreenHistoryModel.h +++ b/KelvinDashboardGUI/DapScreenHistoryModel.h @@ -1,10 +1,12 @@ #ifndef DAPSCREENHISTORYMODEL_H #define DAPSCREENHISTORYMODEL_H +#include <QtGlobal> #include <QDebug> #include <QImage> #include <QAbstractListModel> #include <QDateTime> +#include <QTimer> #include "DapHistoryType.h" #define MASK_FOR_MODEL QString("MMMM, dd") @@ -14,24 +16,7 @@ class DapScreenHistoryModel : public QAbstractListModel Q_OBJECT public: -// enum DapTransactionStatus { -// Pending, -// Sent, -// Received, -// Error -// }; -// Q_ENUM(DapTransactionStatus) - -// struct DapTransactionItem { -// QDateTime Date; -// QImage TokenPic; -// DapTransactionStatus Status; -// QString TokenName; -// QString WalletNumber; -// QString Cryptocurrency; -// QString Currency; -// }; - + /// Role enumeration enum { DisplayDateRole = Qt::UserRole, DateRole, @@ -49,14 +34,28 @@ private: public: explicit DapScreenHistoryModel(QObject *parent = nullptr); + /// Get instance of this class + /// @param instance of this class static DapScreenHistoryModel &getInstance(); + /// Override model's methods int rowCount(const QModelIndex &parent = QModelIndex()) const override; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; QHash<int, QByteArray> roleNames() const override; + Q_INVOKABLE QString toConvertCurrency(const QString& aMoney) const; + public slots: + /// Receive new tx history + /// @param QList<QStringList> data void receiveNewData(const QVariant& aData); + +signals: + /// Signal for requset current state of tx history + /// By defalt this signal emits when the client has just started while + /// the tx model will not get at least one tx history. + /// The signal stop emitting after getting the request result + void sendRequestHistory(); }; #endif // DAPSCREENHISTORYMODEL_H diff --git a/KelvinDashboardGUI/DapServiceController.cpp b/KelvinDashboardGUI/DapServiceController.cpp index df1d1f18a7a08f34d4d9a73cc8a0e77b7dcf2f3c..d82608f0f7aa6c71efddcfc35e2ea320e7b2e6d8 100755 --- a/KelvinDashboardGUI/DapServiceController.cpp +++ b/KelvinDashboardGUI/DapServiceController.cpp @@ -60,8 +60,8 @@ void DapServiceController::init(DapServiceClient *apDapServiceClient) connect(m_pDapCommandController, &DapCommandController::sendHistory, &DapScreenHistoryModel::getInstance(), &DapScreenHistoryModel::receiveNewData); - connect(&DapUiQmlWidgetConsoleModel::getInstance(), &DapUiQmlWidgetConsoleModel::sendRequest, m_pDapCommandController, &DapCommandController::requestConsole); - connect(m_pDapCommandController, &DapCommandController::responseConsole, &DapUiQmlWidgetConsoleModel::getInstance(), &DapUiQmlWidgetConsoleModel::receiveResponse); + connect(&DapConsoleModel::getInstance(), &DapConsoleModel::sendRequest, m_pDapCommandController, &DapCommandController::requestConsole); + connect(m_pDapCommandController, &DapCommandController::responseConsole, &DapConsoleModel::getInstance(), &DapConsoleModel::receiveResponse); } QString DapServiceController::getBrand() const @@ -81,15 +81,6 @@ QString DapServiceController::getResult() return m_sResult; } -/// Get node logs. -/// @param aiTimeStamp Timestamp start reading logging. -/// @param aiRowCount Number of lines displayed. -void DapServiceController::getNodeLogs(int aiTimeStamp, int aiRowCount) const -{ - qInfo() << QString("getNodeLogs(%1, %2)").arg(aiTimeStamp).arg(aiRowCount); - m_pDapCommandController->getNodeLogs(aiTimeStamp, aiRowCount); -} - void DapServiceController::getWallets() const { qInfo() << QString("getNodeLogs()"); @@ -190,7 +181,6 @@ void DapServiceController::getHistory() void DapServiceController::getNodeNetwork() { - qInfo() << QString("requestNodeNetwork"); m_pDapCommandController->getNodeNetwork(); } diff --git a/KelvinDashboardGUI/DapServiceController.h b/KelvinDashboardGUI/DapServiceController.h index 55fe6b2960333e099476070d1b50454b4bd80d08..472d304a73e0016dd9ea0f19b3a7727caad40c41 100755 --- a/KelvinDashboardGUI/DapServiceController.h +++ b/KelvinDashboardGUI/DapServiceController.h @@ -15,7 +15,7 @@ #include "DapChainWalletsModel.h" #include "DapChainNodeNetworkModel.h" #include "DapScreenHistoryModel.h" -#include "DapUiQmlWidgetConsole.h" +#include "DapConsoleModel.h" class DapServiceController : public QObject { @@ -36,8 +36,6 @@ class DapServiceController : public QObject explicit DapServiceController(QObject *apParent = nullptr); public: - - /// Get an instance of a class. /// @return Instance of a class. Q_INVOKABLE static DapServiceController &getInstance(); @@ -83,7 +81,7 @@ public: void getWalletInfo(const QString& asWalletName); - void getHistory(); + signals: /// The signal is emitted when the Brand company property changes. @@ -120,13 +118,17 @@ private slots: void processGetHistory(const QVariant& aData); public slots: + /// Get history of transaction + void getHistory(); + /// Get node network for explorer void getNodeNetwork(); + /// Change status of node + /// @param it is true if a node is online void setNodeStatus(const bool aIsOnline); - + /// void get(); + /// Get node logs. - /// @param aiTimeStamp Timestamp start reading logging. - /// @param aiRowCount Number of lines displayed. Q_INVOKABLE void getNodeLogs() const; void clearLogModel(); diff --git a/KelvinDashboardGUI/DapUiQmlScreenConsoleForm.qml b/KelvinDashboardGUI/DapUiQmlScreenConsoleForm.qml deleted file mode 100644 index 553a5d815d940e04946ab87252ff68d6ff574466..0000000000000000000000000000000000000000 --- a/KelvinDashboardGUI/DapUiQmlScreenConsoleForm.qml +++ /dev/null @@ -1,63 +0,0 @@ -import QtQuick 2.13 -import QtQml 2.12 -import QtQuick.Controls 2.2 -import QtQuick.Layouts 1.12 - -Page { - - Flickable { - anchors.left: parent.left - anchors.top: parent.top - anchors.right: lastActionsPanel.left - anchors.bottom: parent.bottom - - leftMargin: 30 * pt - topMargin: 30 * pt - rightMargin: 30 * pt - - TextArea.flickable: DapUiQmlWidgetConsoleForm { - } - - ScrollBar.vertical: ScrollBar{} - } - -// DapUiQmlWidgetConsoleLastActionsForm { - -// } - - - - Rectangle { - id: lastActionsPanel - width: 400 * pt - border.color: "#B5B5B5" - border.width: 1 * pt - color: "#EDEFF2" - - anchors { - top: parent.top - right: parent.right - bottom: parent.bottom - } - - ListView { - anchors.fill: parent - - model: dapConsoleModel - delegate: - Component { - Rectangle { - width: lastActionsPanel.width - height: 60 * pt - Text { - text: lastCommand - color: "#000000" - font.pixelSize: 20 * pt - } - } - } - - } - } - -} diff --git a/KelvinDashboardGUI/DapUiQmlScreenConsoleForm.ui.qml b/KelvinDashboardGUI/DapUiQmlScreenConsoleForm.ui.qml new file mode 100644 index 0000000000000000000000000000000000000000..3d05c3ae28629ec8b8859b1bc5f62390797e6e3e --- /dev/null +++ b/KelvinDashboardGUI/DapUiQmlScreenConsoleForm.ui.qml @@ -0,0 +1,25 @@ +import QtQuick 2.13 +import QtQml 2.12 +import QtQuick.Controls 2.2 +import QtQuick.Layouts 1.12 + +Page { + Flickable { + anchors.left: parent.left + anchors.top: parent.top + anchors.right: lastActionsPanel.left + anchors.bottom: parent.bottom + + leftMargin: 30 * pt + topMargin: 30 * pt + rightMargin: 30 * pt + + TextArea.flickable: DapUiQmlWidgetConsoleForm {} + + ScrollBar.vertical: ScrollBar{} + } + + DapUiQmlWidgetConsoleLastActionsForm { + id: lastActionsPanel + } +} diff --git a/KelvinDashboardGUI/DapUiQmlScreenDialog.qml b/KelvinDashboardGUI/DapUiQmlScreenDialog.qml index 98b903eb12867843898e4c09555d6018915d510a..4f15a205050ff270f88df7af748098eb50508491 100644 --- a/KelvinDashboardGUI/DapUiQmlScreenDialog.qml +++ b/KelvinDashboardGUI/DapUiQmlScreenDialog.qml @@ -57,4 +57,15 @@ Page { listViewDapWidgets.addWidget() } } + + DapUiQmlWidgetLastActions { + viewModel: dapHistoryModel + viewDelegate: DapUiQmlWidgetLastActionsDelegateForm {} + viewSection.property: "date" + viewSection.criteria: ViewSection.FullString + viewSection.delegate: DapUiQmlWidgetLastActionsSectionForm { + width: parent.width + height: 30 * pt + } + } } diff --git a/KelvinDashboardGUI/DapUiQmlScreenExchangeForm.ui.qml b/KelvinDashboardGUI/DapUiQmlScreenExchangeForm.ui.qml new file mode 100644 index 0000000000000000000000000000000000000000..7e796a587da699b94c49f35573c5fa321f35e87b --- /dev/null +++ b/KelvinDashboardGUI/DapUiQmlScreenExchangeForm.ui.qml @@ -0,0 +1,31 @@ +import QtQuick 2.12 +import QtQml 2.12 +import QtQuick.Controls 2.12 +import QtQuick.Layouts 1.12 + +Page { + + Row { + anchors.left: parent.left + anchors.bottom: parent.bottom + anchors.leftMargin: 28 * pt + anchors.bottomMargin: 42 * pt + spacing: 68 * pt + + DapUiQmlWidgetExchangeOrderForm { + titleOrder: qsTr("Buy") + + } + + DapUiQmlWidgetExchangeOrderForm { + titleOrder: qsTr("Sell") + } + } +} + + + +/*##^## Designer { + D{i:0;autoSize:true;height:480;width:640} +} + ##^##*/ diff --git a/KelvinDashboardGUI/DapUiQmlScreenHistory.qml b/KelvinDashboardGUI/DapUiQmlScreenHistory.qml index 71473ee8c45de898c060d4ed2a2a5a36442f5b1a..05772a700f25ad9ef22190aafcea97ba71a7e2a3 100644 --- a/KelvinDashboardGUI/DapUiQmlScreenHistory.qml +++ b/KelvinDashboardGUI/DapUiQmlScreenHistory.qml @@ -5,21 +5,13 @@ import QtQuick.Layouts 1.12 import DapTransactionHistory 1.0 -Page { - ListView { - id: dapListView - anchors.fill: parent - model: dapHistoryModel - delegate: dapDelegate - section.property: "date" - section.criteria: ViewSection.FullString - section.delegate: dapDate - } +DapUiQmlScreenHistoryForm { + id: dapUiQmlScreenHistory Component { - id: dapDate + id: delegateDate Rectangle { - width: dapListView.width + width: parent.width height: 30 * pt color: "#DFE1E6" @@ -36,8 +28,9 @@ Page { } } + Component { - id: dapDelegate + id: delegateConetnet Column { Rectangle { @@ -249,4 +242,11 @@ Page { } } } + + +} + +/*##^## Designer { + D{i:0;autoSize:true;height:480;width:640} } + ##^##*/ diff --git a/KelvinDashboardGUI/DapUiQmlScreenHistoryForm.ui.qml b/KelvinDashboardGUI/DapUiQmlScreenHistoryForm.ui.qml new file mode 100644 index 0000000000000000000000000000000000000000..2fd35cb48adc5d570387ed689a33bbe005624d79 --- /dev/null +++ b/KelvinDashboardGUI/DapUiQmlScreenHistoryForm.ui.qml @@ -0,0 +1,18 @@ +import QtQuick 2.9 +import QtQml 2.12 +import QtQuick.Controls 2.2 +import QtQuick.Layouts 1.12 + +import DapTransactionHistory 1.0 + +Page { + ListView { + id: dapListView + anchors.fill: parent + model: dapHistoryModel + delegate: delegateConetnet + section.property: "date" + section.criteria: ViewSection.FullString + section.delegate: delegateDate + } +} diff --git a/KelvinDashboardGUI/DapUiQmlScreenMainWindow.qml b/KelvinDashboardGUI/DapUiQmlScreenMainWindow.qml new file mode 100644 index 0000000000000000000000000000000000000000..3e3535ac0ec40c26713dd48fc2bec6f685182c7c --- /dev/null +++ b/KelvinDashboardGUI/DapUiQmlScreenMainWindow.qml @@ -0,0 +1,102 @@ +import QtQuick 2.9 +import QtQuick.Controls 1.4 + +DapUiQmlScreenMainWindowForm { + id: dapQmlScreenMainWindow + + Component{ + id: componentItemMainMenuTab + Column { + id: columnTab + height: 148 + Rectangle { + id: componentItem + property bool isPushed: listViewTabs.currentIndex === index + + width: listViewTabs.width + height: 150 + color: "transparent" + Rectangle + { + id: spacerItem1 + height: 25 + anchors.top: parent.top + } + Image + { + id: imageItem + anchors.top: spacerItem1.bottom + source: model.source + height: 60 + width: 60 + anchors.horizontalCenter: parent.horizontalCenter + } + Rectangle + { + id: spacerItem2 + anchors.top: imageItem.bottom + height: 16 + } + Text + { + id: textItemMenu + anchors.top: spacerItem2.bottom + text: qsTr(name) + color: "#505559" + anchors.horizontalCenter: parent.horizontalCenter + font.family: "Roboto" + font.weight: componentItem.isPushed ? Font.Normal : Font.Light + font.pointSize: 16 + } + Rectangle + { + id: spacerItem3 + anchors.top: textItemMenu.bottom + height: 30 + } + MouseArea { + anchors.fill: parent + hoverEnabled: true + onEntered: + { + textItemMenu.font.weight = Font.Normal + if(!componentItem.isPushed) componentItem.color ="#B0B0B5" + } + onExited: + { + textItemMenu.font.weight = Font.Light + if(!componentItem.isPushed) componentItem.color = "transparent" + } + + onClicked: + { + listViewTabs.currentIndex = index + stackViewScreenDashboard.setSource(Qt.resolvedUrl(page)) + } + } + + onIsPushedChanged: { + componentItem.color = (isPushed ? "#D0D3D6" : "transparent"); + } + } + Rectangle + { + id: borderItem + height: 1 + color: "#B5B5B5" + width: parent.width + } + } + } +} + + + + + + + +/*##^## Designer { + D{i:0;autoSize:true;height:480;width:640} +} + ##^##*/ diff --git a/KelvinDashboardGUI/DapUiQmlScreenMainWindow.ui.qml b/KelvinDashboardGUI/DapUiQmlScreenMainWindow.ui.qml deleted file mode 100644 index 4f6d67ec1377c3aaf98d75915fa1422af5ff32fd..0000000000000000000000000000000000000000 --- a/KelvinDashboardGUI/DapUiQmlScreenMainWindow.ui.qml +++ /dev/null @@ -1,8 +0,0 @@ -import QtQuick 2.9 -import QtQuick.Controls 1.4 -import QtQuick.Controls 2.2 - -Page { - - title: qsTr("General") -} diff --git a/KelvinDashboardGUI/DapUiQmlScreenMainWindowForm.ui.qml b/KelvinDashboardGUI/DapUiQmlScreenMainWindowForm.ui.qml new file mode 100644 index 0000000000000000000000000000000000000000..da3b890a6e1a6b55b9dfce28f743851fccaf86e7 --- /dev/null +++ b/KelvinDashboardGUI/DapUiQmlScreenMainWindowForm.ui.qml @@ -0,0 +1,122 @@ +import QtQuick 2.9 +import QtQuick.Controls 1.4 +import QtQuick.Controls 2.2 +import QtQuick.Controls.Styles 1.4 + +import KelvinDashboard 1.0 + +Page { + id: dapUiQmlScreenMainWindow + title: qsTr("General") + + property alias listViewTabs: listViewTabs + property alias stackViewScreenDashboard: stackViewScreenDashboard + + + Rectangle + { + id: rectangleTabsBorder + anchors.top: parent.top + anchors.bottom: parent.bottom + anchors.left: parent.left + color: "#B5B5B5" + width: 150 + Rectangle { + id: rectangleTabs + anchors.fill: parent + anchors.leftMargin: 1 + anchors.rightMargin: 1 + + color: "#E1E4E6" + ListView { + id: listViewTabs + anchors.fill: parent + model: listModelTabs + spacing: 3 + + ListModel { + id: listModelTabs + + ListElement { + name: qsTr("Dashboard") + page: "DapUiQmlScreenDialog.qml" + source: "qrc:/Resources/Icons/defaul_icon.png" + } + ListElement { + name: qsTr("Exchange") + page: "DapUiQmlScreenExchangeForm.ui.qml" + source: "qrc:/Resources/Icons/defaul_icon.png" + } + ListElement { + name: qsTr("Settings") + page: "DapQmlScreenAbout.qml" + source: "qrc:/Resources/Icons/defaul_icon.png" + } + ListElement { + name: qsTr("Logs") + page: "DapUiQmlWidgetChainNodeLogs.qml" + source: "qrc:/Resources/Icons/defaul_icon.png" + } + ListElement { + name: qsTr("History") + page: "DapUiQmlScreenHistory.qml" + source: "qrc:/Resources/Icons/defaul_icon.png" + } + ListElement { + name: qsTr("Console") + page: "DapUiQmlScreenConsoleForm.ui.qml" + source: "qrc:/Resources/Icons/defaul_icon.png" + } + ListElement { + name: qsTr("About") + page: "DapQmlScreenAbout.qml" + source: "qrc:/Resources/Icons/defaul_icon.png" + } + } + delegate: componentItemMainMenuTab + + } + focus: true + } + } + + Rectangle + { + id: rectangleStatusBar + anchors.left: rectangleTabsBorder.right + anchors.top: parent.top + anchors.right: parent.right + color: "#B5B5B5" + height: 60 + Rectangle + { + anchors.fill: parent + anchors.bottomMargin: 1 + color: "#F2F2F4" + } + } + + Rectangle { + id: mainDashboard + anchors.left: rectangleTabsBorder.right + anchors.top: rectangleStatusBar.bottom + anchors.bottom: parent.bottom + anchors.right: parent.right + border.color: "whitesmoke" + + Loader { + id: stackViewScreenDashboard + clip: true + anchors.fill: parent + source: "DapUiQmlScreenDialog.qml" + } + } +} + + + + +/*##^## Designer { + D{i:0;autoSize:true;height:480;width:640} +} + ##^##*/ diff --git a/KelvinDashboardGUI/DapUiQmlWidgetConsoleLastActionsDelegateForm.qml b/KelvinDashboardGUI/DapUiQmlWidgetConsoleLastActionsDelegateForm.qml new file mode 100644 index 0000000000000000000000000000000000000000..65ae6d23b6144cd7954fcce735ba841e352a355b --- /dev/null +++ b/KelvinDashboardGUI/DapUiQmlWidgetConsoleLastActionsDelegateForm.qml @@ -0,0 +1,14 @@ +import QtQuick 2.0 + +Rectangle { + color: "transparent" + + Text { + anchors.fill: parent + verticalAlignment: Qt.AlignVCenter + text: lastCommand + color: "#5F5F63" + font.family: "Roboto Regular" + font.pixelSize: 14 * pt + } +} diff --git a/KelvinDashboardGUI/DapUiQmlWidgetConsoleLastActionsForm.qml b/KelvinDashboardGUI/DapUiQmlWidgetConsoleLastActionsForm.qml index 0790e5bb58baa026e21207fc99608740046ecb9b..df9a98fedc1a4e1642d540aac80c5a1f3b018844 100644 --- a/KelvinDashboardGUI/DapUiQmlWidgetConsoleLastActionsForm.qml +++ b/KelvinDashboardGUI/DapUiQmlWidgetConsoleLastActionsForm.qml @@ -1,12 +1,12 @@ import QtQuick 2.0 -ListView { - - model: dapConsoleController - delegate: Text { - text: lastCommand - color: "#000000"; - font.pixelSize: 20 * pt +DapUiQmlWidgetLastActions { + id: lastActionsPanel + viewModel: dapConsoleModel + viewDelegate: DapUiQmlWidgetConsoleLastActionsDelegateForm { + width: lastActionsPanel.width + height: 50 * pt + anchors.left: parent.left + anchors.leftMargin: 18 * pt } - } diff --git a/KelvinDashboardGUI/DapUiQmlWidgetExchangeOrderButtonForm.ui.qml b/KelvinDashboardGUI/DapUiQmlWidgetExchangeOrderButtonForm.ui.qml new file mode 100644 index 0000000000000000000000000000000000000000..d85a8a71cf3b9adecae3c3825ec3c580656ff263 --- /dev/null +++ b/KelvinDashboardGUI/DapUiQmlWidgetExchangeOrderButtonForm.ui.qml @@ -0,0 +1,27 @@ +import QtQuick 2.12 +import QtQml 2.12 +import QtQuick.Controls 2.12 +import QtQuick.Layouts 1.12 + +Button { + property alias buttonFont: buttonText.font.family + property alias buttonText: buttonText.text + + id: buttonBuy + width: 70 * pt + height: 30 * pt + + contentItem: Text { + id: buttonText + color: "#FFFFFF" + font.pixelSize: 14 * pt + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + } + + background: Rectangle { + implicitWidth: parent.width + implicitHeight: parent.height + color: buttonBuy.hovered ? "#A2A4A7" : "#4F5357" + } +} diff --git a/KelvinDashboardGUI/DapUiQmlWidgetExchangeOrderContentForm.ui.qml b/KelvinDashboardGUI/DapUiQmlWidgetExchangeOrderContentForm.ui.qml new file mode 100644 index 0000000000000000000000000000000000000000..be2e895fc8157631d9e83a19ca3d80c9a27579ef --- /dev/null +++ b/KelvinDashboardGUI/DapUiQmlWidgetExchangeOrderContentForm.ui.qml @@ -0,0 +1,73 @@ +import QtQuick 2.12 +import QtQml 2.12 +import QtQuick.Controls 2.12 +import QtQuick.Layouts 1.12 + +Item { + property string contentFont: "" + width: childrenRect.width + height: childrenRect.height + + ColumnLayout { + spacing: 16 * pt + + Repeater { + model: [qsTr("Ammount"), qsTr("Price"), qsTr("Total"), qsTr("Fee (0.2%)"), qsTr("Total+Fee")] + RowLayout { + spacing: 0 + Rectangle { + height: childrenRect.height + width: 120 * pt + + Text { + text: modelData + color: "#ACACAF" + font.family: contentFont + font.pixelSize: 12 * pt + } + } + + + Rectangle { + width: 130 * pt + height: 22 * pt + border.width: 1 * pt + border.color: "#B0B1B5" + + TextInput { + id: currencyTextInput + anchors.left: parent.left + anchors.top: parent.top + anchors.bottom: parent.bottom + anchors.right: textCurrency.left + anchors.leftMargin: 6 * pt + anchors.rightMargin: 6 * pt + color: readOnly ? "#ACACAF" : "#737880" + font.family: contentFont + font.pixelSize: 12 * pt + verticalAlignment: Qt.AlignVCenter + validator: RegExpValidator{ regExp: /\d+/ } + clip: true + readOnly: index === 3 || index === 4 + text: readOnly ? "0" : "" + } + + Text { + id: textCurrency + anchors.right: parent.right + anchors.top: parent.top + anchors.bottom: parent.bottom + anchors.rightMargin: 6 * pt + verticalAlignment: Text.AlignVCenter + horizontalAlignment: Text.AlignRight + color: currencyTextInput.readOnly ? "#ACACAF" : "#737880" + font.family: contentFont + font.pixelSize: 12 * pt + text: index === 0 ? currencyName : qsTr("USD") + } + } + } + } + } + +} diff --git a/KelvinDashboardGUI/DapUiQmlWidgetExchangeOrderForm.ui.qml b/KelvinDashboardGUI/DapUiQmlWidgetExchangeOrderForm.ui.qml new file mode 100644 index 0000000000000000000000000000000000000000..0f23637175f6f3c6557015c9d25a9f9011f3ff07 --- /dev/null +++ b/KelvinDashboardGUI/DapUiQmlWidgetExchangeOrderForm.ui.qml @@ -0,0 +1,49 @@ +import QtQuick 2.12 +import QtQml 2.12 +import QtQuick.Controls 2.12 +import QtQuick.Layouts 1.12 + +Item { + property alias titleOrder: orderTitle.orderText + property string currencyName: qsTr("KLVN") + property string balance: "0" + + width: childrenRect.width + height: childrenRect.height + + ColumnLayout { + + DapUiQmlWidgetExchangeOrderTitleForm { + id: orderTitle + orderFont: "Roboto" + + } + + Text { + text: qsTr("Balance: ") + balance + " " + currencyName + color: "#ACACAF" + font.family: "Roboto" + font.pixelSize: 12 * pt + } + + Rectangle { + width: parent.width + height: 6 * pt + + } + + DapUiQmlWidgetExchangeOrderContentForm { + contentFont: "Roboto" + } + + Rectangle { + height: 12 * pt + width: parent.width + } + + DapUiQmlWidgetExchangeOrderButtonForm { + buttonFont: "Roboto" + buttonText: titleOrder + } + } +} diff --git a/KelvinDashboardGUI/DapUiQmlWidgetExchangeOrderTitleForm.ui.qml b/KelvinDashboardGUI/DapUiQmlWidgetExchangeOrderTitleForm.ui.qml new file mode 100644 index 0000000000000000000000000000000000000000..a90eb4096a863a238ba3cd91048decb89f341133 --- /dev/null +++ b/KelvinDashboardGUI/DapUiQmlWidgetExchangeOrderTitleForm.ui.qml @@ -0,0 +1,32 @@ +import QtQuick 2.12 +import QtQml 2.12 +import QtQuick.Controls 2.12 +import QtQuick.Layouts 1.12 + +Item { + property alias orderText: textOrder.text + property alias orderFont: textOrder.font.family + + width: childrenRect.width + height: childrenRect.height + + RowLayout { + spacing: 8 * pt + Rectangle { + width: 32 + height: 32 + border.color: "#000000" + border.width: 1 + + Image { + anchors.fill: parent + } + } + + Text { + id: textOrder + color: "#4F5357" + font.pixelSize: 14 * pt + } + } +} diff --git a/KelvinDashboardGUI/DapUiQmlWidgetLastActions.qml b/KelvinDashboardGUI/DapUiQmlWidgetLastActions.qml new file mode 100644 index 0000000000000000000000000000000000000000..43b5284e3fdd437e19645472fca63bc05432f8e9 --- /dev/null +++ b/KelvinDashboardGUI/DapUiQmlWidgetLastActions.qml @@ -0,0 +1,57 @@ +import QtQuick 2.9 +import QtQml 2.12 +import QtQuick.Controls 2.2 +import QtQuick.Layouts 1.12 + +import DapTransactionHistory 1.0 + +DapUiQmlWidgetLastActionsForm { + + property alias viewModel: dapListView.model + property alias viewDelegate: dapListView.delegate + property alias viewSection: dapListView.section + + MouseArea { + id: mainMouseArea + anchors.fill: parent + hoverEnabled: true + + onEntered: { + if(!buttonListScroll.isHovered) + buttonListScroll.visible = true; + } + + onExited: { + if(!buttonListScroll.isHovered) + buttonListScroll.visible = false; + } + } + + DapUiQmlWidgetLastActionsHeaderForm { + id: dapHeader + } + + ListView { + id: dapListView + anchors.top: dapHeader.bottom + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: parent.bottom + clip: true + + property var contentPos: 0.0; + onContentYChanged: { + if(atYBeginning) buttonListScroll.state = "goUp"; + else if(atYEnd) buttonListScroll.state = "goDown" + else if(contentPos < contentItem.y) buttonListScroll.state = "goUp"; + else buttonListScroll.state = "goDown"; + + contentPos = contentItem.y; + } + + DapUiQmlWidgetLastActionsButtonForm { + id: buttonListScroll + viewData: dapListView + } + } +} diff --git a/KelvinDashboardGUI/DapUiQmlWidgetLastActionsButtonForm.qml b/KelvinDashboardGUI/DapUiQmlWidgetLastActionsButtonForm.qml new file mode 100644 index 0000000000000000000000000000000000000000..4cfdf0c59f097f6e465531c1bb2c4a9b1d0e3146 --- /dev/null +++ b/KelvinDashboardGUI/DapUiQmlWidgetLastActionsButtonForm.qml @@ -0,0 +1,91 @@ +import QtQuick 2.9 +import QtQml 2.12 +import QtQuick.Controls 2.2 +import QtQuick.Layouts 1.12 + +Item { + id: buttonScroll + + property ListView viewData: ListView{} + property bool isHovered: false + + width: 36 * pt + height: width + anchors.right: viewData.right + anchors.bottom: viewData.bottom + anchors.bottomMargin: 10 * pt + anchors.topMargin: 10 * pt + anchors.rightMargin: 10 * pt + visible: false + + Image { + id: imageButton + anchors.fill: parent + fillMode: Image.PreserveAspectFit + source: "qrc:/Resources/Icons/ic_scroll-down.png" + } + + states: [ + State { + name: "goDown" + PropertyChanges { + target: buttonScroll + onStateChanged: { + buttonScroll.anchors.top = undefined; + buttonScroll.anchors.bottom = dapListView.bottom; + buttonMouseArea.exited(); + } + } + }, + + State { + name: "goUp" + PropertyChanges { + target: buttonScroll + onStateChanged: { + buttonScroll.anchors.bottom = undefined; + buttonScroll.anchors.top = viewData.top; + buttonMouseArea.exited(); + } + } + } + ] + + state: "goUp" + + MouseArea { + id: buttonMouseArea + anchors.fill: parent + hoverEnabled: true + + onEntered: { + isHovered = true; + if(buttonScroll.state === "goUp") + imageButton.source = "qrc:/Resources/Icons/ic_scroll-down_hover.png"; + else if(buttonScroll.state === "goDown") + imageButton.source = "qrc:/Resources/Icons/ic_scroll-up_hover.png"; + + } + + onExited: { + isHovered = false; + if(buttonScroll.state === "goUp") + imageButton.source = "qrc:/Resources/Icons/ic_scroll-down.png"; + else if(buttonScroll.state === "goDown") + imageButton.source = "qrc:/Resources/Icons/ic_scroll-up.png"; + } + + onClicked: { + if(buttonScroll.state === "goUp") + { + viewData.positionViewAtEnd(); + buttonScroll.state = "goDown"; + } + else if(buttonScroll.state === "goDown") + { + viewData.positionViewAtBeginning(); + buttonScroll.state = "goUp"; + } + } + } +} diff --git a/KelvinDashboardGUI/DapUiQmlWidgetLastActionsDelegateForm.qml b/KelvinDashboardGUI/DapUiQmlWidgetLastActionsDelegateForm.qml new file mode 100644 index 0000000000000000000000000000000000000000..66af5b4500966a15ef2c9ca47832ebf634d4faec --- /dev/null +++ b/KelvinDashboardGUI/DapUiQmlWidgetLastActionsDelegateForm.qml @@ -0,0 +1,68 @@ +import QtQuick 2.9 +import QtQml 2.12 +import QtQuick.Controls 2.2 +import QtQuick.Layouts 1.12 + +Component { + Rectangle { + id: dapContentDelegate + width: parent.width + height: 50 * pt + color: "transparent" + + border.color: "#C2CAD1" + border.width: 1 * pt + + Rectangle { + id: dapData + width: childrenRect.width + height: childrenRect.height + Layout.alignment: Qt.AlignVCenter + anchors.left: dapContentDelegate.left + anchors.leftMargin: 16 * pt + anchors.top: parent.top + anchors.topMargin: 13 + + Column { + anchors.fill: parent + spacing: 2 + + Text { + text: tokenName + color: "#5F5F63" + font.family: "Roboto Regular" + font.pixelSize: 14 * pt + } + + Text { + text: txStatus + color: "#A7A7A7" + font.family: "Roboto" + font.pixelSize: 12 * pt + } + } + } + + Text { + anchors.left: dapData.right + anchors.top: parent.top + anchors.right: parent.right + anchors.bottom: parent.bottom + anchors.rightMargin: 20 * pt + + horizontalAlignment: Qt.AlignRight + verticalAlignment: Qt.AlignVCenter + color: "#505559" + text: cryptocurrency; + font.family: "Roboto" + font.pixelSize: 14 * pt + } + + Rectangle { + width: parent.width + height: 1 * pt + color: "#C7C9CC" + anchors.bottom: parent.bottom + } + } +} diff --git a/KelvinDashboardGUI/DapUiQmlWidgetLastActionsForm.ui.qml b/KelvinDashboardGUI/DapUiQmlWidgetLastActionsForm.ui.qml new file mode 100644 index 0000000000000000000000000000000000000000..27c038bccdac2e0064179f19529f0dc3684d6cc4 --- /dev/null +++ b/KelvinDashboardGUI/DapUiQmlWidgetLastActionsForm.ui.qml @@ -0,0 +1,14 @@ +import QtQuick 2.4 + +Rectangle { + width: 400 * pt + border.color: "#B5B5B5" + border.width: 1 * pt + color: "#EDEFF2" + + anchors { + top: parent.top + right: parent.right + bottom: parent.bottom + } +} diff --git a/KelvinDashboardGUI/DapUiQmlWidgetLastActionsHeaderForm.qml b/KelvinDashboardGUI/DapUiQmlWidgetLastActionsHeaderForm.qml new file mode 100644 index 0000000000000000000000000000000000000000..5a999d93f371f6ab0d5c091f8f9719702f9539e2 --- /dev/null +++ b/KelvinDashboardGUI/DapUiQmlWidgetLastActionsHeaderForm.qml @@ -0,0 +1,27 @@ +import QtQuick 2.9 +import QtQml 2.12 +import QtQuick.Controls 2.2 +import QtQuick.Layouts 1.12 + +Rectangle { + width: parent.width + height: 36 * pt + color: "#EDEFF2" + + Item { + width: childrenRect.width + height: childrenRect.height + anchors.top: parent.top + anchors.left: parent.left + + anchors.leftMargin: 16 * pt + anchors.topMargin: 13 + + Text { + text: qsTr("Last actions") + font.family: "Roboto" + font.pixelSize: 12 * pt + color: "#5F5F63" + } + } +} diff --git a/KelvinDashboardGUI/DapUiQmlWidgetLastActionsSectionForm.qml b/KelvinDashboardGUI/DapUiQmlWidgetLastActionsSectionForm.qml new file mode 100644 index 0000000000000000000000000000000000000000..a015babb205d8a140f241e1a11c204e522a42f9e --- /dev/null +++ b/KelvinDashboardGUI/DapUiQmlWidgetLastActionsSectionForm.qml @@ -0,0 +1,21 @@ +import QtQuick 2.9 +import QtQml 2.12 +import QtQuick.Controls 2.2 +import QtQuick.Layouts 1.12 + +Rectangle { +// width: dapListView.width +// height: 30 * pt + color: "#C2CAD1" + + Text { + anchors.fill: parent + verticalAlignment: Qt.AlignVCenter + horizontalAlignment: Qt.AlignLeft + color: "#797979" + text: section + font.family: "Roboto" + font.pixelSize: 12 * pt + leftPadding: 16 * pt + } +} diff --git a/KelvinDashboardGUI/KelvinDashboardGUI.pro b/KelvinDashboardGUI/KelvinDashboardGUI.pro index bf431dd61b01d9e1bff236419e3832a6ddf73ecd..9386bcf43829781d39fe1b2047e253e6fbfa45b5 100755 --- a/KelvinDashboardGUI/KelvinDashboardGUI.pro +++ b/KelvinDashboardGUI/KelvinDashboardGUI.pro @@ -42,10 +42,10 @@ ICON = icon.ico SOURCES += \ DapChainNodeNetworkExplorer.cpp \ DapChainNodeNetworkModel.cpp \ + DapConsoleModel.cpp \ DapScreenHistoryFilterModel.cpp \ DapScreenHistoryModel.cpp \ DapUiQmlWidgetChainTransactions.cpp \ - DapUiQmlWidgetConsole.cpp \ main.cpp \ DapUiQmlWidgetChainBallance.cpp \ DapUiQmlWidgetChainBlockExplorer.cpp \ @@ -79,6 +79,7 @@ else: unix:!android: target.path = /opt/kelvin-dashboard/bin HEADERS += \ DapChainNodeNetworkExplorer.h \ DapChainNodeNetworkModel.h \ + DapConsoleModel.h \ DapScreenHistoryFilterModel.h \ DapScreenHistoryModel.h \ DapUiQmlWidgetChainBallance.h \ @@ -87,7 +88,6 @@ HEADERS += \ DapUiQmlScreenDashboard.h \ DapUiQmlWidgetChainOperations.h \ DapUiQmlWidgetChainTransactions.h \ - DapUiQmlWidgetConsole.h \ DapUiQmlWidgetModel.h \ DapUiQmlWidget.h \ DapScreenDialog.h \ diff --git a/KelvinDashboardGUI/Resources/Fonts/LICENSE.txt b/KelvinDashboardGUI/Resources/Fonts/LICENSE.txt new file mode 100644 index 0000000000000000000000000000000000000000..d645695673349e3947e8e5ae42332d0ac3164cd7 --- /dev/null +++ b/KelvinDashboardGUI/Resources/Fonts/LICENSE.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/KelvinDashboardGUI/Resources/Fonts/roboto_black.ttf b/KelvinDashboardGUI/Resources/Fonts/roboto_black.ttf new file mode 100644 index 0000000000000000000000000000000000000000..51c71bbe2d565247a020319ff9b324e8c8e05353 Binary files /dev/null and b/KelvinDashboardGUI/Resources/Fonts/roboto_black.ttf differ diff --git a/KelvinDashboardGUI/Resources/Fonts/roboto_black_italic.ttf b/KelvinDashboardGUI/Resources/Fonts/roboto_black_italic.ttf new file mode 100644 index 0000000000000000000000000000000000000000..ca20ca399981d14c441b9ea2f3decc1c88e69da4 Binary files /dev/null and b/KelvinDashboardGUI/Resources/Fonts/roboto_black_italic.ttf differ diff --git a/KelvinDashboardGUI/Resources/Fonts/roboto_bold.ttf b/KelvinDashboardGUI/Resources/Fonts/roboto_bold.ttf new file mode 100644 index 0000000000000000000000000000000000000000..e612852d259930d0dcc632318ac0f15ae312422b Binary files /dev/null and b/KelvinDashboardGUI/Resources/Fonts/roboto_bold.ttf differ diff --git a/KelvinDashboardGUI/Resources/Fonts/roboto_bold_italic.ttf b/KelvinDashboardGUI/Resources/Fonts/roboto_bold_italic.ttf new file mode 100644 index 0000000000000000000000000000000000000000..677bc045e565c7b74c3ce0f8ad55df305bb28a29 Binary files /dev/null and b/KelvinDashboardGUI/Resources/Fonts/roboto_bold_italic.ttf differ diff --git a/KelvinDashboardGUI/Resources/Fonts/roboto_italic.ttf b/KelvinDashboardGUI/Resources/Fonts/roboto_italic.ttf new file mode 100644 index 0000000000000000000000000000000000000000..5fd05c3b645a8fdcdeffae18bffc19369514a76a Binary files /dev/null and b/KelvinDashboardGUI/Resources/Fonts/roboto_italic.ttf differ diff --git a/KelvinDashboardGUI/Resources/Fonts/roboto_light.ttf b/KelvinDashboardGUI/Resources/Fonts/roboto_light.ttf new file mode 100644 index 0000000000000000000000000000000000000000..4f1fb5805f432036d390a353c43191f06b0ad6e0 Binary files /dev/null and b/KelvinDashboardGUI/Resources/Fonts/roboto_light.ttf differ diff --git a/KelvinDashboardGUI/Resources/Fonts/roboto_light_italic.ttf b/KelvinDashboardGUI/Resources/Fonts/roboto_light_italic.ttf new file mode 100644 index 0000000000000000000000000000000000000000..eec0ae9be8f8f74279afe5253de5286c04fc2fad Binary files /dev/null and b/KelvinDashboardGUI/Resources/Fonts/roboto_light_italic.ttf differ diff --git a/KelvinDashboardGUI/Resources/Fonts/roboto_medium.ttf b/KelvinDashboardGUI/Resources/Fonts/roboto_medium.ttf new file mode 100644 index 0000000000000000000000000000000000000000..86d1c52ed5ee125fdfa6ed63a58f5c02f08dd246 Binary files /dev/null and b/KelvinDashboardGUI/Resources/Fonts/roboto_medium.ttf differ diff --git a/KelvinDashboardGUI/Resources/Fonts/roboto_medium_italic.ttf b/KelvinDashboardGUI/Resources/Fonts/roboto_medium_italic.ttf new file mode 100644 index 0000000000000000000000000000000000000000..66aa174f058481c39bcd60bdb464a1b3f78e4dcc Binary files /dev/null and b/KelvinDashboardGUI/Resources/Fonts/roboto_medium_italic.ttf differ diff --git a/KelvinDashboardGUI/Resources/Fonts/roboto_regular.ttf b/KelvinDashboardGUI/Resources/Fonts/roboto_regular.ttf new file mode 100644 index 0000000000000000000000000000000000000000..cb8ffcf1ad2c163bbf95ce6ff829b537d8bebd18 Binary files /dev/null and b/KelvinDashboardGUI/Resources/Fonts/roboto_regular.ttf differ diff --git a/KelvinDashboardGUI/Resources/Fonts/roboto_thin.ttf b/KelvinDashboardGUI/Resources/Fonts/roboto_thin.ttf new file mode 100644 index 0000000000000000000000000000000000000000..a85eb7c29505713608ec9fd8489944977914be21 Binary files /dev/null and b/KelvinDashboardGUI/Resources/Fonts/roboto_thin.ttf differ diff --git a/KelvinDashboardGUI/Resources/Fonts/roboto_thin_italic.ttf b/KelvinDashboardGUI/Resources/Fonts/roboto_thin_italic.ttf new file mode 100644 index 0000000000000000000000000000000000000000..ac77951b80fc3ad37533dcae49c9e8085c42f1fb Binary files /dev/null and b/KelvinDashboardGUI/Resources/Fonts/roboto_thin_italic.ttf differ diff --git a/KelvinDashboardGUI/Resources/Icons/ic_scroll-down.png b/KelvinDashboardGUI/Resources/Icons/ic_scroll-down.png new file mode 100644 index 0000000000000000000000000000000000000000..d818c8143a6559934f39f7dff38f40f45286023d Binary files /dev/null and b/KelvinDashboardGUI/Resources/Icons/ic_scroll-down.png differ diff --git a/KelvinDashboardGUI/Resources/Icons/ic_scroll-down_hover.png b/KelvinDashboardGUI/Resources/Icons/ic_scroll-down_hover.png new file mode 100644 index 0000000000000000000000000000000000000000..aa00573edda7f485f7616a97337b101fd4ad6844 Binary files /dev/null and b/KelvinDashboardGUI/Resources/Icons/ic_scroll-down_hover.png differ diff --git a/KelvinDashboardGUI/Resources/Icons/ic_scroll-up.png b/KelvinDashboardGUI/Resources/Icons/ic_scroll-up.png new file mode 100644 index 0000000000000000000000000000000000000000..e0ace3f8ac7d1cf8f0b2c264d58682bc68fed2f4 Binary files /dev/null and b/KelvinDashboardGUI/Resources/Icons/ic_scroll-up.png differ diff --git a/KelvinDashboardGUI/Resources/Icons/ic_scroll-up_hover.png b/KelvinDashboardGUI/Resources/Icons/ic_scroll-up_hover.png new file mode 100644 index 0000000000000000000000000000000000000000..8c698e0bd164cd4efac4da44d0103201411a26ca Binary files /dev/null and b/KelvinDashboardGUI/Resources/Icons/ic_scroll-up_hover.png differ diff --git a/KelvinDashboardGUI/main.cpp b/KelvinDashboardGUI/main.cpp index b073281bacc8b23ce68cbb6eceb9695cce32b9b4..7e765e08e73538565cb93a4078b0bca4bd7cf0c4 100755 --- a/KelvinDashboardGUI/main.cpp +++ b/KelvinDashboardGUI/main.cpp @@ -23,7 +23,7 @@ #include "DapChainNodeNetworkModel.h" #include "DapChainNodeNetworkExplorer.h" #include "DapScreenHistoryFilterModel.h" -#include "DapUiQmlWidgetConsole.h" +#include "DapConsoleModel.h" #include <QRegExp> @@ -51,43 +51,32 @@ int main(int argc, char *argv[]) DapServiceController &controller = DapServiceController::getInstance(); controller.init(&dapServiceClient); dapServiceClient.init(); - controller.getNodeLogs(0, 100); controller.getWallets(); controller.getHistory(); DapScreenHistoryFilterModel::getInstance() .setSourceModel(&DapScreenHistoryModel::getInstance()); -// controller.getNodeNetwork(); qmlRegisterType<DapScreenDialog>("KelvinDashboard", 1, 0, "DapScreenDialog"); qmlRegisterType<DapScreenDialogChangeWidget>("KelvinDashboard", 1, 0, "DapScreenDialogChangeWidget"); qmlRegisterType<DapLogMessage>("LogMessage", 1, 0, "DapLogMessage"); qmlRegisterType<DapChainNodeNetworkExplorer>("NodeNetworkExplorer", 1, 0, "DapUiQmlWidgetNodeNetwork"); -// qmlRegisterType<DapScreenHistoryModel>("") qmlRegisterSingletonType<DapUiQmlWidgetModel>("KelvinDashboard", 1, 0, "DapUiQmlWidgetModel", DapUiQmlWidgetModel::singletonProvider); qmlRegisterType<DapScreenHistoryModel>("DapTransactionHistory", 1, 0, "DapTransactionModel"); QQmlApplicationEngine engine; + /// TODO: this method for getting DPI screen can be useful in the future // qreal dpi = QGuiApplication::primaryScreen()->physicalDotsPerInch(); engine.rootContext()->setContextProperty("dapServiceController", &DapServiceController::getInstance()); engine.rootContext()->setContextProperty("dapUiQmlWidgetModel", &DapUiQmlWidgetModel::getInstance()); engine.rootContext()->setContextProperty("dapLogModel", &DapLogModel::getInstance()); engine.rootContext()->setContextProperty("dapChainWalletsModel", &DapChainWalletsModel::getInstance()); engine.rootContext()->setContextProperty("dapNodeNetworkModel", &DapChainNodeNetworkModel::getInstance()); - engine.rootContext()->setContextProperty("dapConsoleModel", &DapUiQmlWidgetConsoleModel::getInstance()); + engine.rootContext()->setContextProperty("dapConsoleModel", &DapConsoleModel::getInstance()); engine.rootContext()->setContextProperty("dapHistoryModel", &DapScreenHistoryFilterModel::getInstance()); - engine.rootContext()->setContextProperty("pt", 1.3 /* *dpi */); + engine.rootContext()->setContextProperty("pt", 1.3); engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); -// DapSettings &settings = DapSettings::getInstance("Settings.json"); -// DapSettingsCipher &set = DapSettingsCipher::getInstance(settings); -// qDebug() << "Settings file name: " << set.getFileName(); -// set.setKeyValue("user", "Vasy"); -// bool f = false; -// set.setGroupPropertyValue("widgets", "name", "Services client", "visible", f); -// qDebug() << set.getGroupPropertyValue("widgets", "name", "Services client", "visible").toBool(); -// qDebug() << set.getKeyValue("user"); - if (engine.rootObjects().isEmpty()) return -1; diff --git a/KelvinDashboardGUI/main.qml b/KelvinDashboardGUI/main.qml index 5fb41f07e5aa83c52a99947a036421c6769508d7..7a9e4cb62177127555645e9b6aed14705cf14b6b 100755 --- a/KelvinDashboardGUI/main.qml +++ b/KelvinDashboardGUI/main.qml @@ -17,10 +17,10 @@ ApplicationWindow { console.log("Close") window.hide() } - + Connections { target: dapServiceController - + onActivateWindow: { if(window.visibility === Window.Hidden) { window.show() @@ -30,7 +30,7 @@ ApplicationWindow { window.hide() } } - + // onErrorConnect: { // imageNetwork.visible = false // if(imageErrorNetwork.visible) @@ -38,15 +38,15 @@ ApplicationWindow { // else // imageErrorNetwork.visible = true // } - + // onConnectedToService: { // imageNetwork.visible = true // imageErrorNetwork.visible = false // console.log("Connected") // } } - - + + // header: // Column // { @@ -125,7 +125,7 @@ ApplicationWindow { // color: "green" // } // } - + Drawer { id: drawerMenu width: window.width * 0.3 @@ -197,7 +197,7 @@ ApplicationWindow { StackView { id: stackView - initialItem: "DapUiQmlScreenDashboard.qml" + initialItem: "DapUiQmlScreenMainWindow.qml" anchors.fill: parent } } diff --git a/KelvinDashboardGUI/qml.qrc b/KelvinDashboardGUI/qml.qrc index 5373110621342b0bb65e0e07e642c673ef8c78c4..4ad98416764ba7c8b52b02214a0235f1bf2c673b 100755 --- a/KelvinDashboardGUI/qml.qrc +++ b/KelvinDashboardGUI/qml.qrc @@ -1,8 +1,6 @@ <RCC> <qresource prefix="/"> <file>main.qml</file> - <file>DapUiQmlScreenDashboard.qml</file> - <file>DapUiQmlScreenMainWindow.ui.qml</file> <file>KelvinDashboardGUI.conf</file> <file>DapUiQmlWidgetChainBlockExplorer.ui.qml</file> <file>DapUiQmlWidgetChainExchanges.ui.qml</file> @@ -25,10 +23,42 @@ <file>DapUiQmlScreenDialogSendToken.qml</file> <file>DapUiQmlScreenDialogRemoveWallet.qml</file> <file>DapUiQmlWidgetNodeNetworkExplorer.qml</file> + <file>Resources/Icons/defaul_icon.png</file> + <file>DapUiQmlScreenExchangeForm.ui.qml</file> + <file>Resources/Fonts/roboto_black.ttf</file> + <file>Resources/Fonts/roboto_black_italic.ttf</file> + <file>Resources/Fonts/roboto_bold.ttf</file> + <file>Resources/Fonts/roboto_bold_italic.ttf</file> + <file>Resources/Fonts/roboto_italic.ttf</file> + <file>Resources/Fonts/roboto_light.ttf</file> + <file>Resources/Fonts/roboto_light_italic.ttf</file> + <file>Resources/Fonts/roboto_medium.ttf</file> + <file>Resources/Fonts/roboto_medium_italic.ttf</file> + <file>Resources/Fonts/roboto_regular.ttf</file> + <file>Resources/Fonts/roboto_thin.ttf</file> + <file>Resources/Fonts/roboto_thin_italic.ttf</file> + <file>DapUiQmlWidgetExchangeOrderForm.ui.qml</file> + <file>DapUiQmlWidgetExchangeOrderTitleForm.ui.qml</file> + <file>DapUiQmlWidgetExchangeOrderContentForm.ui.qml</file> + <file>DapUiQmlWidgetExchangeOrderButtonForm.ui.qml</file> <file>DapUiQmlScreenHistory.qml</file> <file>Resources/Icons/defaul_icon.png</file> - <file>DapUiQmlScreenConsoleForm.qml</file> + <file>Resources/Icons/ic_scroll-down.png</file> + <file>Resources/Icons/ic_scroll-down_hover.png</file> + <file>Resources/Icons/ic_scroll-up.png</file> + <file>Resources/Icons/ic_scroll-up_hover.png</file> + <file>DapUiQmlWidgetLastActionsButtonForm.qml</file> + <file>DapUiQmlWidgetLastActionsDelegateForm.qml</file> + <file>DapUiQmlWidgetLastActionsSectionForm.qml</file> + <file>DapUiQmlWidgetLastActionsHeaderForm.qml</file> + <file>DapUiQmlScreenMainWindow.qml</file> + <file>DapUiQmlScreenMainWindowForm.ui.qml</file> + <file>DapUiQmlWidgetLastActions.qml</file> + <file>DapUiQmlWidgetLastActionsForm.ui.qml</file> + <file>DapUiQmlScreenHistoryForm.ui.qml</file> + <file>DapUiQmlScreenConsoleForm.ui.qml</file> <file>DapUiQmlWidgetConsoleForm.qml</file> <file>DapUiQmlWidgetConsoleLastActionsForm.qml</file> + <file>DapUiQmlWidgetConsoleLastActionsDelegateForm.qml</file> </qresource> </RCC> diff --git a/KelvinDashboardService/DapChainDashboardService.cpp b/KelvinDashboardService/DapChainDashboardService.cpp index 4120c1bc7121a3f2b6c2af9195836b60afc74ae5..cdc89599dc208a7efc42cc49bc78ce46159fea04 100755 --- a/KelvinDashboardService/DapChainDashboardService.cpp +++ b/KelvinDashboardService/DapChainDashboardService.cpp @@ -72,9 +72,8 @@ QMap<QString, QVariant> DapChainDashboardService::getWallets() QStringList DapChainDashboardService::getWalletInfo(const QString &asWalletName) { -// qInfo() << QString("getWalletInfo(%1)").arg(asWalletName); -// return m_pDapChainWalletHandler->getWalletInfo(asWalletName); - return QStringList(); + qInfo() << QString("getWalletInfo(%1)").arg(asWalletName); + return m_pDapChainWalletHandler->getWalletInfo(asWalletName); } QVariant DapChainDashboardService::getNodeNetwork() const diff --git a/KelvinDashboardService/DapChainDashboardService.h b/KelvinDashboardService/DapChainDashboardService.h index 573826f8b1cdd07428b74458edd5e1e636c2e71b..d2448c87de594789321e75221a8518f720b46d0c 100755 --- a/KelvinDashboardService/DapChainDashboardService.h +++ b/KelvinDashboardService/DapChainDashboardService.h @@ -43,11 +43,11 @@ class DapChainDashboardService : public DapRpcService DapUiSocketServer * m_pSocketService {nullptr}; /// Log reader. DapChainLogHandler * m_pDapChainLogHandler {nullptr}; - + /// Recipient wallet inforamtion DapChainWalletHandler * m_pDapChainWalletHandler {nullptr}; - + /// Recipient node network DapChainNodeNetworkHandler * m_pDapChainNodeHandler {nullptr}; - + /// Recipient history of transactions DapChainHistoryHandler* m_pDapChainHistoryHandler {nullptr}; DapChainConsoleHandler* m_pDapChainConsoleHandler {nullptr}; @@ -78,21 +78,32 @@ public slots: /// @param aiRowCount Number of lines displayed. /// @return Logs node. QStringList getNodeLogs(int aiTimeStamp, int aiRowCount); - + /// Add new wallet QStringList addWallet(const QString &asWalletName); - + /// Remove wallet void removeWallet(const QString &asWalletName); - + /// Get wallet + /// @return data for wallets QMap<QString, QVariant> getWallets(); - + /// Get information of wallet such as balance, currencies + /// @param number of wallet + /// @return data for the wallet QStringList getWalletInfo(const QString &asWalletName); - + /// Create new transactio + /// @param name of wallet + /// @param address of a receiver + /// @param name of token + /// @param sum for transaction + /// @return result of trasaction QString sendToken(const QString &asWalletName, const QString &asReceiverAddr, const QString &asToken, const QString &asAmount); - + /// Get node network + /// @return QMap node network QVariant getNodeNetwork() const; - + /// Receive new status for node + /// @param true if online void setNodeStatus(const bool aIsOnline); - + /// Get history + /// @return QList data history QVariant getHistory() const; QString getQueryResult(const QString& aQuery) const; diff --git a/KelvinDashboardService/DapChainHistoryHandler.cpp b/KelvinDashboardService/DapChainHistoryHandler.cpp index 68a3dd6b63668e3cf6cf1a913a7311057685d82b..2bb2dd5fa738fa85d28175000dce01d695fe562e 100644 --- a/KelvinDashboardService/DapChainHistoryHandler.cpp +++ b/KelvinDashboardService/DapChainHistoryHandler.cpp @@ -10,8 +10,6 @@ DapChainHistoryHandler::DapChainHistoryHandler(QObject *parent) : QVariant DapChainHistoryHandler::getHistory() const { -// qDebug() << "get story" << m_history; - return m_history; } @@ -27,28 +25,16 @@ void DapChainHistoryHandler::onRequestNewHistory(const QMap<QString, QVariant>& process.start(QString(CLI_PATH) + " tx_history -net private -chain gdb -addr " + wallets.at(i).toString()); process.waitForFinished(-1); - QString result = QString::fromStdString(process.readAll().toStdString()); + QByteArray result = process.readAll(); if(!result.isEmpty()) { - // TODO: error with "\r\n" - QString reg_str; -#ifdef Q_OS_LINUX - reg_str = "(\\w{3}\\s\\w{3}\\s\\d+\\s\\d{1,2}:\\d{2}:\\d{2}\\s\\d{4})\\n" - "\\s(\\w+)\\s(\\d+)\\s(\\w+)\\s\\w+\\s+(\\w+)"; -#endif -#ifdef Q_OS_WIN - reg_str = "(\\w{3}\\s\\w{3}\\s\\d+\\s\\d{1,2}:\\d{2}:\\d{2}\\s\\d{4})\\r\\n" - "\\s(\\w+)\\s(\\d+)\\s(\\w+)\\s\\w+\\s+(\\w+)"; -#endif - - QRegExp rx(reg_str); + QRegExp rx("((\\w{3}\\s+){2}\\d{1,2}\\s+(\\d{1,2}:*){3}\\s+\\d{4})\\s+(\\w+)\\s+(\\d+)\\s(\\w+)\\s+\\w+\\s+([\\w\\d]+)"); int pos = 0; while ((pos = rx.indexIn(result, pos)) != -1) { - QStringList dataItem = QStringList() << rx.cap(1) << QString::number(DapTransactionStatusConvertor::getStatusByShort(rx.cap(2))) << rx.cap(3) << rx.cap(4) << rx.cap(5) << wallets.at(i).toString(); - qDebug() << "NEW MATCH" << pos << dataItem; + QStringList dataItem = QStringList() << rx.cap(1) << QString::number(DapTransactionStatusConvertor::getStatusByShort(rx.cap(4))) << rx.cap(5) << rx.cap(6) << rx.cap(7) << wallets.at(i).toString(); data << dataItem; pos += rx.matchedLength(); } diff --git a/KelvinDashboardService/DapChainHistoryHandler.h b/KelvinDashboardService/DapChainHistoryHandler.h index 748546110f063b1e602909f4622df81b0e682661..1d204c46ac0e6a7a0a3102784a2e2c107738711e 100644 --- a/KelvinDashboardService/DapChainHistoryHandler.h +++ b/KelvinDashboardService/DapChainHistoryHandler.h @@ -22,13 +22,27 @@ private: public: explicit DapChainHistoryHandler(QObject *parent = nullptr); + /// Get current state of history + /// @return data QVariant getHistory() const; public slots: + /// Request new tx history + /// @param wallet list void onRequestNewHistory(const QMap<QString, QVariant>& aWallets); signals: + /// Signal for request wallets list void requsetWallets(); + /// Signal about getting new transatcion history + /// @param data of history QList<QVariant>. + /// QVariant is QStringList. QStringList consists + /// 0: date + /// 1: status + /// 2: currency + /// 3: token + /// 4: wallet_to + /// 5: wallet_from void changeHistory(QVariant); }; diff --git a/KelvinDashboardService/DapChainLogHandler.cpp b/KelvinDashboardService/DapChainLogHandler.cpp index 73c633b7e66ba1e464ac43c08bea1b412231d15b..809610d45a0a6ee894541db4ea0b857083f7c89d 100755 --- a/KelvinDashboardService/DapChainLogHandler.cpp +++ b/KelvinDashboardService/DapChainLogHandler.cpp @@ -13,29 +13,31 @@ DapChainLogHandler::DapChainLogHandler(QObject *parent) : QObject(parent) QStringList DapChainLogHandler::request() { - QStringList m_listLogs; - QFile file(LOG_FILE); - if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) - { - emit onUpdateModel(); - } - else - { - QTextStream in(&file); -// QRegExp rx("(\\[|\\]|\\s)([\\w*]{1,1}[\\w\\s\\W]+)([\\n]|\\])" ); !!! DO NOT DELETE!!! - QRegExp rx("(\\[|\\]|\\s)([\\w*]{1,1}[\\w\\s\\W]+)(\\]|$)" ); - rx.setMinimal(true); + /// TODO: The application doesn't work because of it. It needs to be changed +// QStringList m_listLogs; +// QFile file(LOG_FILE); +// if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) +// { +// emit onUpdateModel(); +// } +// else +// { +// QTextStream in(&file); +//// QRegExp rx("(\\[|\\]|\\s)([\\w*]{1,1}[\\w\\s\\W]+)([\\n]|\\])" ); !!! DO NOT DELETE!!! +// QRegExp rx("(\\[|\\]|\\s)([\\w*]{1,1}[\\w\\s\\W]+)(\\]|$)" ); +// rx.setMinimal(true); - while (!in.atEnd()) { - QString line = in.readLine(); - int pos{0}; - while((pos = rx.indexIn(line, pos)) != -1) - { - m_listLogs.append(rx.cap(2)); - pos += rx.matchedLength(); - } - } - } - return m_listLogs; +// while (!in.atEnd()) { +// QString line = in.readLine(); +// int pos{0}; +// while((pos = rx.indexIn(line, pos)) != -1) +// { +// m_listLogs.append(rx.cap(2)); +// pos += rx.matchedLength(); +// } +// } +// } +// return m_listLogs; + return QStringList(); } diff --git a/KelvinDashboardService/DapChainNodeNetworkHandler.cpp b/KelvinDashboardService/DapChainNodeNetworkHandler.cpp index 08aa838e3845554febe8302a4bde1f0948866c25..fa829cefec1b741f507d928316e3c6e34731ce3e 100644 --- a/KelvinDashboardService/DapChainNodeNetworkHandler.cpp +++ b/KelvinDashboardService/DapChainNodeNetworkHandler.cpp @@ -65,66 +65,10 @@ QVariant DapChainNodeNetworkHandler::getNodeNetwork() const } return nodeMap; - -// DapNodeMap nodeMap; - -// if(!result.isEmpty()) -// { -// QStringList nodes = QString::fromStdString(result.toStdString()).split("node "); -// for(int m = 1; m < nodes.count(); m++) -// { -// QString node = nodes.at(m); -// DapNodeData nodeData; -// QRegExp rx_node("address ((?:[0-9A-F]{4}::){3}[0-9A-F]{4}).+" -// "cell (0[xX][0-9A-F]{16}).+" -// "ipv4 ((?:[0-9]{1,3}\\.){3}[0-9]{1,3}).+" -// "ipv6 ::.+" -// "alias (\\S+).+" -// "links (\\d+).+"); - -// rx_node.indexIn(node, 0); -// nodeData.Cell = rx_node.cap(2).toUInt(); -// nodeData.Ipv4 = rx_node.cap(3); -// nodeData.Alias = rx_node.cap(4); - -// if(rx_node.cap(5).toUInt() > 0) -// { -// QStringList nodeLink; -// QRegExp rx_links("link\\d+ address : ((?:[0-9A-F]{4}::){3}[0-9A-F]{4})"); -// int pos = 0; - -// while ((pos = rx_links.indexIn(node, pos)) != -1) -// { -// nodeLink << rx_links.cap(1); -// pos += rx_links.matchedLength(); -// } -// } - -// qDebug() << rx_node.cap(1) << nodeMap.count(); -// nodeMap[rx_node.cap(1)] = nodeData; -// } -// } - -// QProcess process_status; -// process_status.start(QString(CLI_PATH) + QString(" net -net kelvin-testnet get status")); - -// process.waitForFinished(-1); -// QByteArray result_status = process_status.readAll(); - -// if(!result_status.isEmpty()) -// { -// QRegExp reg_exp("Network \"([\\w\\W]+)\" has state (\\w+) \\(target state [\\w]+\\), " -// "active links \\d+ from \\d+, cur node address ((?:[0-9A-F]{4}::){3}[0-9A-F]{4})"); - -// reg_exp.indexIn(result_status, 0); -// nodeMap[reg_exp.cap(2)].Status = reg_exp.cap(1) == "NET_STATE_OFFLINE" ? false : true; -// nodeMap[reg_exp.cap(2)].isCurrentNode = true; -// } } void DapChainNodeNetworkHandler::setNodeStatus(const bool aIsOnline) { - qDebug() << "SeT new status" << aIsOnline; QProcess process; process.start(QString(CLI_PATH) + QString(" net -net kelvin-testnet go %1").arg(aIsOnline ? "online" : "offline")); process.waitForFinished(-1); diff --git a/KelvinDashboardService/DapChainNodeNetworkHandler.h b/KelvinDashboardService/DapChainNodeNetworkHandler.h index d487eb26da0fcdfdad6f29182aff3fbcb7abbed3..e8cc121bed7349e55fc4faeecb6f5788f12567f3 100644 --- a/KelvinDashboardService/DapChainNodeNetworkHandler.h +++ b/KelvinDashboardService/DapChainNodeNetworkHandler.h @@ -17,7 +17,11 @@ public: explicit DapChainNodeNetworkHandler(QObject *parent = nullptr); public slots: + /// Change status of a node + /// @param it is true if a node is online void setNodeStatus(const bool aIsOnline); + /// Get new node network + /// @return data of node network QVariant getNodeNetwork() const; }; diff --git a/KelvinDashboardService/DapChainWalletHandler.cpp b/KelvinDashboardService/DapChainWalletHandler.cpp index 00e39b7005e7b3cb74753a99a79a731266d064e8..e6f1a298790427d8f56c919b14959491f58e4d2c 100755 --- a/KelvinDashboardService/DapChainWalletHandler.cpp +++ b/KelvinDashboardService/DapChainWalletHandler.cpp @@ -43,7 +43,6 @@ QMap<QString, QVariant> DapChainWalletHandler::getWallets() process.start(QString("%1 wallet list").arg(CLI_PATH)); process.waitForFinished(-1); 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; @@ -70,53 +69,23 @@ 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(CLI_PATH).arg(asNameWallet)); + process.start(QString("%1 wallet info -w %2 -net private").arg(CLI_PATH).arg(asNameWallet)); process.waitForFinished(-1); - char* response = process.readAll().data(); - //qDebug() << response; + QByteArray result = process.readAll(); + QRegExp rx("wallet: (\\w+)\\s+addr:\\s+(\\w+)\\s+(balance)|(\\d+.\\d+)\\s(\\(\\d+\\))\\s(\\w+)"); QStringList list; -#ifdef Q_OS_WIN32 - char *context = nullptr; - char *data = nullptr; - data = strtok_r(response, ":", &context); - if (strcmp(data, "wallet") != 0) { - data = strtok_r(response, ":", &context); - } - data = strtok_r(context+1, "\r", &context); - list.append(QString(data)); - data = strtok_r(context+1, ":", &context); - data = strtok_r(context+1, "\r", &context); - list.append(QString(data)); - data = strtok_r(context+1, ":", &context); - list.append(QString(data)); - data = strtok_r(context+4, "\r", &context); - - char *subctx; - char *subdata; - if (strlen(data) > 2) { - subdata = strtok_r(data+1, " ", &subctx); - } else { - subdata = strtok_r(data, " ", &subctx); - } - list.append(QString(subdata)); - subdata = strtok_r(subctx, " ", &subctx); - list.append(QString(subdata)); - subdata = strtok_r(subctx, "\r", &subctx); - list.append(QString(subdata)); -#else - QString str = QString::fromLatin1(process.readAll()).replace("\\", "\\\\"); - - QRegExp rx("[(:\\)\\t]{1,1}([^\\\\\\n\\t]+)[\\\\(|\\n|\\r]{1,1}"); - rx.setMinimal(true); - int pos{0}; - while((pos = rx.indexIn(str, pos)) != -1) + int pos = 0; + while((pos = rx.indexIn(result, pos)) != -1) { - list.append(rx.cap(1)); + if(rx.cap(1).isEmpty()) + list << rx.cap(4) << rx.cap(5) << rx.cap(6); + else + list << rx.cap(1) << rx.cap(2) << rx.cap(3); + pos += rx.matchedLength(); } -#endif - qDebug() << list; + return list; } diff --git a/KelvinDashboardService/KelvinDashboardService.pro b/KelvinDashboardService/KelvinDashboardService.pro index e021179c1eef25c4120a952d9695e04550bb95d0..1c7464286402e0f6f93d6224333da8625a57013f 100755 --- a/KelvinDashboardService/KelvinDashboardService.pro +++ b/KelvinDashboardService/KelvinDashboardService.pro @@ -21,12 +21,12 @@ ICON = icon.ico win32 { VERSION = $${VER_MAJ}.$${VER_MIN}.$$VER_PAT DEFINES += CLI_PATH=\\\"./kelvin-node-cli.exe\\\" - DEFINES += LOG_FILE=\\\"./opt/kelvin-node/bin/kelvin-node_logs.txt\\\" + DEFINES += LOG_FILE=\\\"./opt/kelvin-node/var/log/kelvin-node_logs.txt\\\" } else { VERSION = $$VER_MAJ\.$$VER_MIN\-$$VER_PAT DEFINES += CLI_PATH=\\\"/opt/kelvin-node/bin/kelvin-node-cli\\\" - DEFINES += LOG_FILE=\\\"/opt/kelvin-node/kelvin-node_logs.txt\\\" + DEFINES += LOG_FILE=\\\"/opt/kelvin-node/var/log/kelvin-node_logs.txt\\\" } # The following define makes your compiler emit warnings if you use diff --git a/libKelvinDashboardCommon/DapChainWallet.h b/libKelvinDashboardCommon/DapChainWallet.h index 062b86047e3a5c9b584b828593ca443b039afcbd..cbfd1247d0ea46d90206d1413876e45fd189a6ab 100755 --- a/libKelvinDashboardCommon/DapChainWallet.h +++ b/libKelvinDashboardCommon/DapChainWallet.h @@ -28,27 +28,43 @@ public: Q_PROPERTY(QStringList tokens MEMBER m_tokens READ getTokens WRITE setTokens NOTIFY tokensChanged) Q_PROPERTY(int count MEMBER m_iCount READ getCount) + /// Get name of wallet QString getName() const; + /// Set name for wallet void setName(const QString &asName); + /// Get address of wallet QString getAddress() const; + /// Set address for wallet void setAddress(const QString &asAddress); + /// Get icon path QString getIconPath() const; + /// Set icon path void setIconPath(const QString &asIconPath); + /// Get balance QStringList getBalance() const; + /// Set balance void setBalance(const QStringList& aBalance); + /// Get tokens name QStringList getTokens() const; + /// Set tokens name void setTokens(const QStringList& aTokens); + /// get number of tokens int getCount() const; signals: + /// Signal changes for icon path void iconPathChanged(const QString& asIconPath); + /// Signal changes for name of wallet void nameChanged(const QString& asName); + /// Signal changes for address of wallet void addressChanged(const QString& asAddress); + /// Signal changes for balance void balanceChanged(const QStringList& aBalance); + /// Signal changes for tokens void tokensChanged(const QStringList& aTokens); }; diff --git a/libKelvinDashboardCommon/DapHistoryType.h b/libKelvinDashboardCommon/DapHistoryType.h index 736a89f3946187923806e09dd71b5bda702a088a..cdd0b02ce524cfd99d9766ce9a3f443a3e7181c1 100644 --- a/libKelvinDashboardCommon/DapHistoryType.h +++ b/libKelvinDashboardCommon/DapHistoryType.h @@ -6,6 +6,7 @@ #include <QMap> #include <QStringList> +/// Enumeration of transaction status enum DapTransactionStatus { stUnknow, stPending, @@ -14,6 +15,7 @@ enum DapTransactionStatus { stError }; +/// Structure for transaction item struct DapTransactionItem { QDateTime Date; QImage TokenPic; @@ -24,6 +26,8 @@ struct DapTransactionItem { QString Currency; }; +/// Class-convertor transaction status +/// @todo This class does not have all statuses class DapTransactionStatusConvertor { @@ -31,10 +35,25 @@ private: static const QMap<DapTransactionStatus, QStringList> m_statusMap; public: + /// Get short text of status. CLI uses short text of transaction + /// @param enum status of transaction + /// @return short text of status static QString getShortStatus(const DapTransactionStatus aStatus); + /// Get long text of status. Client uses long text of status + /// @param enum status of transaction + /// @return long text of status static QString getLongStatus(const DapTransactionStatus aStatus); + /// Get enum status tranaction by short text of status tranasction + /// @param short text of trasaction + /// @return enum status of tranaction static DapTransactionStatus getStatusByShort(const QString& aShortStatus); + /// Get enum status of tranaction by long text of transaction + /// @param long text of transaction + /// @return enum status of transaction static DapTransactionStatus getStatusByLong(const QString& aLongStatus); + /// Get color for status of transaction + /// @param enum status of transaction + /// @return color for status of transaction static QColor getStatusColor(const DapTransactionStatus aStatus); }; diff --git a/libKelvinDashboardCommon/DapLogMessage.h b/libKelvinDashboardCommon/DapLogMessage.h index c283311bfed3f236f3edbacfc49abe2b27b78789..4867f50fc8b578e883c087e2426b6ae2a070481b 100644 --- a/libKelvinDashboardCommon/DapLogMessage.h +++ b/libKelvinDashboardCommon/DapLogMessage.h @@ -21,7 +21,7 @@ class DapLogMessage : public QObject QString m_sMessage; public: - explicit DapLogMessage(QObject *parent = nullptr) {} + explicit DapLogMessage(QObject *parent = nullptr) { Q_UNUSED(parent) } DapLogMessage(const QString &type, const QString ×tamp, const QString &file, const QString &message, QObject *parent = nullptr); diff --git a/libKelvinDashboardCommon/DapLogModel.cpp b/libKelvinDashboardCommon/DapLogModel.cpp index 4038781a15e3499b14139fdd8081f0569ba97d41..be73100b336ba478eb051d809cc778398cd5fb2e 100644 --- a/libKelvinDashboardCommon/DapLogModel.cpp +++ b/libKelvinDashboardCommon/DapLogModel.cpp @@ -18,23 +18,8 @@ int DapLogModel::rowCount(const QModelIndex &) const QVariant DapLogModel::data(const QModelIndex &index, int role) const { - - int y = rowCount(); if (index.row() < rowCount()) - switch (role) { -// case TypeRole: -// switch (m_dapLogMessage.at(index.row())->getType()) { -// case Type::Info: -// return "qrc:/Resources/Icons/dialog-information.png"; -// case Type::Warning: -// return "qrc:/Resources/Icons/dialog-warning.png"; -// case Type::Error: -// return "qrc:/Resources/Icons/dialog-error.png"; -// case Type::Debug: -// return "qrc:/Resources/Icons/dialog-question.png"; -// default: -// break; -// } + switch (role) { case TypeRole: { QString s = m_dapLogMessage.at(index.row())->getType(); @@ -44,13 +29,12 @@ QVariant DapLogModel::data(const QModelIndex &index, int role) const case FileRole: return m_dapLogMessage.at(index.row())->getFile(); case MessageRole: { - int x = index.row(); QString s1 = m_dapLogMessage.at(index.row())->getMessage(); return m_dapLogMessage.at(index.row())->getMessage(); } default: - break; + break; } return QVariant(); } @@ -58,11 +42,11 @@ QVariant DapLogModel::data(const QModelIndex &index, int role) const QHash<int, QByteArray> DapLogModel::roleNames() const { static const QHash<int, QByteArray> roles { - { TypeRole, "type" }, - { TimeStampRole, "timestamp" }, - { FileRole, "file" }, - { MessageRole, "message" } - }; + { TypeRole, "type" }, + { TimeStampRole, "timestamp" }, + { FileRole, "file" }, + { MessageRole, "message" } + }; return roles; } diff --git a/libKelvinDashboardCommon/DapLogModel.h b/libKelvinDashboardCommon/DapLogModel.h index 44bc2c0cc34bf8937914230ce16d7b3d8158dd26..114ee1091307c038ecc906491a5939e25ea340ec 100644 --- a/libKelvinDashboardCommon/DapLogModel.h +++ b/libKelvinDashboardCommon/DapLogModel.h @@ -19,6 +19,7 @@ enum DapLogRole { MessageRole }; +/// Class model for log screen class DapLogModel : public QAbstractListModel { Q_OBJECT @@ -44,7 +45,7 @@ public: Q_INVOKABLE void append(const QString &type, const QString ×tamp, const QString &file, const QString &message); Q_INVOKABLE void set(int row, const QString &type, const QString ×tamp, const QString &file, const QString &message); Q_INVOKABLE void remove(int row); - Q_INVOKABLE void clear(); + Q_INVOKABLE void clear(); public slots: /// Method that implements the singleton pattern for the qml layer. diff --git a/libKelvinDashboardCommon/DapNodeType.h b/libKelvinDashboardCommon/DapNodeType.h index 7e9991a795875a46f307d78113455d4332d23df1..4dfaa833dc86fbaef0673eb2744b593ff95fb203 100644 --- a/libKelvinDashboardCommon/DapNodeType.h +++ b/libKelvinDashboardCommon/DapNodeType.h @@ -5,6 +5,7 @@ #include <QStringList> #include <QDataStream> +/// Structure for node network data struct DapNodeData { quint32 Cell; QString Ipv4;