Warning, /plasma-bigscreen/youtube-voice-application/ui/CategoryBoxHomeView.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 Mycroft 1.0 as Mycroft
0024 import "+android/views" as Views
0025 import "+android/delegates" as Delegates
0026 
0027 Item {
0028     property var trendListModel: sessionData.trendListBlob.videoList
0029     property var newsListModel: sessionData.newsListBlob.videoList
0030     property var musicListModel: sessionData.musicListBlob.videoList
0031     property var techListModel: sessionData.techListBlob.videoList
0032     property var polListModel: sessionData.polListBlob.videoList
0033     property var gamingListModel: sessionData.gamingListBlob.videoList
0034     property var searchListModel: sessionData.searchListBlob.videoList
0035     property var recentHomeModel: sessionData.recentHomeListBlob.recentList
0036     property var historyListModel: sessionData.recentListBlob.recentList
0037     Layout.fillWidth: true
0038     Layout.fillHeight: true
0039     
0040     onFocusChanged: {
0041         if(focus && recentListView.visible){
0042             recentListView.forceActiveFocus()
0043         } else if (focus && !recentListView.visible) {
0044             trendListView.forceActiveFocus()
0045         }
0046     }
0047     
0048     onNewsListModelChanged: {
0049        newsListView.view.forceLayout()
0050     }
0051     onMusicListModelChanged: {
0052        musicListView.view.forceLayout()
0053     }
0054     onTechListModelChanged: {
0055        techListView.view.forceLayout()
0056     }
0057     onPolListModelChanged: {
0058        polListView.view.forceLayout()
0059     }
0060     onGamingListModelChanged: {
0061        gamingListView.view.forceLayout()
0062     }
0063     onRecentHomeModelChanged: {
0064         recentListView.view.forceLayout()
0065     }
0066     onTrendListModelChanged: {
0067         trendListView.view.forceLayout()
0068     }
0069     
0070     Flickable {
0071         width: parent.width
0072         height: parent.height
0073         contentHeight: contentLayout.implicitHeight
0074     
0075         ColumnLayout {
0076             id: contentLayout
0077             anchors {
0078                 left: parent.left
0079                 right: parent.right
0080                 margins: Kirigami.Units.largeSpacing * 3
0081             }
0082             property Item currentSection
0083             readonly property int rowHeight: recentListView.cellWidth / 1.8 + Kirigami.Units.gridUnit * 7
0084             y: currentSection ? -currentSection.y : 0
0085 
0086             Behavior on y {
0087                 NumberAnimation {
0088                     duration: Kirigami.Units.longDuration * 2
0089                     easing.type: Easing.InOutQuad
0090                 }
0091             }
0092 
0093             spacing: Kirigami.Units.largeSpacing * 4
0094 
0095             Views.TileView {
0096                 id: recentListView
0097                 focus: true
0098                 model: recentHomeModel
0099                 title: "Recently Watched"
0100                 cellWidth: parent.width / 2
0101                 delegate: Delegates.ListVideoCard{}
0102                 visible: recentListView.view.count > 0 ? 1 : 0
0103                 onActiveFocusChanged: {
0104                     if(activeFocus){
0105                         contentLayout.currentSection = recentListView
0106                     }
0107                 }
0108 
0109                 implicitHeight: contentLayout.rowHeight
0110             }
0111 
0112             Views.TileView {
0113                 id: trendListView
0114                 focus: false
0115                 model: trendListModel
0116                 title: "Trending"
0117                 cellWidth: parent.width / 2
0118                 delegate: Delegates.ListVideoCard{}
0119                 onActiveFocusChanged: {
0120                     if(activeFocus){
0121                         contentLayout.currentSection = trendListView
0122                     }
0123                 }
0124 
0125                 implicitHeight: contentLayout.rowHeight
0126             }
0127 
0128             Views.TileView {
0129                 id: newsListView
0130                 focus: false
0131                 model: newsListModel
0132                 title: "News"
0133                 cellWidth: parent.width / 2
0134                 delegate: Delegates.ListVideoCard{}
0135                 onActiveFocusChanged: {
0136                     if(activeFocus){
0137                         contentLayout.currentSection = newsListView
0138                     }
0139                 }
0140                 
0141                 implicitHeight: contentLayout.rowHeight
0142             }
0143             
0144             Views.TileView {
0145                 id: musicListView
0146                 focus: false
0147                 model: musicListModel
0148                 title: "Music"
0149                 cellWidth: parent.width / 2
0150                 delegate: Delegates.ListVideoCard{}
0151                 onActiveFocusChanged: {
0152                     if(activeFocus){
0153                         contentLayout.currentSection = musicListView
0154                     }
0155                 }
0156 
0157                 implicitHeight: contentLayout.rowHeight
0158             }
0159             
0160             Views.TileView {
0161                 id: techListView
0162                 focus: false
0163                 model: techListModel
0164                 title: "Technology"
0165                 cellWidth: parent.width / 2
0166                 delegate: Delegates.ListVideoCard{}
0167                 onActiveFocusChanged: {
0168                     if(activeFocus){
0169                         contentLayout.currentSection = techListView
0170                     }
0171                 }
0172 
0173                 implicitHeight: contentLayout.rowHeight
0174             }
0175             
0176             Views.TileView {
0177                 id: polListView
0178                 focus: false
0179                 model: polListModel
0180                 title: "Politics"
0181                 cellWidth: parent.width / 2
0182                 delegate: Delegates.ListVideoCard{}
0183                 onActiveFocusChanged: {
0184                     if(activeFocus){
0185                         contentLayout.currentSection = polListView
0186                     }
0187                 }
0188 
0189                 implicitHeight: contentLayout.rowHeight
0190             }
0191             
0192             Views.TileView {
0193                 id: gamingListView
0194                 focus: false
0195                 model: gamingListModel
0196                 title: "Gaming"
0197                 cellWidth: parent.width / 2
0198                 delegate: Delegates.ListVideoCard{}
0199                 onActiveFocusChanged: {
0200                     if(activeFocus){
0201                         contentLayout.currentSection = gamingListView
0202                     }
0203                 }
0204 
0205                 implicitHeight: contentLayout.rowHeight
0206             }
0207         }
0208     }
0209 }