diff --git a/CellFrameDashboardGUI/DapApplication.cpp b/CellFrameDashboardGUI/DapApplication.cpp index ff46200c01da1ef3f0147e2c795e8c76164d81c3..f0b6e889a0592919a9a258e98e8842691bf11537 100644 --- a/CellFrameDashboardGUI/DapApplication.cpp +++ b/CellFrameDashboardGUI/DapApplication.cpp @@ -2,6 +2,7 @@ #include <QQmlContext> #include <DapLogMessage.h> #include <QIcon> +#include <QClipboard> DapApplication::DapApplication(int &argc, char **argv) :QApplication(argc, argv) @@ -40,6 +41,11 @@ QQmlApplicationEngine *DapApplication::qmlEngine() return &m_engine; } +void DapApplication::setClipboardText(const QString &text) +{ + clipboard()->setText(text); +} + void DapApplication::registerQmlTypes() { //register only enums @@ -68,8 +74,9 @@ void DapApplication::registerQmlTypes() void DapApplication::setContextProperties() { + m_engine.rootContext()->setContextProperty("app", this); m_engine.rootContext()->setContextProperty("dapServiceController", &DapServiceController::getInstance()); m_engine.rootContext()->setContextProperty("pt", 1); - m_engine.rootContext()->setContextProperty("networksModel", QVariant::fromValue(this->networks()->model())); + m_engine.rootContext()->setContextProperty("networks", this->networks()); } diff --git a/CellFrameDashboardGUI/DapApplication.h b/CellFrameDashboardGUI/DapApplication.h index 72ecceb3894eb50b1871123a067f4b1e14d52a02..ef5a846456c023ca9da8a8d793ed4e36325d37ef 100644 --- a/CellFrameDashboardGUI/DapApplication.h +++ b/CellFrameDashboardGUI/DapApplication.h @@ -8,12 +8,16 @@ class DapApplication : public QApplication { + Q_OBJECT + public: DapApplication(int &argc, char **argv); DapNetworksList *networks(); QQmlApplicationEngine *qmlEngine(); + Q_INVOKABLE void setClipboardText(const QString &text); + private: void setContextProperties(); void registerQmlTypes(); diff --git a/CellFrameDashboardGUI/qml.qrc b/CellFrameDashboardGUI/qml.qrc index 7dea54a16891472e83ef1376a63c2de56cce1cd9..33810961d5853e2234b3b24a4e8b9e7224dabe1b 100755 --- a/CellFrameDashboardGUI/qml.qrc +++ b/CellFrameDashboardGUI/qml.qrc @@ -175,5 +175,19 @@ <file>screen/desktop/Wallet/DapWalletTab.qml</file> <file>screen/desktop/Wallet/DapWalletTopPanel.qml</file> <file>screen/desktop/DapTokensListView.qml</file> + <file>screen/desktop/NetworksPanel/DapNetworksPanel.qml</file> + <file>screen/desktop/NetworksPanel/DapNetworkPanelButton.qml</file> + <file>screen/desktop/NetworksPanel/DapNetworksList.qml</file> + <file>screen/desktop/NetworksPanel/DapNetworkPopup.qml</file> + <file>screen/desktop/NetworksPanel/DapNetworkName.qml</file> + <file>screen/desktop/NetworksPanel/DapNetworkPopupButton.qml</file> + <file>resources/icons/ic_copy.svg</file> + <file>resources/icons/ic_copy_hover.svg</file> + <file>resources/icons/icon_on_off_net.svg</file> + <file>resources/icons/icon_on_off_net_hover.svg</file> + <file>resources/icons/Icon_sync_net.svg</file> + <file>resources/icons/Icon_sync_net_hover.svg</file> + <file>resources/icons/next-page.svg</file> + <file>resources/icons/next-page_hover.svg</file> </qresource> </RCC> diff --git a/CellFrameDashboardGUI/resources/icons/Icon_sync_net.svg b/CellFrameDashboardGUI/resources/icons/Icon_sync_net.svg new file mode 100644 index 0000000000000000000000000000000000000000..5455f9b1707db00afaf56c5903e4c91216332504 --- /dev/null +++ b/CellFrameDashboardGUI/resources/icons/Icon_sync_net.svg @@ -0,0 +1 @@ +<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><rect width="24" height="24" fill="none"/><g transform="translate(2.428 -2.7)"><path d="M3.475,13.654l-.885-2.92a.491.491,0,0,1,.339-.61h0a.5.5,0,0,1,.619.334l.516,1.7a6.115,6.115,0,0,1,11.205.436.5.5,0,0,1-.457.668.512.512,0,0,1-.472-.32,5.126,5.126,0,0,0-9.465-.218l1.887-.567a.5.5,0,0,1,.619.334h0a.491.491,0,0,1-.339.61l-2.963.872A.5.5,0,0,1,3.475,13.654Z" transform="translate(0 0)" fill="#453f5a"/><path d="M22.858,58.42l-.516-1.7a6.132,6.132,0,0,1-11.22-.45.5.5,0,0,1,.457-.668.512.512,0,0,1,.472.32,5.126,5.126,0,0,0,9.465.218l-1.887.567a.5.5,0,0,1-.619-.334.491.491,0,0,1,.339-.61l2.963-.872a.5.5,0,0,1,.619.334l.885,2.92a.491.491,0,0,1-.339.61h0A.5.5,0,0,1,22.858,58.42Z" transform="translate(-7.264 -39.464)" fill="#453f5a"/></g></svg> \ No newline at end of file diff --git a/CellFrameDashboardGUI/resources/icons/Icon_sync_net_hover.svg b/CellFrameDashboardGUI/resources/icons/Icon_sync_net_hover.svg new file mode 100644 index 0000000000000000000000000000000000000000..d91167f3385c91e0ece24d04b6744ba46ad11663 --- /dev/null +++ b/CellFrameDashboardGUI/resources/icons/Icon_sync_net_hover.svg @@ -0,0 +1 @@ +<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><rect width="24" height="24" fill="none"/><g transform="translate(2.428 -2.7)"><path d="M3.475,13.654l-.885-2.92a.491.491,0,0,1,.339-.61h0a.5.5,0,0,1,.619.334l.516,1.7a6.115,6.115,0,0,1,11.205.436.5.5,0,0,1-.457.668.512.512,0,0,1-.472-.32,5.126,5.126,0,0,0-9.465-.218l1.887-.567a.5.5,0,0,1,.619.334h0a.491.491,0,0,1-.339.61l-2.963.872A.5.5,0,0,1,3.475,13.654Z" transform="translate(0 0)" fill="#fff"/><path d="M22.858,58.42l-.516-1.7a6.132,6.132,0,0,1-11.22-.45.5.5,0,0,1,.457-.668.512.512,0,0,1,.472.32,5.126,5.126,0,0,0,9.465.218l-1.887.567a.5.5,0,0,1-.619-.334.491.491,0,0,1,.339-.61l2.963-.872a.5.5,0,0,1,.619.334l.885,2.92a.491.491,0,0,1-.339.61h0A.5.5,0,0,1,22.858,58.42Z" transform="translate(-7.264 -39.464)" fill="#fff"/></g></svg> \ No newline at end of file diff --git a/CellFrameDashboardGUI/resources/icons/ic_copy.svg b/CellFrameDashboardGUI/resources/icons/ic_copy.svg new file mode 100644 index 0000000000000000000000000000000000000000..1ff98a1dc65f5e900c8f9e69b77a83ea0a9443e6 --- /dev/null +++ b/CellFrameDashboardGUI/resources/icons/ic_copy.svg @@ -0,0 +1 @@ +<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16"><rect width="16" height="16" fill="none"/><g transform="translate(-3 -956.362)"><path d="M9.722,958.362a.268.268,0,0,0-.243.268v1.606H6.243A.268.268,0,0,0,6,960.5v9.367a.268.268,0,0,0,.268.268h7.493a.268.268,0,0,0,.268-.268v-2.409h2.409a.268.268,0,0,0,.268-.268V958.63a.268.268,0,0,0-.268-.268H9.722Zm.293.535H16.17v8.028H14.029V960.5a.268.268,0,0,0-.268-.268H10.014Zm-3.479,1.873h6.958V969.6H6.535Z" transform="translate(0 0)" fill="#757184"/></g></svg> \ No newline at end of file diff --git a/CellFrameDashboardGUI/resources/icons/ic_copy_hover.svg b/CellFrameDashboardGUI/resources/icons/ic_copy_hover.svg new file mode 100644 index 0000000000000000000000000000000000000000..eaa41c099b56dd845e8cae46045575727639ddc9 --- /dev/null +++ b/CellFrameDashboardGUI/resources/icons/ic_copy_hover.svg @@ -0,0 +1 @@ +<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16"><rect width="16" height="16" fill="none"/><g transform="translate(-3 -956.362)"><path d="M9.722,958.362a.268.268,0,0,0-.243.268v1.606H6.243A.268.268,0,0,0,6,960.5v9.367a.268.268,0,0,0,.268.268h7.493a.268.268,0,0,0,.268-.268v-2.409h2.409a.268.268,0,0,0,.268-.268V958.63a.268.268,0,0,0-.268-.268H9.722Zm.293.535H16.17v8.028H14.029V960.5a.268.268,0,0,0-.268-.268H10.014Zm-3.479,1.873h6.958V969.6H6.535Z" transform="translate(0 0)" fill="#d51f5d"/></g></svg> \ No newline at end of file diff --git a/CellFrameDashboardGUI/resources/icons/icon_on_off_net.svg b/CellFrameDashboardGUI/resources/icons/icon_on_off_net.svg new file mode 100644 index 0000000000000000000000000000000000000000..eaa52d544fc72640d25669bedc37944a3bbce8aa --- /dev/null +++ b/CellFrameDashboardGUI/resources/icons/icon_on_off_net.svg @@ -0,0 +1 @@ +<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><g transform="translate(6 5)"><g transform="translate(-6 -5)" fill="rgba(255,255,255,0)" stroke="rgba(0,0,0,0)" stroke-width="1"></g><g transform="translate(0.796 2)"><path d="M13.665,12.913a.54.54,0,1,0-.65.862,4.827,4.827,0,1,1-5.8-.009.54.54,0,1,0-.65-.862,5.914,5.914,0,1,0,9.463,4.732,5.867,5.867,0,0,0-2.365-4.723Z" transform="translate(-5 -12.549)" fill="#453f5a"/><path d="M44.9,8.965a.54.54,0,0,0,.54-.54V4.1a.54.54,0,1,0-1.08,0V8.425A.54.54,0,0,0,44.9,8.965Z" transform="translate(-39.734 -4.564)" fill="#453f5a"/></g></g></svg> diff --git a/CellFrameDashboardGUI/resources/icons/icon_on_off_net_hover.svg b/CellFrameDashboardGUI/resources/icons/icon_on_off_net_hover.svg new file mode 100644 index 0000000000000000000000000000000000000000..481f66be60ba7f55390ea63fcd14bdffac3c7a92 --- /dev/null +++ b/CellFrameDashboardGUI/resources/icons/icon_on_off_net_hover.svg @@ -0,0 +1 @@ +<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><g transform="translate(6 5)"><g transform="translate(-6 -5)" fill="rgba(255,255,255,0)" stroke="rgba(0,0,0,0)" stroke-width="1"></g><g transform="translate(0.796 2)"><path d="M13.665,12.913a.54.54,0,1,0-.65.862,4.827,4.827,0,1,1-5.8-.009.54.54,0,1,0-.65-.862,5.914,5.914,0,1,0,9.463,4.732,5.867,5.867,0,0,0-2.365-4.723Z" transform="translate(-5 -12.549)" fill="#fff"/><path d="M44.9,8.965a.54.54,0,0,0,.54-.54V4.1a.54.54,0,1,0-1.08,0V8.425A.54.54,0,0,0,44.9,8.965Z" transform="translate(-39.734 -4.564)" fill="#fff"/></g></g></svg> diff --git a/CellFrameDashboardGUI/resources/icons/next-page.svg b/CellFrameDashboardGUI/resources/icons/next-page.svg new file mode 100644 index 0000000000000000000000000000000000000000..6d7a523026ebe017845bc0f47b3a853621c23353 --- /dev/null +++ b/CellFrameDashboardGUI/resources/icons/next-page.svg @@ -0,0 +1 @@ +<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 40 40"><rect width="40" height="40" fill="none"/><path d="M9.04-5.9v.5L2.112-1.648l-.528-.9L7.248-5.632,1.536-8.544l.592-.9Zm9.6,0v.5l-6.928,3.76-.528-.9,5.664-3.088L11.136-8.544l.592-.9Z" transform="translate(9.464 25.44)" fill="#fff"/></svg> \ No newline at end of file diff --git a/CellFrameDashboardGUI/resources/icons/next-page_hover.svg b/CellFrameDashboardGUI/resources/icons/next-page_hover.svg new file mode 100644 index 0000000000000000000000000000000000000000..5b9360ffb9e29f9aa8cdb7921a16d5048ba50f49 --- /dev/null +++ b/CellFrameDashboardGUI/resources/icons/next-page_hover.svg @@ -0,0 +1 @@ +<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 40 40"><rect width="40" height="40" fill="none"/><path d="M9.04-5.9v.5L2.112-1.648l-.528-.9L7.248-5.632,1.536-8.544l.592-.9Zm9.6,0v.5l-6.928,3.76-.528-.9,5.664-3.088L11.136-8.544l.592-.9Z" transform="translate(9.464 25.44)" fill="#d51f5d"/></svg> \ No newline at end of file diff --git a/CellFrameDashboardGUI/screen/DapMainApplicationWindow.qml b/CellFrameDashboardGUI/screen/DapMainApplicationWindow.qml index 7bd3c8914e6995973a0817a548f4a4fc13a510d1..37a4206174d1f00d22ed5f3182b528d6160090d8 100644 --- a/CellFrameDashboardGUI/screen/DapMainApplicationWindow.qml +++ b/CellFrameDashboardGUI/screen/DapMainApplicationWindow.qml @@ -1,7 +1,7 @@ import QtQuick 2.4 import "qrc:/resources/QML" import "qrc:/screen/desktop/Certificates" - +import "qrc:/screen/desktop/NetworksPanel" @@ -53,7 +53,13 @@ Item { { id: rowMainWindow - anchors.fill: parent + anchors { + left: parent.left; + top: parent.top; + right: parent.right; + bottom: networksPanel.top + bottomMargin: 4 * pt + } // Virtual logo column frame and menu bar Column @@ -128,6 +134,18 @@ Item { } } + DapNetworksPanel + { + id: networksPanel + y: parent.height - height + width: parent.width + } + + DapNetworkPopup + { + id: networkPanelPopup + } + property var dapWallets: [] diff --git a/CellFrameDashboardGUI/screen/desktop/NetworksPanel/DapNetworkName.qml b/CellFrameDashboardGUI/screen/desktop/NetworksPanel/DapNetworkName.qml new file mode 100644 index 0000000000000000000000000000000000000000..1e1201982c8adaf863d5cef6b5b6746a428764a4 --- /dev/null +++ b/CellFrameDashboardGUI/screen/desktop/NetworksPanel/DapNetworkName.qml @@ -0,0 +1,53 @@ +import QtQuick 2.7 + +Item { + id: control + + property string name + property string networkState + property color textColor + + Row { + id: row1 + + anchors.centerIn: parent + spacing: 8 * pt + leftPadding: spacing + rightPadding: spacing + + Text { + id: textName + + width: Math.min(implicitWidth, control.width - indicator.width - row1.spacing - row1.rightPadding - row1.leftPadding) + height: Math.min(implicitHeight, control.height) + + font: quicksandFonts.medium12 + elide: Text.ElideRight + color: control.textColor + text: control.name + } + + Rectangle { + id: indicator + + anchors.verticalCenter: parent.verticalCenter + width: 8 * pt + height: width + radius: width * 0.5 + + color: { + switch (control.networkState) { + case "NET_STATE_ONLINE": + return "#9DD51F"; + case "NET_STATE_OFFLINE": + return "#FFC527"; + default: + if (control.state.length > 0) + console.warn("Unknown network state: " + control.networkState); + return "#000000"; + } + } + } + } + +} diff --git a/CellFrameDashboardGUI/screen/desktop/NetworksPanel/DapNetworkPanelButton.qml b/CellFrameDashboardGUI/screen/desktop/NetworksPanel/DapNetworkPanelButton.qml new file mode 100644 index 0000000000000000000000000000000000000000..f5e83f8bccb73315e7b1d10e907bd2082a587359 --- /dev/null +++ b/CellFrameDashboardGUI/screen/desktop/NetworksPanel/DapNetworkPanelButton.qml @@ -0,0 +1,31 @@ +import QtQuick 2.7 + +Item { + id: control + + property string normalIcon + property string hoverIcon + property alias mirror: img.mirror + + signal clicked + + implicitWidth: 40 * pt + implicitHeight: 40 * pt + + Image { + id: img + + anchors.fill: parent + sourceSize: Qt.size(control.width, control.height) + source: mouseArea.containsMouse ? control.hoverIcon : control.normalIcon + } + + MouseArea { + id: mouseArea + + anchors.fill: parent + hoverEnabled: true + + onClicked: control.clicked() + } +} diff --git a/CellFrameDashboardGUI/screen/desktop/NetworksPanel/DapNetworkPopup.qml b/CellFrameDashboardGUI/screen/desktop/NetworksPanel/DapNetworkPopup.qml new file mode 100644 index 0000000000000000000000000000000000000000..30d7457588302a441dda4990e7540a5741037777 --- /dev/null +++ b/CellFrameDashboardGUI/screen/desktop/NetworksPanel/DapNetworkPopup.qml @@ -0,0 +1,243 @@ +import QtQuick 2.7 +import QtQuick.Controls 2.2 +import QtQuick.Layouts 1.3 +import QtGraphicalEffects 1.0 + +Popup { + id: control + + property point networkDelegateItemCoords + property int networkDelegateItemWidth + property int networkDelegateItemHeight + + property string name + property string networkState + property string networkTargetState + property int activeLinksCount + property int linksCount + property string nodeAddress + + function show(networkDelegateItem) + { + networkDelegateItemCoords = Qt.binding(function() { return parent.mapFromItem(networkDelegateItem.parent, networkDelegateItem.x, networkDelegateItem.y) }); + networkDelegateItemWidth = Qt.binding(function() { return networkDelegateItem.width }); + networkDelegateItemHeight = Qt.binding(function() { return networkDelegateItem.height }); + + name = Qt.binding(function() { return networkDelegateItem.name }); + networkState = Qt.binding(function() { return networkDelegateItem.networkState }); + networkTargetState = Qt.binding(function() { return networkDelegateItem.networkTargetState }); + activeLinksCount = Qt.binding(function() { return networkDelegateItem.activeLinksCount }); + linksCount = Qt.binding(function() { return networkDelegateItem.linksCount }); + nodeAddress = Qt.binding(function() { return networkDelegateItem.nodeAddress }); + + open(); + } + + function release() + { + networkDelegateItemCoords = Qt.point(0, 0); + networkDelegateItemWidth = 0; + networkDelegateItemHeight = 0; + + name = ""; + networkState = ""; + networkTargetState = ""; + activeLinksCount = 0; + linksCount = 0; + nodeAddress = 0; + } + + x: networkDelegateItemCoords.x + y: networkDelegateItemCoords.y + networkDelegateItemHeight - height + width: networkDelegateItemWidth + height: contentHeight + + margins: 0 + padding: 0 + + enter: Transition { + NumberAnimation { property: "opacity"; from: 0.0; to: 1.0; duration: 100 } + } + + exit: Transition { + NumberAnimation { property: "opacity"; from: 1.0; to: 0.0; duration: 100 } + } + + contentItem: Item { + id: contentItem + + function networkStateToString(networkState) + { + switch (networkState) { + case "NET_STATE_ONLINE": + return qsTr("ONLINE"); + case "NET_STATE_OFFLINE": + return qsTr("OFFLINE"); + default: + if (state.length > 0) + console.warn("Unknown network state: " + networkState); + return ""; + } + } + + implicitWidth: columnItem.width + implicitHeight: columnItem.height + + Column { + id: columnItem + + spacing: Math.floor(control.networkDelegateItemHeight / 2) + + Row { + DapNetworkPopupButton { + width: contentItem.width / 2 + height: 24 * pt + text: qsTr("Sync network") + iconNormal: "qrc:/resources/icons/Icon_sync_net.svg" + iconHover: "qrc:/resources/icons/Icon_sync_net_hover.svg" + + onClicked: console.log("SYNC NETWORK CLICKED", control.name) + } + DapNetworkPopupButton { + width: contentItem.width / 2 + height: 24 * pt + text: control.networkState == "NET_STATE_ONLINE" ? qsTr("Off network") : qsTr("On network") + iconNormal: "qrc:/resources/icons/icon_on_off_net.svg" + iconHover: "qrc:/resources/icons/icon_on_off_net_hover.svg" + + onClicked: { + if (control.networkState == "NET_STATE_ONLINE") { + dapServiceController.changeNetworkStateToOffline(control.name); + } else if (control.networkState == "NET_STATE_OFFLINE") { + dapServiceController.changeNetworkStateToOnline(control.name); + } else { + console.warn("Unknown network state: " + control.networkState); + } + } + } + } + + ColumnLayout { + width: contentItem.width + + RowLayout { + Text { + font: quicksandFonts.medium12 + color: "#070023" + text: qsTr("State: ") + } + Text { + font: quicksandFonts.regular12 + color: "#070023" + elide: Text.ElideRight + text: contentItem.networkStateToString(control.networkState) + Layout.fillWidth: true + Layout.maximumWidth: Math.ceil(implicitWidth) + } + + Layout.alignment: Qt.AlignHCenter + } + + RowLayout { + Text { + font: quicksandFonts.medium12 + color: "#070023" + text: qsTr("Target state: ") + } + Text { + font: quicksandFonts.regular12 + color: "#070023" + elide: Text.ElideRight + text: contentItem.networkStateToString(control.networkTargetState) + Layout.fillWidth: true + Layout.maximumWidth: Math.ceil(implicitWidth) + } + + Layout.alignment: Qt.AlignHCenter + } + + RowLayout { + Text { + font: quicksandFonts.medium12 + color: "#070023" + text: qsTr("Active links: ") + } + Text { + font: quicksandFonts.regular12 + color: "#070023" + elide: Text.ElideRight + text: control.activeLinksCount + qsTr(" from ") + control.linksCount + Layout.fillWidth: true + Layout.maximumWidth: Math.ceil(implicitWidth) + } + + Layout.alignment: Qt.AlignHCenter + } + + RowLayout { + Text { + id: textAddress + font: quicksandFonts.medium12 + color: "#070023" + text: qsTr("Address: ") + } + Text { + font: quicksandFonts.regular12 + color: "#070023" + elide: Text.ElideRight + text: control.nodeAddress + Layout.fillWidth: true + Layout.maximumWidth: Math.ceil(implicitWidth) + } + Image { + source: btnCopyAddressMouseArea.containsMouse ? "qrc:/resources/icons/ic_copy_hover.svg" : "qrc:/resources/icons/ic_copy.svg" + sourceSize: Qt.size(12 * pt, 12 * pt) + + Layout.alignment: Qt.AlignVCenter + + MouseArea { + id: btnCopyAddressMouseArea + anchors.fill: parent + hoverEnabled: true + onClicked: app.setClipboardText(control.nodeAddress) + } + } + + Layout.alignment: Qt.AlignHCenter + } + } + + DapNetworkName { + id: networkName + + y: parent.height - height + width: control.networkDelegateItemWidth + height: control.networkDelegateItemHeight + textColor: "#070023" + name: control.name + networkState: control.networkState + } + } + } + + background: Item { + Rectangle { + id: r1 + width: parent.width + height: parent.height + visible: true + color: "#FFFFFF" + } + + DropShadow { + anchors.fill: r1 + opacity: control.opacity === 1.0 ? 1.0 : control.opacity / 5 + source: r1 + radius: 5 + samples: 11 + color: "#80000000" + } + } + + onClosed: release() +} diff --git a/CellFrameDashboardGUI/screen/desktop/NetworksPanel/DapNetworkPopupButton.qml b/CellFrameDashboardGUI/screen/desktop/NetworksPanel/DapNetworkPopupButton.qml new file mode 100644 index 0000000000000000000000000000000000000000..efd89db545160162bc5c95a8f75c1ee8a4ae394b --- /dev/null +++ b/CellFrameDashboardGUI/screen/desktop/NetworksPanel/DapNetworkPopupButton.qml @@ -0,0 +1,45 @@ +import QtQuick 2.7 + +Rectangle { + id: control + + property alias text: _text.text + property string iconNormal + property string iconHover + + property bool highlight: mouseArea.containsMouse + property int spacing: 6 * pt + + signal clicked + + color: highlight ? "#D51F5D" : "#FFFFFF" + + Image { + id: icon + anchors.verticalCenter: control.verticalCenter + anchors.right: _text.left + anchors.rightMargin: control.spacing + sourceSize: Qt.size(24 * pt, 24 * pt) + source: control.highlight ? control.iconHover : control.iconNormal + } + + Text { + id: _text + + anchors.verticalCenter: control.verticalCenter + x: Math.floor(icon.width + control.spacing + (control.width - (width + icon.width + control.spacing)) * 0.5) + width: Math.min(implicitWidth, control.width - icon.width - control.spacing) + font: quicksandFonts.medium12 + color: control.highlight ? "#FFFFFF" : "#453F5A" + elide: Text.ElideRight + } + + MouseArea { + id: mouseArea + + anchors.fill: parent + hoverEnabled: true + + onClicked: control.clicked() + } +} diff --git a/CellFrameDashboardGUI/screen/desktop/NetworksPanel/DapNetworksList.qml b/CellFrameDashboardGUI/screen/desktop/NetworksPanel/DapNetworksList.qml new file mode 100644 index 0000000000000000000000000000000000000000..c7b74db22cfd265b761c0992aa688c0cdee75df0 --- /dev/null +++ b/CellFrameDashboardGUI/screen/desktop/NetworksPanel/DapNetworksList.qml @@ -0,0 +1,129 @@ +import QtQml 2.2 +import QtQuick 2.7 + +Item { + id: control + + property bool hasLeft: listView.leftIndex - 1 >= 0 + property bool hasRight: listView.leftIndex + listView.visibleItems < listView.count + + function scrollToLeft() + { + if (hasLeft) { + listView.positionViewAtIndexAnimation(listView.leftIndex - 1, ListView.Beginning); + listView.leftIndex--; + } + } + + function scrollToRight() + { + if (hasRight) { + listView.positionViewAtIndexAnimation(listView.leftIndex + listView.visibleItems, ListView.End); + listView.leftIndex++; + } + } + + ListView { + id: listView + + property int visibleItems: 0 + property int delegateWidth: Math.floor(control.width / 4) + property int leftIndex: 0 + + function positionViewAtIndexAnimation(index, mode) + { + scrollAnimation.running = false; + var pos = listView.contentX; + listView.positionViewAtIndex(index, mode); + var dest = listView.contentX; + + scrollAnimation.from = pos; + scrollAnimation.to = dest; + scrollAnimation.running = true; + } + + function setNetworks(networks) + { + model = networks; + + // for set position of elements if there are less than 4 + // [*][*][*][*] if 4+ + // [ ][*][*][*] if 3 + // [ ][*][*][ ] 2 + // [ ][ ][ ][*] 1 + var visibleItems = networks.length; + if (visibleItems >= 4) { + visibleItems = 4; + listView.width = Qt.binding(function() { return control.width }); + } else if (visibleItems === 1 || visibleItems === 3) { + listView.width = Qt.binding(function() { return control.width - listView.delegateWidth * (4 - visibleItems) }); + } else if (visibleItems === 2) { + listView.width = Qt.binding(function() { return control.width - listView.delegateWidth }); + } + listView.visibleItems = visibleItems; + + listView.leftIndex = 0; + } + + anchors.right: parent.right + height: parent.height + orientation: Qt.Horizontal + clip: true + interactive: false + + delegate: Rectangle { + id: delegateItem + + // properties duplicated for DapNetworkPopup + property string name: modelData.name + property string networkState: modelData.state + property string networkTargetState: modelData.targetState + property int activeLinksCount: modelData.activeLinksCount + property int linksCount: modelData.linksCount + property string nodeAddress: modelData.nodeAddress + + width: listView.delegateWidth + height: listView.height + color: "#070023" + + DapNetworkName { + width: parent.width + height: parent.height + textColor: "#FFFFFF" + name: delegateItem.name + networkState: delegateItem.networkState + } + + MouseArea { + id: delegateMouseArea + + width: parent.width + height: parent.height + + onClicked: { + if (index >= listView.leftIndex && index < listView.leftIndex + listView.visibleItems) { + networkPanelPopup.show(delegateItem); + } + } + } + } + + onDelegateWidthChanged: { + if (listView.leftIndex >= 0 && listView.leftIndex < listView.count) { + listView.positionViewAtIndex(listView.leftIndex, ListView.Beginning); + } + } + + NumberAnimation { + id: scrollAnimation + target: listView + property: "contentX" + duration: 100 + } + } + + Connections { + target: networks + onListCompositionChanged: listView.setNetworks(networks.model()) + } +} diff --git a/CellFrameDashboardGUI/screen/desktop/NetworksPanel/DapNetworksPanel.qml b/CellFrameDashboardGUI/screen/desktop/NetworksPanel/DapNetworksPanel.qml new file mode 100644 index 0000000000000000000000000000000000000000..24efc370c8e2649e2879a66faae2446406ff0815 --- /dev/null +++ b/CellFrameDashboardGUI/screen/desktop/NetworksPanel/DapNetworksPanel.qml @@ -0,0 +1,40 @@ +import QtQuick 2.7 + +Rectangle { + id: control + + implicitHeight: Math.max(btnPrevious.implicitHeight, networksListView.implicitHeight, btnNext.implicitHeight) + implicitWidth: btnPrevious.implicitWidth + btnNext.implicitWidth + 180 * pt + + color: "#070023" + + DapNetworkPanelButton { + id: btnPrevious + + visible: networksListView.hasLeft + height: parent.height + mirror: true + normalIcon: "qrc:/resources/icons/next-page.svg" + hoverIcon: "qrc:/resources/icons/next-page_hover.svg" + onClicked: networksListView.scrollToLeft() + } + + DapNetworksList { + id: networksListView + + anchors.left: btnPrevious.right + anchors.right: btnNext.left + height: parent.height + } + + DapNetworkPanelButton { + id: btnNext + + visible: networksListView.hasRight + anchors.right: parent.right + height: parent.height + normalIcon: "qrc:/resources/icons/next-page.svg" + hoverIcon: "qrc:/resources/icons/next-page_hover.svg" + onClicked: networksListView.scrollToRight() + } +} diff --git a/CellFrameDashboardService/CellFrameDashboardService.pro b/CellFrameDashboardService/CellFrameDashboardService.pro index a2797c1d597aa6e79ad71e9db1c856f03a33d937..738fbd54ea3842a8c5d8e518ff9a9bac944e9a95 100755 --- a/CellFrameDashboardService/CellFrameDashboardService.pro +++ b/CellFrameDashboardService/CellFrameDashboardService.pro @@ -42,6 +42,8 @@ else { # deprecated API in order to know how to port your code away from it. DEFINES += QT_DEPRECATED_WARNINGS +DEFINES += DAP_VERSION=\\\"$$VERSION\\\" + # You can also make your code fail to compile if you use deprecated APIs. # In order to do so, uncomment the following line. # You can also select to disable deprecated APIs only up to a certain version of Qt. diff --git a/cellframe-sdk b/cellframe-sdk index eea08f6c16ee7c0db0d5864f83e9d4a944290a7c..6f8ef2b81e57b0f00a4b52be460bc37092b95663 160000 --- a/cellframe-sdk +++ b/cellframe-sdk @@ -1 +1 @@ -Subproject commit eea08f6c16ee7c0db0d5864f83e9d4a944290a7c +Subproject commit 6f8ef2b81e57b0f00a4b52be460bc37092b95663 diff --git a/cellframe-ui-sdk b/cellframe-ui-sdk index 2d2759312365ec355e82384c3fb8ccf64ca9abfa..d9c7a081eea35af0f4c3f373f3b4d51c1202d4ae 160000 --- a/cellframe-ui-sdk +++ b/cellframe-ui-sdk @@ -1 +1 @@ -Subproject commit 2d2759312365ec355e82384c3fb8ccf64ca9abfa +Subproject commit d9c7a081eea35af0f4c3f373f3b4d51c1202d4ae diff --git a/dap-ui-sdk b/dap-ui-sdk index 1e3fc3ce8fb483d15f2c210cf6bbd7a7b8731edd..ac371d6c6a4b019f5306faaa2c39ab09450bc845 160000 --- a/dap-ui-sdk +++ b/dap-ui-sdk @@ -1 +1 @@ -Subproject commit 1e3fc3ce8fb483d15f2c210cf6bbd7a7b8731edd +Subproject commit ac371d6c6a4b019f5306faaa2c39ab09450bc845