Skip to content

Commit

Permalink
Refs #2, Dashboards now have their own StackView.
Browse files Browse the repository at this point in the history
  • Loading branch information
doumdi committed Mar 12, 2024
1 parent ec78005 commit 9a5d1d8
Show file tree
Hide file tree
Showing 9 changed files with 104 additions and 15 deletions.
5 changes: 4 additions & 1 deletion Frontend/DashboardsViewer/content/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -32,11 +34,12 @@ qt6_add_qml_module(content
dataSources/ParticipantListDataSource.qml
dataSources/ParticipantSessionListDataSource.qml
# Delegates
delegates/BaseDelegate.qml
delegates/ParticipantDelegate.qml
delegates/SessionDelegate.qml
delegates/GenericItemDelegate.qml

RESOURCES
fonts/Arimo-VariableFont_wght.ttf
images/logos/LogoOpenTera.png
)
)
6 changes: 6 additions & 0 deletions Frontend/DashboardsViewer/content/delegates/BaseDelegate.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import QtQuick 2.15

Item {
id: baseDelegate
property Item stackView: dashboardStackView ? dashboardStackView : null
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -50,7 +50,11 @@ Item {
}
onPressAndHold: {
console.log("SessionDelegate long pressed");
dialog.open()

if (stackView) {
stackView.push("../widgets/SessionViewerWidget.qml", {"session": model})
}

}
}
}
Expand Down
15 changes: 9 additions & 6 deletions Frontend/DashboardsViewer/content/screens/Dashboard.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Frontend/DashboardsViewer/content/widgets/BaseWidget.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
72 changes: 72 additions & 0 deletions Frontend/DashboardsViewer/content/widgets/SessionViewerWidget.qml
Original file line number Diff line number Diff line change
@@ -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")
}
}

0 comments on commit 9a5d1d8

Please sign in to comment.