diff --git a/KelvinDashboardGUI/DapScreenHistoryModel.cpp b/KelvinDashboardGUI/DapScreenHistoryModel.cpp index 24656d6ef26e797c8a34d3729ebba18a6978e6fe..8683499828ff45a331d4697a579afc00c2855267 100644 --- a/KelvinDashboardGUI/DapScreenHistoryModel.cpp +++ b/KelvinDashboardGUI/DapScreenHistoryModel.cpp @@ -26,6 +26,22 @@ 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; @@ -59,6 +75,7 @@ void DapScreenHistoryModel::receiveNewData(const QVariant& aData) default: break; } + item.Cryptocurrency = toConvertCurrency(item.Cryptocurrency); item.Cryptocurrency += " " + item.TokenName; m_elementList.append(item); diff --git a/KelvinDashboardGUI/DapScreenHistoryModel.h b/KelvinDashboardGUI/DapScreenHistoryModel.h index 4314fe2fb74fb20b37ad317ac7e24fac096b1cc0..43ff5aea10fc6320d1a6bb8e3bcc206456f8a17c 100644 --- a/KelvinDashboardGUI/DapScreenHistoryModel.h +++ b/KelvinDashboardGUI/DapScreenHistoryModel.h @@ -14,24 +14,6 @@ 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; -// }; - enum { DisplayDateRole = Qt::UserRole, DateRole, @@ -55,6 +37,8 @@ public: 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: void receiveNewData(const QVariant& aData); }; diff --git a/KelvinDashboardGUI/DapUiQmlScreenDashboard.qml b/KelvinDashboardGUI/DapUiQmlScreenDashboard.qml new file mode 100755 index 0000000000000000000000000000000000000000..ad42c4374c14bb08a9bc2920d007cd5d9a110925 --- /dev/null +++ b/KelvinDashboardGUI/DapUiQmlScreenDashboard.qml @@ -0,0 +1,182 @@ +import QtQuick 2.9 +import QtQuick.Controls 1.4 +import QtQuick.Controls 2.2 +import QtQuick.Controls.Styles 1.4 + +Page { + id: dapUiQmlScreenDashboard + title: qsTr("General") + + 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("Home") + page: "DapUiQmlScreenDialog.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("About") + page: "DapQmlScreenAbout.qml" + source: "qrc:/Resources/Icons/defaul_icon.png" + } + } + + + + delegate: + Column { + id: componentTab + 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 + } + } + } + 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" + } + } +} + diff --git a/KelvinDashboardGUI/DapUiQmlScreenDialog.qml b/KelvinDashboardGUI/DapUiQmlScreenDialog.qml index 98b903eb12867843898e4c09555d6018915d510a..14861e3b2dcab11d88621ddb0142c12251804ea4 100644 --- a/KelvinDashboardGUI/DapUiQmlScreenDialog.qml +++ b/KelvinDashboardGUI/DapUiQmlScreenDialog.qml @@ -57,4 +57,6 @@ Page { listViewDapWidgets.addWidget() } } + + DapUiQmlWidgetLastActionsForm {} } diff --git a/KelvinDashboardGUI/DapUiQmlWidgetLastActions.qml b/KelvinDashboardGUI/DapUiQmlWidgetLastActions.qml new file mode 100644 index 0000000000000000000000000000000000000000..6dc8088d818ce6d946eeb0c55172db663981d65b --- /dev/null +++ b/KelvinDashboardGUI/DapUiQmlWidgetLastActions.qml @@ -0,0 +1,59 @@ +import QtQuick 2.9 +import QtQml 2.12 +import QtQuick.Controls 2.2 +import QtQuick.Layouts 1.12 + +import DapTransactionHistory 1.0 + +DapUiQmlWidgetLastActionsForm { + + 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 + + model: dapHistoryModel + delegate: DapUiQmlWidgetLastActionsDelegateForm {} + section.property: "date" + section.criteria: ViewSection.FullString + section.delegate: DapUiQmlWidgetLastActionsSectionForm {} + + 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..2f57446cc5f0365f4aefd64d9538c37c21d1d724 --- /dev/null +++ b/KelvinDashboardGUI/DapUiQmlWidgetLastActionsSectionForm.qml @@ -0,0 +1,23 @@ +import QtQuick 2.9 +import QtQml 2.12 +import QtQuick.Controls 2.2 +import QtQuick.Layouts 1.12 + +Component { + 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/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 0239d20a45384a95f552ef5eb871661320e579c9..93b34e115c8371e6394c9cfae0d18d99927ebdaf 100755 --- a/KelvinDashboardGUI/main.cpp +++ b/KelvinDashboardGUI/main.cpp @@ -86,7 +86,7 @@ int main(int argc, char *argv[]) // 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/qml.qrc b/KelvinDashboardGUI/qml.qrc index c5fbd286bdbebda49a7922eda9a5173bf3f449c7..7a448e8884e56595dba1f1e76cbc22a85ba0c53c 100755 --- a/KelvinDashboardGUI/qml.qrc +++ b/KelvinDashboardGUI/qml.qrc @@ -44,8 +44,18 @@ <file>DapUiQmlWidgetExchangeOrderContentForm.ui.qml</file> <file>DapUiQmlWidgetExchangeOrderButtonForm.ui.qml</file> <file>DapUiQmlScreenHistory.qml</file> - <file>DapUiQmlScreenHistoryForm.ui.qml</file> + <file>Resources/Icons/defaul_icon.png</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> </qresource> </RCC> diff --git a/KelvinDashboardService/DapChainHistoryHandler.cpp b/KelvinDashboardService/DapChainHistoryHandler.cpp index 68a3dd6b63668e3cf6cf1a913a7311057685d82b..e229a148806fa9ab870f6b1a67247e8e86c6b2c9 100644 --- a/KelvinDashboardService/DapChainHistoryHandler.cpp +++ b/KelvinDashboardService/DapChainHistoryHandler.cpp @@ -31,18 +31,8 @@ void DapChainHistoryHandler::onRequestNewHistory(const QMap<QString, QVariant>& 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\\w{3}\\s\\d+\\s\\d{1,2}:\\d{2}:\\d{2}\\s\\d{4})\\s+" + "\\s(\\w+)\\s(\\d+)\\s(\\w+)\\s\\w+\\s+(\\w+)"); int pos = 0; while ((pos = rx.indexIn(result, pos)) != -1)