Warning, /plasma-bigscreen/youtube-voice-application/ui/SuggestionArea.qml is written in an unsupported language. File is not indexed.
0001 import QtQuick.Layouts 1.4
0002 import QtQuick 2.9
0003 import QtQuick.Controls 2.0 as Controls
0004 import org.kde.kirigami 2.8 as Kirigami
0005 import QtGraphicalEffects 1.0
0006 import Mycroft 1.0 as Mycroft
0007 import "+mediacenter/views" as Views
0008 import "+mediacenter/delegates" as Delegates
0009 import org.kde.mycroft.bigscreen 1.0 as BigScreen
0010
0011 Rectangle {
0012 id: suggestionBox
0013 color: Qt.rgba(Kirigami.Theme.backgroundColor.r, Kirigami.Theme.backgroundColor.g, Kirigami.Theme.backgroundColor.b, 0.6)
0014 property var videoSuggestionList
0015 property alias suggestionListFocus: suggestListView.focus
0016 property var nxtSongBlob
0017 property int countdownSeconds: 15
0018 property int seconds: countdownSeconds
0019 anchors.left: parent.left
0020 anchors.right: parent.right
0021 anchors.verticalCenter: parent.verticalCenter
0022 implicitHeight: suggestBoxLayout.implicitHeight + Kirigami.Units.largeSpacing * 4
0023
0024 onFocusChanged: {
0025 if(visible && focus){
0026 suggestListView.forceActiveFocus()
0027 }
0028 }
0029
0030 onNxtSongBlobChanged: {
0031 nextSongCdBar.imageSource = nxtSongBlob.videoImage
0032 nextSongCdBar.nextSongTitle = nxtSongBlob.videoTitle
0033 }
0034
0035 onVideoSuggestionListChanged: {
0036 console.log(JSON.stringify(videoSuggestionList))
0037 suggestListView.view.forceLayout()
0038 }
0039
0040 onVisibleChanged: {
0041 if(visible) {
0042 autoPlayTimer.start()
0043 }
0044 }
0045
0046 Timer {
0047 id: autoPlayTimer
0048 interval: 1000
0049 repeat: true
0050 onTriggered: {
0051 suggestionBox.seconds--;
0052 autoplayTimeHeading.text = "Next Video In: " + suggestionBox.seconds
0053 if(suggestionBox.seconds == 0) {
0054 running = false;
0055 suggestionBox.seconds = suggestionBox.countdownSeconds
0056 Mycroft.MycroftController.sendRequest("aiix.youtube-skill.playvideo_id", {vidID: nxtSongBlob.videoID, vidTitle: nxtSongBlob.videoTitle, vidImage: nxtSongBlob.videoImage, vidChannel: nxtSongBlob.videoChannel, vidViews: nxtSongBlob.videoViews, vidUploadDate: nxtSongBlob.videoUploadDate, vidDuration: nxtSongBlob.videoDuration})
0057 }
0058 }
0059 }
0060
0061 ColumnLayout {
0062 id: suggestBoxLayout
0063 anchors.fill: parent
0064 BigScreen.TileView {
0065 id: suggestListView
0066 clip: true
0067 model: videoSuggestionList
0068 delegate: Delegates.ListVideoCard{}
0069 title: "Watch Next"
0070 Layout.margins: Kirigami.Units.largeSpacing * 2
0071 cellWidth: parent.width / 4
0072 navigationDown: stopNextAutoplay
0073 }
0074 Kirigami.Separator {
0075 Layout.fillWidth: true
0076 Layout.preferredHeight: 1
0077 }
0078 RowLayout{
0079 Layout.fillWidth: true
0080 Layout.fillHeight: true
0081 Layout.alignment: Qt.AlignHCenter
0082
0083 Views.CountdownBar {
0084 id: nextSongCdBar
0085 Layout.preferredWidth: parent.width / 3
0086 Layout.fillHeight: true
0087 }
0088 Kirigami.Separator {
0089 Layout.fillHeight: true
0090 Layout.preferredWidth: 1
0091 }
0092 Controls.Button {
0093 id: stopNextAutoplay
0094 Layout.preferredWidth: parent.width / 3
0095 Layout.fillHeight: true
0096 text: "Cancel Autoplay"
0097
0098 KeyNavigation.up: suggestListView
0099
0100 onClicked: {
0101 if(autoplayTimeHeading.visible){
0102 autoPlayTimer.stop()
0103 autoplayTimeHeading.visible = false
0104 stopNextAutoplay.text = "Next Video"
0105 suggestionBox.seconds = suggestionBox.countdownSeconds
0106 } else {
0107 suggestionBox.seconds = suggestionBox.countdownSeconds
0108 autoPlayTimer.start()
0109 autoplayTimeHeading.visible = true
0110 stopNextAutoplay.text = "Cancel Autoplay"
0111 }
0112 }
0113
0114 Keys.onReturnPressed: {
0115 if(autoplayTimeHeading.visible){
0116 autoPlayTimer.stop()
0117 autoplayTimeHeading.visible = false
0118 stopNextAutoplay.text = "Next Video"
0119 suggestionBox.seconds = suggestionBox.countdownSeconds
0120 } else {
0121 suggestionBox.seconds = suggestionBox.countdownSeconds
0122 autoPlayTimer.start()
0123 autoplayTimeHeading.visible = true
0124 stopNextAutoplay.text = "Cancel Autoplay"
0125 }
0126 }
0127 }
0128
0129 Kirigami.Separator {
0130 Layout.fillHeight: true
0131 Layout.preferredWidth: 1
0132 }
0133
0134 Kirigami.Heading {
0135 id: autoplayTimeHeading
0136 horizontalAlignment: Text.AlignHCenter
0137 verticalAlignment: Text.AlignVCenter
0138 Layout.preferredWidth: parent.width / 3
0139 Layout.fillHeight: true
0140 level: 3
0141 }
0142 }
0143 }
0144 }