Warning, /plasma-bigscreen/youtube-voice-application/ui/+mediacenter/delegates/ListVideoCard.qml is written in an unsupported language. File is not indexed.

0001 import QtQuick 2.9
0002 import QtQuick.Layouts 1.4
0003 import QtGraphicalEffects 1.0
0004 import QtQuick.Controls 2.3
0005 import org.kde.kirigami 2.8 as Kirigami
0006 import org.kde.plasma.core 2.0 as PlasmaCore
0007 import org.kde.plasma.components 3.0 as PlasmaComponents3
0008 import org.kde.plasma.components 2.0 as PlasmaComponents
0009 import Mycroft 1.0 as Mycroft
0010 import org.kde.mycroft.bigscreen 1.0 as BigScreen
0011 
0012 
0013 BigScreen.AbstractDelegate {
0014     id: delegate
0015     
0016     implicitWidth: listView.cellWidth
0017     height: parent.height
0018 
0019     contentItem: ColumnLayout {
0020         spacing: Kirigami.Units.smallSpacing
0021 
0022         Item {
0023             id: imgRoot
0024             //clip: true
0025             Layout.alignment: Qt.AlignTop
0026             Layout.fillWidth: true
0027             Layout.topMargin: -delegate.topPadding + delegate.topInset + extraBorder
0028             Layout.leftMargin: -delegate.leftPadding + delegate.leftInset + extraBorder
0029             Layout.rightMargin: -delegate.rightPadding + delegate.rightInset + extraBorder
0030             // Any width times 0.5625 is a 16:9 ratio
0031             // Adding baseRadius is needed to prevent the bottom from being rounded
0032             Layout.preferredHeight: width * 0.5625 + delegate.baseRadius
0033             // FIXME: another thing copied from AbstractDelegate
0034             property real extraBorder: 0
0035 
0036             layer.enabled: true
0037             layer.effect: OpacityMask {
0038                 cached: true
0039                 maskSource: Rectangle {
0040                     x: imgRoot.x;
0041                     y: imgRoot.y
0042                     width: imgRoot.width
0043                     height: imgRoot.height
0044                     radius: delegate.baseRadius
0045                 }
0046             }
0047 
0048             Image {
0049                 id: img
0050                 source: modelData.videoImage
0051                 anchors {
0052                     fill: parent
0053                     // To not round under
0054                     bottomMargin: delegate.baseRadius
0055                 }
0056                 opacity: 1
0057                 fillMode: Image.PreserveAspectCrop
0058 
0059                 Rectangle {
0060                     id: videoDurationTime
0061                     anchors.bottom: parent.bottom
0062                     anchors.bottomMargin: Kirigami.Units.largeSpacing
0063                     anchors.right: parent.right
0064                     anchors.rightMargin: Kirigami.Units.largeSpacing
0065                     // FIXME: kind of hacky to get the padding around the text right
0066                     width: durationText.width + Kirigami.Units.largeSpacing
0067                     height: Kirigami.Units.gridUnit
0068                     radius: delegate.baseRadius
0069                     color: Qt.rgba(0, 0, 0, 0.8)
0070 
0071                     PlasmaComponents.Label {
0072                         id: durationText
0073                         anchors.centerIn: parent
0074                         text: modelData.videoDuration
0075                         color: Kirigami.Theme.textColor
0076                     }
0077                 }
0078             }
0079             
0080             states: [
0081                 State {
0082                     when: delegate.isCurrent
0083                     PropertyChanges {
0084                         target: imgRoot
0085                         extraBorder: delegate.borderSize
0086                     }
0087                 },
0088                 State {
0089                     when: !delegate.isCurrent
0090                     PropertyChanges {
0091                         target: imgRoot
0092                         extraBorder: 0
0093                     }
0094                 }
0095             ]
0096             transitions: Transition {
0097                 onRunningChanged: {
0098                     // Optimize when animating the thumbnail
0099                     img.smooth = !running
0100                 }
0101                 NumberAnimation {
0102                     property: "extraBorder"
0103                     duration: Kirigami.Units.longDuration
0104                     easing.type: Easing.InOutQuad
0105                 }
0106             }
0107         }
0108 
0109         ColumnLayout {
0110             Layout.fillWidth: true
0111             Layout.fillHeight: true
0112             // Compensate for blank space created from not rounding thumbnail bottom corners
0113             Layout.topMargin: -delegate.baseRadius
0114             Layout.alignment: Qt.AlignLeft | Qt.AlignTop
0115             spacing: Kirigami.Units.smallSpacing
0116 
0117             Kirigami.Heading {
0118                 id: videoLabel
0119                 Layout.fillWidth: true
0120                 Layout.alignment: Qt.AlignLeft | Qt.AlignTop
0121                 wrapMode: Text.Wrap
0122                 level: 3
0123                 //verticalAlignment: Text.AlignVCenter
0124                 maximumLineCount: 1
0125                 elide: Text.ElideRight
0126                 color: PlasmaCore.ColorScope.textColor
0127                 Component.onCompleted: {
0128                     text = modelData.videoTitle
0129                 }
0130             }
0131 
0132             PlasmaComponents.Label {
0133                 id: videoChannelName
0134                 Layout.fillWidth: true
0135                 wrapMode: Text.WordWrap
0136                 Layout.alignment: Qt.AlignLeft | Qt.AlignTop
0137                 maximumLineCount: 1
0138                 elide: Text.ElideRight
0139                 color: PlasmaCore.ColorScope.textColor
0140                 text: modelData.videoChannel
0141             }
0142 
0143             RowLayout {
0144                 Layout.fillWidth: true
0145 
0146                 PlasmaComponents.Label {
0147                     id: videoViews
0148                     Layout.alignment: Qt.AlignLeft
0149                     Layout.rightMargin: Kirigami.Units.largeSpacing
0150                     elide: Text.ElideRight
0151                     color: PlasmaCore.ColorScope.textColor
0152                     text: modelData.videoViews
0153                 }
0154 
0155                 PlasmaComponents.Label {
0156                     id: videoUploadDate
0157                     Layout.fillWidth: true
0158                     Layout.alignment: Qt.AlignRight | Qt.AlignTop
0159                     horizontalAlignment: Text.AlignRight
0160                     elide: Text.ElideRight
0161                     color: PlasmaCore.ColorScope.textColor
0162                     text: modelData.videoUploadDate
0163                 }
0164             }
0165         }
0166     }
0167 
0168     onClicked: {
0169         busyIndicatorPop.open()
0170         Mycroft.MycroftController.sendRequest("aiix.youtube-skill.playvideo_id", {vidID: modelData.videoID, vidTitle: modelData.videoTitle, vidImage: modelData.videoImage, vidChannel: modelData.videoChannel, vidViews: modelData.videoViews, vidUploadDate: modelData.videoUploadDate, vidDuration: modelData.videoDuration})
0171     }
0172 }