1
0
Fork 0
VideoPlayer/src/qml/main.qml

1285 lines
44 KiB
QML
Raw Normal View History

2018-10-28 12:19:24 +00:00
import QtQuick 2.11
2018-10-13 15:38:31 +01:00
import QtQuick.Controls 2.4
import QtQuick.Dialogs 1.3
import QtQuick.Layouts 1.11
import QtQuick.Window 2.11
2018-10-24 17:41:41 +01:00
import Qt.labs.settings 1.0
2018-10-13 15:38:31 +01:00
import player 1.0
import QtGraphicalEffects 1.0
2018-10-13 15:38:31 +01:00
import "codes.js" as LanguageCodes
2018-10-23 23:19:26 +01:00
ApplicationWindow {
2018-10-13 15:38:31 +01:00
id: mainWindow
title: titleLabel.text
2018-10-13 15:38:31 +01:00
visible: true
width: 720
height: 480
2018-10-23 23:19:26 +01:00
FontLoader {
id: notoFont
source: "fonts/NotoSans.ttf"
2018-10-24 19:49:05 +01:00
}
2018-10-23 23:19:26 +01:00
2018-10-13 15:38:31 +01:00
property int lastScreenVisibility
2018-10-16 16:55:25 +01:00
function toggleFullscreen() {
if (mainWindow.visibility != Window.FullScreen) {
lastScreenVisibility = mainWindow.visibility
mainWindow.visibility = Window.FullScreen
} else {
mainWindow.visibility = lastScreenVisibility
}
}
2018-10-13 15:38:31 +01:00
function tracksMenuUpdate() {
2018-10-23 15:42:44 +01:00
var tracks = player.getProperty("track-list/count")
2018-10-13 15:38:31 +01:00
var track = 0
subModel.clear()
audioModel.clear()
vidModel.clear()
2018-10-23 15:42:44 +01:00
var aid = player.getProperty("aid")
var sid = player.getProperty("sid")
var vid = player.getProperty("vid")
2018-10-13 15:38:31 +01:00
for (track = 0; track <= tracks; track++) {
2018-10-23 15:42:44 +01:00
var trackID = player.getProperty("track-list/" + track + "/id")
2018-10-24 19:49:05 +01:00
var trackType = player.getProperty("track-list/" + track + "/type")
2018-10-13 15:38:31 +01:00
var trackLang = LanguageCodes.localeCodeToEnglish(
2018-10-23 15:42:44 +01:00
String(player.getProperty(
2018-10-13 15:38:31 +01:00
"track-list/" + track + "/lang")))
2018-10-23 15:42:44 +01:00
var trackTitle = player.getProperty(
2018-10-13 15:38:31 +01:00
"track-list/" + track + "/title")
if (trackType == "sub") {
subModel.append({
key: trackLang,
value: trackID
})
2018-10-23 15:42:44 +01:00
if (player.getProperty("track-list/" + track + "/selected")) {
subList.currentIndex = subList.count - 1
2018-10-13 15:38:31 +01:00
}
} else if (trackType == "audio") {
audioModel.append({
key: (trackTitle === undefined ? "" : trackTitle + " ")
+ trackLang,
value: trackID
})
2018-10-23 15:42:44 +01:00
if (player.getProperty("track-list/" + track + "/selected")) {
audioList.currentIndex = audioList.count - 1
2018-10-13 15:38:31 +01:00
}
} else if (trackType == "video") {
vidModel.append({
key: "Video " + trackID,
value: trackID
})
2018-10-23 15:42:44 +01:00
if (player.getProperty("track-list/" + track + "/selected")) {
vidList.currentIndex = vidList.count - 1
2018-10-13 15:38:31 +01:00
}
}
}
}
MpvObject {
2018-10-23 15:42:44 +01:00
id: player
2018-10-13 15:38:31 +01:00
anchors.fill: parent
width: parent.width
height: parent.height
2018-10-18 11:07:09 +01:00
2018-10-21 14:32:39 +01:00
Timer {
id: initTimer
interval: 1000
2018-10-21 14:32:39 +01:00
running: false
2018-10-24 19:49:05 +01:00
repeat: false
2018-10-21 14:32:39 +01:00
onTriggered: {
2018-10-24 19:49:05 +01:00
player.startPlayer()
2018-10-21 14:32:39 +01:00
}
}
2018-10-24 19:49:05 +01:00
Component.onCompleted: {
initTimer.start()
}
2018-10-21 14:32:39 +01:00
2018-10-18 11:07:09 +01:00
function startPlayer() {
2018-10-13 15:38:31 +01:00
var args = Qt.application.arguments
var len = Qt.application.arguments.length
var argNo = 0
2018-10-23 15:42:44 +01:00
player.setOption("ytdl-format", "bestvideo[width<=" + Screen.width
2018-10-24 19:49:05 +01:00
+ "][height<=" + Screen.height + "]+bestaudio")
2018-10-13 15:38:31 +01:00
if (len > 1) {
for (argNo = 1; argNo < len; argNo++) {
2018-10-13 15:38:31 +01:00
var argument = args[argNo]
2018-10-24 19:49:05 +01:00
if (argument.indexOf("KittehPlayer") !== -1) {
continue
}
2018-10-21 13:00:25 +01:00
if (argument.startsWith("--")) {
2018-10-13 15:38:31 +01:00
argument = argument.substr(2)
if (argument.length > 0) {
var splitArg = argument.split(/=(.+)/)
if (splitArg[0] == "fullscreen") {
toggleFullscreen()
} else {
if (splitArg[1].length == 0) {
splitArg[1] = "true"
}
2018-10-23 15:42:44 +01:00
player.setOption(splitArg[0], splitArg[1])
}
}
2018-10-24 19:49:05 +01:00
} else {
2018-10-23 15:42:44 +01:00
player.command(["loadfile", argument])
2018-10-21 13:00:25 +01:00
}
2018-10-13 15:38:31 +01:00
}
}
}
function createTimestamp(d) {
d = Number(d)
var h = Math.floor(d / 3600)
var m = Math.floor(d % 3600 / 60)
var s = Math.floor(d % 3600 % 60)
var hour = h > 0 ? h + ":" : ""
var minute = m + ":"
2018-10-15 08:05:20 +01:00
var second = s < 10 ? "0" + s : s
2018-10-13 15:38:31 +01:00
return hour + minute + second
}
function setProgressBarEnd(val) {
progressBar.to = val
2018-10-27 11:34:13 +01:00
}
2018-10-13 15:38:31 +01:00
function setProgressBarValue(val) {
timeLabel.text = createTimestamp(val) + " / " + createTimestamp(
2018-10-27 11:34:13 +01:00
progressBar.to) + " (" + parseFloat(player.getProperty("speed").toFixed(2)) + "x)"
2018-10-13 15:38:31 +01:00
progressBar.value = val
}
function skipToNinth(val) {
var skipto = 0
if (val != 0) {
skipto = Math.floor(progressBar.to / 9 * val)
}
player.command(["seek", skipto, "absolute"])
}
2018-10-26 15:13:14 +01:00
function updatePrev(val) {
if (val != 0) {
playlistPrevButton.visible = true
playlistPrevButton.width = playPauseButton.width
} else {
playlistPrevButton.visible = false
playlistPrevButton.width = 0
}
2018-10-13 15:38:31 +01:00
}
2018-10-26 15:13:14 +01:00
function updateVolume(volume) {
var muted = player.getProperty("mute")
if (muted || volume === 0) {
volumeButton.icon.source = "qrc:/player/icons/volume-mute.svg"
} else {
if (volume < 25) {
volumeButton.icon.source = "qrc:/player/icons/volume-down.svg"
} else {
volumeButton.icon.source = "qrc:/player/icons/volume-up.svg"
}
}
}
function updateMuted(muted) {
if (muted) {
volumeButton.icon.source = "qrc:/player/icons/volume-mute.svg"
}
}
function updatePlayPause() {
var paused = player.getProperty("pause")
if (paused) {
playPauseButton.icon.source = "qrc:/player/icons/play.svg"
} else {
playPauseButton.icon.source = "qrc:/player/icons/pause.svg"
}
}
function setTitle(title) {
titleLabel.text = title
}
function setSubtitles(subs) {
nativeSubs.text = subs
}
2018-10-24 15:50:22 +01:00
function isAnyMenuOpen() {
2018-10-24 19:49:05 +01:00
return subtitlesMenu.visible || settingsMenu.visible
|| fileMenuBarItem.opened || playbackMenuBarItem.opened
2018-10-28 12:19:24 +00:00
|| viewMenuBarItem.opened || audioMenuBarItem.opened
|| screenshotSaveDialog.visible || videoMenuBarItem.opened
2018-10-28 13:21:45 +00:00
|| subsMenuBarItem.opened
2018-10-24 15:50:22 +01:00
}
function hideControls(force) {
if (!isAnyMenuOpen() || force) {
2018-10-24 19:49:05 +01:00
//player.setOption("sub-margin-y", "22")
2018-10-21 14:32:39 +01:00
controlsBar.visible = false
controlsBackground.visible = false
titleBar.visible = false
titleBackground.visible = false
2018-10-23 23:19:26 +01:00
menuBar.visible = false
2018-10-21 14:32:39 +01:00
}
2018-10-13 15:38:31 +01:00
}
function showControls() {
2018-10-24 19:49:05 +01:00
if (!controlsBar.visible) {
//player.setOption("sub-margin-y", String(controlsBar.height + progressBar.height))
controlsBar.visible = true
controlsBackground.visible = true
if (appearance.titleOnlyOnFullscreen) {
if (mainWindow.visibility == Window.FullScreen) {
titleBar.visible = true
}
} else {
titleBar.visible = true
}
titleBackground.visible = true
2018-10-23 23:19:26 +01:00
menuBar.visible = true
}
2018-10-13 15:38:31 +01:00
}
Settings {
id: appearance
category: "Appearance"
property bool titleOnlyOnFullscreen: true
}
2018-10-26 19:11:07 +01:00
Settings {
id: fun
category: "Fun"
property bool nyanCat: false
}
Dialog {
id: screenshotSaveDialog
title: "Save Screenshot To"
standardButtons: StandardButton.Cancel | StandardButton.Open
onAccepted: {
player.grabToImage(function (result) {
result.saveToFile(screenshotFile.text)
nativeSubs.visible = true
})
}
TextField {
id: screenshotFile
2018-10-27 11:34:13 +01:00
placeholderText: "~/screenshot.jpg"
}
}
2018-10-21 15:42:52 +01:00
FileDialog {
id: fileDialog
title: "Please choose a file"
folder: shortcuts.home
onAccepted: {
2018-10-23 15:42:44 +01:00
player.command(["loadfile", String(fileDialog.fileUrl)])
2018-10-21 15:42:52 +01:00
fileDialog.close()
}
onRejected: {
fileDialog.close()
}
}
Dialog {
id: loadDialog
title: "URL / File Path"
2018-10-21 15:42:52 +01:00
standardButtons: StandardButton.Cancel | StandardButton.Open
onAccepted: {
2018-10-24 19:49:05 +01:00
player.command(["loadfile", pathText.text])
pathText.text = ""
}
2018-10-21 15:42:52 +01:00
TextField {
id: pathText
placeholderText: qsTr("URL / File Path")
}
}
2018-10-13 15:38:31 +01:00
MouseArea {
id: mouseAreaBar
x: 0
y: parent.height
2018-10-13 15:38:31 +01:00
width: parent.width
height: (controlsBar.height * 2) + progressBar.height
2018-10-13 15:38:31 +01:00
anchors.bottom: parent.bottom
anchors.bottomMargin: 0
hoverEnabled: true
onEntered: {
mouseAreaPlayerTimer.stop()
}
2018-10-13 15:38:31 +01:00
}
MouseArea {
id: mouseAreaPlayer
width: parent.width
anchors.bottom: mouseAreaBar.top
anchors.bottomMargin: 10
anchors.right: parent.right
anchors.rightMargin: 0
anchors.left: parent.left
anchors.leftMargin: 0
anchors.top: titleBar.bottom
anchors.topMargin: 0
hoverEnabled: true
cursorShape: controlsBar.visible ? Qt.ArrowCursor : Qt.BlankCursor
2018-10-21 14:32:39 +01:00
onClicked: {
2018-10-23 15:42:44 +01:00
player.command(["cycle", "pause"])
2018-10-21 14:32:39 +01:00
}
Timer {
id: mouseAreaPlayerTimer
interval: 1000
running: false
repeat: false
onTriggered: {
2018-10-23 15:42:44 +01:00
player.hideControls()
}
}
onPositionChanged: {
2018-10-23 15:42:44 +01:00
player.showControls()
mouseAreaPlayerTimer.restart()
}
}
2018-10-13 15:38:31 +01:00
2018-10-24 17:41:41 +01:00
Settings {
id: keybinds
category: "Keybinds"
property string playPause: "K"
property string forward10: "L"
property string rewind10: "J"
property string forward5: "Right"
property string rewind5: "Left"
property string openFile: "Ctrl+O"
property string openURI: "Ctrl+Shift+O"
property string quit: "Ctrl+Q"
property string fullscreen: "F"
property string tracks: "Ctrl+T"
property string statsForNerds: "I"
2018-10-24 18:02:46 +01:00
property string forwardFrame: "."
property string backwardFrame: ","
property string cycleSub: "Alt+S"
property string cycleSubBackwards: "Alt+Shift+S"
property string cycleAudio: "A"
property string cycleVideo: "V"
property string cycleVideoAspect: "Shift+A"
property string screenshot: "S"
property string screenshotWithoutSubtitles: "Shift+S"
property string fullScreenshot: "Ctrl+S"
2018-10-26 19:11:07 +01:00
property string nyanCat: "Ctrl+N"
2018-10-27 11:34:13 +01:00
property string decreaseSpeedBy10Percent: "["
property string increaseSpeedBy10Percent: "]"
property string halveSpeed: "{"
property string doubleSpeed: "}"
2018-10-28 12:19:24 +00:00
property string increaseVolume: "*"
property string decreaseVolume: "/"
property string mute: "m"
2018-10-24 17:41:41 +01:00
}
2018-10-24 19:49:05 +01:00
MenuBar {
id: menuBar
//width: parent.width
height: Screen.height / 24
delegate: MenuBarItem {
id: menuBarItem
2018-10-23 23:19:26 +01:00
2018-10-24 19:49:05 +01:00
contentItem: Text {
text: menuBarItem.text
font.family: notoFont.name
font.pixelSize: 14
renderType: Text.NativeRendering
opacity: 1
color: menuBarItem.highlighted ? "#5a50da" : "white"
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
}
2018-10-23 23:19:26 +01:00
2018-10-24 19:49:05 +01:00
background: Rectangle {
implicitWidth: 10
implicitHeight: 10
opacity: 1
color: menuBarItem.highlighted ? "#c0c0f0" : "transparent"
}
2018-10-23 23:19:26 +01:00
}
background: Rectangle {
2018-10-27 16:11:29 +01:00
width: parent.width
implicitHeight: 10
color: "black"
opacity: 0.6
}
2018-10-24 19:49:05 +01:00
Menu {
id: fileMenuBarItem
title: "File"
2018-10-26 17:03:20 +01:00
width: 150
2018-10-24 19:49:05 +01:00
background: Rectangle {
implicitWidth: parent.width
implicitHeight: 10
color: "black"
opacity: 0.6
}
delegate: CustomMenuItem {
}
2018-10-24 19:49:05 +01:00
Action {
text: "Open File"
onTriggered: fileDialog.open()
shortcut: keybinds.openFile
}
Action {
text: "Open URI/URL"
onTriggered: loadDialog.open()
shortcut: keybinds.openURI
}
Action {
text: "Screenshot"
onTriggered: {
player.hideControls(true)
screenshotSaveDialog.open()
}
shortcut: keybinds.screenshot
}
Action {
text: "Screenshot w/o subtitles"
onTriggered: {
player.hideControls(true)
nativeSubs.visible = false
screenshotSaveDialog.open()
}
shortcut: keybinds.screenshotWithoutSubtitles
}
Action {
text: "Full Screenshot"
onTriggered: {
screenshotSaveDialog.open()
}
shortcut: keybinds.fullScreenshot
}
2018-10-24 19:49:05 +01:00
Action {
text: "Exit"
onTriggered: Qt.quit()
shortcut: keybinds.quit
}
2018-10-23 23:19:26 +01:00
}
2018-10-24 19:49:05 +01:00
Menu {
id: playbackMenuBarItem
title: "Playback"
2018-10-27 16:11:29 +01:00
width: 150
2018-10-24 19:49:05 +01:00
background: Rectangle {
implicitWidth: parent.width
implicitHeight: 10
color: "black"
opacity: 0.6
}
delegate: CustomMenuItem {
2018-10-27 16:11:29 +01:00
width: parent.width
2018-10-24 19:49:05 +01:00
}
2018-10-23 23:19:26 +01:00
2018-10-24 19:49:05 +01:00
Action {
text: "Play/Pause"
onTriggered: {
player.command(["cycle", "pause"])
}
shortcut: String(keybinds.playPause)
}
2018-10-24 19:49:05 +01:00
Action {
text: "Rewind 10s"
onTriggered: {
player.command(["seek", "-10"])
}
shortcut: keybinds.rewind10
}
2018-10-24 19:49:05 +01:00
Action {
text: "Forward 10s"
onTriggered: {
player.command(["seek", "10"])
}
shortcut: keybinds.forward10
}
2018-10-24 19:49:05 +01:00
Action {
text: "Rewind 5s"
onTriggered: {
player.command(["seek", "-5"])
}
shortcut: keybinds.rewind5
}
2018-10-24 19:49:05 +01:00
Action {
text: "Forward 5s"
onTriggered: {
player.command(["seek", "5"])
}
shortcut: keybinds.forward5
}
2018-10-27 11:34:13 +01:00
Action {
text: "Speed -10%"
onTriggered: {
player.command(["multiply", "speed", "1/1.1"])
}
shortcut: keybinds.decreaseSpeedBy10Percent
}
Action {
text: "Speed +10%"
onTriggered: {
player.command(["multiply", "speed", "1.1"])
}
shortcut: keybinds.increaseSpeedBy10Percent
}
Action {
text: "Halve Speed"
onTriggered: {
player.command(["multiply", "speed", "0.5"])
}
shortcut: keybinds.halveSpeed
}
Action {
text: "Double Speed"
onTriggered: {
player.command(["multiply", "speed", "2.0"])
}
shortcut: keybinds.doubleSpeed
}
2018-10-24 19:49:05 +01:00
Action {
text: "Forward Frame"
onTriggered: {
player.command(["frame-step"])
}
shortcut: keybinds.forwardFrame
}
Action {
text: "Back Frame"
onTriggered: {
player.command(["frame-back-step"])
}
shortcut: keybinds.backwardFrame
}
2018-10-28 12:19:24 +00:00
}
Menu {
id: audioMenuBarItem
title: "Audio"
width: 140
background: Rectangle {
implicitWidth: parent.width
implicitHeight: 10
color: "black"
opacity: 0.6
}
delegate: CustomMenuItem {
width: parent.width
}
2018-10-24 19:49:05 +01:00
Action {
2018-10-28 12:19:24 +00:00
text: "Cycle Audio"
2018-10-24 19:49:05 +01:00
onTriggered: {
2018-10-28 12:19:24 +00:00
player.command(["cycle", "audio"])
2018-10-24 19:49:05 +01:00
}
2018-10-28 12:19:24 +00:00
shortcut: keybinds.cycleAudio
}
Action {
text: "Increase Volume"
onTriggered: {
player.command(["add", "volume", "2"])
}
shortcut: keybinds.increaseVolume
2018-10-28 12:19:24 +00:00
}
Action {
text: "Decrease Volume"
onTriggered: {
player.command(["add", "volume", "-2"])
}
shortcut: keybinds.decreaseVolume
}
Action {
text: "Mute"
onTriggered: {
player.command(["cycle", "mute"])
}
shortcut: keybinds.mute
}
}
2018-10-24 19:49:05 +01:00
Menu {
2018-10-28 12:19:24 +00:00
id: videoMenuBarItem
title: "Video"
2018-10-27 16:11:29 +01:00
width: 140
2018-10-24 19:49:05 +01:00
background: Rectangle {
implicitWidth: parent.width
implicitHeight: 10
color: "black"
opacity: 0.6
}
delegate: CustomMenuItem {
2018-10-27 16:11:29 +01:00
width: parent.width
2018-10-24 19:49:05 +01:00
}
Action {
2018-10-28 12:19:24 +00:00
text: "Cycle Video"
2018-10-24 19:49:05 +01:00
onTriggered: {
2018-10-28 12:19:24 +00:00
player.command(["cycle", "video"])
2018-10-24 19:49:05 +01:00
}
2018-10-28 12:19:24 +00:00
shortcut: keybinds.cycleVideo
}
}
Menu {
id: subsMenuBarItem
title: "Subtitles"
width: 140
background: Rectangle {
implicitWidth: parent.width
implicitHeight: 10
color: "black"
opacity: 0.6
}
delegate: CustomMenuItem {
width: parent.width
2018-10-24 19:49:05 +01:00
}
Action {
text: "Cycle Subs"
onTriggered: {
player.command(["cycle", "sub"])
}
shortcut: keybinds.cycleSub
}
Action {
text: "Cycle Subs Backwards"
onTriggered: {
player.command(["cycle", "sub", "down"])
}
shortcut: keybinds.cycleSubBackwards
}
}
2018-10-24 19:49:05 +01:00
Menu {
id: viewMenuBarItem
title: "View"
2018-10-27 16:11:29 +01:00
width: 120
2018-10-24 19:49:05 +01:00
background: Rectangle {
implicitWidth: parent.width
implicitHeight: 10
color: "black"
opacity: 0.6
}
delegate: CustomMenuItem {
2018-10-27 16:11:29 +01:00
width: parent.width
2018-10-24 19:49:05 +01:00
}
Action {
text: "Fullscreen"
onTriggered: {
toggleFullscreen()
}
shortcut: keybinds.fullscreen
}
2018-10-28 12:19:24 +00:00
Action {
text: "Track Menu"
onTriggered: {
tracksMenuUpdate()
subtitlesMenu.visible = !subtitlesMenu.visible
subtitlesMenuBackground.visible = !subtitlesMenuBackground.visible
}
shortcut: keybinds.tracks
}
2018-10-24 19:49:05 +01:00
Action {
text: "Stats For Nerds"
onTriggered: {
player.command(
["script-binding", "stats/display-stats-toggle"])
}
shortcut: keybinds.statsForNerds
}
2018-10-26 19:11:07 +01:00
Action {
text: "Toggle Nyan Cat"
onTriggered: {
fun.nyanCat = ! fun.nyanCat
}
shortcut: keybinds.nyanCat
}
}
2018-10-24 19:49:05 +01:00
Action {
onTriggered: player.skipToNinth(parseInt(shortcut))
shortcut: "1"
}
Action {
2018-10-24 19:49:05 +01:00
onTriggered: player.skipToNinth(parseInt(shortcut))
shortcut: "2"
}
Action {
2018-10-24 19:49:05 +01:00
onTriggered: player.skipToNinth(parseInt(shortcut))
shortcut: "3"
}
Action {
2018-10-24 19:49:05 +01:00
onTriggered: player.skipToNinth(parseInt(shortcut))
shortcut: "4"
}
Action {
2018-10-24 19:49:05 +01:00
onTriggered: player.skipToNinth(parseInt(shortcut))
shortcut: "5"
}
Action {
2018-10-24 19:49:05 +01:00
onTriggered: player.skipToNinth(parseInt(shortcut))
shortcut: "6"
}
2018-10-24 19:49:05 +01:00
Action {
onTriggered: player.skipToNinth(parseInt(shortcut))
shortcut: "7"
2018-10-23 23:19:26 +01:00
}
Action {
2018-10-24 19:49:05 +01:00
onTriggered: player.skipToNinth(parseInt(shortcut))
shortcut: "8"
}
2018-10-24 15:50:22 +01:00
Action {
2018-10-24 19:49:05 +01:00
onTriggered: player.skipToNinth(parseInt(shortcut))
shortcut: "9"
}
Action {
onTriggered: player.skipToNinth(parseInt(shortcut))
shortcut: "0"
2018-10-24 15:50:22 +01:00
}
}
2018-10-24 19:49:05 +01:00
Rectangle {
id: subtitlesMenuBackground
anchors.fill: subtitlesMenu
Layout.fillWidth: true
Layout.fillHeight: true
visible: false
color: "black"
opacity: 0.6
}
2018-10-24 19:49:05 +01:00
Rectangle {
id: subtitlesMenu
color: "transparent"
width: childrenRect.width
height: childrenRect.height
visible: false
anchors.centerIn: player
border.color: "black"
border.width: 2
2018-10-23 23:19:26 +01:00
2018-10-24 19:49:05 +01:00
Text {
id: audioLabel
anchors.left: parent.left
anchors.right: parent.right
text: "Audio"
color: "white"
font.family: notoFont.name
font.pixelSize: 14
renderType: Text.NativeRendering
horizontalAlignment: Text.AlignHCenter
opacity: 1
}
2018-10-24 19:49:05 +01:00
ComboBox {
id: audioList
textRole: "key"
anchors.top: audioLabel.bottom
model: ListModel {
id: audioModel
}
2018-10-24 19:49:05 +01:00
onActivated: {
player.command(["set", "aid", String(audioModel.get(
index).value)])
}
2018-10-24 19:49:05 +01:00
opacity: 1
}
Text {
id: subLabel
anchors.left: parent.left
anchors.right: parent.right
text: "Subtitles"
color: "white"
font.family: notoFont.name
font.pixelSize: 14
anchors.top: audioList.bottom
renderType: Text.NativeRendering
horizontalAlignment: Text.AlignHCenter
opacity: 1
}
ComboBox {
id: subList
textRole: "key"
anchors.top: subLabel.bottom
model: ListModel {
id: subModel
}
2018-10-24 19:49:05 +01:00
onActivated: {
player.command(["set", "sid", String(subModel.get(
index).value)])
}
2018-10-24 19:49:05 +01:00
opacity: 1
}
Text {
id: vidLabel
anchors.left: parent.left
anchors.right: parent.right
text: "Video"
color: "white"
font.family: notoFont.name
font.pixelSize: 14
anchors.top: subList.bottom
renderType: Text.NativeRendering
horizontalAlignment: Text.AlignHCenter
opacity: 1
}
ComboBox {
id: vidList
textRole: "key"
anchors.top: vidLabel.bottom
model: ListModel {
id: vidModel
}
2018-10-24 19:49:05 +01:00
onActivated: {
player.command(["set", "vid", String(vidModel.get(
index).value)])
}
2018-10-24 19:49:05 +01:00
opacity: 1
}
2018-10-24 19:49:05 +01:00
}
2018-10-13 15:38:31 +01:00
Rectangle {
id: titleBackground
height: titleBar.height
2018-10-23 23:19:26 +01:00
anchors.top: titleBar.top
anchors.left: titleBar.left
anchors.right: titleBar.right
2018-10-13 15:38:31 +01:00
Layout.fillWidth: true
Layout.fillHeight: true
color: "black"
opacity: 0.6
}
Rectangle {
id: titleBar
height: menuBar.height
anchors.right: parent.right
anchors.left: menuBar.right
anchors.top: parent.top
2018-10-26 19:11:07 +01:00
visible: !appearance.titleOnlyOnFullscreen
2018-10-13 15:38:31 +01:00
color: "transparent"
Text {
id: titleLabel
text: "Title"
2018-10-13 15:38:31 +01:00
color: "white"
width: parent.width
height: parent.height
2018-10-13 15:38:31 +01:00
anchors.left: parent.left
anchors.leftMargin: 10
anchors.bottom: parent.bottom
anchors.bottomMargin: 4
anchors.topMargin: 4
anchors.top: parent.top
2018-10-13 15:38:31 +01:00
font.family: notoFont.name
fontSizeMode: Text.Fit
minimumPixelSize: 10
font.pixelSize: 72
verticalAlignment: Text.AlignVCenter
2018-10-13 15:38:31 +01:00
renderType: Text.NativeRendering
opacity: 1
}
}
Rectangle {
id: controlsBackground
height: controlsBar.visible ? controlsBar.height + progressBackground.height + (progressBar.topPadding * 2)
2018-10-26 19:11:07 +01:00
- (progressBackground.height * 2): 0
anchors.bottom: parent.bottom
2018-10-13 15:38:31 +01:00
anchors.left: parent.left
anchors.right: parent.right
Layout.fillWidth: true
Layout.fillHeight: true
color: "black"
opacity: 0.6
}
2018-10-13 15:38:31 +01:00
2018-10-24 19:49:05 +01:00
Rectangle {
id: nativeSubtitles
height: nativeSubs.font.pixelSize + 4
visible: nativeSubs.text == "" ? false : true
anchors.left: controlsBar.left
anchors.right: controlsBar.right
anchors.bottom: controlsBackground.top
2018-10-27 11:34:13 +01:00
anchors.bottomMargin: 0
2018-10-26 19:11:07 +01:00
2018-10-24 19:49:05 +01:00
radius: 5
color: "transparent"
2018-10-26 15:13:14 +01:00
TextMetrics {
id: t_metrics
font.family: notoFont.name
font.pixelSize: nativeSubs.fontInfo.pixelSize
text: nativeSubs.text
}
2018-10-24 19:49:05 +01:00
Label {
id: nativeSubs
width: parent.width
text: ""
color: "white"
font.family: notoFont.name
font.pixelSize: 24
renderType: Text.NativeRendering
horizontalAlignment: Text.AlignHCenter
anchors.bottom: parent.top
opacity: 1
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
background: Rectangle {
2018-10-26 15:13:14 +01:00
id: subsBackground
2018-10-24 19:49:05 +01:00
color: Qt.rgba(0, 0, 0, 0.6)
2018-10-26 15:13:14 +01:00
width: t_metrics.tightBoundingRect.width + 8
2018-10-24 19:49:05 +01:00
anchors.left: parent.left
anchors.leftMargin: (nativeSubtitles.width
- t_metrics.tightBoundingRect.width) / 2
2018-10-24 19:49:05 +01:00
anchors.right: parent.right
2018-10-26 15:13:14 +01:00
anchors.rightMargin: anchors.leftMargin
2018-10-24 19:49:05 +01:00
}
}
}
function setCachedDuration(val) {
2018-10-28 12:19:24 +00:00
cachedLength.width = ((progressBar.width / progressBar.to) * val) - progressLength.width
}
Rectangle {
id: controlsBar
height: controlsBar.visible ? Screen.height / 24 : 0
anchors.right: parent.right
anchors.rightMargin: parent.width / 128
anchors.left: parent.left
anchors.leftMargin: parent.width / 128
anchors.bottom: parent.bottom
anchors.bottomMargin: 1
visible: true
color: "transparent"
2018-10-23 16:45:44 +01:00
Rectangle {
id: settingsMenuBackground
anchors.fill: settingsMenu
Layout.fillWidth: true
Layout.fillHeight: true
visible: false
color: "black"
opacity: 0.6
radius: 5
}
Rectangle {
id: settingsMenu
color: "transparent"
width: childrenRect.width
height: childrenRect.height
visible: false
anchors.right: settingsButton.right
anchors.bottom: progressBar.top
radius: 5
ColumnLayout {
Button {
text: "Open File"
onClicked: fileDialog.open()
}
Button {
text: "Enter Path"
onClicked: loadDialog.open()
}
}
2018-10-26 19:11:07 +01:00
}
Slider {
id: progressBar
to: 1
value: 0.0
anchors.bottom: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.bottomMargin: 0
2018-10-27 11:34:13 +01:00
anchors.topMargin: progressBackground.height
bottomPadding: 0
2018-10-13 15:38:31 +01:00
onMoved: {
2018-10-23 15:42:44 +01:00
player.command(["seek", progressBar.value, "absolute"])
}
2018-10-13 15:38:31 +01:00
background: Rectangle {
id: progressBackground
x: progressBar.leftPadding
y: progressBar.topPadding + progressBar.availableHeight / 2 - height / 2
2018-10-26 19:11:07 +01:00
implicitHeight: (Screen.height / 256) < (fun.nyanCat ? 12 : 2) ? (fun.nyanCat ? 12 : 2) : Screen.height / 256
width: progressBar.availableWidth
height: implicitHeight
2018-10-26 19:11:07 +01:00
color: Qt.rgba(255, 255, 255, 0.6)
Rectangle {
id: progressLength
width: progressBar.visualPosition * parent.width
height: parent.height
color: "red"
opacity: 1
2018-10-26 19:11:07 +01:00
LinearGradient {
height: parent.height
visible: fun.nyanCat
anchors.fill: parent
gradient: Gradient {
GradientStop {
position: 0.0
color: "#f00"
}
GradientStop {
position: 0.17
color: "#f90"
}
GradientStop {
position: 0.33
color: "#ff0"
}
GradientStop {
position: 0.50
color: "#3f0"
}
GradientStop {
position: 0.67
color: "#09f"
}
GradientStop {
position: 0.83
color: "#63f"
}
GradientStop {
position: 1
color: "#63f"
}
}
}
}
Rectangle {
id: cachedLength
z: 10
anchors.left: progressLength.right
2018-10-28 12:19:24 +00:00
anchors.leftMargin: progressBar.handle.width -2
//anchors.left: progressBar.handle.horizontalCenter
anchors.bottom: progressBar.background.bottom
anchors.top: progressBar.background.top
height: progressBar.background.height
color: "white"
opacity: 0.8
}
}
2018-10-13 15:38:31 +01:00
handle: Rectangle {
2018-10-15 17:39:04 +01:00
id: handleRect
x: progressBar.leftPadding + progressBar.visualPosition
* (progressBar.availableWidth - width)
y: progressBar.topPadding + progressBar.availableHeight / 2 - height / 2
implicitHeight: 12
2018-10-26 19:11:07 +01:00
implicitWidth: 12
radius: 12
2018-10-26 19:11:07 +01:00
color: fun.nyanCat ? "transparent" : "red"
//border.color: "red"
AnimatedImage {
visible: fun.nyanCat
paused: progressBar.pressed
height: 30
2018-10-26 19:11:07 +01:00
id: nyanimation
anchors.centerIn: parent
source: "qrc:/player/icons/nyancat.gif"
fillMode: Image.PreserveAspectFit
}
}
2018-10-13 15:38:31 +01:00
}
Button {
id: playlistPrevButton
//icon.name: "prev"
icon.source: "icons/prev.svg"
icon.color: "white"
display: AbstractButton.IconOnly
2018-10-16 16:55:25 +01:00
anchors.top: parent.top
anchors.bottom: parent.bottom
visible: false
width: 0
onClicked: {
2018-10-23 15:42:44 +01:00
player.command(["playlist-prev"])
}
background: Rectangle {
color: "transparent"
}
2018-10-13 15:38:31 +01:00
}
Button {
id: playPauseButton
//icon.name: "pause"
icon.source: "icons/pause.svg"
icon.color: "white"
display: AbstractButton.IconOnly
2018-10-16 16:55:25 +01:00
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.left: playlistPrevButton.right
onClicked: {
2018-10-26 15:13:14 +01:00
player.command(["cycle", "pause"])
}
background: Rectangle {
color: "transparent"
}
2018-10-13 15:38:31 +01:00
}
Button {
id: playlistNextButton
//icon.name: "next"
icon.source: "icons/next.svg"
icon.color: "white"
display: AbstractButton.IconOnly
2018-10-16 16:55:25 +01:00
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.left: playPauseButton.right
onClicked: {
2018-10-23 15:42:44 +01:00
player.command(["playlist-next", "force"])
}
background: Rectangle {
color: "transparent"
}
2018-10-13 15:38:31 +01:00
}
Button {
id: volumeButton
//icon.name: "volume-up"
icon.source: "icons/volume-up.svg"
icon.color: "white"
display: AbstractButton.IconOnly
2018-10-16 16:55:25 +01:00
anchors.top: parent.top
anchors.bottom: parent.bottom
anchors.left: playlistNextButton.right
onClicked: {
2018-10-23 15:42:44 +01:00
player.command(["cycle", "mute"])
}
background: Rectangle {
color: "transparent"
2018-10-13 15:38:31 +01:00
}
}
Slider {
id: volumeBar
to: 100
value: 100
palette.dark: "#f00"
implicitWidth: Math.max(
background ? background.implicitWidth : 0,
(handle ? handle.implicitWidth : 0)
+ leftPadding + rightPadding)
implicitHeight: Math.max(
background ? background.implicitHeight : 0,
(handle ? handle.implicitHeight : 0)
+ topPadding + bottomPadding)
anchors.left: volumeButton.right
anchors.top: parent.top
anchors.bottom: parent.bottom
onMoved: {
2018-10-23 15:42:44 +01:00
player.command(["set", "volume", Math.round(
2018-10-24 19:49:05 +01:00
volumeBar.value).toString()])
}
2018-10-13 15:38:31 +01:00
handle: Rectangle {
x: volumeBar.leftPadding + volumeBar.visualPosition
* (volumeBar.availableWidth - width)
y: volumeBar.topPadding + volumeBar.availableHeight / 2 - height / 2
implicitWidth: 12
implicitHeight: 12
radius: 12
color: "#f6f6f6"
border.color: "#f6f6f6"
}
2018-10-13 15:38:31 +01:00
background: Rectangle {
x: volumeBar.leftPadding
y: volumeBar.topPadding + volumeBar.availableHeight / 2 - height / 2
implicitWidth: 60
implicitHeight: 3
width: volumeBar.availableWidth
height: implicitHeight
color: "#33333311"
Rectangle {
width: volumeBar.visualPosition * parent.width
height: parent.height
color: "white"
}
}
2018-10-13 15:38:31 +01:00
}
Text {
id: timeLabel
text: "0:00 / 0:00"
color: "white"
anchors.left: volumeBar.right
2018-10-16 16:55:25 +01:00
anchors.top: parent.top
anchors.bottom: parent.bottom
2018-10-23 23:56:24 +01:00
padding: 2
font.family: notoFont.name
2018-10-23 23:56:24 +01:00
font.pixelSize: 14
verticalAlignment: Text.AlignVCenter
renderType: Text.NativeRendering
2018-10-13 15:38:31 +01:00
}
Button {
id: subtitlesButton
//icon.name: "subtitles"
icon.source: "icons/subtitles.svg"
icon.color: "white"
anchors.right: settingsButton.left
2018-10-16 16:55:25 +01:00
anchors.top: parent.top
anchors.bottom: parent.bottom
display: AbstractButton.IconOnly
onClicked: {
tracksMenuUpdate()
subtitlesMenu.visible = !subtitlesMenu.visible
subtitlesMenuBackground.visible = !subtitlesMenuBackground.visible
}
background: Rectangle {
color: "transparent"
}
2018-10-13 15:38:31 +01:00
}
Button {
id: settingsButton
//icon.name: "settings"
icon.source: "icons/settings.svg"
icon.color: "white"
Layout.alignment: Qt.AlignVCenter | Qt.AlignRight
anchors.right: fullscreenButton.left
2018-10-16 16:55:25 +01:00
anchors.top: parent.top
anchors.bottom: parent.bottom
display: AbstractButton.IconOnly
onClicked: {
2018-10-23 16:45:44 +01:00
settingsMenu.visible = !settingsMenu.visible
settingsMenuBackground.visible = !settingsMenuBackground.visible
}
background: Rectangle {
color: "transparent"
2018-10-13 15:38:31 +01:00
}
}
Button {
id: fullscreenButton
//icon.name: "fullscreen"
icon.source: "icons/fullscreen.svg"
icon.color: "white"
Layout.alignment: Qt.AlignVCenter | Qt.AlignRight
anchors.right: parent.right
2018-10-16 16:55:25 +01:00
anchors.top: parent.top
anchors.bottom: parent.bottom
display: AbstractButton.IconOnly
onClicked: {
toggleFullscreen()
}
background: Rectangle {
color: "transparent"
}
2018-10-13 15:38:31 +01:00
}
}
2018-10-13 15:38:31 +01:00
}
}