1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-11-07 03:22:33 +01:00
ScreenPlay/ScreenPlayWorkshop/qml/Sidebar.qml

368 lines
10 KiB
QML
Raw Normal View History

import QtQuick
2021-07-15 12:07:39 +02:00
import Qt5Compat.GraphicalEffects
import QtQuick.Controls
import QtQuick.Layouts
import QtQuick.Controls.Material
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
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) {
if (root.publishedFileID === publishedFileID) {
2021-05-16 19:37:55 +02:00
if (!root.visible)
root.open()
2021-05-16 19:37:55 +02:00
else
root.close()
return
2020-08-20 17:21:09 +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)
root.open()
2021-05-16 19:37:55 +02:00
steamWorkshop.requestWorkshopItemDetails(publishedFileID)
2021-05-16 19:37:55 +02: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) {
tagListModel.clear()
// 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({
"name": tags[i]
})
}
rpTagList.model = tagListModel
} else {
rpTagList.model = null
2020-08-20 17:21:09 +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"
pbVotes.to = votesDown + votesUp
pbVotes.value = votesUp
txtVotesDown.text = votesDown
txtVotesUp.text = votesUp
2021-05-16 19:37:55 +02:00
if (description === "")
description = qsTr("No description...")
2021-05-16 19:37:55 +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
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
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
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: {
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
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: {
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
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
Text {
id: txtFileSize
2021-05-16 19:37:55 +02: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
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
font.pointSize: 12
2020-08-20 17:21:09 +02:00
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
}
}
}
}
}
2021-05-16 19:37:55 +02: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
ToolButton {
id: btnOpenInSteam
2021-05-16 19:37:55 +02:00
font.pointSize: 10
icon.source: "qrc:/ScreenPlayWorkshop/assets/icons/icon_open_in_new.svg"
height: 25
text: qsTr("Open In Steam")
onClicked: Qt.openUrlExternally(
"steam://url/CommunityFilePage/" + root.publishedFileID)
}
2021-05-16 19:37:55 +02:00
Button {
id: btnSubscribe
highlighted: !root.subscribed
enabled: !root.subscribed
icon.source: "qrc:/ScreenPlayWorkshop/assets/icons/icon_download.svg"
text: root.subscribed ? qsTr("Subscribed!") : qsTr("Subscribe")
onClicked: {
root.subscribed = true
root.steamWorkshop.subscribeItem(root.publishedFileID)
}
2020-08-20 17:21:09 +02:00
}
}
2021-05-16 19:37:55 +02:00
background: Rectangle {
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
}
}
}