Debian Codegraph @

src/qml/Haruna/Components/AudioTracksMenu.qml

raw
1 /*
2 * SPDX-FileCopyrightText: 2023 George Florea Bănuș <[email protected]>
3 *
4 * SPDX-License-Identifier: GPL-3.0-or-later
5 */
6
7 pragma ComponentBehavior: Bound
8
9 import QtQuick
10 import QtQuick.Controls
11
12 import org.kde.haruna
13
14 Menu {
15 id: root
16
17 required property MpvVideo m_mpv
18
19 property TracksModel model: m_mpv.audioTracksModel
20
21 enabled: model.rowCount > 0
22
23 contentItem: ListView {
24 property bool hasCheckables: false
25 property bool hasIcons: false
26
27 model: root.model
28 implicitWidth: contentItem.children.reduce((maxWidth, child) => Math.max(maxWidth, child.implicitWidth), 0)
29 implicitHeight: Math.max(1, contentItem.childrenRect.height)
30 spacing: 0
31 clip: true
32 delegate: MenuItem {
33 id: delegate
34
35 required property int trackId
36 required property string displayText
37 required property string language
38 required property string title
39 required property string codec
40
41 checkable: true
42 checked: delegate.trackId === root.m_mpv.audioId
43 text: delegate.displayText
44 onTriggered: {
45 root.m_mpv.audioId = delegate.trackId
46 }
47 }
48 }
49 }