From 9a5d1d83ff1e481c182c72b5c0ba000d31a1bb6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominic=20L=C3=A9tourneau?= Date: Tue, 12 Mar 2024 14:11:38 -0400 Subject: [PATCH] Refs #2, Dashboards now have their own StackView. --- .../DashboardsViewer/content/CMakeLists.txt | 5 +- .../content/delegates/BaseDelegate.qml | 6 ++ .../content/delegates/GenericItemDelegate.qml | 2 +- .../content/delegates/ParticipantDelegate.qml | 2 +- .../content/delegates/SessionDelegate.qml | 8 ++- .../content/screens/Dashboard.qml | 15 ++-- .../content/screens/DashboardForm.ui.qml | 7 +- .../content/widgets/BaseWidget.qml | 2 +- .../content/widgets/SessionViewerWidget.qml | 72 +++++++++++++++++++ 9 files changed, 104 insertions(+), 15 deletions(-) create mode 100644 Frontend/DashboardsViewer/content/delegates/BaseDelegate.qml create mode 100644 Frontend/DashboardsViewer/content/widgets/SessionViewerWidget.qml diff --git a/Frontend/DashboardsViewer/content/CMakeLists.txt b/Frontend/DashboardsViewer/content/CMakeLists.txt index 6a48f68..febfbe5 100644 --- a/Frontend/DashboardsViewer/content/CMakeLists.txt +++ b/Frontend/DashboardsViewer/content/CMakeLists.txt @@ -22,6 +22,8 @@ qt6_add_qml_module(content widgets/ClockWidget.qml widgets/ButtonWidget.qml widgets/ListViewWidget.qml + widgets/SessionViewerWidget.qml + # Layouts layouts/BaseLayout.qml layouts/CenteredRowLayout.qml @@ -32,6 +34,7 @@ qt6_add_qml_module(content dataSources/ParticipantListDataSource.qml dataSources/ParticipantSessionListDataSource.qml # Delegates + delegates/BaseDelegate.qml delegates/ParticipantDelegate.qml delegates/SessionDelegate.qml delegates/GenericItemDelegate.qml @@ -39,4 +42,4 @@ qt6_add_qml_module(content RESOURCES fonts/Arimo-VariableFont_wght.ttf images/logos/LogoOpenTera.png -) + ) diff --git a/Frontend/DashboardsViewer/content/delegates/BaseDelegate.qml b/Frontend/DashboardsViewer/content/delegates/BaseDelegate.qml new file mode 100644 index 0000000..7b0b908 --- /dev/null +++ b/Frontend/DashboardsViewer/content/delegates/BaseDelegate.qml @@ -0,0 +1,6 @@ +import QtQuick 2.15 + +Item { + id: baseDelegate + property Item stackView: dashboardStackView ? dashboardStackView : null +} diff --git a/Frontend/DashboardsViewer/content/delegates/GenericItemDelegate.qml b/Frontend/DashboardsViewer/content/delegates/GenericItemDelegate.qml index 99b9d32..fa4952f 100644 --- a/Frontend/DashboardsViewer/content/delegates/GenericItemDelegate.qml +++ b/Frontend/DashboardsViewer/content/delegates/GenericItemDelegate.qml @@ -2,7 +2,7 @@ import QtQuick 2.15 import QtQuick.Controls 2.15 import QtQuick.Layouts 2.15 -Item { +BaseDelegate { id: myDelegate signal itemClicked(int id); diff --git a/Frontend/DashboardsViewer/content/delegates/ParticipantDelegate.qml b/Frontend/DashboardsViewer/content/delegates/ParticipantDelegate.qml index d8a3208..155c81c 100644 --- a/Frontend/DashboardsViewer/content/delegates/ParticipantDelegate.qml +++ b/Frontend/DashboardsViewer/content/delegates/ParticipantDelegate.qml @@ -2,7 +2,7 @@ import QtQuick 2.15 import QtQuick.Controls 2.15 import QtQuick.Layouts 2.15 -Item { +BaseDelegate { id: myDelegate height: parent ? 80 : 0 width: parent ? parent.width : 0 diff --git a/Frontend/DashboardsViewer/content/delegates/SessionDelegate.qml b/Frontend/DashboardsViewer/content/delegates/SessionDelegate.qml index 821c968..ef65ebf 100644 --- a/Frontend/DashboardsViewer/content/delegates/SessionDelegate.qml +++ b/Frontend/DashboardsViewer/content/delegates/SessionDelegate.qml @@ -2,7 +2,7 @@ import QtQuick 2.15 import QtQuick.Controls 2.15 import QtQuick.Layouts 2.15 -Item { +BaseDelegate { id: myDelegate height: parent ? 80 : 0 width: parent ? parent.width : 0 @@ -50,7 +50,11 @@ Item { } onPressAndHold: { console.log("SessionDelegate long pressed"); - dialog.open() + + if (stackView) { + stackView.push("../widgets/SessionViewerWidget.qml", {"session": model}) + } + } } } diff --git a/Frontend/DashboardsViewer/content/screens/Dashboard.qml b/Frontend/DashboardsViewer/content/screens/Dashboard.qml index 25c6fd3..c86c349 100644 --- a/Frontend/DashboardsViewer/content/screens/Dashboard.qml +++ b/Frontend/DashboardsViewer/content/screens/Dashboard.qml @@ -30,14 +30,17 @@ DashboardForm { { try { - //Create object from dynamicQML - var dynamicObject = Qt.createQmlObject(dynamicQML[i], mainView); + //Create object from dynamicQML + var dynamicObject = Qt.createQmlObject(dynamicQML[i], dashboardStackView); - console.log("dynamicObject", dynamicObject) + console.log("dynamicObject", dynamicObject) + + // Push to stackView + if (dynamicObject) + { + dashboardStackView.push(dynamicObject); + } - if (dynamicObject) { - dynamicObject.stackView = stackview; - } } catch(e) { console.log("Error", e) diff --git a/Frontend/DashboardsViewer/content/screens/DashboardForm.ui.qml b/Frontend/DashboardsViewer/content/screens/DashboardForm.ui.qml index 9898de8..4984510 100644 --- a/Frontend/DashboardsViewer/content/screens/DashboardForm.ui.qml +++ b/Frontend/DashboardsViewer/content/screens/DashboardForm.ui.qml @@ -17,7 +17,8 @@ Item { property alias button: button property alias loadButton: loadButton - property alias mainView: mainView + property alias mainView: dashboardStackView + property alias dashboardStackView: dashboardStackView Text { id: dashboardText @@ -47,8 +48,8 @@ Item { text: qsTr("Load") } - Item { - id: mainView + StackView { + id: dashboardStackView anchors.top: dashboardText.bottom anchors.bottom: parent.bottom width: parent.width diff --git a/Frontend/DashboardsViewer/content/widgets/BaseWidget.qml b/Frontend/DashboardsViewer/content/widgets/BaseWidget.qml index f2a1a0a..bb99b9b 100644 --- a/Frontend/DashboardsViewer/content/widgets/BaseWidget.qml +++ b/Frontend/DashboardsViewer/content/widgets/BaseWidget.qml @@ -7,7 +7,7 @@ Item { id: widgetRoot implicitHeight: 400 implicitWidth: 400 - property Item stackView: null + property Item stackView: dashboardStackView ? dashboardStackView : null Component.onCompleted: { console.log("Using StackView: ", stackView) diff --git a/Frontend/DashboardsViewer/content/widgets/SessionViewerWidget.qml b/Frontend/DashboardsViewer/content/widgets/SessionViewerWidget.qml new file mode 100644 index 0000000..52f038a --- /dev/null +++ b/Frontend/DashboardsViewer/content/widgets/SessionViewerWidget.qml @@ -0,0 +1,72 @@ +import QtQuick 2.15 +import QtQuick.Controls 2.15 +import QtQuick.Layouts 2.15 +import DashboardsViewer 1.0 + +BaseWidget { + id:mySessionViewerWidget + property var session: null + + Rectangle { + id: background + anchors.fill: parent + color: Constants.backgroundColor + + ColumnLayout { + id: sessionLayout + spacing: 10 + anchors.fill: parent + anchors.margins: 10 + Button { + id: button + Layout.fillWidth: false + Layout.fillHeight: false + Layout.alignment: Qt.AlignRight + implicitWidth: 200 + implicitHeight: 50 + text: "Click me to close." + onClicked: { + console.log("Button clicked") + if (stackView.currentItem === mySessionViewerWidget) { + stackView.pop(); + } + } + } + + Rectangle { + id: sessionName + Layout.fillWidth: true + Layout.fillHeight: false + implicitHeight: 30 + color: "lightblue" + Text { + id: sessionNameText + text: session.session_name + font.bold: true + font.pointSize: 20 + anchors.centerIn: parent + } + } + Rectangle { + id: sessionComments + Layout.fillWidth: true + Layout.fillHeight: false + implicitHeight: 30 + color: "lightyellow" + Text { + id: sessionCommentsText + text: session.session_comments + font.pointSize: 16 + anchors.fill: parent + wrapMode: Text.Wrap + } + } + } + + } + + + Component.onCompleted: { + console.log("Item completed") + } +}