Skip to content

Commit

Permalink
Refs #2. Updated ParticipantDelegate visuals with download assets button
Browse files Browse the repository at this point in the history
  • Loading branch information
SBriere committed Apr 22, 2024
1 parent 5f603ff commit 803cd0a
Show file tree
Hide file tree
Showing 4 changed files with 117 additions and 11 deletions.
2 changes: 2 additions & 0 deletions Frontend/DashboardsViewer/content/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ qt6_add_qml_module(content
widgets/BaseWidget.qml
widgets/ButtonWidget.qml
widgets/ClockWidget.qml
widgets/ImageButtonWidget.qml
widgets/ListViewWidget.qml
widgets/SessionViewerWidget.qml
widgets/TimeLineWidget.qml
Expand Down Expand Up @@ -57,6 +58,7 @@ qt6_add_qml_module(content
images/icons/battery_full.png
images/icons/battery_low.png
images/icons/dashboard.png
images/icons/data.png
images/icons/device.png
images/icons/error.png
images/icons/flag.png
Expand Down
28 changes: 17 additions & 11 deletions Frontend/DashboardsViewer/content/delegates/ParticipantDelegate.qml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ BaseDelegate {
property int daysWarningThreshold: 2
property int daysErrorThreshold: 4

property bool showDownloadAssets: true

property bool isCurrentItem: ListView ? ListView.isCurrentItem : false

states: [
Expand Down Expand Up @@ -88,6 +90,16 @@ BaseDelegate {
border.color: isCurrentItem ? "lightgrey" : "black"
border.width: isCurrentItem ? 5 : 1
radius: 5

MouseArea {
id: mouseArea
anchors.fill: parent
onClicked: {
if (myDelegate.ListView)
myDelegate.ListView.view.currentIndex = index;
model.dataSource.itemSelected(model[model.dataSource.fieldIdName])
}
}
}

RowLayout{
Expand Down Expand Up @@ -134,10 +146,12 @@ BaseDelegate {
}
}
}
ButtonWidget{
ImageButtonWidget{
id: btnDownload
text: qsTr("Download")
visible: showDownloadAssets
imgPath: "../images/icons/data.png"
onClicked: {
console.log("Download");
fileDownloader.downloadParticipantArchive(model[model.dataSource.fieldIdName])
}
}
Expand All @@ -147,14 +161,6 @@ BaseDelegate {
id: fileDownloader
}

MouseArea {
id: mouseArea
anchors.fill: parent
onClicked: {
if (myDelegate.ListView)
myDelegate.ListView.view.currentIndex = index;
model.dataSource.itemSelected(model[model.dataSource.fieldIdName])
}
}


}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
98 changes: 98 additions & 0 deletions Frontend/DashboardsViewer/content/widgets/ImageButtonWidget.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Effects
import QtQuick.Layouts 1.15

BaseWidget {

signal clicked() // This signal is emitted when the button is clicked

property alias text: control.text
required property string imgPath

implicitHeight: control.implicitHeight
implicitWidth: control.implicitWidth + 10

Button {
id: control

implicitWidth: iconItem.implicitWidth + leftPadding + rightPadding
implicitHeight: iconItem.implicitHeight + topPadding + bottomPadding
leftPadding: 4
rightPadding: 4

text: ""

background: buttonBackground
Rectangle {
id: buttonBackground
color: "transparent"
implicitWidth: iconItem.implicitWidth
implicitHeight: iconItem.implicitHeight
opacity: enabled ? 1 : 0.5
radius: 5

MouseArea {
id: mouseHover
anchors.fill: parent
propagateComposedEvents: true
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
}
}

contentItem: iconItem
Item{
id: iconItem
implicitHeight: layoutIcon.implicitHeight
implicitWidth: layoutIcon.implicitWidth
RowLayout{
id: layoutIcon
anchors.fill: parent
Image{
id: imgIcon
source: imgPath
width: 32
height: width
sourceSize.width: width
sourceSize.height: height
}

Text {
id: textItem
text: control.text
visible: control.text

opacity: enabled ? 1.0 : 0.5
color: "white"
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
style: enabled ? Text.Outline : Text.Normal
}
}
}
}
states: [
State {
name: "down"
when: control.down || (mouseHover.containsMouse && enabled)
PropertyChanges {
target: textItem
color: "black"
style: Text.Normal
}

PropertyChanges {
target: buttonBackground
color: "#55000033"
}
}
]

Connections {
target: control
onClicked: clicked()
}
}


0 comments on commit 803cd0a

Please sign in to comment.