Warning, /plasma-bigscreen/peertube-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 id: cbView 0032 property alias model: videoListView.model 0033 Layout.fillWidth: true 0034 Layout.fillHeight: true 0035 readonly property int responsiveCellWidth: width >= 800 ? videoListView.view.width / 4 : videoListView.view.width / 2 0036 readonly property bool miniModeState: delegate.delegateMiniMode 0037 0038 states: [ 0039 State { 0040 name: "miniModeType" 0041 0042 AnchorChanges { 0043 target: videoListView 0044 anchors.top: cbView.top 0045 } 0046 }, 0047 State { 0048 name: "maxModeType" 0049 0050 AnchorChanges { 0051 target: videoListView 0052 anchors.top: searchBarArea.bottom 0053 } 0054 } 0055 ] 0056 0057 onMiniModeStateChanged: { 0058 if(miniModeState) { 0059 cbView.state = "miniModeType" 0060 } else { 0061 cbView.state = "maxModeType" 0062 } 0063 } 0064 0065 0066 onFocusChanged: { 0067 if(focus && !delegate.delegateMiniMode){ 0068 searchBarArea.forceActiveFocus() 0069 } else if(focus && delegate.delegateMiniMode){ 0070 videoListView.forceActiveFocus() 0071 } 0072 } 0073 0074 function timeSanitize(sec) { 0075 var millisec = sec * 1000; 0076 var seconds = (millisec / 1000).toFixed(0); 0077 var minutes = Math.floor(seconds / 60); 0078 var hours = ""; 0079 if (minutes > 59) { 0080 hours = Math.floor(minutes / 60); 0081 hours = (hours >= 10) ? hours : "0" + hours; 0082 minutes = minutes - (hours * 60); 0083 minutes = (minutes >= 10) ? minutes : "0" + minutes; 0084 } 0085 0086 seconds = Math.floor(seconds % 60); 0087 seconds = (seconds >= 10) ? seconds : "0" + seconds; 0088 if (hours != "") { 0089 return hours + ":" + minutes + ":" + seconds; 0090 } 0091 return minutes + ":" + seconds; 0092 } 0093 0094 function searchpTResults(query){ 0095 triggerGuiEvent("PeerTube.SearchQuery", {"search_query": query}) 0096 categoryLayout.currentIndex = 5 0097 searchQuery = query 0098 busyIndicatorPop.open() 0099 } 0100 0101 function setPublishedDate(publishDate){ 0102 var date1 = new Date(publishDate).getTime(); 0103 var date2 = new Date().getTime(); 0104 console.log(date1) 0105 console.log(date2) 0106 0107 var msec = date2 - date1; 0108 var mins = Math.floor(msec / 60000); 0109 var hrs = Math.floor(mins / 60); 0110 var days = Math.floor(hrs / 24); 0111 var yrs = Math.floor(days / 365); 0112 mins = mins % 60; 0113 hrs = hrs % 24; 0114 days = days % 365; 0115 var result = "" 0116 if(days == 0 && hrs > 0) { 0117 result = hrs + " hours, " + mins + " minutes ago" 0118 } else if (days == 0 && hrs == 0) { 0119 result = mins + " minutes ago" 0120 } else { 0121 result = days + " days, " + hrs + " hours, " + mins + " minutes ago" 0122 } 0123 return result 0124 } 0125 0126 function returnCategory(){ 0127 switch(catName){ 0128 case "News": 0129 return homeCatButton 0130 break 0131 case "Music": 0132 return musicCatButton 0133 break 0134 case "Technology": 0135 return techCatButton 0136 break 0137 case "Entertainment": 0138 return entertainmentCatButton 0139 break 0140 case "Gaming": 0141 return gamingCatButton 0142 break 0143 case "Search Results": 0144 return searchCatButton 0145 break 0146 } 0147 } 0148 0149 Rectangle { 0150 id: searchBarArea 0151 anchors.top: parent.top 0152 anchors.topMargin: Kirigami.Units.largeSpacing 0153 anchors.horizontalCenter: parent.horizontalCenter 0154 height: !delegate.delegateMiniMode ? Kirigami.Units.gridUnit * 3 : 0 0155 width: parent.width / 3 0156 radius: 12 0157 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) 0158 visible: !delegate.delegateMiniMode 0159 enabled: !delegate.delegateMiniMode 0160 0161 Keys.onReturnPressed: { 0162 videoQueryBox.forceActiveFocus() 0163 } 0164 0165 KeyNavigation.up: returnCategory() 0166 KeyNavigation.down: videoListView 0167 0168 RowLayout { 0169 anchors.fill: parent 0170 TextField { 0171 id: videoQueryBox 0172 Layout.leftMargin: Kirigami.Units.largeSpacing 0173 Layout.fillWidth: true 0174 placeholderText: "Search here..." 0175 Layout.fillHeight: true 0176 text: searchQuery.length > 0 ? searchQuery : "" 0177 onAccepted: { 0178 searchBitChuteLiveResults(videoQueryBox.text) 0179 } 0180 KeyNavigation.down: videoListView 0181 KeyNavigation.right: searchVideoQuery 0182 0183 onTextChanged: { 0184 searchQuery = videoQueryBox.text 0185 } 0186 } 0187 0188 Kirigami.Icon { 0189 id: searchVideoQuery 0190 Layout.preferredWidth: Kirigami.Units.gridUnit * 2 0191 Layout.fillHeight: true 0192 source: "search" 0193 KeyNavigation.left: videoQueryBox 0194 KeyNavigation.down: videoListView 0195 0196 Keys.onReturnPressed: { 0197 searchBitChuteLiveResults(videoQueryBox.text) 0198 } 0199 0200 MouseArea { 0201 anchors.fill: parent 0202 onClicked: { 0203 searchBitChuteLiveResults(videoQueryBox.text) 0204 } 0205 } 0206 0207 ColorOverlay { 0208 anchors.fill: parent 0209 source: searchVideoQuery 0210 color: Kirigami.Theme.highlightColor 0211 visible: searchVideoQuery.activeFocus ? 1 : 0 0212 } 0213 } 0214 } 0215 } 0216 0217 Views.TileView { 0218 id: videoListView 0219 focus: true 0220 title: " " 0221 anchors { 0222 top: searchBarArea.bottom 0223 left: parent.left 0224 right: parent.right 0225 bottom: parent.bottom 0226 } 0227 delegate: Delegates.VideoCard { 0228 width: videoListView.cellWidth 0229 height: videoListView.cellHeight 0230 } 0231 cellWidth: cbView.responsiveCellWidth 0232 cellHeight: cellWidth / 1.8 + Kirigami.Units.gridUnit * 5 0233 KeyNavigation.up: searchBarArea 0234 } 0235 }