1
0
Fork 0

[UI] Optimized track list a bit.

This commit is contained in:
Kitteh 2018-11-04 13:21:50 +00:00
parent 09cca0e017
commit e4f64c1c7f
3 changed files with 22 additions and 18 deletions

View file

@ -249,6 +249,11 @@ void MpvPlayerBackend::seek(const QVariant &seekTime)
mpv::qt::command_variant(mpv, QVariantList() << "seek" << seekTime);
}
QVariant MpvPlayerBackend::getTracks() const
{
return mpv::qt::get_property_variant(mpv, "track-list");
}
void MpvPlayerBackend::on_mpv_events()
{
while (mpv) {

View file

@ -38,6 +38,8 @@ public slots:
void nextSubtitleTrack();
void prevPlaylistItem();
void nextPlaylistItem();
QVariant getTracks() const;
void setVolume(const QVariant& volume);
void addVolume(const QVariant& volume);
void loadFile(const QVariant& filename);

View file

@ -30,30 +30,23 @@ ApplicationWindow {
}
function tracksMenuUpdate() {
var tracks = player.getProperty("track-list/count")
var track = 0
subModel.clear()
audioModel.clear()
vidModel.clear()
var newTracks = player.getTracks()
var aid = player.getProperty("aid")
var sid = player.getProperty("sid")
var vid = player.getProperty("vid")
for (track = 0; track <= tracks; track++) {
var trackID = player.getProperty("track-list/" + track + "/id")
var trackType = player.getProperty("track-list/" + track + "/type")
var trackLang = LanguageCodes.localeCodeToEnglish(
String(player.getProperty(
"track-list/" + track + "/lang")))
var trackTitle = player.getProperty(
"track-list/" + track + "/title")
for(var i=0, len=newTracks.length; i < len; i++){
var track = newTracks[i]
var trackID = track["id"]
var trackType = track["type"]
var trackLang = LanguageCodes.localeCodeToEnglish(track["lang"])
var trackTitle = track["title"]
if (trackType == "sub") {
subModel.append({
key: trackLang,
value: trackID
})
if (player.getProperty("track-list/" + track + "/selected")) {
if (track["selected"]) {
subList.currentIndex = subList.count - 1
}
} else if (trackType == "audio") {
@ -62,7 +55,7 @@ ApplicationWindow {
+ trackLang,
value: trackID
})
if (player.getProperty("track-list/" + track + "/selected")) {
if (track["selected"]) {
audioList.currentIndex = audioList.count - 1
}
} else if (trackType == "video") {
@ -70,7 +63,7 @@ ApplicationWindow {
key: "Video " + trackID,
value: trackID
})
if (player.getProperty("track-list/" + track + "/selected")) {
if (track["selected"]) {
vidList.currentIndex = vidList.count - 1
}
}
@ -820,9 +813,10 @@ ApplicationWindow {
Rectangle {
id: subtitlesMenu
color: "transparent"
width: childrenRect.width
width: controlsBar.width / 2
height: childrenRect.height
visible: false
z:90000
anchors.centerIn: player
border.color: "black"
border.width: 2
@ -841,6 +835,7 @@ ApplicationWindow {
ComboBox {
id: audioList
textRole: "key"
width: parent.width
anchors.top: audioLabel.bottom
model: ListModel {
id: audioModel
@ -866,6 +861,7 @@ ApplicationWindow {
ComboBox {
id: subList
textRole: "key"
width: parent.width
anchors.top: subLabel.bottom
model: ListModel {
id: subModel
@ -891,6 +887,7 @@ ApplicationWindow {
ComboBox {
id: vidList
textRole: "key"
width: parent.width
anchors.top: vidLabel.bottom
model: ListModel {
id: vidModel