[UI] Optimized track list a bit.
This commit is contained in:
parent
09cca0e017
commit
e4f64c1c7f
|
@ -249,6 +249,11 @@ void MpvPlayerBackend::seek(const QVariant &seekTime)
|
||||||
mpv::qt::command_variant(mpv, QVariantList() << "seek" << 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()
|
void MpvPlayerBackend::on_mpv_events()
|
||||||
{
|
{
|
||||||
while (mpv) {
|
while (mpv) {
|
||||||
|
|
|
@ -38,6 +38,8 @@ public slots:
|
||||||
void nextSubtitleTrack();
|
void nextSubtitleTrack();
|
||||||
void prevPlaylistItem();
|
void prevPlaylistItem();
|
||||||
void nextPlaylistItem();
|
void nextPlaylistItem();
|
||||||
|
QVariant getTracks() const;
|
||||||
|
|
||||||
void setVolume(const QVariant& volume);
|
void setVolume(const QVariant& volume);
|
||||||
void addVolume(const QVariant& volume);
|
void addVolume(const QVariant& volume);
|
||||||
void loadFile(const QVariant& filename);
|
void loadFile(const QVariant& filename);
|
||||||
|
|
|
@ -30,30 +30,23 @@ ApplicationWindow {
|
||||||
}
|
}
|
||||||
|
|
||||||
function tracksMenuUpdate() {
|
function tracksMenuUpdate() {
|
||||||
var tracks = player.getProperty("track-list/count")
|
|
||||||
var track = 0
|
|
||||||
subModel.clear()
|
subModel.clear()
|
||||||
audioModel.clear()
|
audioModel.clear()
|
||||||
vidModel.clear()
|
vidModel.clear()
|
||||||
|
var newTracks = player.getTracks()
|
||||||
|
|
||||||
var aid = player.getProperty("aid")
|
for(var i=0, len=newTracks.length; i < len; i++){
|
||||||
var sid = player.getProperty("sid")
|
var track = newTracks[i]
|
||||||
var vid = player.getProperty("vid")
|
var trackID = track["id"]
|
||||||
|
var trackType = track["type"]
|
||||||
for (track = 0; track <= tracks; track++) {
|
var trackLang = LanguageCodes.localeCodeToEnglish(track["lang"])
|
||||||
var trackID = player.getProperty("track-list/" + track + "/id")
|
var trackTitle = track["title"]
|
||||||
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")
|
|
||||||
if (trackType == "sub") {
|
if (trackType == "sub") {
|
||||||
subModel.append({
|
subModel.append({
|
||||||
key: trackLang,
|
key: trackLang,
|
||||||
value: trackID
|
value: trackID
|
||||||
})
|
})
|
||||||
if (player.getProperty("track-list/" + track + "/selected")) {
|
if (track["selected"]) {
|
||||||
subList.currentIndex = subList.count - 1
|
subList.currentIndex = subList.count - 1
|
||||||
}
|
}
|
||||||
} else if (trackType == "audio") {
|
} else if (trackType == "audio") {
|
||||||
|
@ -62,7 +55,7 @@ ApplicationWindow {
|
||||||
+ trackLang,
|
+ trackLang,
|
||||||
value: trackID
|
value: trackID
|
||||||
})
|
})
|
||||||
if (player.getProperty("track-list/" + track + "/selected")) {
|
if (track["selected"]) {
|
||||||
audioList.currentIndex = audioList.count - 1
|
audioList.currentIndex = audioList.count - 1
|
||||||
}
|
}
|
||||||
} else if (trackType == "video") {
|
} else if (trackType == "video") {
|
||||||
|
@ -70,7 +63,7 @@ ApplicationWindow {
|
||||||
key: "Video " + trackID,
|
key: "Video " + trackID,
|
||||||
value: trackID
|
value: trackID
|
||||||
})
|
})
|
||||||
if (player.getProperty("track-list/" + track + "/selected")) {
|
if (track["selected"]) {
|
||||||
vidList.currentIndex = vidList.count - 1
|
vidList.currentIndex = vidList.count - 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -820,9 +813,10 @@ ApplicationWindow {
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: subtitlesMenu
|
id: subtitlesMenu
|
||||||
color: "transparent"
|
color: "transparent"
|
||||||
width: childrenRect.width
|
width: controlsBar.width / 2
|
||||||
height: childrenRect.height
|
height: childrenRect.height
|
||||||
visible: false
|
visible: false
|
||||||
|
z:90000
|
||||||
anchors.centerIn: player
|
anchors.centerIn: player
|
||||||
border.color: "black"
|
border.color: "black"
|
||||||
border.width: 2
|
border.width: 2
|
||||||
|
@ -841,6 +835,7 @@ ApplicationWindow {
|
||||||
ComboBox {
|
ComboBox {
|
||||||
id: audioList
|
id: audioList
|
||||||
textRole: "key"
|
textRole: "key"
|
||||||
|
width: parent.width
|
||||||
anchors.top: audioLabel.bottom
|
anchors.top: audioLabel.bottom
|
||||||
model: ListModel {
|
model: ListModel {
|
||||||
id: audioModel
|
id: audioModel
|
||||||
|
@ -866,6 +861,7 @@ ApplicationWindow {
|
||||||
ComboBox {
|
ComboBox {
|
||||||
id: subList
|
id: subList
|
||||||
textRole: "key"
|
textRole: "key"
|
||||||
|
width: parent.width
|
||||||
anchors.top: subLabel.bottom
|
anchors.top: subLabel.bottom
|
||||||
model: ListModel {
|
model: ListModel {
|
||||||
id: subModel
|
id: subModel
|
||||||
|
@ -891,6 +887,7 @@ ApplicationWindow {
|
||||||
ComboBox {
|
ComboBox {
|
||||||
id: vidList
|
id: vidList
|
||||||
textRole: "key"
|
textRole: "key"
|
||||||
|
width: parent.width
|
||||||
anchors.top: vidLabel.bottom
|
anchors.top: vidLabel.bottom
|
||||||
model: ListModel {
|
model: ListModel {
|
||||||
id: vidModel
|
id: vidModel
|
||||||
|
|
Loading…
Reference in a new issue