You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

153 lines
3.8 KiB
QML

/*
* SPDX-FileCopyrightText: 2021 Reion Wong <reion@cutefishos.com>
* SPDX-FileCopyrightText: 2020 George Florea Bănuș <georgefb899@gmail.com>
*
* SPDX-License-Identifier: GPL-3.0-or-later
*/
import QtQuick 2.12
import QtQuick.Window 2.12
import QtQuick.Controls 2.12
import QtQuick.Layouts 1.12
import QtGraphicalEffects 1.12
import Qt.labs.platform 1.0 as Platform
import FishUI 1.0 as FishUI
import mpv 1.0
FishUI.Window {
id: rootWindow
width: 720
height: 480
minimumWidth: 700
minimumHeight: 450
color: FishUI.Theme.backgroundColor
header.visible: mpv.mouseY >= 0 && mpv.mouseY <= header.height
headerBackground.color: FishUI.Theme.secondBackgroundColor
headerBackground.opacity: 0.95
contentTopMargin: 0
property int preFullScreenVisibility
onVisibilityChanged: {
if (!rootWindow.isFullScreen()) {
preFullScreenVisibility = visibility
}
}
headerItem: Item {
Label {
id: headerLabel
anchors.left: parent.left
anchors.top: parent.top
anchors.topMargin: FishUI.Units.smallSpacing * 1.5
anchors.leftMargin: FishUI.Units.largeSpacing
text: mpv.mediaTitle
color: "white"
z: 100
}
DropShadow {
anchors.fill: headerLabel
source: headerLabel
z: -1
horizontalOffset: 1
verticalOffset: 1
radius: Math.round(6 * FishUI.Units.devicePixelRatio)
samples: radius * 2 + 1
spread: 0.35
color: Qt.rgba(0, 0, 0, 0.5)
opacity: 0.4
visible: true
}
}
Actions {
id: actions
}
MpvVideo {
id: mpv
anchors.fill: parent
Image {
id: _logo
anchors.centerIn: parent
width: 128
height: 128
source: "qrc:/images/cutefish-videoplayer.svg"
sourceSize: Qt.size(width, height)
visible: playList.playlistView.count === 0
}
Button {
visible: _logo.visible
anchors.top: _logo.bottom
anchors.topMargin: FishUI.Units.largeSpacing
anchors.horizontalCenter: parent.horizontalCenter
text: qsTr("Open")
onClicked: fileDialog.open()
}
}
Platform.FileDialog {
id: fileDialog
property url location: ""
folder: location
title: "Select file"
fileMode: Platform.FileDialog.OpenFile
onAccepted: {
openFile(fileDialog.file.toString(), true)
// the timer scrolls the playlist to the playing file
// once the table view rows are loaded
playList.scrollPositionTimer.start()
mpv.focus = true
}
onRejected: mpv.focus = true
}
PlayList {
id: playList
}
Footer {
id: footer
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: mpv.bottom
}
function openFile(path, startPlayback) {
mpv.playlistModel.addVideo(path)
// mpv.playlistModel.clear()
mpv.pause = !startPlayback
// mpv.playlistModel.getVideos(path)
mpv.loadFile(path)
}
function isFullScreen() {
return rootWindow.visibility === Window.FullScreen
}
function toggleFullScreen() {
if (!isFullScreen()) {
rootWindow.showFullScreen()
} else {
if (rootWindow.preFullScreenVisibility === Window.Windowed) {
rootWindow.showNormal()
}
if (rootWindow.preFullScreenVisibility === Window.Maximized) {
rootWindow.show()
rootWindow.showMaximized()
}
}
app.showCursor()
playList.scrollPositionTimer.start()
}
}