2021-07-29 13:33:22 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
import QtQuick.Layouts 1.3
|
2021-08-02 07:11:28 +00:00
|
|
|
import QtGraphicalEffects 1.0
|
2021-09-23 02:52:17 +00:00
|
|
|
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
|
2021-09-28 15:04:06 +00:00
|
|
|
|
|
|
|
import utils 1.0
|
2021-12-08 21:20:43 +00:00
|
|
|
import shared.stores 1.0
|
2021-07-29 13:33:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
Column {
|
|
|
|
id: root
|
2021-08-02 07:11:28 +00:00
|
|
|
spacing: 8
|
2021-07-29 13:33:22 +00:00
|
|
|
property alias gifList: repeater
|
2022-07-05 07:20:57 +00:00
|
|
|
property int gifWidth: 0
|
2022-01-13 08:58:42 +00:00
|
|
|
property var store
|
2021-07-29 13:33:22 +00:00
|
|
|
property var gifSelected: function () {}
|
2021-08-03 08:48:06 +00:00
|
|
|
property var toggleFavorite: function () {}
|
2021-09-23 02:52:17 +00:00
|
|
|
property string lastHoveredId
|
|
|
|
signal gifHovered(string id)
|
2021-07-29 13:33:22 +00:00
|
|
|
|
|
|
|
Repeater {
|
|
|
|
id: repeater
|
|
|
|
|
|
|
|
delegate: Rectangle {
|
2021-09-23 02:52:17 +00:00
|
|
|
id: thumb
|
|
|
|
property alias hovered: mouseArea.containsMouse
|
|
|
|
onHoveredChanged: {
|
|
|
|
if (hovered) {
|
|
|
|
root.gifHovered(model.id)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-02 07:11:28 +00:00
|
|
|
height: animation.status != Image.Ready ? loader.height : animation.height
|
2021-07-29 13:33:22 +00:00
|
|
|
width: root.gifWidth
|
2021-08-02 07:11:28 +00:00
|
|
|
color: Style.current.background
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
id: loader
|
|
|
|
height: 100
|
|
|
|
width: root.gifWidth
|
|
|
|
visible: animation.status != Image.Ready
|
|
|
|
radius: Style.current.radius
|
|
|
|
rotation: 90
|
|
|
|
gradient: Gradient {
|
|
|
|
GradientStop { position: 0.0; color: "transparent" }
|
|
|
|
GradientStop { position: 1.0; color: "#E6EEF2" }
|
|
|
|
}
|
|
|
|
}
|
2021-07-29 13:33:22 +00:00
|
|
|
|
2021-09-23 02:52:17 +00:00
|
|
|
StatusBaseButton {
|
2021-08-03 08:48:06 +00:00
|
|
|
id: starButton
|
2022-01-13 08:58:42 +00:00
|
|
|
property bool favorite: RootStore.isFavorite(model.id)
|
2021-09-23 02:52:17 +00:00
|
|
|
|
|
|
|
type: StatusFlatRoundButton.Type.Secondary
|
|
|
|
textColor: hovered || favorite ? Style.current.yellow : Style.current.secondaryText
|
|
|
|
icon.name: favorite ? "star-icon" : "star-icon-outline"
|
|
|
|
icon.width: (14/104) * thumb.width
|
|
|
|
icon.height: (13/104) * thumb.width
|
|
|
|
topPadding: (6/104) * thumb.width
|
|
|
|
rightPadding: (6/104) * thumb.width
|
|
|
|
bottomPadding: (6/104) * thumb.width
|
|
|
|
leftPadding: (6/104) * thumb.width
|
2022-09-13 07:37:09 +00:00
|
|
|
normalColor: "transparent"
|
2021-09-23 02:52:17 +00:00
|
|
|
visible: !loader.visible && model.id === root.lastHoveredId
|
2021-08-03 08:48:06 +00:00
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
z: 1
|
|
|
|
onClicked: {
|
|
|
|
root.toggleFavorite(model)
|
2021-09-23 02:52:17 +00:00
|
|
|
favorite = !favorite
|
|
|
|
}
|
|
|
|
onHoveredChanged: {
|
|
|
|
if (hovered) {
|
|
|
|
root.gifHovered(model.id)
|
2021-08-03 08:48:06 +00:00
|
|
|
}
|
|
|
|
}
|
2021-09-23 02:52:17 +00:00
|
|
|
StatusToolTip {
|
|
|
|
id: statusToolTip
|
|
|
|
text: starButton.favorite ?
|
|
|
|
qsTr("Remove from favorites") :
|
|
|
|
qsTr("Add to favorites")
|
|
|
|
visible: starButton.hovered
|
|
|
|
}
|
2021-08-03 08:48:06 +00:00
|
|
|
}
|
|
|
|
|
2021-07-29 13:33:22 +00:00
|
|
|
AnimatedImage {
|
|
|
|
id: animation
|
2021-08-02 07:11:28 +00:00
|
|
|
visible: animation.status == Image.Ready
|
|
|
|
source: model.tinyUrl
|
2021-07-29 13:33:22 +00:00
|
|
|
width: root.gifWidth
|
|
|
|
fillMode: Image.PreserveAspectFit
|
2021-08-03 08:48:06 +00:00
|
|
|
z: 0
|
2021-08-02 07:11:28 +00:00
|
|
|
layer.enabled: true
|
|
|
|
layer.effect: OpacityMask {
|
2021-09-23 02:52:17 +00:00
|
|
|
opacity: model.id === root.lastHoveredId ? 0.6 : 1
|
2021-08-02 07:11:28 +00:00
|
|
|
maskSource: Rectangle {
|
|
|
|
width: animation.width
|
|
|
|
height: animation.height
|
|
|
|
radius: Style.current.radius
|
|
|
|
}
|
|
|
|
}
|
2021-07-29 13:33:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
MouseArea {
|
2021-08-03 08:48:06 +00:00
|
|
|
id: mouseArea
|
2022-08-12 12:11:57 +00:00
|
|
|
objectName: "gifMouseArea_" + index
|
2021-08-03 08:48:06 +00:00
|
|
|
cursorShape: Qt.PointingHandCursor
|
2021-07-29 13:33:22 +00:00
|
|
|
anchors.fill: parent
|
2021-08-03 08:48:06 +00:00
|
|
|
hoverEnabled: true
|
2021-07-29 13:33:22 +00:00
|
|
|
onClicked: function (event) {
|
2022-01-13 08:58:42 +00:00
|
|
|
root.store.addToRecentsGif(model.id)
|
2022-04-01 09:52:44 +00:00
|
|
|
root.gifSelected(event, model.url)
|
2021-07-29 13:33:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|