Warning, /plasma-bigscreen/youtube-voice-application/ui/YoutubeLiveSearch.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.3
0023 import org.kde.kirigami 2.8 as Kirigami
0024 import Mycroft 1.0 as Mycroft
0025 import "+android/views" as Views
0026 import "+android/delegates" as Delegates
0027
0028 Mycroft.Delegate {
0029 id: delegate
0030 property bool busyIndicate: false
0031
0032 fillWidth: true
0033
0034 leftPadding: 0
0035 rightPadding: 0
0036 topPadding: 0
0037 bottomPadding: 0
0038
0039 skillBackgroundSource: sessionData.bgImage ? "https://source.unsplash.com/weekly?" + sessionData.bgImage : "https://source.unsplash.com/weekly?music"
0040
0041 function highlightActiveCategory(cat){
0042 switch(cat){
0043 case "Home":
0044 historyCatButton.checked = false
0045 searchCatButton.checked = false
0046 homeCatButton.checked = true
0047 break;
0048 case "History":
0049 searchCatButton.checked = false
0050 homeCatButton.checked = false
0051 historyCatButton.checked = true
0052 break;
0053 case "Search":
0054 homeCatButton.checked = false
0055 historyCatButton.checked = false
0056 searchCatButton.checked = true
0057 break;
0058 }
0059 }
0060
0061 Connections {
0062 target: Mycroft.MycroftController
0063 onIntentRecevied: {
0064 if(type == "speak") {
0065 busyIndicatorPop.close()
0066 busyIndicate = false
0067 }
0068 }
0069 }
0070
0071 onFocusChanged: {
0072 busyIndicatorPop.close()
0073 busyIndicate = false
0074 if(delegate.focus){
0075 console.log("focus is here")
0076 }
0077 }
0078
0079 Keys.onBackPressed: {
0080 parent.parent.parent.currentIndex++
0081 parent.parent.parent.currentItem.contentItem.forceActiveFocus()
0082 }
0083
0084
0085 contentItem: ColumnLayout {
0086 id: colLay1
0087
0088 Rectangle {
0089 color: Qt.rgba(0, 0, 0, 0.8)
0090 Layout.fillWidth: true
0091 Layout.preferredHeight: Kirigami.Units.gridUnit * 3
0092 Layout.maximumHeight: Kirigami.Units.gridUnit * 4
0093 z: 100
0094
0095 TopBarTabButton {
0096 id: backButton
0097 anchors.left: parent.left
0098 anchors.verticalCenter: parent.verticalCenter
0099 anchors.leftMargin: Kirigami.Units.largeSpacing
0100 source: "+android/images/back.png"
0101 onClicked: {
0102 Mycroft.MycroftController.sendRequest("mycroft.gui.screen.close", {})
0103 }
0104 }
0105
0106 RowLayout {
0107 id: categoryRepeater
0108 anchors {
0109 right: parent.right
0110 top: parent.top
0111 bottom: parent.bottom
0112 }
0113 width: parent.width / 2
0114 anchors.leftMargin: Kirigami.Units.gridUnit
0115 anchors.rightMargin: Kirigami.Units.gridUnit
0116
0117 TopBarTabButton {
0118 id: homeCatButton
0119 KeyNavigation.right: historyCatButton
0120 KeyNavigation.down: categoryLayout
0121 checked: true
0122 source: "+android/images/home.png"
0123 onClicked: {
0124 categoryLayout.pop(categoryLayout.find(function(item) {
0125 return item.name == "homeCat";}))
0126 highlightActiveCategory("Home")
0127 }
0128 }
0129
0130 TopBarTabButton {
0131 id: historyCatButton
0132 KeyNavigation.left: homeCatButton
0133 KeyNavigation.right: searchCatButton
0134 KeyNavigation.down: categoryLayout
0135 checked: false
0136 source: "+android/images/history.png"
0137 onClicked: {
0138 if(categoryLayout.depth >= 2) {
0139 categoryLayout.pop(null)
0140 }
0141 categoryLayout.push(historyCat)
0142 highlightActiveCategory("History")
0143 }
0144 }
0145
0146 TopBarTabButton {
0147 id: searchCatButton
0148 KeyNavigation.left: historyCatButton
0149 KeyNavigation.down: categoryLayout
0150 checked: false
0151 source: "+android/images/search.png"
0152 onClicked: {
0153 if(categoryLayout.depth >= 2) {
0154 categoryLayout.pop(null)
0155 }
0156 categoryLayout.push(searchCat)
0157 highlightActiveCategory("Search")
0158 }
0159 }
0160 }
0161 }
0162
0163 Component {
0164 id: homeCat
0165 CategoryBoxHomeView {
0166 id: homeCatView
0167 }
0168 }
0169
0170 Component {
0171 id: historyCat
0172 CategoryBoxHistoryView {
0173 id: historyCatView
0174 }
0175 }
0176
0177 Component {
0178 id: searchCat
0179 CategoryBoxSearchView {
0180 id: searchCatView
0181 }
0182 }
0183
0184 StackView {
0185 id: categoryLayout
0186 Layout.fillWidth: true
0187 Layout.fillHeight: true
0188
0189 Component.onCompleted: {
0190 categoryLayout.push(homeCat)
0191 }
0192 }
0193 }
0194
0195 Popup {
0196 id: busyIndicatorPop
0197 width: parent.width
0198 height: parent.height
0199 background: Rectangle {
0200 anchors.fill: parent
0201 color: Qt.rgba(0, 0, 0, 0.5)
0202 }
0203 closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutsideParent
0204
0205 BusyIndicator {
0206 running: busyIndicate
0207 anchors.centerIn: parent
0208 }
0209
0210 onOpened: {
0211 busyIndicate = true
0212 }
0213
0214 onClosed: {
0215 busyIndicate = false
0216 }
0217 }
0218 }
0219