Warning, /maui/clip/src/views/youtube/YouTubeView.qml is written in an unsupported language. File is not indexed.
0001 import QtQuick 2.14 0002 import QtQuick.Controls 2.14 0003 import QtQuick.Layouts 1.3 0004 0005 import org.mauikit.controls 1.3 as Maui 0006 0007 import ".." 0008 0009 import org.maui.clip 1.0 as Clip 0010 0011 Maui.AltBrowser 0012 { 0013 id: control 0014 0015 signal itemClicked(var item) 0016 signal itemRightClicked(var item) 0017 0018 gridView.itemSize: 180 0019 0020 viewType: control.width < Maui.Style.units.gridUnit * 30 ? Maui.AltBrowser.ViewType.List : Maui.AltBrowser.ViewType.Grid 0021 0022 holder.visible: control.currentView.count === 0 0023 holder.emojiSize: Maui.Style.iconSizes.huge 0024 holder.emoji: "qrc:/img/assets/help-feedback.svg" 0025 holder.title: i18n("Nothing Here!") 0026 holder.body: i18n("Start searching for online videos.") 0027 0028 model : Maui.BaseModel 0029 { 0030 id: _youtubeModel 0031 list: Clip.YouTube 0032 { 0033 id: _youtubeList 0034 key: settings.youtubeKey 0035 limit: settings.youtubeQueryLimit 0036 } 0037 } 0038 0039 headBar.middleContent: Maui.TextField 0040 { 0041 id: _searchField 0042 Layout.fillWidth: true 0043 Layout.maximumWidth: 500 0044 placeholderText: i18n("Search...") 0045 onAccepted: 0046 { 0047 _youtubeList.query = text 0048 } 0049 } 0050 0051 listDelegate: ListDelegate 0052 { 0053 id: _listDelegate 0054 width: ListView.view.width 0055 0056 onToggled: 0057 { 0058 control.currentIndex = index 0059 control.currentView.itemsSelected([index]) 0060 } 0061 0062 onClicked: 0063 { 0064 control.currentIndex = index 0065 if(selectionMode || (mouse.button == Qt.LeftButton && (mouse.modifiers & Qt.ControlModifier))) 0066 { 0067 control.currentView.itemsSelected([index]) 0068 }else if(Maui.Handy.singleClick) 0069 { 0070 play(_youtubeModel.get(index)) 0071 } 0072 } 0073 0074 onDoubleClicked: 0075 { 0076 control.currentIndex = index 0077 if(!Maui.Handy.singleClick && !selectionMode) 0078 { 0079 play(_youtubeModel.get(index)) 0080 } 0081 } 0082 0083 onPressAndHold: 0084 { 0085 if(!Maui.Handy.isTouch) 0086 return 0087 0088 control.currentIndex = index 0089 control.itemRightClicked(index) 0090 _menu.popup() 0091 } 0092 0093 onRightClicked: 0094 { 0095 control.currentIndex = index 0096 control.itemRightClicked(index) 0097 _menu.popup() 0098 } 0099 } 0100 0101 gridDelegate: Item 0102 { 0103 property bool isCurrentItem : GridView.isCurrentItem 0104 height: control.gridView.cellHeight 0105 width: control.gridView.cellWidth 0106 0107 Maui.GridBrowserDelegate 0108 { 0109 id: delegate 0110 0111 iconSizeHint: height * 0.6 0112 label1.text: model.label 0113 imageSource: model.thumbnail 0114 template.fillMode: Image.PreserveAspectFit 0115 0116 anchors.centerIn: parent 0117 height: control.gridView.cellHeight - 15 0118 width: control.gridView.itemSize - 20 0119 padding: Maui.Style.space.tiny 0120 isCurrentItem: parent.isCurrentItem 0121 tooltipText: model.url 0122 checkable: root.selectionMode 0123 checked: (selectionBar ? selectionBar.contains(model.url) : false) 0124 draggable: true 0125 opacity: model.hidden == "true" ? 0.5 : 1 0126 0127 Drag.keys: ["text/uri-list"] 0128 Drag.mimeData: Drag.active ? 0129 { 0130 "text/uri-list": control.filterSelectedItems(model.url) 0131 } : {} 0132 0133 onClicked: 0134 { 0135 control.currentIndex = index 0136 if(selectionMode || (mouse.button == Qt.LeftButton && (mouse.modifiers & Qt.ControlModifier))) 0137 { 0138 control.currentView.itemsSelected([index]) 0139 }else if(Maui.Handy.singleClick) 0140 { 0141 play(_youtubeModel.get(index)) 0142 } 0143 } 0144 0145 onDoubleClicked: 0146 { 0147 control.currentIndex = index 0148 if(!Maui.Handy.singleClick && !selectionMode) 0149 { 0150 play(_youtubeModel.get(index)) 0151 } 0152 } 0153 0154 onPressAndHold: 0155 { 0156 if(!Maui.Handy.isTouch) 0157 return 0158 0159 control.currentIndex = index 0160 control.itemRightClicked(model) 0161 _menu.popup() 0162 } 0163 0164 onRightClicked: 0165 { 0166 control.currentIndex = index 0167 control.itemRightClicked(model) 0168 _menu.popup() 0169 } 0170 0171 onToggled: 0172 { 0173 control.currentIndex = index 0174 control.currentView.itemsSelected([index]) 0175 } 0176 0177 Connections 0178 { 0179 target: selectionBar 0180 0181 function onUriRemoved(uri) 0182 { 0183 if(uri === model.url) 0184 delegate.checked = false 0185 } 0186 0187 function onUriAdded(uri) 0188 { 0189 if(uri === model.url) 0190 delegate.checked = true 0191 } 0192 0193 function onCleared(uri) 0194 { 0195 delegate.checked = false 0196 } 0197 } 0198 } 0199 } 0200 0201 0202 0203 function watchVideo(track) 0204 { 0205 if(track && track.url) 0206 { 0207 var url = track.url 0208 if(url && url.length > 0) 0209 { 0210 youtubeViewer.currentYt = track 0211 youtubeViewer.webView.url = url+"?autoplay=1" 0212 stackView.push(youtubeViewer) 0213 0214 } 0215 } 0216 } 0217 0218 function playTrack(url) 0219 { 0220 if(url && url.length > 0) 0221 { 0222 var newURL = url.replace("embed/", "watch?v=") 0223 console.log(newURL) 0224 webView.url = newURL+"?autoplay=1+&vq=tiny" 0225 webView.runJavaScript("document.title", function(result) { console.log(result); }); 0226 } 0227 } 0228 0229 function runSearch(searchTxt) 0230 { 0231 if(searchTxt) 0232 if(searchTxt !== youtubeTable.title) 0233 { 0234 youtubeTable.title = searchTxt 0235 Vvave.YouTube.getQuery(searchTxt, Maui.Handy.loadSettings("YOUTUBELIMIT", "BABE", 25)) 0236 } 0237 } 0238 0239 function clearSearch() 0240 { 0241 searchInput.clear() 0242 youtubeTable.listView.model.clear() 0243 youtubeTable.title = "" 0244 searchRes = [] 0245 } 0246 0247 function populate(tracks) 0248 { 0249 youtubeTable.model.clear() 0250 for(var i in tracks) 0251 youtubeTable.model.append(tracks[i]) 0252 } 0253 }