Warning, /plasma-bigscreen/youtube-voice-application/ui/+mediacenter/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 Controls.Control { 0012 id: suggestionBox 0013 property var videoSuggestionList 0014 property alias suggestionListFocus: suggestListView.focus 0015 property var nxtSongBlob 0016 property int countdownSeconds: 15 0017 property int seconds: countdownSeconds 0018 implicitWidth: parent.width 0019 anchors.top: parent.top 0020 anchors.topMargin: Kirigami.Units.gridUnit 0021 anchors.bottom: parent.bottom 0022 anchors.bottomMargin: Kirigami.Units.gridUnit * 2 0023 property bool busyIndicate: false 0024 0025 onFocusChanged: { 0026 if(visible && focus){ 0027 suggestListView.forceActiveFocus() 0028 } 0029 } 0030 0031 onNxtSongBlobChanged: { 0032 nextSongCdBar.imageSource = nxtSongBlob.videoImage 0033 nextSongCdBar.nextSongTitle = nxtSongBlob.videoTitle 0034 } 0035 0036 onVideoSuggestionListChanged: { 0037 console.log(JSON.stringify(videoSuggestionList)) 0038 suggestListView.view.forceLayout() 0039 } 0040 0041 onVisibleChanged: { 0042 if(visible) { 0043 autoPlayTimer.start() 0044 } 0045 } 0046 0047 Connections { 0048 target: Mycroft.MycroftController 0049 onIntentRecevied: { 0050 if(type == "speak") { 0051 busyIndicatorPop.close() 0052 busyIndicate = false 0053 } 0054 } 0055 } 0056 0057 Timer { 0058 id: autoPlayTimer 0059 interval: 1000 0060 repeat: true 0061 onTriggered: { 0062 suggestionBox.seconds--; 0063 autoplayTimeHeading.text = "Next Video In: " + suggestionBox.seconds 0064 if(suggestionBox.seconds == 0) { 0065 running = false; 0066 suggestionBox.seconds = suggestionBox.countdownSeconds 0067 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}) 0068 } 0069 } 0070 } 0071 0072 background: Rectangle { 0073 color: Qt.rgba(Kirigami.Theme.backgroundColor.r, Kirigami.Theme.backgroundColor.g, Kirigami.Theme.backgroundColor.b, 0.6) 0074 } 0075 0076 contentItem: Item { 0077 0078 BigScreen.TileView { 0079 id: suggestListView 0080 clip: false 0081 model: videoSuggestionList 0082 anchors.top: parent.top 0083 anchors.left: parent.left 0084 anchors.leftMargin: Kirigami.Units.largeSpacing * 2 0085 width: parent.width 0086 height: cellWidth + Kirigami.Units.gridUnit * 1.5 0087 delegate: Delegates.ListVideoCard{} 0088 cellWidth: parent.width / 4 0089 title: "Watch Next" 0090 visible: suggestionBox.visible 0091 navigationDown: replayButton 0092 } 0093 0094 ColumnLayout { 0095 id: suggestBoxLayout 0096 anchors { 0097 left: parent.left 0098 right: parent.right 0099 top: suggestListView.bottom 0100 bottom: parent.bottom 0101 } 0102 0103 Kirigami.Separator { 0104 Layout.fillWidth: true 0105 Layout.preferredHeight: 1 0106 } 0107 0108 RowLayout{ 0109 Layout.fillWidth: true 0110 Layout.fillHeight: true 0111 Layout.alignment: Qt.AlignHCenter 0112 0113 Views.CountdownBar { 0114 id: nextSongCdBar 0115 Layout.preferredWidth: parent.width / 3 0116 Layout.fillHeight: true 0117 } 0118 Kirigami.Separator { 0119 Layout.fillHeight: true 0120 Layout.preferredWidth: 1 0121 } 0122 0123 RowLayout { 0124 Layout.preferredWidth: parent.width / 3 0125 Layout.fillHeight: true 0126 0127 Controls.Button { 0128 id: replayButton 0129 Layout.fillWidth: true 0130 Layout.fillHeight: true 0131 text: "Replay Video" 0132 0133 KeyNavigation.up: suggestListView 0134 KeyNavigation.right: stopNextAutoplay 0135 0136 background: Rectangle { 0137 Kirigami.Theme.colorSet: Kirigami.Theme.Button 0138 color: replayButton.activeFocus ? Kirigami.Theme.highlightColor : Kirigami.Theme.backgroundColor 0139 border.color: Kirigami.Theme.textColor 0140 border.width: 1 0141 } 0142 0143 onClicked: { 0144 if(autoplayTimeHeading.visible){ 0145 autoPlayTimer.stop() 0146 autoplayTimeHeading.visible = false 0147 stopNextAutoplay.text = "Next Video" 0148 suggestionBox.seconds = suggestionBox.countdownSeconds 0149 } 0150 triggerGuiEvent("YoutubeSkill.ReplayLast", {}) 0151 } 0152 0153 Keys.onReturnPressed: { 0154 if(autoplayTimeHeading.visible){ 0155 autoPlayTimer.stop() 0156 autoplayTimeHeading.visible = false 0157 stopNextAutoplay.text = "Next Video" 0158 suggestionBox.seconds = suggestionBox.countdownSeconds 0159 } 0160 triggerGuiEvent("YoutubeSkill.ReplayLast", {}) 0161 } 0162 } 0163 0164 Controls.Button { 0165 id: stopNextAutoplay 0166 Layout.fillWidth: true 0167 Layout.fillHeight: true 0168 text: "Cancel Autoplay" 0169 0170 KeyNavigation.up: suggestListView 0171 KeyNavigation.left: replayButton 0172 0173 background: Rectangle { 0174 Kirigami.Theme.colorSet: Kirigami.Theme.Button 0175 color: stopNextAutoplay.activeFocus ? Kirigami.Theme.highlightColor : Kirigami.Theme.backgroundColor 0176 border.color: Kirigami.Theme.textColor 0177 border.width: 1 0178 } 0179 0180 onClicked: { 0181 if(autoplayTimeHeading.visible){ 0182 autoPlayTimer.stop() 0183 autoplayTimeHeading.visible = false 0184 stopNextAutoplay.text = "Next Video" 0185 suggestionBox.seconds = suggestionBox.countdownSeconds 0186 } else { 0187 suggestionBox.seconds = suggestionBox.countdownSeconds 0188 autoPlayTimer.start() 0189 autoplayTimeHeading.visible = true 0190 stopNextAutoplay.text = "Cancel Autoplay" 0191 } 0192 } 0193 0194 Keys.onReturnPressed: { 0195 if(autoplayTimeHeading.visible){ 0196 autoPlayTimer.stop() 0197 autoplayTimeHeading.visible = false 0198 stopNextAutoplay.text = "Next Video" 0199 suggestionBox.seconds = suggestionBox.countdownSeconds 0200 } else { 0201 suggestionBox.seconds = suggestionBox.countdownSeconds 0202 autoPlayTimer.start() 0203 autoplayTimeHeading.visible = true 0204 stopNextAutoplay.text = "Cancel Autoplay" 0205 } 0206 } 0207 } 0208 } 0209 0210 Kirigami.Separator { 0211 Layout.fillHeight: true 0212 Layout.preferredWidth: 1 0213 } 0214 0215 Kirigami.Heading { 0216 id: autoplayTimeHeading 0217 horizontalAlignment: Text.AlignHCenter 0218 verticalAlignment: Text.AlignVCenter 0219 Layout.preferredWidth: parent.width / 3 0220 Layout.fillHeight: true 0221 level: 3 0222 } 0223 } 0224 } 0225 } 0226 0227 Controls.Popup { 0228 id: busyIndicatorPop 0229 width: parent.width 0230 height: parent.height 0231 background: Rectangle { 0232 anchors.fill: parent 0233 color: Qt.rgba(0, 0, 0, 0.5) 0234 } 0235 closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent 0236 0237 Controls.BusyIndicator { 0238 running: busyIndicate 0239 anchors.centerIn: parent 0240 } 0241 0242 onOpened: { 0243 busyIndicate = true 0244 autoPlayTimer.stop() 0245 autoplayTimeHeading.visible = false 0246 stopNextAutoplay.text = "Next Video" 0247 suggestionBox.seconds = suggestionBox.countdownSeconds 0248 } 0249 0250 onClosed: { 0251 busyIndicate = false 0252 } 0253 } 0254 }