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

302 lines
6.9 KiB
QML
Raw Normal View History

import QtQuick
2021-07-15 12:07:39 +02:00
import Qt5Compat.GraphicalEffects
import QtQuick.Controls
2020-08-20 17:21:09 +02:00
Item {
id: screenPlayItem
2021-05-16 19:37:55 +02:00
property alias checkBox: checkBox
2020-08-20 17:21:09 +02:00
property string preview: screenPreview
property bool isSelected: false
property string absoluteStoragePath
property string type
property bool hasMenuOpen: false
property var publishedFileID: 0
2020-08-20 17:21:09 +02:00
property int itemIndex
property string folderName
2021-05-16 19:37:55 +02:00
signal itemClicked(var folderName, var type, var isActive)
2020-08-20 17:21:09 +02:00
2021-05-16 19:37:55 +02:00
width: 320
height: 180
state: "invisible"
opacity: 0
2020-08-20 17:21:09 +02:00
onTypeChanged: {
2021-05-16 19:37:55 +02:00
if (type === "widget")
icnType.source = "icons/icon_widgets.svg";
else if (type === "qmlScene")
icnType.source = "icons/icon_code.svg";
2020-08-20 17:21:09 +02:00
}
Component.onCompleted: {
2021-05-16 19:37:55 +02:00
screenPlayItem.state = "visible";
2020-08-20 17:21:09 +02:00
}
transform: [
Rotation {
id: rt
2021-05-16 19:37:55 +02:00
origin.x: screenPlayItem.width * 0.5
origin.y: screenPlayItem.height * 0.5
2021-05-16 19:37:55 +02:00
angle: 0
2020-08-20 17:21:09 +02:00
axis {
2021-05-16 19:37:55 +02:00
x: -0.5
2020-08-20 17:21:09 +02:00
y: 0
z: 0
}
},
Translate {
id: tr
},
Scale {
id: sc
2021-05-16 19:37:55 +02:00
origin.x: screenPlayItem.width * 0.5
origin.y: screenPlayItem.height * 0.5
2020-08-20 17:21:09 +02:00
}
]
2021-05-16 19:37:55 +02:00
Timer {
id: timerAnim
interval: 40 * screenPlayItem.itemIndex * Math.random()
2021-05-16 19:37:55 +02:00
running: true
repeat: false
onTriggered: showAnim.start()
}
2020-08-20 17:21:09 +02:00
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: screenPlayItem
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"
}
}
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
}
Item {
id: screenPlayItemWrapper
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(screenPlayItem.width, screenPlayItem.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
anchors.fill: parent
visible: false
ScreenPlayItemImage {
id: screenPlayItemImage
2021-05-16 19:37:55 +02:00
anchors.fill: parent
sourceImage: Qt.resolvedUrl(screenPlayItem.absoluteStoragePath + "/" + screenPlayItem.screenPreview)
2020-08-20 17:21:09 +02:00
}
Image {
id: icnType
2021-05-16 19:37:55 +02:00
2020-08-20 17:21:09 +02:00
width: 20
height: 20
opacity: 0
sourceSize: Qt.size(20, 20)
2021-05-16 19:37:55 +02:00
2020-08-20 17:21:09 +02:00
anchors {
top: parent.top
left: parent.left
margins: 10
}
}
Rectangle {
color: "#AAffffff"
height: 30
visible: false
2021-05-16 19:37:55 +02:00
2020-08-20 17:21:09 +02:00
anchors {
right: parent.right
left: parent.left
bottom: parent.bottom
}
}
}
OpacityMask {
anchors.fill: itemWrapper
source: itemWrapper
maskSource: mask
MouseArea {
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
acceptedButtons: Qt.LeftButton | Qt.RightButton
onEntered: {
if (!screenPlayItem.hasMenuOpen)
2021-05-16 19:37:55 +02:00
screenPlayItem.state = "hover";
2020-08-20 17:21:09 +02:00
}
onExited: {
if (!screenPlayItem.hasMenuOpen)
2021-05-16 19:37:55 +02:00
screenPlayItem.state = "visible";
}
onClicked: function (mouse) {
2021-05-16 19:37:55 +02:00
checkBox.toggle();
if (mouse.button === Qt.LeftButton)
itemClicked(screenPlayItem.folderName, type, checkBox.checkState === Qt.Checked);
2020-08-20 17:21:09 +02:00
}
}
}
CheckBox {
id: checkBox
2021-05-16 19:37:55 +02:00
2020-08-20 17:21:09 +02:00
onCheckStateChanged: {
2021-05-16 19:37:55 +02:00
if (checkState == Qt.Checked)
screenPlayItem.isSelected = true;
2021-05-16 19:37:55 +02:00
else
screenPlayItem.isSelected = false;
2020-08-20 17:21:09 +02:00
}
anchors {
top: parent.top
right: parent.right
margins: 10
}
}
2021-05-16 19:37:55 +02:00
}
2020-08-20 17:21:09 +02:00
states: [
State {
name: "invisible"
PropertyChanges {
target: screenPlayItemWrapper
y: -10
opacity: 0
}
2021-05-16 19:37:55 +02:00
2020-08-20 17:21:09 +02:00
PropertyChanges {
target: effect
opacity: 0
}
},
State {
name: "visible"
2021-05-16 19:37:55 +02:00
2020-08-20 17:21:09 +02:00
PropertyChanges {
target: effect
opacity: 0.4
}
2021-05-16 19:37:55 +02:00
2020-08-20 17:21:09 +02:00
PropertyChanges {
target: screenPlayItemWrapper
y: 0
opacity: 1
}
2021-05-16 19:37:55 +02:00
2020-08-20 17:21:09 +02:00
PropertyChanges {
target: screenPlayItem
width: 320
height: 180
}
2021-05-16 19:37:55 +02:00
2020-08-20 17:21:09 +02:00
PropertyChanges {
target: icnType
opacity: 0
}
},
State {
name: "selected"
PropertyChanges {
target: screenPlayItemWrapper
y: 0
opacity: 1
}
2021-05-16 19:37:55 +02:00
2020-08-20 17:21:09 +02:00
PropertyChanges {
target: icnType
2021-05-16 19:37:55 +02:00
opacity: 0.5
2020-08-20 17:21:09 +02:00
}
}
]
transitions: [
Transition {
from: "invisible"
to: "visible"
},
Transition {
from: "visible"
to: "selected"
reversible: true
PropertyAnimation {
target: icnType
property: "opacity"
duration: 80
}
}
]
}