2021-09-10 12:45:15 +02:00
|
|
|
import QtQuick
|
2021-07-15 12:07:39 +02:00
|
|
|
import Qt5Compat.GraphicalEffects
|
2021-09-10 12:45:15 +02:00
|
|
|
import QtQuick.Controls
|
|
|
|
import QtQuick.Layouts
|
|
|
|
import QtQuick.Controls.Material
|
2022-04-23 14:32:36 +02:00
|
|
|
import ScreenPlayWorkshop 1.0
|
2020-08-20 17:21:09 +02:00
|
|
|
|
|
|
|
Drawer {
|
|
|
|
id: root
|
|
|
|
|
2021-05-16 19:37:55 +02:00
|
|
|
property SteamWorkshop steamWorkshop
|
2020-08-20 17:21:09 +02:00
|
|
|
property url videoPreview
|
|
|
|
property alias imgUrl: img.source
|
|
|
|
property string name
|
2021-01-21 18:37:25 +01:00
|
|
|
property var publishedFileID
|
2020-08-20 17:21:09 +02:00
|
|
|
property int itemIndex
|
|
|
|
property int subscriptionCount
|
|
|
|
property bool subscribed: false
|
|
|
|
|
2021-05-16 19:37:55 +02:00
|
|
|
signal tagClicked(var tag)
|
2020-08-20 17:21:09 +02:00
|
|
|
|
2021-05-16 19:37:55 +02:00
|
|
|
function setWorkshopItem(publishedFileID, imgUrl, videoPreview, subscriptionCount) {
|
2021-01-21 18:37:25 +01:00
|
|
|
if (root.publishedFileID === publishedFileID) {
|
2021-05-16 19:37:55 +02:00
|
|
|
if (!root.visible)
|
2021-09-10 12:45:15 +02:00
|
|
|
root.open()
|
2021-05-16 19:37:55 +02:00
|
|
|
else
|
2021-09-10 12:45:15 +02:00
|
|
|
root.close()
|
|
|
|
return
|
2020-08-20 17:21:09 +02:00
|
|
|
}
|
2021-09-10 12:45:15 +02:00
|
|
|
root.publishedFileID = publishedFileID
|
|
|
|
root.imgUrl = imgUrl
|
|
|
|
root.subscriptionCount = subscriptionCount
|
|
|
|
root.videoPreview = videoPreview
|
|
|
|
root.subscribed = false
|
|
|
|
txtVotesUp.highlighted = false
|
|
|
|
txtVotesDown.highlighted = false
|
2021-05-16 19:37:55 +02:00
|
|
|
if (!root.visible)
|
2021-09-10 12:45:15 +02:00
|
|
|
root.open()
|
2021-05-16 19:37:55 +02:00
|
|
|
|
2021-09-10 12:45:15 +02:00
|
|
|
steamWorkshop.requestWorkshopItemDetails(publishedFileID)
|
2021-05-16 19:37:55 +02:00
|
|
|
}
|
2021-01-21 18:37:25 +01:00
|
|
|
|
2021-05-16 19:37:55 +02:00
|
|
|
edge: Qt.RightEdge
|
|
|
|
height: parent.height - 60
|
|
|
|
dim: false
|
|
|
|
modal: false
|
|
|
|
width: 400
|
|
|
|
interactive: false
|
2020-08-20 17:21:09 +02:00
|
|
|
|
|
|
|
Connections {
|
|
|
|
function onRequestItemDetailReturned(title, tags, steamIDOwner, description, votesUp, votesDown, url, fileSize, publishedFileId) {
|
2021-09-10 12:45:15 +02:00
|
|
|
tagListModel.clear()
|
2021-02-21 17:15:04 +01:00
|
|
|
// Even if the tags array is empty it still contains
|
|
|
|
// one empty string, resulting in an empty button
|
|
|
|
if (tags.length > 1) {
|
|
|
|
for (var i in tags) {
|
|
|
|
tagListModel.append({
|
2021-09-10 12:45:15 +02:00
|
|
|
"name": tags[i]
|
|
|
|
})
|
2021-02-21 17:15:04 +01:00
|
|
|
}
|
2021-09-10 12:45:15 +02:00
|
|
|
rpTagList.model = tagListModel
|
2021-02-21 17:15:04 +01:00
|
|
|
} else {
|
2021-09-10 12:45:15 +02:00
|
|
|
rpTagList.model = null
|
2020-08-20 17:21:09 +02:00
|
|
|
}
|
2021-09-10 12:45:15 +02:00
|
|
|
txtTitle.text = title
|
|
|
|
const size = Math.floor((1000 * ((fileSize / 1024) / 1000)) / 1000)
|
2021-09-18 15:42:30 +02:00
|
|
|
txtFileSize.text = qsTr("Size: ") + size + " MB"
|
2021-09-10 12:45:15 +02:00
|
|
|
pbVotes.to = votesDown + votesUp
|
|
|
|
pbVotes.value = votesUp
|
|
|
|
txtVotesDown.text = votesDown
|
|
|
|
txtVotesUp.text = votesUp
|
2021-05-16 19:37:55 +02:00
|
|
|
if (description === "")
|
2021-09-10 12:45:15 +02:00
|
|
|
description = qsTr("No description...")
|
2021-05-16 19:37:55 +02:00
|
|
|
|
2021-09-10 12:45:15 +02:00
|
|
|
txtDescription.text = description
|
|
|
|
pbVotes.hoverText = votesUp + " / " + votesDown
|
2020-08-20 17:21:09 +02:00
|
|
|
}
|
2021-05-16 19:37:55 +02:00
|
|
|
|
|
|
|
target: steamWorkshop
|
2020-08-20 17:21:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Item {
|
|
|
|
id: imgWrapper
|
2021-05-16 19:37:55 +02:00
|
|
|
|
2020-08-20 17:21:09 +02:00
|
|
|
width: parent.width
|
|
|
|
height: 220
|
2021-05-16 19:37:55 +02:00
|
|
|
|
2020-08-20 17:21:09 +02:00
|
|
|
Image {
|
|
|
|
id: img
|
2021-05-16 19:37:55 +02:00
|
|
|
|
2020-08-20 17:21:09 +02:00
|
|
|
fillMode: Image.PreserveAspectCrop
|
|
|
|
anchors.fill: parent
|
|
|
|
}
|
2021-05-16 19:37:55 +02:00
|
|
|
|
2020-08-20 17:21:09 +02:00
|
|
|
|
|
|
|
|
|
|
|
LinearGradient {
|
|
|
|
height: 50
|
|
|
|
cached: true
|
2021-05-16 19:37:55 +02:00
|
|
|
start: Qt.point(0, 50)
|
|
|
|
end: Qt.point(0, 0)
|
2020-08-20 17:21:09 +02:00
|
|
|
|
|
|
|
anchors {
|
|
|
|
bottom: parent.bottom
|
|
|
|
right: parent.right
|
|
|
|
left: parent.left
|
|
|
|
}
|
2021-05-16 19:37:55 +02:00
|
|
|
|
2020-08-20 17:21:09 +02:00
|
|
|
gradient: Gradient {
|
|
|
|
GradientStop {
|
2021-05-16 19:37:55 +02:00
|
|
|
position: 0
|
2020-08-20 17:21:09 +02:00
|
|
|
color: "#EE000000"
|
|
|
|
}
|
2021-05-16 19:37:55 +02:00
|
|
|
|
2020-08-20 17:21:09 +02:00
|
|
|
GradientStop {
|
2021-05-16 19:37:55 +02:00
|
|
|
position: 1
|
2020-08-20 17:21:09 +02:00
|
|
|
color: "#00000000"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Text {
|
|
|
|
id: txtTitle
|
|
|
|
font.weight: Font.Thin
|
|
|
|
verticalAlignment: Text.AlignBottom
|
|
|
|
font.pointSize: 16
|
|
|
|
color: "white"
|
|
|
|
wrapMode: Text.WordWrap
|
|
|
|
elide: Text.ElideRight
|
|
|
|
height: 50
|
2021-05-16 19:37:55 +02:00
|
|
|
|
2020-08-20 17:21:09 +02:00
|
|
|
anchors {
|
|
|
|
bottom: parent.bottom
|
|
|
|
right: parent.right
|
|
|
|
margins: 20
|
|
|
|
left: parent.left
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
id: button
|
2021-05-16 19:37:55 +02:00
|
|
|
|
2020-08-20 17:21:09 +02:00
|
|
|
height: 50
|
|
|
|
width: 50
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.left: parent.left
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
onClicked: root.close()
|
|
|
|
|
|
|
|
Image {
|
|
|
|
id: imgBack
|
2021-05-16 19:37:55 +02:00
|
|
|
|
2022-04-23 14:32:36 +02:00
|
|
|
source: "qrc:/ScreenPlayWorkshop/assets/icons/icon_arrow_right.svg"
|
2020-08-20 17:21:09 +02:00
|
|
|
sourceSize: Qt.size(15, 15)
|
|
|
|
fillMode: Image.PreserveAspectFit
|
|
|
|
anchors.centerIn: parent
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ColumnLayout {
|
2021-05-16 19:37:55 +02:00
|
|
|
spacing: 20
|
|
|
|
|
2020-08-20 17:21:09 +02:00
|
|
|
anchors {
|
|
|
|
top: imgWrapper.bottom
|
|
|
|
right: parent.right
|
|
|
|
left: parent.left
|
2021-02-21 17:15:04 +01:00
|
|
|
bottom: rlBottomButtons.top
|
2020-08-20 17:21:09 +02:00
|
|
|
margins: 20
|
|
|
|
}
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
Layout.fillHeight: true
|
|
|
|
Layout.fillWidth: true
|
|
|
|
spacing: 20
|
|
|
|
|
|
|
|
ColumnLayout {
|
|
|
|
Layout.maximumWidth: 280
|
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
|
|
|
|
RowLayout {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
spacing: 20
|
|
|
|
|
|
|
|
ToolButton {
|
|
|
|
id: txtVotesUp
|
2021-05-16 19:37:55 +02:00
|
|
|
|
2020-08-20 17:21:09 +02:00
|
|
|
Layout.fillWidth: true
|
2022-04-23 14:32:36 +02:00
|
|
|
icon.source: "qrc:/ScreenPlayWorkshop/assets/icons/icon_thumb_up.svg"
|
2020-08-20 17:21:09 +02:00
|
|
|
ToolTip.visible: hovered
|
|
|
|
ToolTip.text: qsTr("Click here if you like the content")
|
|
|
|
onClicked: {
|
2021-09-10 12:45:15 +02:00
|
|
|
steamWorkshop.vote(root.publishedFileID, true)
|
|
|
|
txtVotesUp.highlighted = true
|
|
|
|
txtVotesDown.highlighted = false
|
2020-08-20 17:21:09 +02:00
|
|
|
}
|
|
|
|
}
|
2021-05-16 19:37:55 +02:00
|
|
|
|
2020-08-20 17:21:09 +02:00
|
|
|
ToolButton {
|
|
|
|
id: txtVotesDown
|
2021-05-16 19:37:55 +02:00
|
|
|
|
2020-08-20 17:21:09 +02:00
|
|
|
Layout.fillWidth: true
|
2022-04-23 14:32:36 +02:00
|
|
|
icon.source: "qrc:/ScreenPlayWorkshop/assets/icons/icon_thumb_down.svg"
|
2020-08-20 17:21:09 +02:00
|
|
|
ToolTip.visible: hovered
|
|
|
|
ToolTip.text: qsTr("Click here if you do not like the content")
|
|
|
|
onClicked: {
|
2021-09-10 12:45:15 +02:00
|
|
|
steamWorkshop.vote(root.publishedFileID, false)
|
|
|
|
txtVotesUp.highlighted = false
|
|
|
|
txtVotesDown.highlighted = true
|
2020-08-20 17:21:09 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ProgressBar {
|
|
|
|
id: pbVotes
|
2021-05-16 19:37:55 +02:00
|
|
|
|
2020-08-20 17:21:09 +02:00
|
|
|
property string hoverText
|
2021-05-16 19:37:55 +02:00
|
|
|
|
2020-08-20 17:21:09 +02:00
|
|
|
Layout.alignment: Qt.AlignHCenter
|
|
|
|
Layout.fillWidth: true
|
|
|
|
ToolTip.visible: hovered
|
|
|
|
ToolTip.text: hoverText
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-11 17:23:20 +01:00
|
|
|
Flickable {
|
2021-02-20 17:39:23 +01:00
|
|
|
Layout.preferredHeight: 40
|
2021-03-11 17:23:20 +01:00
|
|
|
Layout.maximumHeight: 40
|
2020-08-20 17:21:09 +02:00
|
|
|
Layout.fillWidth: true
|
2021-03-11 17:23:20 +01:00
|
|
|
clip: true
|
|
|
|
contentWidth: rowTagList.width + rpTagList.count * rowTagList.spacing
|
2021-05-16 19:37:55 +02:00
|
|
|
|
2021-02-21 17:15:04 +01:00
|
|
|
ListModel {
|
|
|
|
id: tagListModel
|
2020-08-20 17:21:09 +02:00
|
|
|
}
|
2021-05-16 19:37:55 +02:00
|
|
|
|
2021-03-11 17:23:20 +01:00
|
|
|
Row {
|
|
|
|
id: rowTagList
|
2021-05-16 19:37:55 +02:00
|
|
|
|
2021-03-11 17:23:20 +01:00
|
|
|
width: parent.width
|
|
|
|
spacing: 10
|
2021-05-16 19:37:55 +02:00
|
|
|
|
2021-03-11 17:23:20 +01:00
|
|
|
Repeater {
|
|
|
|
id: rpTagList
|
|
|
|
|
|
|
|
delegate: Button {
|
|
|
|
id: txtTags
|
2021-05-16 19:37:55 +02:00
|
|
|
|
2021-03-11 17:23:20 +01:00
|
|
|
property string tags
|
2021-05-16 19:37:55 +02:00
|
|
|
|
2021-03-11 17:23:20 +01:00
|
|
|
text: name
|
|
|
|
font.pointSize: 8
|
|
|
|
onClicked: root.tagClicked(txtTags.text)
|
2021-02-20 17:39:23 +01:00
|
|
|
}
|
|
|
|
}
|
2020-08-20 17:21:09 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
RowLayout {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
spacing: 20
|
2021-05-16 19:37:55 +02:00
|
|
|
|
2020-08-20 17:21:09 +02:00
|
|
|
Text {
|
|
|
|
id: txtSubscriptionCount
|
2021-05-16 19:37:55 +02:00
|
|
|
|
2020-08-20 17:21:09 +02:00
|
|
|
color: Material.secondaryTextColor
|
|
|
|
font.pointSize: 11
|
|
|
|
text: qsTr("Subscribtions: ") + root.subscriptionCount
|
|
|
|
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
|
|
|
|
}
|
2021-05-16 19:37:55 +02:00
|
|
|
|
2021-01-07 18:07:19 +01:00
|
|
|
Item {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
2020-08-20 17:21:09 +02:00
|
|
|
|
2021-02-21 17:15:04 +01:00
|
|
|
Text {
|
|
|
|
id: txtFileSize
|
2021-05-16 19:37:55 +02:00
|
|
|
|
2021-02-21 17:15:04 +01:00
|
|
|
color: Material.secondaryTextColor
|
|
|
|
font.pointSize: 11
|
|
|
|
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
|
2020-08-20 17:21:09 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.minimumHeight: 150
|
|
|
|
Layout.fillHeight: true //txtDescription.paintedHeight > 100
|
|
|
|
color: Material.backgroundColor
|
|
|
|
radius: 3
|
2021-05-16 19:37:55 +02:00
|
|
|
|
2020-08-20 17:21:09 +02:00
|
|
|
ScrollView {
|
|
|
|
anchors.fill: parent
|
2021-02-21 17:15:04 +01:00
|
|
|
anchors.margins: 20
|
2020-08-20 17:21:09 +02:00
|
|
|
clip: true
|
|
|
|
ScrollBar.vertical.policy: ScrollBar.AsNeeded
|
|
|
|
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
|
|
|
|
|
|
|
|
Text {
|
|
|
|
id: txtDescription
|
2021-05-16 19:37:55 +02:00
|
|
|
|
2020-08-20 17:21:09 +02:00
|
|
|
width: parent.width
|
|
|
|
color: Material.primaryTextColor
|
2021-02-21 17:15:04 +01:00
|
|
|
font.pointSize: 12
|
2020-08-20 17:21:09 +02:00
|
|
|
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-05-16 19:37:55 +02:00
|
|
|
|
2021-02-21 17:15:04 +01:00
|
|
|
RowLayout {
|
|
|
|
id: rlBottomButtons
|
2021-05-16 19:37:55 +02:00
|
|
|
|
|
|
|
spacing: 20
|
|
|
|
|
2020-08-20 17:21:09 +02:00
|
|
|
anchors {
|
|
|
|
horizontalCenter: parent.horizontalCenter
|
|
|
|
bottom: parent.bottom
|
|
|
|
bottomMargin: 20
|
|
|
|
}
|
2021-05-16 19:37:55 +02:00
|
|
|
|
2021-02-21 17:15:04 +01:00
|
|
|
ToolButton {
|
|
|
|
id: btnOpenInSteam
|
2021-05-16 19:37:55 +02:00
|
|
|
|
2021-02-21 17:15:04 +01:00
|
|
|
font.pointSize: 10
|
2022-04-23 14:32:36 +02:00
|
|
|
icon.source: "qrc:/ScreenPlayWorkshop/assets/icons/icon_open_in_new.svg"
|
2021-02-21 17:15:04 +01:00
|
|
|
height: 25
|
|
|
|
text: qsTr("Open In Steam")
|
2021-09-10 12:45:15 +02:00
|
|
|
onClicked: Qt.openUrlExternally(
|
|
|
|
"steam://url/CommunityFilePage/" + root.publishedFileID)
|
2021-02-21 17:15:04 +01:00
|
|
|
}
|
2021-05-16 19:37:55 +02:00
|
|
|
|
2021-02-21 17:15:04 +01:00
|
|
|
Button {
|
|
|
|
id: btnSubscribe
|
|
|
|
|
|
|
|
highlighted: !root.subscribed
|
|
|
|
enabled: !root.subscribed
|
2022-04-23 14:32:36 +02:00
|
|
|
icon.source: "qrc:/ScreenPlayWorkshop/assets/icons/icon_download.svg"
|
2021-02-21 17:15:04 +01:00
|
|
|
text: root.subscribed ? qsTr("Subscribed!") : qsTr("Subscribe")
|
|
|
|
onClicked: {
|
2021-09-10 12:45:15 +02:00
|
|
|
root.subscribed = true
|
|
|
|
root.steamWorkshop.subscribeItem(root.publishedFileID)
|
2021-02-21 17:15:04 +01:00
|
|
|
}
|
2020-08-20 17:21:09 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-16 19:37:55 +02:00
|
|
|
background: Rectangle {
|
2021-09-10 12:45:15 +02:00
|
|
|
color: Material.theme === Material.Light ? "white" : Qt.darker(
|
|
|
|
Material.background)
|
2021-05-16 19:37:55 +02:00
|
|
|
opacity: 0.95
|
|
|
|
}
|
|
|
|
|
|
|
|
enter: Transition {
|
|
|
|
SmoothedAnimation {
|
|
|
|
velocity: 10
|
|
|
|
easing.type: Easing.InOutQuart
|
|
|
|
}
|
|
|
|
}
|
2020-08-20 17:21:09 +02:00
|
|
|
|
2021-05-16 19:37:55 +02:00
|
|
|
exit: Transition {
|
|
|
|
SmoothedAnimation {
|
|
|
|
velocity: 10
|
|
|
|
easing.type: Easing.InOutQuart
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|