Warning, /multimedia/plasmatube/src/ui/components/VideoListItem.qml is written in an unsupported language. File is not indexed.

0001 // SPDX-FileCopyrightText: 2019 Linus Jahn <lnj@kaidan.im>
0002 // SPDX-FileCopyrightText: 2022 Devin Lin <devin@kde.org>
0003 // SPDX-License-Identifier: GPL-3.0-or-later
0004 
0005 import QtQuick
0006 import QtQuick.Layouts
0007 import QtQuick.Controls as QQC2
0008 import Qt5Compat.GraphicalEffects
0009 
0010 import org.kde.kirigami as Kirigami
0011 
0012 import "utils.js" as Utils
0013 
0014 QQC2.ItemDelegate {
0015     id: root
0016 
0017     property string vid
0018     property url thumbnail
0019     property bool liveNow
0020     property date length
0021     property string title
0022     property string author
0023     property string authorId
0024     property string description
0025     property int viewCount
0026     property string publishedText
0027     property bool watched
0028 
0029     signal contextMenuRequested
0030 
0031     hoverEnabled: !Kirigami.Settings.hasTransientTouchInput
0032     onPressAndHold: contextMenuRequested()
0033 
0034     contentItem: RowLayout {
0035         id: gridLayout
0036         anchors.top: parent.top
0037         anchors.topMargin: root.topPadding
0038         anchors.left: parent.left
0039         anchors.leftMargin: root.leftPadding
0040         anchors.right: parent.right
0041         anchors.rightMargin: root.rightPadding
0042 
0043         spacing: Kirigami.Units.largeSpacing
0044 
0045         TapHandler {
0046             acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchPad
0047             acceptedButtons: Qt.RightButton
0048             onTapped: root.contextMenuRequested()
0049         }
0050 
0051         Image {
0052             id: thumb
0053             Layout.preferredWidth: root.width < 500 ? Kirigami.Units.gridUnit * 8 : Kirigami.Units.gridUnit * 12
0054             Layout.preferredHeight: root.width < 500 ? Kirigami.Units.gridUnit * 4.5 : Kirigami.Units.gridUnit * 6.75
0055             Layout.maximumWidth: root.width < 500 ? Kirigami.Units.gridUnit * 8 : Kirigami.Units.gridUnit * 12
0056             Layout.maximumHeight: root.width < 500 ? Kirigami.Units.gridUnit * 4.5 : Kirigami.Units.gridUnit * 6.75
0057             source: thumbnail
0058             fillMode: Image.PreserveAspectCrop
0059             layer.enabled: true
0060             layer.effect: OpacityMask {
0061                 maskSource: mask
0062             }
0063             Rectangle {
0064                 id: mask
0065                 radius: 7
0066                 anchors.fill: thumb
0067                 visible: false
0068             }
0069             PlaceholderItem {
0070                 anchors.fill: parent
0071                 visible: thumb.status !== Image.Ready
0072             }
0073             Text {
0074                 visible: !liveNow && text !== "00:00"
0075                 text: Utils.formatTime(length)
0076                 color: "white"
0077 
0078                 anchors.right: parent.right
0079                 anchors.bottom: parent.bottom
0080                 anchors.rightMargin: 7
0081                 anchors.bottomMargin: 3
0082 
0083                 z: 2
0084 
0085                 Rectangle {
0086                     anchors.fill: parent
0087                     anchors.leftMargin: -2
0088                     anchors.rightMargin: -2
0089                     z: -1
0090                     color: "#90000000"
0091                     radius: 2
0092                     width: 60
0093                     height: 15
0094                 }
0095             }
0096 
0097             Rectangle {
0098                 id: watchIndicator
0099 
0100                 color: "black"
0101                 opacity: 0.5
0102                 visible: root.watched
0103                 anchors.fill: parent
0104 
0105                 Rectangle {
0106                     anchors {
0107                         bottom: parent.bottom
0108                         left: parent.left
0109                         right: parent.right
0110                     }
0111 
0112                     color: "red"
0113                     height: 3
0114                 }
0115             }
0116         }
0117 
0118         ColumnLayout {
0119             id: videoInfo
0120             Layout.alignment: Qt.AlignTop
0121             // Layout.preferredHeight: thumb.height
0122             spacing: Kirigami.Units.smallSpacing
0123 
0124             Kirigami.Heading {
0125                 Layout.alignment: Qt.AlignTop
0126                 Layout.fillWidth: true
0127 
0128                 text: title
0129                 level: 4
0130                 maximumLineCount: 2
0131                 wrapMode: Text.Wrap
0132                 elide: Text.ElideRight
0133             }
0134 
0135             QQC2.Label {
0136                 font.pointSize: Kirigami.Theme.smallFont.pointSize
0137                 text: author
0138                 color: Kirigami.Theme.disabledTextColor
0139                 maximumLineCount: 2
0140                 elide: Text.ElideRight
0141             }
0142 
0143             Row {
0144                 spacing: 0
0145 
0146                 QQC2.Label {
0147                     font.pointSize: Kirigami.Theme.smallFont.pointSize
0148                     text: i18n("%1 views", Utils.formatCount(viewCount))
0149                     color: Kirigami.Theme.disabledTextColor
0150                     maximumLineCount: 1
0151                     elide: Text.ElideRight
0152                 }
0153 
0154                 QQC2.Label {
0155                     font.pointSize: Kirigami.Theme.smallFont.pointSize
0156                     text: i18n(" \u2022 %1", liveNow ? "<i>live now</i>" : publishedText)
0157                     color: Kirigami.Theme.disabledTextColor
0158                     maximumLineCount: 1
0159                     elide: Text.ElideRight
0160                     visible: publishedText.length !== 0
0161                 }
0162             }
0163         }
0164     }
0165 }