[UI] Added playlist menu item.
This commit is contained in:
parent
0f7327bfca
commit
afba6a63d2
|
@ -109,6 +109,7 @@ DirectMpvPlayerBackend::DirectMpvPlayerBackend(QQuickItem* parent)
|
|||
mpv_observe_property(mpv, 0, "time-pos", MPV_FORMAT_DOUBLE);
|
||||
mpv_observe_property(mpv, 0, "demuxer-cache-duration", MPV_FORMAT_DOUBLE);
|
||||
mpv_observe_property(mpv, 0, "pause", MPV_FORMAT_NONE);
|
||||
mpv_observe_property(mpv, 0, "playlist", MPV_FORMAT_NONE);
|
||||
mpv_set_wakeup_callback(mpv, wakeup, this);
|
||||
|
||||
if (mpv_initialize(mpv) < 0)
|
||||
|
@ -425,6 +426,20 @@ DirectMpvPlayerBackend::playerCommand(const Enums::Commands& cmd,
|
|||
break;
|
||||
}
|
||||
|
||||
case Enums::Commands::GetPlaylist: {
|
||||
|
||||
return getProperty("playlist");
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case Enums::Commands::SetPlaylistPos: {
|
||||
|
||||
command(QVariantList() << "set" << "playlist-pos" << args);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default: {
|
||||
qDebug() << "Command not found: " << cmd;
|
||||
break;
|
||||
|
@ -553,6 +568,8 @@ DirectMpvPlayerBackend::handle_mpv_event(mpv_event* event)
|
|||
emit tracksChanged();
|
||||
} else if (strcmp(prop->name, "audio-device-list") == 0) {
|
||||
emit audioDevicesChanged();
|
||||
} else if (strcmp(prop->name, "playlist") == 0) {
|
||||
emit playlistChanged();
|
||||
}
|
||||
#ifdef DISCORD
|
||||
updateDiscord();
|
||||
|
|
|
@ -82,6 +82,7 @@ signals:
|
|||
void durationStringChanged(const QString& string);
|
||||
void tracksChanged();
|
||||
void audioDevicesChanged();
|
||||
void playlistChanged();
|
||||
|
||||
private slots:
|
||||
void doUpdate();
|
||||
|
|
|
@ -148,6 +148,7 @@ MpvPlayerBackend::MpvPlayerBackend(QQuickItem* parent)
|
|||
mpv_observe_property(mpv, 0, "time-pos", MPV_FORMAT_DOUBLE);
|
||||
mpv_observe_property(mpv, 0, "demuxer-cache-duration", MPV_FORMAT_DOUBLE);
|
||||
mpv_observe_property(mpv, 0, "pause", MPV_FORMAT_NONE);
|
||||
mpv_observe_property(mpv, 0, "playlist", MPV_FORMAT_NONE);
|
||||
mpv_set_wakeup_callback(mpv, wakeup, this);
|
||||
|
||||
if (mpv_initialize(mpv) < 0)
|
||||
|
@ -415,6 +416,20 @@ MpvPlayerBackend::playerCommand(const Enums::Commands& cmd,
|
|||
break;
|
||||
}
|
||||
|
||||
case Enums::Commands::GetPlaylist: {
|
||||
|
||||
return getProperty("playlist");
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case Enums::Commands::SetPlaylistPos: {
|
||||
|
||||
command(QVariantList() << "set" << "playlist-pos" << args);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
default: {
|
||||
qDebug() << "Command not found: " << cmd;
|
||||
break;
|
||||
|
@ -520,6 +535,8 @@ MpvPlayerBackend::handle_mpv_event(mpv_event* event)
|
|||
emit tracksChanged();
|
||||
} else if (strcmp(prop->name, "audio-device-list") == 0) {
|
||||
emit audioDevicesChanged();
|
||||
} else if (strcmp(prop->name, "playlist") == 0) {
|
||||
emit playlistChanged();
|
||||
}
|
||||
#ifdef DISCORD
|
||||
updateDiscord();
|
||||
|
|
|
@ -64,6 +64,8 @@ signals:
|
|||
void durationStringChanged(const QString& string);
|
||||
void tracksChanged();
|
||||
void audioDevicesChanged();
|
||||
void playlistChanged();
|
||||
|
||||
|
||||
private slots:
|
||||
void doUpdate();
|
||||
|
|
|
@ -44,7 +44,9 @@ enum class Commands : int
|
|||
GetTracks = 20,
|
||||
ForwardFrame = 21,
|
||||
BackwardFrame = 22,
|
||||
SetTrack = 23
|
||||
SetTrack = 23,
|
||||
GetPlaylist = 24,
|
||||
SetPlaylistPos = 25
|
||||
};
|
||||
Q_ENUM_NS(Commands)
|
||||
enum class Backends : int
|
||||
|
|
|
@ -124,6 +124,89 @@ MenuBar {
|
|||
}
|
||||
}
|
||||
|
||||
Dialog {
|
||||
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 {
|
||||
id: menuBarItem
|
||||
|
||||
|
@ -480,6 +563,13 @@ MenuBar {
|
|||
player.toggleOnTop()
|
||||
}
|
||||
}
|
||||
Action {
|
||||
text: translate.getTranslation("PLAYLIST_MENU",
|
||||
i18n.language)
|
||||
onTriggered: {
|
||||
playlistDialog.open()
|
||||
}
|
||||
}
|
||||
}
|
||||
CustomMenu {
|
||||
id: aboutMenuBarItem
|
||||
|
|
|
@ -42,7 +42,8 @@ var translations = {
|
|||
TOGGLE_ALWAYS_ON_TOP: "Toggle Always On Top",
|
||||
DISABLE_TRACK: "Disable Track",
|
||||
AUDIO_DEVICES: "Audio Devices",
|
||||
UPDATE: "Update"
|
||||
UPDATE: "Update",
|
||||
PLAYLIST_MENU: "Playlist Menu"
|
||||
},
|
||||
spanish: {
|
||||
SAVE_SCREENSHOT: "Guardar captura en",
|
||||
|
|
Loading…
Reference in a new issue