Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Vvave
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
6
Issues
6
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Maui
Vvave
Commits
3747ff09
Commit
3747ff09
authored
Mar 07, 2018
by
Camilo Higuita
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updates
parent
c57cb5de
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
296 additions
and
113 deletions
+296
-113
services/web/YouTube.qml
services/web/YouTube.qml
+193
-104
services/web/YoutubeViewer.qml
services/web/YoutubeViewer.qml
+103
-9
No files found.
services/web/YouTube.qml
View file @
3747ff09
...
...
@@ -11,6 +11,10 @@ Page
id
:
youtubeViewRoot
property
var
searchRes
:
[]
clip
:
true
property
alias
viewer
:
youtubeViewer
property
int
openVideo
:
0
Connections
{
target
:
youtube
...
...
@@ -19,17 +23,72 @@ Page
searchRes
=
res
;
populate
(
searchRes
)
youtubeTable
.
forceActiveFocus
()
if
(
openVideo
>
0
)
{
console
.
log
(
"
trying to open video
"
)
watchVideo
(
youtubeTable
.
model
.
get
(
openVideo
-
1
))
openVideo
=
0
}
}
}
function
watchVideo
(
track
)
{
if
(
track
&&
track
.
url
)
{
var
url
=
track
.
url
if
(
url
&&
url
.
length
>
0
)
{
youtubeViewer
.
currentYt
=
track
youtubeViewer
.
webView
.
url
=
url
+
"
?autoplay=1?
"
stackView
.
push
(
youtubeViewer
)
Loader
}
}
}
function
playTrack
(
url
)
{
id
:
youtubeViewer
source
:
isMobile
?
"
qrc:/services/web/YoutubeViewer_A.qml
"
:
"
qrc:/services/web/YoutubeViewer.qml
"
if
(
url
&&
url
.
length
>
0
)
{
var
newURL
=
url
.
replace
(
"
embed/
"
,
"
watch?v=
"
)
console
.
log
(
newURL
)
youtubePlayer
.
item
.
url
=
newURL
+
"
?autoplay=1+&vq=tiny
"
youtubePlayer
.
item
.
runJavaScript
(
"
document.title
"
,
function
(
result
)
{
console
.
log
(
result
);
});
}
}
function
runSearch
(
searchTxt
)
{
if
(
searchTxt
)
if
(
searchTxt
!==
youtubeTable
.
headerBarTitle
)
{
youtubeTable
.
headerBarTitle
=
searchTxt
youtube
.
getQuery
(
searchTxt
,
bae
.
loadSetting
(
"
YOUTUBELIMIT
"
,
"
BABE
"
,
25
))
}
}
function
clearSearch
()
{
searchInput
.
clear
()
youtubeTable
.
clearTable
()
youtubeTable
.
headerBarTitle
=
""
searchRes
=
[]
}
function
populate
(
tracks
)
{
youtubeTable
.
clearTable
()
for
(
var
i
in
tracks
)
youtubeTable
.
model
.
append
(
tracks
[
i
])
}
Loader
{
id
:
youtubePlayer
source
:
isMobile
?
"
qrc:/services/web/YoutubePlayer_A.qml
"
:
"
qrc:/services/web/YoutubePlayer.qml
"
}
BabePopup
{
...
...
@@ -62,7 +121,6 @@ Page
Layout.column
:
1
Layout.row
:
2
Layout.fillWidth
:
true
}
TextField
...
...
@@ -111,138 +169,169 @@ Page
}
}
function
runSearch
(
searchTxt
)
{
if
(
searchTxt
)
if
(
searchTxt
!==
youtubeTable
.
headerBarTitle
)
{
youtubeTable
.
headerBarTitle
=
searchTxt
youtube
.
getQuery
(
searchTxt
,
bae
.
loadSetting
(
"
YOUTUBELIMIT
"
,
"
BABE
"
,
25
))
}
}
function
clearSearch
()
{
searchInput
.
clear
()
youtubeTable
.
clearTable
()
youtubeTable
.
headerBarTitle
=
""
searchRes
=
[]
}
function
populate
(
tracks
)
{
youtubeTable
.
clearTable
()
for
(
var
i
in
tracks
)
youtubeTable
.
model
.
append
(
tracks
[
i
])
}
ColumnLayout
StackView
{
id
:
stackView
anchors.fill
:
parent
width
:
parent
.
width
height
:
parent
.
height
Layout.margins
:
0
spacing
:
0
focus
:
true
BabeTable
pushEnter
:
Transition
{
id
:
youtubeTable
Layout.fillHeight
:
true
Layout.fillWidth
:
true
trackNumberVisible
:
false
headerBarVisible
:
true
headerBarExit
:
true
headerBarExitIcon
:
"
edit-clear
"
holder.message
:
"
No YouTube results!
"
coverArtVisible
:
true
trackDuration
:
true
trackRating
:
true
onExit
:
clearSearch
()
isArtworkRemote
:
true
appendBtn.visible
:
false
playAllBtn.visible
:
false
menuBtn.visible
:
false
headerBarRight
:
BabeButton
PropertyAnimation
{
id
:
menuBtn
iconName
:
"
application-menu
"
onClicked
:
configPopup
.
open
()
}
onRowClicked
:
{
youtubeViewer
.
item
.
open
()
youtubeViewer
.
item
.
webView
.
url
=
youtubeTable
.
model
.
get
(
index
).
url
property
:
"
opacity
"
from
:
0
to
:
1
duration
:
200
}
}
onQuickPlayTrack
:
pushExit
:
Transition
{
PropertyAnimation
{
bae
.
getYoutubeTrack
(
JSON
.
stringify
(
youtubeTable
.
model
.
get
(
index
)))
property
:
"
opacity
"
from
:
1
to
:
0
duration
:
200
}
}
Kirigami.Separator
popEnter
:
Transition
{
visible
:
!
isMobile
Layout.fillWidth
:
true
width
:
parent
.
width
height
:
1
PropertyAnimation
{
property
:
"
opacity
"
from
:
0
to
:
1
duration
:
200
}
}
ToolBar
popExit
:
Transition
{
id
:
searchBox
Layout.fillWidth
:
true
width
:
parent
.
width
height
:
toolBarHeight
position
:
ToolBar
.
Footer
Rectangle
PropertyAnimation
{
anchors.fill
:
parent
z
:
-
999
color
:
backgroundColor
property
:
"
opacity
"
from
:
1
to
:
0
duration
:
200
}
}
RowLayout
initialItem
:
Item
{
id
:
youtubeList
ColumnLayout
{
anchors.fill
:
parent
width
:
parent
.
width
height
:
parent
.
height
Layout.margins
:
0
spacing
:
0
TextInput
BabeTable
{
id
:
searchInput
color
:
foregroundColor
Layout.fillWidth
:
true
id
:
youtubeTable
Layout.fillHeight
:
true
horizontalAlignment
:
Text
.
AlignHCenter
verticalAlignment
:
Text
.
AlignVCenter
selectByMouse
:
!
root
.
isMobile
selectionColor
:
babeHighlightColor
selectedTextColor
:
foregroundColor
focus
:
true
text
:
""
wrapMode
:
TextEdit
.
Wrap
onAccepted
:
runSearch
(
searchInput
.
text
)
Layout.fillWidth
:
true
trackNumberVisible
:
false
headerBarVisible
:
true
headerBarExit
:
true
headerBarExitIcon
:
"
edit-clear
"
holder.message
:
"
No YouTube results!
"
coverArtVisible
:
true
trackDuration
:
true
trackRating
:
true
onExit
:
clearSearch
()
isArtworkRemote
:
true
appendBtn.visible
:
false
playAllBtn.visible
:
false
menuBtn.visible
:
false
headerBarRight
:
BabeButton
{
id
:
menuBtn
iconName
:
"
application-menu
"
onClicked
:
configPopup
.
open
()
}
onRowClicked
:
{
watchVideo
(
youtubeTable
.
model
.
get
(
index
))
}
onQuickPlayTrack
:
{
playTrack
(
youtubeTable
.
model
.
get
(
index
).
url
)
}
}
BabeButton
Kirigami.Separator
{
Layout.rightMargin
:
contentMargins
iconName
:
"
edit-clear
"
onClicked
:
searchInput
.
clear
()
visible
:
!
isMobile
Layout.fillWidth
:
true
width
:
parent
.
width
height
:
1
}
ToolBar
{
id
:
searchBox
Layout.fillWidth
:
true
width
:
parent
.
width
height
:
toolBarHeight
position
:
ToolBar
.
Footer
Rectangle
{
anchors.fill
:
parent
z
:
-
999
color
:
backgroundColor
}
RowLayout
{
anchors.fill
:
parent
TextInput
{
id
:
searchInput
color
:
foregroundColor
Layout.fillWidth
:
true
Layout.fillHeight
:
true
horizontalAlignment
:
Text
.
AlignHCenter
verticalAlignment
:
Text
.
AlignVCenter
selectByMouse
:
!
root
.
isMobile
selectionColor
:
babeHighlightColor
selectedTextColor
:
foregroundColor
focus
:
true
text
:
""
wrapMode
:
TextEdit
.
Wrap
onAccepted
:
runSearch
(
searchInput
.
text
)
}
BabeButton
{
Layout.rightMargin
:
contentMargins
iconName
:
"
edit-clear
"
onClicked
:
searchInput
.
clear
()
}
}
}
}
}
YoutubeViewer
{
id
:
youtubeViewer
}
}
}
services/web/YoutubeViewer.qml
View file @
3747ff09
...
...
@@ -2,21 +2,115 @@ import QtQuick 2.9
import
QtQuick
.
Controls
2.2
import
QtQuick
.
Layouts
1.3
import
"
../../view_models
"
import
QtWebKit
3.0
BabePopup
import
org
.
kde
.
kirigami
2.2
as
Kirigami
Page
{
id
:
videoPlayback
property
alias
webView
:
webView
maxHeight
:
200
property
alias
webView
:
webViewer
.
item
property
bool
wasPlaying
:
false
property
var
currentYt
:
({})
WebView
ColumnLayout
{
id
:
webView
anchors.fill
:
parent
onLoadingChanged
:
{
if
(
loadRequest
.
errorString
)
console
.
error
(
loadRequest
.
errorString
);
spacing
:
0
Rectangle
{
id
:
headerRoot
width
:
parent
.
width
height
:
visible
?
toolBarHeight
:
0
Layout.fillWidth
:
true
focus
:
true
color
:
darkDarkColor
Kirigami.Separator
{
visible
:
!
isMobile
width
:
parent
.
width
height
:
1
anchors
{
left
:
parent
.
left
right
:
parent
.
right
bottom
:
parent
.
bottom
}
}
RowLayout
{
id
:
headerBar
anchors.fill
:
parent
BabeButton
{
Layout.alignment
:
Qt
.
AlignLeft
Layout.leftMargin
:
contentMargins
width
:
rowHeight
iconName
:
"
arrow-left
"
iconColor
:
darkForegroundColor
onClicked
:
stackView
.
pop
(
youtubeList
)
}
Label
{
text
:
currentYt
?
currentYt
.
title
:
"
YouTube
"
Layout.fillHeight
:
true
Layout.fillWidth
:
true
Layout.alignment
:
Qt
.
AlignCenter
elide
:
Text
.
ElideRight
font.bold
:
false
color
:
darkForegroundColor
font.pointSize
:
fontSizes
.
big
horizontalAlignment
:
Text
.
AlignHCenter
verticalAlignment
:
Text
.
AlignVCenter
}
BabeButton
{
Layout.alignment
:
Qt
.
AlignLeft
width
:
rowHeight
iconName
:
"
link
"
iconColor
:
darkForegroundColor
onClicked
:
bae
.
openFile
(
webView
.
url
)
}
BabeButton
{
Layout.alignment
:
Qt
.
AlignLeft
width
:
rowHeight
iconName
:
"
download
"
iconColor
:
darkForegroundColor
onClicked
:
bae
.
getYoutubeTrack
(
JSON
.
stringify
(
currentYt
))
}
BabeButton
{
Layout.alignment
:
Qt
.
AlignLeft
Layout.rightMargin
:
contentMargins
width
:
rowHeight
iconName
:
"
overflow-menu
"
iconColor
:
darkForegroundColor
}
}
}
Loader
{
id
:
webViewer
Layout.fillHeight
:
true
Layout.fillWidth
:
true
source
:
isMobile
?
"
qrc:/services/web/WebView_A.qml
"
:
"
qrc:/services/web/WebView.qml
"
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment