feat: rebuild the interface after Haruna
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
54ad4eecf3
commit
614a31db1b
45 files changed
+3818
-798
No files matched your search
@@ -0,0 +1,64 @@
|
||||
// SPDX-FileCopyrightText: 2020 George Florea Bănuș <georgefb899@gmail.com>
|
||||
// SPDX-FileCopyrightText: 2026 Tri Vo Khac
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
pragma ComponentBehavior: Bound
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import org.kde.ki18n
|
||||
|
||||
// Checkable list of subtitle tracks, for the primary or the secondary subtitle.
|
||||
Menu {
|
||||
id: root
|
||||
|
||||
required property MpvItem mpv
|
||||
property bool isPrimary: true
|
||||
|
||||
readonly property int selectedId: isPrimary ? mpv.subtitleId : mpv.secondarySubtitleId
|
||||
readonly property int otherId: isPrimary ? mpv.secondarySubtitleId : mpv.subtitleId
|
||||
|
||||
function trackLabel(track: var): string {
|
||||
const name = track.title || (track.external ? track.externalFilename.split("/").pop() : "")
|
||||
const lang = track.lang ? `[${track.lang}]` : ""
|
||||
const description = [name, lang].filter(part => part.length > 0).join(" ")
|
||||
return KI18n.i18nc("@item:inmenu subtitle track number and description", "%1: %2",
|
||||
track.id, description || KI18n.i18nc("@item:inmenu", "Untitled"))
|
||||
}
|
||||
|
||||
function select(id: int) {
|
||||
if (root.isPrimary) {
|
||||
root.mpv.subtitleId = id
|
||||
} else {
|
||||
root.mpv.secondarySubtitleId = id
|
||||
}
|
||||
}
|
||||
|
||||
enabled: mpv.subtitleTracks.length > 0
|
||||
|
||||
MenuItem {
|
||||
text: KI18n.i18nc("@item:inmenu no subtitle", "None")
|
||||
checkable: true
|
||||
checked: root.selectedId === 0
|
||||
onTriggered: {
|
||||
root.select(0)
|
||||
// Clicking a checked item unchecks it, which drops the binding.
|
||||
checked = Qt.binding(() => root.selectedId === 0)
|
||||
}
|
||||
}
|
||||
|
||||
Instantiator {
|
||||
model: root.mpv.subtitleTracks
|
||||
delegate: MenuItem {
|
||||
required property var modelData
|
||||
text: root.trackLabel(modelData)
|
||||
checkable: true
|
||||
checked: modelData.id === root.selectedId
|
||||
// mpv cannot show one track in both places.
|
||||
enabled: modelData.id !== root.otherId
|
||||
onTriggered: root.select(modelData.id)
|
||||
}
|
||||
onObjectAdded: (index, object) => root.insertItem(index + 1, object)
|
||||
onObjectRemoved: (index, object) => root.removeItem(object)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user