Warning, /plasma-bigscreen/youtube-voice-application/ui/+mediacenter/CategoryBoxSearchView.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 var searchListModel: sessionData.searchListBlob.videoList
0032     Layout.fillWidth: true
0033     Layout.fillHeight: true
0034     
0035     onFocusChanged: {
0036         if(focus){
0037             searchBarArea.forceActiveFocus()
0038         }
0039     }
0040     
0041     function searchYoutubeLiveResults(query){
0042         triggerGuiEvent("YoutubeSkill.SearchLive", {"Query": query})
0043     }
0044     
0045     Rectangle {
0046         id: searchBarArea
0047         anchors.top: parent.top
0048         anchors.topMargin: Kirigami.Units.largeSpacing
0049         anchors.horizontalCenter: parent.horizontalCenter
0050         height: Kirigami.Units.gridUnit * 3
0051         width: parent.width / 3
0052         radius: 12
0053         color: searchBarArea.activeFocus ? Qt.rgba(Kirigami.Theme.highlightColor.r, Kirigami.Theme.highlightColor.g, Kirigami.Theme.highlightColor.b, 0.95) : Qt.rgba(Kirigami.Theme.backgroundColor.r, Kirigami.Theme.backgroundColor.g, Kirigami.Theme.backgroundColor.b, 0.95)
0054                 
0055         Keys.onReturnPressed: {
0056             videoQueryBox.forceActiveFocus()
0057         }
0058         
0059         KeyNavigation.up: searchCatButton
0060         KeyNavigation.down: searchGridView
0061         
0062         RowLayout {
0063             anchors.fill: parent
0064             TextField {
0065                 id: videoQueryBox
0066                 Layout.leftMargin: Kirigami.Units.largeSpacing
0067                 Layout.fillWidth: true
0068                 placeholderText: "Search here..."
0069                 Layout.fillHeight: true
0070                 onAccepted: {
0071                     searchYoutubeLiveResults(videoQueryBox.text)
0072                 }
0073                 KeyNavigation.down: searchGridView
0074                 KeyNavigation.right: searchVideoQuery
0075             }
0076             
0077             Kirigami.Icon {
0078                 id: searchVideoQuery
0079                 Layout.preferredWidth: Kirigami.Units.gridUnit * 2
0080                 Layout.fillHeight: true
0081                 source: "search" 
0082                 KeyNavigation.left: videoQueryBox
0083                 KeyNavigation.down: searchGridView
0084                 
0085                 Keys.onReturnPressed: {
0086                     searchYoutubeLiveResults(videoQueryBox.text)
0087                 }
0088                 
0089                 MouseArea {
0090                     anchors.fill: parent
0091                     onClicked: {
0092                         searchYoutubeLiveResults(videoQueryBox.text)
0093                     }
0094                 }
0095                 
0096                 ColorOverlay {
0097                     anchors.fill: parent
0098                     source: searchVideoQuery
0099                     color: Kirigami.Theme.highlightColor
0100                     visible: searchVideoQuery.activeFocus ? 1 : 0
0101                 }
0102             }
0103         }
0104     }
0105 
0106     Views.BigTileView {
0107         id: searchGridView
0108         anchors {
0109             top: searchBarArea.bottom
0110             left: parent.left
0111             right: parent.right
0112             bottom: parent.bottom
0113             topMargin: Kirigami.Units.largeSpacing
0114         }
0115         focus: true
0116         model: searchListModel
0117         Layout.fillWidth: true
0118         Layout.fillHeight: true
0119         cellWidth: view.width / 4
0120         // FIXME: componentize more all this stuff
0121         cellHeight: cellWidth / 1.8 + Kirigami.Units.gridUnit * 5
0122         title: count > 0 ? "Search Results" : " "
0123         delegate: Delegates.ListVideoCard {
0124             width: searchGridView.cellWidth
0125             height: searchGridView.cellHeight
0126         }
0127         
0128         KeyNavigation.up: searchBarArea
0129     }
0130 }