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

0001 /*
0002  *  Copyright 2018 by Aditya Mehra <aix.m@outlook.com>
0003  *  Copyright 2018 Marco Martin <mart@kde.org>
0004  *
0005  *  This program is free software: you can redistribute it and/or modify
0006  *  it under the terms of the GNU General Public License as published by
0007  *  the Free Software Foundation, either version 3 of the License, or
0008  *  (at your option) any later version.
0009 
0010  *  This program is distributed in the hope that it will be useful,
0011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
0012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
0013  *  GNU General Public License for more details.
0014 
0015  *  You should have received a copy of the GNU General Public License
0016  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
0017  */
0018 
0019 import QtQuick 2.9
0020 import QtQuick.Layouts 1.4
0021 import QtGraphicalEffects 1.0
0022 import QtQuick.Controls 2.2
0023 import org.kde.kirigami 2.8 as Kirigami
0024 import org.kde.plasma.core 2.0 as PlasmaCore
0025 import org.kde.plasma.components 2.0 as PlasmaComponents
0026 import Mycroft 1.0 as Mycroft
0027 
0028 Mycroft.Delegate {
0029     id: delegate
0030 
0031     property var videoListModel: sessionData.videoListBlob.videoList
0032     property var currentSongUrl: sessionData.currenturl
0033     property var currenttitle: sessionData.currenttitle
0034     property Component highlighter: PlasmaComponents.Highlight{}
0035     property Component emptyHighlighter: Item{}
0036 
0037     skillBackgroundSource: "https://source.unsplash.com/weekly?music"
0038     
0039     onVideoListModelChanged: {
0040         leftSearchView.forceLayout()
0041     }
0042 
0043     Keys.onBackPressed: {
0044         parent.parent.parent.currentIndex--
0045         parent.parent.parent.currentItem.contentItem.forceActiveFocus()
0046     }
0047     
0048     ColumnLayout {
0049         id: recentlyPlayerColumn
0050         anchors.fill: parent
0051         spacing: Kirigami.Units.smallSpacing
0052 
0053         Kirigami.Heading {
0054             id: watchItemList
0055             text: "Watch More.."
0056             level: 3
0057         }
0058         
0059         Kirigami.Separator {
0060             id: sept2
0061             Layout.fillWidth: true
0062             Layout.preferredHeight: 1
0063             z: 100
0064         }
0065         
0066         ListView {
0067             id: leftSearchView
0068             keyNavigationEnabled: true
0069             highlight: focus ? highlighter : emptyHighlighter
0070             model: videoListModel
0071             focus: false
0072             interactive: true
0073             bottomMargin: delegate.controlBarItem.height + Kirigami.Units.largeSpacing
0074             Layout.fillWidth: true
0075             Layout.fillHeight: true
0076             spacing: Kirigami.Units.largeSpacing
0077             currentIndex: 0
0078             highlightRangeMode: ListView.StrictlyEnforceRange
0079             snapMode: ListView.SnapToItem
0080             
0081             delegate: Control {
0082                 width: parent.width
0083                 height: Kirigami.Units.gridUnit * 4
0084                 
0085                 background: PlasmaCore.FrameSvgItem {
0086                 id: frame
0087                 anchors {
0088                     fill: parent
0089                 }
0090                 imagePath: "widgets/background"
0091                 
0092                 width: parent.width
0093                 height: parent.height
0094                 opacity: 0.9
0095                 }
0096 
0097                 
0098                 contentItem: Item {
0099                     width: parent.width
0100                     height: parent.height
0101 
0102                     RowLayout {
0103                         id: delegateItem
0104                         anchors.fill: parent
0105                         anchors.margins: Kirigami.Units.smallSpacing
0106                         spacing: Kirigami.Units.largeSpacing
0107 
0108                         Image {
0109                             id: videoImage
0110                             source: modelData.videoImage
0111                             Layout.preferredHeight: parent.height
0112                             Layout.preferredWidth: Kirigami.Units.gridUnit * 4
0113                             Layout.alignment: Qt.AlignHCenter
0114                             fillMode: Image.Stretch
0115                         }
0116 
0117                         Label {
0118                             id: videoLabel
0119                             Layout.fillWidth: true
0120                             text: modelData.videoTitle
0121                             wrapMode: Text.WordWrap
0122                         }
0123                     }
0124                 }
0125                              
0126                 Keys.onReturnPressed: {
0127                     Mycroft.MycroftController.sendRequest("aiix.youtube-skill.playvideo_id", {vidID: modelData.videoID, vidTitle: modelData.videoTitle})
0128                 }
0129             }
0130         }
0131     }
0132     
0133     Component.onCompleted: {
0134         leftSearchView.forceActiveFocus()
0135     }
0136 }
0137