1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-09-18 08:22:33 +02:00
ScreenPlay/ScreenPlayWorkshop/qml/WorkshopItem.qml

441 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.Controls.Material
import ScreenPlayWorkshop
2020-08-20 17:21:09 +02:00
Item {
id: root
property url imgUrl
property url additionalPreviewUrl
property string name
property var publishedFileID: 0
2020-08-20 17:21:09 +02:00
property int itemIndex
property int subscriptionCount
property bool isDownloading: false
2021-02-13 20:17:16 +01:00
property SteamWorkshop steamWorkshop
2020-08-20 17:21:09 +02:00
signal clicked(var publishedFileID, url imgUrl)
2020-08-20 17:21:09 +02:00
2021-05-16 19:37:55 +02:00
width: 320
height: 180
transform: [
Rotation {
id: rt
origin.x: width * 0.5
origin.y: height * 0.5
angle: 0
axis {
x: -0.5
y: 0
z: 0
}
},
Translate {
id: tr
},
Scale {
id: sc
origin.x: width * 0.5
origin.y: height * 0.5
}
]
2020-08-20 17:21:09 +02:00
RectangularGlow {
id: effect
height: parent.height
width: parent.width
cached: true
glowRadius: 3
spread: 0.2
color: "black"
opacity: 0.4
cornerRadius: 15
2021-05-16 19:37:55 +02:00
anchors {
top: parent.top
topMargin: 3
}
2020-08-20 17:21:09 +02:00
}
2021-05-16 19:37:55 +02:00
2020-08-20 17:21:09 +02:00
Timer {
id: timerAnim
2021-05-16 19:37:55 +02:00
2020-08-20 17:21:09 +02:00
interval: 40 * itemIndex * Math.random()
running: true
repeat: false
onTriggered: showAnim.start()
}
ParallelAnimation {
id: showAnim
2021-05-16 19:37:55 +02:00
2020-08-20 17:21:09 +02:00
running: false
2021-05-16 19:37:55 +02:00
2020-08-20 17:21:09 +02:00
RotationAnimation {
target: rt
from: 90
to: 0
duration: 500
easing.type: Easing.OutQuint
property: "angle"
}
2021-05-16 19:37:55 +02:00
2020-08-20 17:21:09 +02:00
PropertyAnimation {
target: root
from: 0
to: 1
duration: 500
easing.type: Easing.OutQuint
property: "opacity"
}
2021-05-16 19:37:55 +02:00
2020-08-20 17:21:09 +02:00
PropertyAnimation {
target: tr
from: 80
to: 0
duration: 500
easing.type: Easing.OutQuint
property: "y"
}
2021-05-16 19:37:55 +02:00
2020-08-20 17:21:09 +02:00
PropertyAnimation {
target: sc
2021-05-16 19:37:55 +02:00
from: 0.8
2020-08-20 17:21:09 +02:00
to: 1
duration: 500
easing.type: Easing.OutQuint
properties: "xScale,yScale"
}
}
Item {
id: screenPlay
2021-05-16 19:37:55 +02:00
2020-08-20 17:21:09 +02:00
anchors.centerIn: parent
height: 180
width: 320
Image {
id: mask
2021-05-16 19:37:55 +02:00
2022-05-01 20:20:57 +02:00
//source: "qrc:/qml/ScreenPlayWorkshop/assets/images/Window.svg"
2020-08-20 17:21:09 +02:00
sourceSize: Qt.size(screenPlay.width, screenPlay.height)
visible: false
smooth: true
fillMode: Image.PreserveAspectFit
}
Item {
id: itemWrapper
2021-05-16 19:37:55 +02:00
2020-08-20 17:21:09 +02:00
visible: false
2021-05-16 19:37:55 +02:00
2020-08-20 17:21:09 +02:00
anchors {
fill: parent
margins: 5
}
ScreenPlayItemImage {
id: screenPlayItemImage
2021-05-16 19:37:55 +02:00
2020-08-20 17:21:09 +02:00
anchors.fill: parent
sourceImage: root.imgUrl
sourceImageGIF: root.additionalPreviewUrl
}
Rectangle {
2020-08-20 17:21:09 +02:00
id: shadow
2021-05-16 19:37:55 +02:00
2020-08-20 17:21:09 +02:00
height: 80
opacity: 0
2021-05-16 19:37:55 +02:00
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 {
position: 1
2020-08-20 17:21:09 +02:00
color: "#CC000000"
}
2021-05-16 19:37:55 +02:00
2020-08-20 17:21:09 +02:00
GradientStop {
position: 0
2020-08-20 17:21:09 +02:00
color: "#00000000"
}
}
}
2021-05-16 19:37:55 +02:00
2020-08-20 17:21:09 +02:00
Text {
id: txtTitle
2021-05-16 19:37:55 +02:00
2020-08-20 17:21:09 +02:00
text: root.name
opacity: 0
height: 30
width: 180
verticalAlignment: Text.AlignVCenter
color: "white"
font.pointSize: 14
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
2021-05-16 19:37:55 +02:00
2020-08-20 17:21:09 +02:00
anchors {
bottom: parent.bottom
right: parent.right
rightMargin: 20
left: parent.left
leftMargin: 20
2020-08-20 17:21:09 +02:00
bottomMargin: -50
}
}
Item {
id: openInWorkshop
2021-05-16 19:37:55 +02:00
2020-08-20 17:21:09 +02:00
height: 20
width: 20
z: 99
opacity: 0
2021-05-16 19:37:55 +02:00
2020-08-20 17:21:09 +02:00
anchors {
margins: 10
top: parent.top
right: parent.right
}
2021-05-16 19:37:55 +02:00
2020-08-20 17:21:09 +02:00
Image {
2022-05-01 20:20:57 +02:00
source: "qrc:/qml/ScreenPlayWorkshop/assets/icons/icon_open_in_new.svg"
2020-08-20 17:21:09 +02:00
sourceSize: Qt.size(parent.width, parent.height)
fillMode: Image.PreserveAspectFit
}
}
}
OpacityMask {
anchors.fill: itemWrapper
source: itemWrapper
maskSource: mask
MouseArea {
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onContainsMouseChanged: {
if (!isDownloading) {
2021-05-16 19:37:55 +02:00
if (containsMouse)
root.state = "hover";
else
root.state = "";
2020-08-20 17:21:09 +02:00
}
}
onClicked: {
2021-05-16 19:37:55 +02:00
root.clicked(root.publishedFileID, root.imgUrl);
2020-08-20 17:21:09 +02:00
}
}
2021-05-16 19:37:55 +02:00
2020-08-20 17:21:09 +02:00
MouseArea {
height: 20
width: 20
cursorShape: Qt.PointingHandCursor
2021-05-16 19:37:55 +02:00
onClicked: {
Qt.openUrlExternally("steam://url/CommunityFilePage/" + root.publishedFileID);
}
2020-08-20 17:21:09 +02:00
anchors {
margins: 10
top: parent.top
right: parent.right
}
}
}
2021-05-16 19:37:55 +02:00
2020-08-20 17:21:09 +02:00
FastBlur {
id: effBlur
2021-05-16 19:37:55 +02:00
2020-08-20 17:21:09 +02:00
anchors.fill: itemWrapper
source: itemWrapper
radius: 0
}
Item {
id: itmDownloading
2021-05-16 19:37:55 +02:00
2020-08-20 17:21:09 +02:00
opacity: 0
2021-05-16 19:37:55 +02:00
2020-08-20 17:21:09 +02:00
anchors {
top: parent.top
topMargin: 50
right: parent.right
bottom: parent.bottom
left: parent.left
}
Text {
id: txtDownloading
2021-05-16 19:37:55 +02:00
2020-08-20 17:21:09 +02:00
text: qsTr("Successfully subscribed to Workshop Item!")
color: "white"
font.pointSize: 18
wrapMode: Text.WordWrap
horizontalAlignment: Qt.AlignHCenter
2021-05-16 19:37:55 +02:00
2020-08-20 17:21:09 +02:00
anchors {
verticalCenter: parent.verticalCenter
right: parent.right
rightMargin: 20
left: parent.left
leftMargin: 20
}
}
}
}
states: [
State {
name: "hover"
PropertyChanges {
target: openInWorkshop
2021-05-16 19:37:55 +02:00
opacity: 0.75
2020-08-20 17:21:09 +02:00
}
PropertyChanges {
target: txtTitle
opacity: 1
anchors.bottomMargin: 20
}
PropertyChanges {
target: shadow
opacity: 1
}
2021-05-16 19:37:55 +02:00
2020-08-20 17:21:09 +02:00
PropertyChanges {
target: effBlur
radius: 0
}
},
State {
name: "downloading"
PropertyChanges {
target: openInWorkshop
opacity: 0
}
PropertyChanges {
target: txtTitle
opacity: 0
}
PropertyChanges {
target: shadow
opacity: 0
}
PropertyChanges {
target: effBlur
radius: 64
}
PropertyChanges {
target: itmDownloading
opacity: 1
anchors.topMargin: 0
}
},
State {
name: "installed"
PropertyChanges {
target: txtTitle
opacity: 0
}
PropertyChanges {
target: shadow
opacity: 0
}
PropertyChanges {
target: effBlur
radius: 64
}
PropertyChanges {
target: itmDownloading
opacity: 1
anchors.topMargin: 0
}
2021-05-16 19:37:55 +02:00
2020-08-20 17:21:09 +02:00
PropertyChanges {
target: txtDownloading
text: qsTr("Download complete!")
}
}
]
transitions: [
Transition {
from: ""
to: "hover"
reversible: true
PropertyAnimation {
target: openInWorkshop
duration: 100
properties: "opacity"
}
2021-05-16 19:37:55 +02:00
2020-08-20 17:21:09 +02:00
PropertyAnimation {
target: txtTitle
duration: 100
properties: "opacity, anchors.bottomMargin"
}
2021-05-16 19:37:55 +02:00
2020-08-20 17:21:09 +02:00
PropertyAnimation {
target: shadow
duration: 100
properties: "opacity"
}
},
Transition {
from: "*"
to: "downloading"
reversible: true
PropertyAnimation {
target: txtTitle
duration: 100
properties: "opacity"
}
2021-05-16 19:37:55 +02:00
2020-08-20 17:21:09 +02:00
PropertyAnimation {
target: shadow
duration: 100
properties: "opacity"
}
2021-05-16 19:37:55 +02:00
2020-08-20 17:21:09 +02:00
SequentialAnimation {
PropertyAnimation {
target: effBlur
duration: 500
properties: "radius"
}
2021-05-16 19:37:55 +02:00
2020-08-20 17:21:09 +02:00
PropertyAnimation {
target: txtTitle
duration: 200
properties: "opacity, anchors.topMargin"
}
}
}
]
}