| 1 |
/* |
| 2 |
* SPDX-FileCopyrightText: 2022 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 QtQml |
| 10 |
import QtQuick |
| 11 |
import Qt.labs.platform as Labs |
| 12 |
|
| 13 |
import org.kde.haruna |
| 14 |
|
| 15 |
Labs.Menu { |
| 16 |
id: root |
| 17 |
|
| 18 |
required property MpvVideo m_mpv |
| 19 |
|
| 20 |
title: i18nc("@title:menu", "&Subtitles") |
| 21 |
|
| 22 |
Labs.Menu { |
| 23 |
id: primarySubtitleMenu |
| 24 |
|
| 25 |
title: i18nc("@title:menu", "Primary Subtitle") |
| 26 |
enabled: root.m_mpv.subtitleTracksModel.rowCount > 1 |
| 27 |
|
| 28 |
Instantiator { |
| 29 |
model: root.m_mpv.subtitleTracksModel |
| 30 |
delegate: Labs.MenuItem { |
| 31 |
id: primarySubDelegate |
| 32 |
|
| 33 |
required property string displayText |
| 34 |
required property string language |
| 35 |
required property string title |
| 36 |
required property string codec |
| 37 |
required property string trackId |
| 38 |
|
| 39 |
enabled: primarySubDelegate.trackId !== root.m_mpv.secondarySubtitleId || primarySubDelegate.trackId === 0 |
| 40 |
checkable: true |
| 41 |
checked: primarySubDelegate.trackId === root.m_mpv.subtitleId |
| 42 |
text: primarySubDelegate.displayText |
| 43 |
onTriggered: { |
| 44 |
root.m_mpv.subtitleId = primarySubDelegate.trackId |
| 45 |
} |
| 46 |
} |
| 47 |
onObjectAdded: function(index, object) { |
| 48 |
primarySubtitleMenu.insertItem(index, object) |
| 49 |
} |
| 50 |
onObjectRemoved: function(index, object) { |
| 51 |
primarySubtitleMenu.removeItem(object) |
| 52 |
} |
| 53 |
} |
| 54 |
} |
| 55 |
|
| 56 |
Labs.Menu { |
| 57 |
id: secondarySubtitleMenu |
| 58 |
|
| 59 |
title: i18nc("@title:menu", "Secondary Subtitle") |
| 60 |
enabled: root.m_mpv.subtitleTracksModel.rowCount > 1 |
| 61 |
|
| 62 |
Instantiator { |
| 63 |
model: root.m_mpv.subtitleTracksModel |
| 64 |
delegate: Labs.MenuItem { |
| 65 |
id: secondarySubDelegate |
| 66 |
|
| 67 |
required property string displayText |
| 68 |
required property string language |
| 69 |
required property string title |
| 70 |
required property string codec |
| 71 |
required property string trackId |
| 72 |
|
| 73 |
enabled: secondarySubDelegate.trackId !== root.m_mpv.subtitleId || secondarySubDelegate.trackId === 0 |
| 74 |
checkable: true |
| 75 |
checked: secondarySubDelegate.trackId === root.m_mpv.secondarySubtitleId |
| 76 |
text: secondarySubDelegate.displayText |
| 77 |
onTriggered: { |
| 78 |
root.m_mpv.secondarySubtitleId = secondarySubDelegate.trackId |
| 79 |
} |
| 80 |
} |
| 81 |
onObjectAdded: function(index, object) { |
| 82 |
secondarySubtitleMenu.insertItem(index, object) |
| 83 |
} |
| 84 |
onObjectRemoved: function(index, object) { |
| 85 |
secondarySubtitleMenu.removeItem(object) |
| 86 |
} |
| 87 |
} |
| 88 |
} |
| 89 |
|
| 90 |
Labs.MenuSeparator {} |
| 91 |
|
| 92 |
Labs.MenuItem { |
| 93 |
icon.name: HarunaApp.actions.addExternalSubtitleAction.icon.name |
| 94 |
text: HarunaApp.actions.addExternalSubtitleAction.text |
| 95 |
onTriggered: HarunaApp.actions.addExternalSubtitleAction.trigger() |
| 96 |
} |
| 97 |
|
| 98 |
Labs.MenuItem { |
| 99 |
icon.name: HarunaApp.actions.subtitleIncreaseFontSizeAction.icon.name |
| 100 |
text: HarunaApp.actions.subtitleIncreaseFontSizeAction.text |
| 101 |
onTriggered: HarunaApp.actions.subtitleIncreaseFontSizeAction.trigger() |
| 102 |
} |
| 103 |
|
| 104 |
Labs.MenuItem { |
| 105 |
icon.name: HarunaApp.actions.subtitleDecreaseFontSizeAction.icon.name |
| 106 |
text: HarunaApp.actions.subtitleDecreaseFontSizeAction.text |
| 107 |
onTriggered: HarunaApp.actions.subtitleDecreaseFontSizeAction.trigger() |
| 108 |
} |
| 109 |
|
| 110 |
Labs.MenuItem { |
| 111 |
icon.name: HarunaApp.actions.subtitleMoveUpAction.icon.name |
| 112 |
text: HarunaApp.actions.subtitleMoveUpAction.text |
| 113 |
onTriggered: HarunaApp.actions.subtitleMoveUpAction.trigger() |
| 114 |
} |
| 115 |
|
| 116 |
Labs.MenuItem { |
| 117 |
icon.name: HarunaApp.actions.subtitleMoveDownAction.icon.name |
| 118 |
text: HarunaApp.actions.subtitleMoveDownAction.text |
| 119 |
onTriggered: HarunaApp.actions.subtitleMoveDownAction.trigger() |
| 120 |
} |
| 121 |
|
| 122 |
Labs.MenuItem { |
| 123 |
icon.name: HarunaApp.actions.subtitleQuickenAction.icon.name |
| 124 |
text: HarunaApp.actions.subtitleQuickenAction.text |
| 125 |
onTriggered: HarunaApp.actions.subtitleQuickenAction.trigger() |
| 126 |
} |
| 127 |
|
| 128 |
Labs.MenuItem { |
| 129 |
icon.name: HarunaApp.actions.subtitleDelayAction.icon.name |
| 130 |
text: HarunaApp.actions.subtitleDelayAction.text |
| 131 |
onTriggered: HarunaApp.actions.subtitleDelayAction.trigger() |
| 132 |
} |
| 133 |
|
| 134 |
Labs.MenuItem { |
| 135 |
icon.name: HarunaApp.actions.subtitleToggleAction.icon.name |
| 136 |
text: HarunaApp.actions.subtitleToggleAction.text |
| 137 |
onTriggered: HarunaApp.actions.subtitleToggleAction.trigger() |
| 138 |
} |
| 139 |
|
| 140 |
Labs.MenuItem { |
| 141 |
icon.name: HarunaApp.actions.subtitleCycleUpAction.icon.name |
| 142 |
text: HarunaApp.actions.subtitleCycleUpAction.text |
| 143 |
onTriggered: HarunaApp.actions.subtitleCycleUpAction.trigger() |
| 144 |
} |
| 145 |
|
| 146 |
Labs.MenuItem { |
| 147 |
icon.name: HarunaApp.actions.subtitleCycleDownAction.icon.name |
| 148 |
text: HarunaApp.actions.subtitleCycleDownAction.text |
| 149 |
onTriggered: HarunaApp.actions.subtitleCycleDownAction.trigger() |
| 150 |
} |
| 151 |
|
| 152 |
} |