1
0
Fork 0

[UI] Moved PlaylistDialog into it's own file.

This commit is contained in:
NamedKitten 2018-11-23 08:19:28 +00:00
parent afba6a63d2
commit 37158fbcad
9 changed files with 416 additions and 372 deletions

5
format-code.sh Executable file
View file

@ -0,0 +1,5 @@
SOURCE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
pushd $SOURCE_DIR
qmlfmt -w src/qml/*.qml
clang-format -style mozilla -i src/*
popd

View file

@ -435,7 +435,8 @@ DirectMpvPlayerBackend::playerCommand(const Enums::Commands& cmd,
case Enums::Commands::SetPlaylistPos: {
command(QVariantList() << "set" << "playlist-pos" << args);
command(QVariantList() << "set"
<< "playlist-pos" << args);
break;
}

View file

@ -425,7 +425,8 @@ MpvPlayerBackend::playerCommand(const Enums::Commands& cmd,
case Enums::Commands::SetPlaylistPos: {
command(QVariantList() << "set" << "playlist-pos" << args);
command(QVariantList() << "set"
<< "playlist-pos" << args);
break;
}

View file

@ -66,7 +66,6 @@ signals:
void audioDevicesChanged();
void playlistChanged();
private slots:
void doUpdate();
void on_mpv_events();

View file

@ -79,7 +79,9 @@ Item {
Rectangle {
id: controlsBackground
height: controlsBar.visible ? controlsBar.height + (fun.nyanCat ? progressBackground.height * 0.3: progressBackground.height * 2) : 0
height: controlsBar.visible ? controlsBar.height
+ (fun.nyanCat ? progressBackground.height
* 0.3 : progressBackground.height * 2) : 0
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.right: parent.right
@ -112,7 +114,9 @@ Item {
bottomPadding: 0
Component.onCompleted: {
player.positionChanged.connect(function (position) {
if (! pressed) {progressBar.value = position}
if (!pressed) {
progressBar.value = position
}
})
player.durationChanged.connect(function (duration) {
progressBar.to = duration
@ -153,7 +157,8 @@ Item {
color: appearance.progressBackgroundColor
ProgressBar {
id: cachedLength
background: Item {}
background: Item {
}
contentItem: Item {
Rectangle {
width: cachedLength.visualPosition * parent.width
@ -174,10 +179,12 @@ Item {
value: progressBar.value
opacity: 1
anchors.leftMargin: 0
background: Item {}
background: Item {
}
contentItem: Item {
Rectangle {
width: progressLength.visualPosition * parent.width + progressBar.handle.width / 2
width: progressLength.visualPosition * parent.width
+ progressBar.handle.width / 2
height: parent.height
color: appearance.progressSliderColor
Image {
@ -222,7 +229,6 @@ RowLayout {
anchors.fill: parent
spacing: 2
Button {
id: playlistPrevButton
objectName: "playlistPrevButton"
@ -234,7 +240,8 @@ RowLayout {
onClicked: {
player.playerCommand(Enums.Commands.PreviousPlaylistItem)
}
background: Item {}
background: Item {
}
Component.onCompleted: {
player.playlistPositionChanged.connect(function (position) {
if (position != 0) {
@ -254,7 +261,8 @@ RowLayout {
onClicked: {
player.playerCommand(Enums.Commands.TogglePlayPause)
}
background: Item {}
background: Item {
}
Component.onCompleted: {
player.playStatusChanged.connect(function (status) {
if (status == Enums.PlayStatus.Playing) {
@ -275,7 +283,8 @@ RowLayout {
onClicked: {
player.playerCommand(Enums.Commands.NextPlaylistItem)
}
background: Item {}
background: Item {
}
}
Button {
@ -287,7 +296,8 @@ RowLayout {
onClicked: {
player.playerCommand(Enums.Commands.ToggleMute)
}
background: Item {}
background: Item {
}
Component.onCompleted: {
player.volumeStatusChanged.connect(function (status) {
if (status == Enums.VolumeStatus.Muted) {
@ -315,7 +325,8 @@ RowLayout {
(handle ? handle.implicitHeight : 0)
+ topPadding + bottomPadding)
onMoved: {
player.playerCommand(Enums.Commands.SetVolume, Math.round(volumeBar.value).toString())
player.playerCommand(Enums.Commands.SetVolume,
Math.round(volumeBar.value).toString())
}
Component.onCompleted: {
player.volumeChanged.connect(function (volume) {
@ -360,7 +371,8 @@ RowLayout {
verticalAlignment: Text.AlignVCenter
renderType: Text.NativeRendering
Component.onCompleted: {
player.durationStringChanged.connect(function(durationString) {
player.durationStringChanged.connect(
function (durationString) {
text = durationString
})
}
@ -380,7 +392,8 @@ RowLayout {
onClicked: {
console.log("Settings Menu Not Yet Implemented.")
}
background: Item {}
background: Item {
}
}
Button {
@ -395,7 +408,8 @@ RowLayout {
toggleFullscreen()
}
background: Item {}
background: Item {
}
}
}
}

View file

@ -14,7 +14,9 @@ MenuBar {
height: Screen.height / 32
function anythingOpen() {
for (var i = 0, len = menuBar.count; i < len; i++) {
if (menuBar.menuAt(i).opened) { return true }
if (menuBar.menuAt(i).opened) {
return true
}
}
}
@ -101,7 +103,8 @@ MenuBar {
title: translate.getTranslation("OPEN_FILE", i18n.language)
nameFilters: ["All files (*)"]
onAccepted: {
player.playerCommand(Enums.Commands.LoadFile, String(fileDialog.file))
player.playerCommand(Enums.Commands.LoadFile,
String(fileDialog.file))
fileDialog.close()
}
onRejected: {
@ -124,87 +127,8 @@ MenuBar {
}
}
Dialog {
PlaylistDialog {
id: playlistDialog
title: "Playlist"
height: 480
width: 720
modality: Qt.NonModal
onAccepted: {
console.log("ok")
}
Component.onCompleted: {
player.titleChanged.connect(updatePlaylistMenu)
player.playlistChanged.connect(updatePlaylistMenu)
}
function updatePlaylistMenu() {
var playlist = player.playerCommand(Enums.Commands.GetPlaylist)
playlistModel.clear()
for (var thing in playlist) {
var item = playlist[thing]
playlistModel.append({
"playlistItemTitle": item["title"],
"playlistItemFilename": item["filename"],
"current": item["current"],
"playlistPos": thing
})
}
}
Component {
id: playlistDelegate
Item {
id: playlistItem
width: playlistDialog.width; height: 0
Button {
height: parent.height
id: playlistItemButton
font.pixelSize: 12
contentItem: Text {
id: playlistItemText
font: parent.font
color: "white"
text: playlistItemButton.text
height: parent.height
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
}
onClicked: {
player.playerCommand(Enums.Commands.SetPlaylistPos, playlistPos)
}
background: Rectangle { color: current ? "orange" : "transparent" }
}
Component.onCompleted: {
var itemText = ""
if (typeof playlistItemTitle !== "undefined") {
itemText += '<b>Title:</b> ' + playlistItemTitle + "<br>"
playlistItem.height += 30
}
if (typeof playlistItemFilename !== "undefined") {
itemText += '<b>Filename:</b> ' + playlistItemFilename + "<br>"
playlistItem.height += 30
}
playlistItemText.text = itemText
}
}
}
ListView {
id: playlistListView
anchors.fill: parent
model: ListModel { id: playlistModel }
delegate: playlistDelegate
highlight: Item {}
focus: true
}
}
delegate: MenuBarItem {
@ -423,7 +347,8 @@ MenuBar {
player.audioDevicesChanged.connect(updateAudioDevices)
}
function updateAudioDevices() {
var audioDevices = player.playerCommand(Enums.Commands.GetAudioDevices)
var audioDevices = player.playerCommand(
Enums.Commands.GetAudioDevices)
for (var i = 0, len = audioDeviceMenu.count; i < len; i++) {
audioDeviceMenu.takeAction(0)
@ -564,8 +489,7 @@ MenuBar {
}
}
Action {
text: translate.getTranslation("PLAYLIST_MENU",
i18n.language)
text: translate.getTranslation("PLAYLIST_MENU", i18n.language)
onTriggered: {
playlistDialog.open()
}

View file

@ -0,0 +1,91 @@
import QtQuick 2.11
import QtQuick.Controls 2.4
import QtQuick.Dialogs 1.3
import QtQuick.Window 2.11
import Qt.labs.settings 1.0
import Qt.labs.platform 1.0 as LabsPlatform
import player 1.0
Dialog {
id: playlistDialog
title: "Playlist"
height: Math.max(480, childrenRect.height * playlistListView.count)
width: 720
modality: Qt.NonModal
Component.onCompleted: {
player.titleChanged.connect(updatePlaylistMenu)
player.playlistChanged.connect(updatePlaylistMenu)
}
function updatePlaylistMenu() {
var playlist = player.playerCommand(Enums.Commands.GetPlaylist)
playlistModel.clear()
for (var thing in playlist) {
var item = playlist[thing]
playlistModel.append({
playlistItemTitle: item["title"],
playlistItemFilename: item["filename"],
current: item["current"],
playlistPos: thing
})
}
}
Component {
id: playlistDelegate
Item {
id: playlistItem
width: playlistDialog.width
height: childrenRect.height
Button {
width: parent.width
id: playlistItemButton
font.pixelSize: 12
padding: 0
bottomPadding: 0
contentItem: Text {
id: playlistItemText
font: parent.font
bottomPadding: 0
color: "white"
text: playlistItemButton.text
height: parent.height
horizontalAlignment: Text.AlignLeft
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
wrapMode: Text.Wrap
}
onClicked: {
player.playerCommand(Enums.Commands.SetPlaylistPos,
playlistPos)
}
background: Rectangle {
color: current ? "orange" : "transparent"
}
}
Component.onCompleted: {
var itemText = ""
if (typeof playlistItemTitle !== "undefined") {
itemText += '<b>Title:</b> ' + playlistItemTitle + "<br>"
}
if (typeof playlistItemFilename !== "undefined") {
itemText += '<b>Filename:</b> ' + playlistItemFilename
}
playlistItemText.text = itemText
}
}
}
ListView {
id: playlistListView
anchors.fill: parent
model: ListModel {
id: playlistModel
}
delegate: playlistDelegate
highlight: Item {
}
focus: true
}
}

View file

@ -98,7 +98,6 @@ ApplicationWindow {
property string customKeybind9Command: ""
}
property int lastScreenVisibility
function toggleFullscreen() {
@ -149,17 +148,23 @@ ApplicationWindow {
argument = argument.substr(2)
if (argument.length > 0) {
var splitArg = argument.split(/=(.+)/)
if (splitArg[0] == "screen" || splitArg[0] == "fs-screen") {
if (splitArg[0] == "screen"
|| splitArg[0] == "fs-screen") {
for (var i = 0, len = Qt.application.screens.length; i < len; i++) {
var screen = Qt.application.screens[i];
console.log("Screen Name: " + screen["name"] + " Screen Number: " + String(i))
if (screen["name"] == splitArg[1] || String(i) == splitArg[1] ) {
var screen = Qt.application.screens[i]
console.log("Screen Name: " + screen["name"]
+ " Screen Number: " + String(
i))
if (screen["name"] == splitArg[1] || String(
i) == splitArg[1]) {
console.log("Switching to screen: " + screen["name"])
mainWindow.screen = screen
mainWindow.width = mainWindow.screen.width / 2
mainWindow.height = mainWindow.screen.height / 2
mainWindow.x = mainWindow.screen.virtualX + mainWindow.width / 2
mainWindow.y = mainWindow.screen.virtualY + mainWindow.height / 2
mainWindow.x = mainWindow.screen.virtualX
+ mainWindow.width / 2
mainWindow.y = mainWindow.screen.virtualY
+ mainWindow.height / 2
if (splitArg[0] == "fs-screen") {
toggleFullscreen()
}
@ -170,16 +175,17 @@ ApplicationWindow {
}
if (splitArg[0] == "fullscreen") {
toggleFullscreen()
continue;
continue
}
if (splitArg[1] == undefined || splitArg[1].length == 0) {
if (splitArg[1] == undefined
|| splitArg[1].length == 0) {
splitArg[1] = "yes"
}
player.setOption(splitArg[0], splitArg[1])
}
} else {
player.playerCommand(Enums.Commands.AppendFile, argument)
player.playerCommand(Enums.Commands.AppendFile,
argument)
}
}
}
@ -198,7 +204,6 @@ ApplicationWindow {
mouseAreaPlayer.cursorShape = Qt.ArrowCursor
}
}
}
Item {
anchors.centerIn: player
@ -239,7 +244,9 @@ ApplicationWindow {
}
Action {
onTriggered: {
if (mainWindow.visibility == Window.FullScreen) {toggleFullscreen()}
if (mainWindow.visibility == Window.FullScreen) {
toggleFullscreen()
}
}
shortcut: "Esc"
}
@ -259,7 +266,7 @@ ApplicationWindow {
}
Timer {
id: mouseAreaPlayerTimer
interval: 2000
interval: 1000
running: true
repeat: false
onTriggered: {
@ -272,7 +279,6 @@ ApplicationWindow {
}
}
MainMenu {
id: menuBar
visible: player.controlsShowing
@ -305,7 +311,9 @@ ApplicationWindow {
font.pixelSize: 14
font.bold: true
opacity: 1
visible: player.controlsShowing && ((!appearance.titleOnlyOnFullscreen) || (mainWindow.visibility == Window.FullScreen) )
visible: player.controlsShowing
&& ((!appearance.titleOnlyOnFullscreen)
|| (mainWindow.visibility == Window.FullScreen))
Component.onCompleted: {
player.titleChanged.connect(function (title) {
text = title

View file

@ -1,6 +1,7 @@
<RCC>
<qresource prefix="/player">
<file>main.qml</file>
<file>PlaylistDialog.qml</file>
<file>CustomComboBox.qml</file>
<file>CustomMenuItem.qml</file>
<file>CustomMenu.qml</file>