-
Notifications
You must be signed in to change notification settings - Fork 0
/
blueboxx.qml
513 lines (462 loc) · 17.5 KB
/
blueboxx.qml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
import QtQuick 2.9
import QtQuick.Layouts 1.5
import QtQuick.Controls 2.5 as QC25
import QtQuick.Controls 1.5 as QC15
import org.kde.plasma.components 2.0
import org.kde.plasma.core 2.1
// *** Streaming movie app
// *** txhammer
// *** 11/2023
// *** json arrays for movie/tv shows
Image {
id:root
anchors.fill:rootMain
source:"bk2.png"
//source:"/home/data/Pictures/wallpapers/bk11.jpg"
property var movieArray:{}
property var tvArray:{}
property var randomArray:[]
property var searchArray:[]
property var selectedItem:randomArray
property string url1:"movies.json"
property string url2:"tv.json"
property int key:0
property string selectedMovie:""
property string selectedMoviePlaylist:""
property string selectedMovieSubtitle:""
property string mpvCMD:"mpv --force-media-title="+"\x22"+selectedMovie+"\x22"+" "+selectedMoviePlaylist+" --sub-file="+"\x22"+selectedMovieSubtitle+"\x22"
anchors.margins:0
Component.onCompleted: {
getData(url1);
getData(url2);
init.start();
}
DataSource {
id: executable
engine: "executable"
connectedSources: []
property var callbacks: ({})
onNewData: {
var stdout = data["stdout"]
if (callbacks[sourceName] !== undefined) {
callbacks[sourceName](stdout);
}
exited(sourceName, stdout)
disconnectSource(sourceName) // exec finished
}
function exec(cmd, onNewDataCallback) {
if (onNewDataCallback !== undefined){
callbacks[cmd] = onNewDataCallback
}
connectSource(cmd)
}
signal exited(string sourceName, string stdout)
}
Timer {
id:init
running:false
repeat:false
interval:200
onTriggered:{
randomGen(0,movieArray.length);
selectedItem=randomArray;
listView.positionViewAtBeginning();
listView.anchors.leftMargin=500;
}
}
QC25.TextField {
id:tf
placeholderText:"Movie Search..."//+movieArray.length
anchors.top:root.top
anchors.rightMargin:80
anchors.topMargin:70
anchors.right:root.right
antialiasing:true
opacity: .75
width:280
height:36
visible:selectedItem==movieArray
onAccepted: {
searchMovies (tf.text)
}
focus:false
placeholderTextColor:"gray"
background: Rectangle {
radius: 8
border.color: parent.focus ? "cyan":"gray"
border.width: 1
width:parent.width
height:parent.height
color: "black"
antialiasing:true
IconItem {
source:"editclear"
width:36
height:30
smooth:true
visible:tf.text.length>0
anchors.top:parent.top
anchors.right:parent.right
anchors.topMargin:4
anchors.rightMargin:-27
MouseArea {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
hoverEnabled:true
acceptedButtons: Qt.LeftButton | Qt.MiddleButton
onClicked:tf.text=""
}
}
}
Timer {
id:tfTimer
running:tf.focus
repeat:false
interval:10000
onTriggered:tf.text=""
}
}
function getData(fileUrl){
var xhr = new XMLHttpRequest;
xhr.open("GET", fileUrl); // set Method and File
xhr.onreadystatechange = function () {
if(xhr.readyState === XMLHttpRequest.DONE){ // if request_status == DONE
if(fileUrl==url1) {
var response = xhr.responseText;
movieArray=JSON.parse(response);
response=null;
}
else {
var response = xhr.responseText;
tvArray=JSON.parse(response);
response=null;
}
}
}
xhr.send(); // begin the request
return null;
}
function randomGen (min,max) {
var r1=[];
var n1=0;
for (x=0;x<5;x++) {
n1=Math.floor(Math.random() * (max - min - x) );
r1.includes(n1) ? n1=Math.floor(Math.random() * (max - min - x) ) : n1=n1 // check for repeats
r1.push(n1);
}
randomArray=r1;
r1=null;
n1=0;
listView.model=randomArray.length;
listView.delegate=movieView;
listView.positionViewAtBeginning();
return null;
}
function searchMovies (s) {
if (typeof(movieArray) != "undefined") {
searchArray = movieArray.filter(x => x.title.toLowerCase().includes(s.toLowerCase()));
selectedItem=searchArray;
listView.model=searchArray.length < 1 ? searchArray.length+1 : searchArray.length
listView.anchors.leftMargin=searchArray.length < 9 ? (listView.width/2)-(searchArray.length*72) : 60
listView.delegate=null;
listView.delegate=movieView;
listView.positionViewAtBeginning();
tf.text=""
}
return null;
}
Component {
id:movieView
Rectangle { width:185;height:295;
color:"black";
border.color:"lightgray"
border.width:2;
radius: 8;
antialiasing:true
Image {
id:posterArt
source: (selectedItem===randomArray) ? "images/"+movieArray[randomArray[index]].poster.split("/").pop() : (selectedItem===movieArray) ? "images/"+movieArray[index].poster.split("/").pop() : (selectedItem===tvArray) ? "images/"+tvArray[index].poster.split("/").pop() : (selectedItem===searchArray) ? (searchArray.length > 0) ? "images/"+searchArray[index].poster.split("/").pop() : "images/movie-poster-credits-178.jpg" : "images/movie-poster-credits-178.jpg"
fillMode : Image.PreserveAspectFit
height:parent.height*.87
anchors.top:parent.top
anchors.topMargin:4
anchors.horizontalCenter:parent.horizontalCenter
cache:true
asynchronous:false
visible:true
opacity:1
Text {
id:title
anchors.top:parent.bottom
anchors.left:parent.left
anchors.topMargin:10
anchors.leftMargin:5
text:(selectedItem===randomArray) ? movieArray[randomArray[index]].title : (selectedItem===movieArray) ? movieArray[index].title : (selectedItem===tvArray) ? tvArray[index].title : (selectedItem===searchArray) ? (searchArray.length > 0) ?searchArray[index].title:"No Results" : "No Results"
color:"white"
antialiasing:true
font.pointSize:11
width:165
elide: Text.ElideRight
wrapMode: Text.NoWrap
visible:true
}
}
Text {
id:synopsis
anchors.top:parent.top
anchors.left:parent.left
anchors.topMargin:10
anchors.leftMargin:10
text:(selectedItem===randomArray) ? movieArray[randomArray[index]].synopsis : (selectedItem===movieArray) ? movieArray[index].synopsis : (selectedItem===tvArray) ? tvArray[index].synopsis : (selectedItem===searchArray) ? (searchArray.length > 0) ?searchArray[index].synopsis:"No Results" : "No Results"
color:"white"
antialiasing:true
font.pointSize:12
width:170
height:290
elide: Text.ElideRight
wrapMode: Text.Wrap
visible:false
}
MouseArea {
id:ma
anchors.fill: parent
hoverEnabled:true
//preventStealing : true
cursorShape: Qt.PointingHandCursor
acceptedButtons: Qt.LeftButton | Qt.MiddleButton
onEntered:{
parent.border.color="cyan";
toolTipTimer.start();
parent.y+=5;
}
onExited:{
parent.y-=5;
parent.border.color="lightgray";
synopsis.visible=false;
posterArt.opacity=1;
toolTipTimer.stop();
}
onClicked:{
selectedMovie=(selectedItem===randomArray) ? movieArray[randomArray[index]].title : (selectedItem===movieArray) ? movieArray[index].title : (selectedItem===tvArray) ? tvArray[index].title : (selectedItem===searchArray) ? (searchArray.length > 0) ? searchArray[index].title : "No Results" : "No Results"
selectedMoviePlaylist=(selectedItem===randomArray) ? movieArray[randomArray[index]].playlist : (selectedItem===movieArray) ? movieArray[index].playlist : (selectedItem===searchArray) ? (searchArray.length > 0) ? searchArray[index].playlist:"No Results" : "No Results"
selectedMovieSubtitle = movieArray[index].subtitle ? movieArray[index].subtitle :" "
if (mouse.button == Qt.LeftButton) {
(selectedItem===randomArray) ? Qt.openUrlExternally(movieArray[randomArray[index]].link1) :
(selectedItem===movieArray) ? Qt.openUrlExternally(movieArray[index].link1) : (selectedItem===searchArray) ? Qt.openUrlExternally(searchArray[index].link1) : (selectedItem===tvArray) ? Qt.openUrlExternally(tvArray[index].link) : Qt.openUrlExternally("https://moviesjoyhd.to/home")
}
if (mouse.button == Qt.MiddleButton) {
selectedItem!=tvArray ? executable.exec(mpvCMD):Qt.openUrlExternally(tvArray[index].link)
}
}
}
Timer {
id:toolTipTimer
running:false
repeat:false
interval:2000
onTriggered:{
posterArt.opacity=.25
synopsis.visible=true
}
}
}
}
Rectangle {
id:logoBox
anchors.top:root.top
anchors.left:root.left
width:124
height:64
radius:12
anchors.margins:20
color:"gray"
border.color:"lightgray"
border.width:.5
opacity:.25
antialiasing:true
}
Text {
text:"BlueBoxx"
color:"#00aaff"
font.pointSize:22;font.family:"Komika Title";
anchors.centerIn:logoBox
antialiasing:true
}
Item {
id:headerView
height:75
width:parent.width
anchors.top:root.top
anchors.topMargin:36
anchors.horizontalCenter:parent.horizontalCenter
Row {
anchors.horizontalCenter:parent.horizontalCenter
anchors.top:headerView.top
anchors.topMargin:15
spacing:60
Rectangle {
width:156;height:36;
color:"transparent"
border.color:(selectedItem===randomArray) ? "cyan":"gray"
radius:8
antialiasing:true
Text {
text:"Now Showing"
color:"white"
font.family:"Komika Title"
font.pointSize:20
anchors.horizontalCenter:parent.horizontalCenter
anchors.verticalCenter:parent.verticalCenter
antialiasing:true
}
MouseArea {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
acceptedButtons: Qt.LeftButton | Qt.MiddleButton
onEntered:parent.border.color="cyan"
onExited:parent.border.color="gray"
hoverEnabled:true
onClicked: {
randomGen(0,movieArray.length);
tf.focus=false
tf.text=""
listView.focus=true
selectedItem=randomArray;
listView.anchors.leftMargin=500;
listView.model=randomArray.length;
listView.delegate=null;
listView.delegate=movieView;
}
}
}
Rectangle {
width:156;height:36;
color:"transparent"
border.color:(selectedItem===movieArray) ? "cyan":"gray"
radius:8
antialiasing:true
Text {
text:"Movies"
color:"white"
font.family:"Komika Title"
font.pointSize:20
anchors.horizontalCenter:parent.horizontalCenter
anchors.verticalCenter:parent.verticalCenter
antialiasing:true
}
MouseArea {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
acceptedButtons: Qt.LeftButton | Qt.MiddleButton
onEntered:parent.border.color="cyan"
onExited:parent.border.color="gray"
hoverEnabled:true
onClicked: {
selectedItem=movieArray;
tf.focus=false
tf.text=""
listView.focus=true
listView.anchors.leftMargin=60;
listView.positionViewAtBeginning();
listView.model=movieArray.length;
listView.delegate=null;
listView.delegate=movieView;
}
}
}
Rectangle {
width:156;height:36;
color:"transparent"
border.color:(selectedItem===tvArray) ? "cyan":"gray"
radius:8
antialiasing:true
Text {
text:"TV Series"
color:"white"
font.family:"Komika Title"
font.pointSize:20
anchors.horizontalCenter:parent.horizontalCenter
anchors.verticalCenter:parent.verticalCenter
antialiasing:true
}
MouseArea {
anchors.fill: parent
cursorShape: Qt.PointingHandCursor
acceptedButtons: Qt.LeftButton | Qt.MiddleButton
onEntered:parent.border.color="cyan"
onExited:parent.border.color="gray"
hoverEnabled:true
onClicked: {
selectedItem=tvArray;
tf.focus=false
listView.focus=true
tf.text=""
listView.anchors.leftMargin=60;
listView.model=tvArray.length;
listView.delegate=null;
listView.delegate=movieView;
}
}
}
}
Rectangle {
id:ts1
anchors.top:parent.bottom
anchors.topMargin:15
anchors.horizontalCenter:parent.horizontalCenter
width:root.width/1.03
height:.5
color:"white"
antialiasing:true
}
}
QC15.ScrollView {
id: scrollView
anchors.top:headerView.bottom
anchors.bottom:root.bottom
anchors.left:root.left
anchors.right:root.right
anchors.topMargin:40
anchors.leftMargin:5
anchors.rightMargin:5
anchors.bottomMargin:0
clip:false
width:root.width
height:root.height-160
enabled : hovered || pressed
__wheelAreaScrollSpeed: 310 /// set scroll page height pixels
GridView {
id:listView
focus:true
visible:false
anchors.top:parent.top
anchors.bottom:parent.bottom
anchors.left:parent.left
anchors.right:parent.right
width:parent.width
height:parent.height
model:selectedItem.length
boundsBehavior: Flickable.StopAtBounds
cacheBuffer:310*27
//highlight:highlightView
clip:false
interactive:false
snapMode :GridView.SnapOneRow
//keyNavigationEnabled: true
//keyNavigationWraps: false // endless scrolling
delegate:null
cellWidth: 200; cellHeight: 310
onDelegateChanged:{
opacity=0;
opacity=1;}
Behavior on opacity {
OpacityAnimator {
duration: units.longDuration
easing.type: Easing.InCubic
}}
Component.onCompleted: {
listView.visible=true;
}
}
}
}