Debian Codegraph @

src/qml/Settings/PlaylistSettings.qml

raw
1 /*
2 * SPDX-FileCopyrightText: 2020 George Florea Bănuș <[email protected]>
3 *
4 * SPDX-License-Identifier: GPL-3.0-or-later
5 */
6
7 import QtQuick
8 import QtQuick.Layouts
9 import QtQuick.Controls
10
11 import org.kde.kirigami as Kirigami
12 import org.kde.haruna
13 import org.kde.haruna.settings
14
15 SettingsBasePage {
16 id: root
17
18 GridLayout {
19 id: content
20
21 columns: 2
22
23 Label {
24 text: i18nc("@label:listbox", "Position")
25 Layout.alignment: Qt.AlignRight
26 }
27
28 ComboBox {
29 textRole: "text"
30 valueRole: "value"
31 model: ListModel {
32 id: positionModel
33 }
34 Component.onCompleted: {
35 const left = {
36 text: i18nc("@item:listbox playlist position", "Left"),
37 value: "left"
38 }
39 positionModel.append(left)
40
41 const right = {
42 text: i18nc("@item:listbox playlist position", "Right"),
43 value: "right"
44 }
45 positionModel.append(right)
46
47 currentIndex = indexOfValue(PlaylistSettings.position)
48 }
49
50 onActivated: function(index) {
51 PlaylistSettings.position = model.get(index).value
52 PlaylistSettings.save()
53 }
54 }
55
56 Label {
57 text: i18nc("@label:listbox", "Playlist style")
58 Layout.alignment: Qt.AlignRight
59 }
60
61 ComboBox {
62 textRole: "text"
63 valueRole: "value"
64 model: ListModel {
65 id: styleModel
66 }
67 Component.onCompleted: {
68 const defaultStyle = {
69 text: i18nc("@item:listbox the style of the playlist", "Default"),
70 value: "default"
71 }
72 styleModel.append(defaultStyle)
73
74 const thumbnail = {
75 text: i18nc("@item:listbox the style of the playlist", "With thumbnails"),
76 value: "withThumbnails"
77 }
78 styleModel.append(thumbnail)
79
80 const compact = {
81 text: i18nc("@item:listbox the style of the playlist", "Compact"),
82 value: "compact"
83 }
84 styleModel.append(compact)
85
86 currentIndex = indexOfValue(PlaylistSettings.style)
87 }
88 onActivated: function(index) {
89 PlaylistSettings.style = model.get(index).value
90 PlaylistSettings.save()
91 }
92 }
93
94 Label {
95 text: i18nc("@label:listbox", "Playback behavior")
96 Layout.alignment: Qt.AlignRight
97 }
98
99 RowLayout {
100 ComboBox {
101 id: playbackBehaviorComboBox
102 textRole: "text"
103 valueRole: "value"
104 model: ListModel {
105 id: playbackBehaviorModel
106 }
107 Component.onCompleted: {
108 const repeat = {
109 text: i18nc("@item:listbox the playback behavior of the playlist", "Repeat playlist"),
110 value: "RepeatPlaylist"
111 }
112 playbackBehaviorModel.append(repeat)
113
114 const stopAfterLast = {
115 text: i18nc("@item:listbox the playback behavior of the playlist", "Stop after last item"),
116 value: "StopAfterLast"
117 }
118 playbackBehaviorModel.append(stopAfterLast)
119
120 const repeatItem = {
121 text: i18nc("@item:listbox the playback behavior of the playlist", "Repeat item"),
122 value: "RepeatItem"
123 }
124 playbackBehaviorModel.append(repeatItem)
125
126 const stopAfterItem = {
127 text: i18nc("@item:listbox the playback behavior of the playlist", "Stop after item"),
128 value: "StopAfterItem"
129 }
130 playbackBehaviorModel.append(stopAfterItem)
131
132 currentIndex = indexOfValue(PlaylistSettings.playbackBehavior)
133 }
134 onActivated: function(index) {
135 PlaylistSettings.playbackBehavior = model.get(index).value
136 PlaylistSettings.save()
137 }
138 // When changed from mpris or toolbar, sync the GUI:
139 Connections {
140 target: PlaylistSettings
141 function onPlaybackBehaviorChanged() {
142 const comboBox = playbackBehaviorComboBox
143 comboBox.currentIndex = comboBox.indexOfValue(PlaylistSettings.playbackBehavior)
144 }
145 }
146 }
147
148 ToolTipButton {
149 toolTipText: i18nc("@info:tooltip playback description",
150 "<strong>Repeat playlist</strong>: playlist is repeated indefinitely<br>" +
151 "<strong>Stop after last item</strong>: playback stops after the last item in the playlist<br>" +
152 "<strong>Repeat item</strong>: current playing item is repeated indefinitely<br>" +
153 "<strong>Stop after item</strong>: playback stops after the current playing item")
154 toolTipWidth: Math.min(450, root.width)
155 }
156 }
157
158 Item { Layout.preferredWidth: 1; Layout.preferredHeight: 1 }
159 CheckBox {
160 checked: PlaylistSettings.randomPlayback
161 enabled: ["StopAfterLast", "RepeatPlaylist"].includes(PlaylistSettings.playbackBehavior)
162 text: i18nc("@item:listbox the playback behavior of the playlist", "Random playback")
163 onClicked: {
164 PlaylistSettings.randomPlayback = checked
165 PlaylistSettings.save()
166 }
167 }
168
169 Item { Layout.preferredWidth: 1; Layout.preferredHeight: 1 }
170 CheckBox {
171 checked: PlaylistSettings.showToolbar
172 text: i18nc("@option:check", "Show toolbar")
173 onClicked: {
174 PlaylistSettings.showToolbar = checked
175 PlaylistSettings.save()
176 }
177 }
178
179 Item { Layout.preferredWidth: 1; Layout.preferredHeight: 1 }
180 CheckBox {
181 checked: PlaylistSettings.overlayVideo
182 text: i18nc("@option:check", "Overlay video")
183 onClicked: {
184 PlaylistSettings.overlayVideo = checked
185 PlaylistSettings.save()
186 }
187
188 ToolTip {
189 text: i18nc("@info:tooltip", "When checked the playlist goes on top of the video\nWhen unchecked the video is resized")
190 }
191 }
192
193 Item { Layout.preferredWidth: 1; Layout.preferredHeight: 1 }
194 CheckBox {
195 checked: PlaylistSettings.showMediaTitle
196 text: i18nc("@option:check", "Show media title instead of file name")
197 onClicked: {
198 PlaylistSettings.showMediaTitle = checked
199 PlaylistSettings.save()
200 }
201 }
202
203 Item { Layout.preferredWidth: 1; Layout.preferredHeight: 1 }
204 CheckBox {
205 checked: PlaylistSettings.loadSiblings
206 text: i18nc("@option:check", "Auto load videos from same folder")
207 onClicked: {
208 PlaylistSettings.loadSiblings = checked
209 PlaylistSettings.save()
210 }
211 }
212
213 Item { Layout.preferredWidth: 1; Layout.preferredHeight: 1 }
214 CheckBox {
215 checked: PlaylistSettings.showRowNumber
216 text: i18nc("@option:check", "Show row number")
217 onClicked: {
218 PlaylistSettings.showRowNumber = checked
219 PlaylistSettings.save()
220 }
221 }
222
223 Item { Layout.preferredWidth: 1; Layout.preferredHeight: 1 }
224 CheckBox {
225 checked: PlaylistSettings.canToggleWithMouse
226 text: i18nc("@option:check", "Toggle with mouse")
227 onClicked: {
228 PlaylistSettings.canToggleWithMouse = checked
229 PlaylistSettings.save()
230 }
231 }
232
233 Item { Layout.preferredWidth: 1; Layout.preferredHeight: 1 }
234 CheckBox {
235 text: i18nc("@option:check", "Increase font size when fullscreen")
236 checked: PlaylistSettings.bigFontFullscreen
237 enabled: PlaylistSettings.style === "compact" ? false : true
238 onClicked: {
239 PlaylistSettings.bigFontFullscreen = checked
240 PlaylistSettings.save()
241 }
242 }
243
244 Item { Layout.preferredWidth: 1; Layout.preferredHeight: 1 }
245 CheckBox {
246 checked: PlaylistSettings.rememberState
247 text: i18nc("@option:check", "Remember last playlist state")
248 onClicked: {
249 PlaylistSettings.rememberState = checked
250 PlaylistSettings.save()
251 }
252
253 ToolTip {
254 text: i18nc("@info:tooltip", "When checked the playlist state (visible/hidden) "
255 + "is remembered across launches")
256 }
257 }
258
259 Item { Layout.preferredWidth: 1; Layout.preferredHeight: 1 }
260 CheckBox {
261 checked: PlaylistSettings.openWithSingleClick
262 text: i18nc("@option:check", "Open items with single click")
263 onClicked: {
264 PlaylistSettings.openWithSingleClick = checked
265 PlaylistSettings.save()
266 }
267 }
268
269 Item {
270 Layout.preferredWidth: Kirigami.Units.gridUnit
271 Layout.preferredHeight: Kirigami.Units.gridUnit
272 }
273 }
274 }