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

0001 /*
0002  *  Copyright 2018 by Aditya Mehra <aix.m@outlook.com>
0003  *
0004  *  This program is free software: you can redistribute it and/or modify
0005  *  it under the terms of the GNU General Public License as published by
0006  *  the Free Software Foundation, either version 3 of the License, or
0007  *  (at your option) any later version.
0008 
0009  *  This program is distributed in the hope that it will be useful,
0010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
0011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0012  *  GNU General Public License for more details.
0013 
0014  *  You should have received a copy of the GNU General Public License
0015  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
0016  */
0017 
0018 import QtQuick 2.9
0019 import QtQuick.Layouts 1.4
0020 import QtGraphicalEffects 1.0
0021 import QtQuick.Controls 2.3
0022 import org.kde.kirigami 2.8 as Kirigami
0023 import org.kde.plasma.core 2.0 as PlasmaCore
0024 import org.kde.plasma.components 3.0 as PlasmaComponents3
0025 import org.kde.plasma.components 2.0 as PlasmaComponents
0026 import Mycroft 1.0 as Mycroft
0027 import "+mediacenter/views" as Views
0028 import "+mediacenter/delegates" as Delegates
0029 
0030 Item {
0031     property alias model: videoListView.model
0032     Layout.fillWidth: true
0033     Layout.fillHeight: true
0034     
0035     onFocusChanged: {
0036         if(focus){
0037             console.log("here in focus")
0038             videoListView.forceActiveFocus()
0039         }
0040     }
0041     
0042     Views.TileView {
0043         id: videoListView
0044         focus: true
0045         clip: true
0046         anchors.top: parent.top
0047         anchors.left: parent.left
0048         anchors.right: parent.right
0049         anchors.bottom: controlAreaButtons.top
0050         property string currentVideoTitle
0051         property string currentVideoId
0052         delegate: Delegates.VideoCard{}
0053         
0054         KeyNavigation.up: videoQueryBox
0055         KeyNavigation.down: nextPageAvailable ? nextButton : previousButton
0056                 
0057         Keys.onReturnPressed: {
0058             busyIndicatorPop.open()
0059             if(focus){
0060                 Mycroft.MycroftController.sendRequest("aiix.youtube-skill.playvideo_id", {vidID: currentVideoId, vidTitle: currentVideoTitle})
0061             }
0062         }
0063             
0064         onCurrentItemChanged: {
0065             currentVideoId = videoListView.currentItem.videoID
0066             currentVideoTitle = videoListView.currentItem.videoTitle
0067             console.log(videoListView.currentItem.videoTitle)
0068         }
0069     }
0070     
0071     RowLayout {
0072         id: controlAreaButtons
0073         anchors.bottom: parent.bottom
0074         anchors.left: parent.left
0075         anchors.right: parent.right
0076         height: Kirigami.Units.gridUnit * 2.5
0077         
0078         Button {
0079             id: previousButton
0080             text: "Previous Page"
0081             Layout.preferredWidth: nextButton.visible ? parent.width / 2 : parent.width
0082             Layout.fillHeight: true
0083             icon.name: "go-previous-symbolic"
0084             enabled: nextPageAvailable ? 0 : 1
0085             visible: nextPageAvailable ? 0 : 1
0086             
0087             background: Rectangle {
0088                 color: previousButton.activeFocus ?  Kirigami.Theme.highlightColor : Kirigami.Theme.backgroundColor
0089             }
0090             
0091             onClicked: {
0092                 triggerGuiEvent("YoutubeSkill.PreviousPage", {"Category": categoryName})
0093                 busyIndicatorPop.open()
0094                 nextButton.forceActiveFocus()
0095             }
0096             
0097             Keys.onReturnPressed: {
0098                 triggerGuiEvent("YoutubeSkill.PreviousPage", {"Category": categoryName})
0099                 busyIndicatorPop.open()
0100                 nextButton.forceActiveFocus()
0101             }
0102             
0103             KeyNavigation.up: videoListView
0104         }
0105         
0106         Button {
0107             id: nextButton
0108             text: "Next Page"
0109             enabled: nextPageAvailable ? 1 : 0
0110             visible: nextPageAvailable ? 1 : 0
0111             Layout.preferredWidth: previousButton.visible ? parent.width / 2 : parent.width
0112             Layout.fillHeight: true
0113             icon.name: "go-next-symbolic"
0114             
0115             background: Rectangle {
0116                 color: nextButton.activeFocus ?  Kirigami.Theme.highlightColor : Kirigami.Theme.backgroundColor
0117             }
0118             
0119             onClicked: {
0120                 triggerGuiEvent("YoutubeSkill.NextPage", {"Category": categoryName})
0121                 busyIndicatorPop.open()
0122                 previousButton.forceActiveFocus()
0123             }
0124             
0125             Keys.onReturnPressed: {
0126                 triggerGuiEvent("YoutubeSkill.NextPage", {"Category": categoryName})
0127                 busyIndicatorPop.open()
0128                 previousButton.forceActiveFocus()
0129             }
0130             
0131             KeyNavigation.up: videoListView
0132         }
0133     }
0134 }