Debian Codegraph @

src/qml/Settings/GeneralSettings.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.utilities
14 import org.kde.haruna.settings
15
16 SettingsBasePage {
17 id: root
18
19 GridLayout {
20 id: content
21
22 columns: 2
23
24 // OSD Font Size
25 Label {
26 text: i18nc("@label:spinbox", "OSD font size")
27 Layout.alignment: Qt.AlignRight
28 }
29
30 SpinBox {
31 id: osdFontSize
32
33 editable: true
34 from: 0
35 to: 100
36 value: GeneralSettings.osdFontSize
37 onValueModified: {
38 GeneralSettings.osdFontSize = osdFontSize.value
39 GeneralSettings.save()
40 }
41 }
42
43 Label {
44 text: i18nc("@label:spinbox", "Maximum recent files")
45 Layout.alignment: Qt.AlignRight
46 }
47
48 RowLayout {
49 SpinBox {
50 id: maxRecentFiles
51
52 from: 0
53 to: 100
54 value: GeneralSettings.maxRecentFiles
55 onValueModified: {
56 GeneralSettings.maxRecentFiles = maxRecentFiles.value
57 GeneralSettings.save()
58 }
59 }
60
61 ToolButton {
62 text: i18nc("@action:button clear (delete from database) recent files", "Clear")
63 onClicked: recentFilesModel.deleteEntries()
64
65 ToolTip {
66 text: i18nc("@info:tooltip", "Deletes recent files from the database")
67 }
68 }
69
70 ToolTipButton {
71 toolTipText: i18nc("@info:tooltip", "The number of recent files to display. Enter 0 (zero) to disable.<br>" +
72 "Every opened file is stored.<br>Bold entries are files opened from the open file/url " +
73 "actions and from external apps (command line, file manager, drag and drop etc.).")
74 toolTipWidth: 450
75
76 Layout.preferredHeight: Kirigami.Units.iconSizes.medium
77 }
78 }
79
80 Item { Layout.preferredWidth: 1 }
81
82 RowLayout {
83 CheckBox {
84 text: i18nc("@option:check", "Allow only one instance")
85 checked: GeneralSettings.useSingleInstance
86 onClicked: {
87 GeneralSettings.useSingleInstance = checked
88 GeneralSettings.save()
89 }
90 }
91
92 ToolTipButton {
93 toolTipText: i18nc("@info:tooltip", "Trying to open another Haruna instance will do nothing.<br>"+
94 "Trying to open another file with Haruna will open the file in the running instance.")
95
96 Layout.preferredHeight: Kirigami.Units.iconSizes.medium
97 }
98 }
99
100 Item { Layout.preferredWidth: 1 }
101
102 RowLayout {
103 CheckBox {
104 text: i18nc("@option:check", "Add file to playlist")
105 checked: GeneralSettings.appendVideoToSingleInstance
106 enabled: GeneralSettings.useSingleInstance
107 onClicked: {
108 GeneralSettings.appendVideoToSingleInstance = checked
109 GeneralSettings.save()
110 }
111 }
112
113 ToolTipButton {
114 toolTipText: i18nc("@info:tooltip", "File will be added to the end of the playlist.")
115
116 Layout.preferredHeight: Kirigami.Units.iconSizes.medium
117 }
118 }
119
120 Item { Layout.preferredWidth: 1 }
121
122 CheckBox {
123 text: i18nc("@option:check", "Play new file")
124 checked: GeneralSettings.playNewFileInSingleInstance
125 enabled: GeneralSettings.useSingleInstance && GeneralSettings.appendVideoToSingleInstance
126 onClicked: {
127 GeneralSettings.playNewFileInSingleInstance = checked
128 GeneralSettings.save()
129 }
130 }
131
132
133 SettingsHeader {
134 text: i18nc("@title", "Interface")
135 Layout.columnSpan: 2
136 Layout.fillWidth: true
137 }
138
139 Label {
140 text: i18nc("@label:spinbox", "Footer style")
141 Layout.alignment: Qt.AlignRight
142 }
143
144 ComboBox {
145 textRole: "text"
146 valueRole: "value"
147 model: ListModel {
148 id: footerStyleModel
149 }
150 Component.onCompleted: {
151 const defaultStyle = {
152 text: i18nc("@item:listbox the footer style", "Default"),
153 value: "default"
154 }
155 footerStyleModel.append(defaultStyle)
156
157 const floatingStyle = {
158 text: i18nc("@item:listbox the footer style", "Floating"),
159 value: "floating"
160 }
161 footerStyleModel.append(floatingStyle)
162
163 currentIndex = indexOfValue(GeneralSettings.footerStyle)
164 }
165 onActivated: function(index) {
166 GeneralSettings.footerStyle = model.get(index).value
167 GeneralSettings.save()
168 }
169 }
170
171 Label {
172 text: i18nc("@label:listbox", "Show floating footer on")
173 Layout.alignment: Qt.AlignRight
174 }
175
176 RowLayout {
177 ComboBox {
178 textRole: "text"
179 valueRole: "value"
180 enabled: GeneralSettings.footerStyle === "floating"
181 model: ListModel {
182 id: floatingFooterTriggerModel
183 }
184
185 Component.onCompleted: {
186 const everyMovement = {
187 text: i18nc("@item:listbox how to trigger the floating footer", "Every mouse movement"),
188 value: "EveryMouseMovement"
189 }
190 floatingFooterTriggerModel.append(everyMovement)
191
192 const bottomMovement = {
193 text: i18nc("@item:listbox how to trigger the floating footer", "Bottom mouse movement"),
194 value: "BottomMouseMovement"
195 }
196 floatingFooterTriggerModel.append(bottomMovement)
197
198 currentIndex = indexOfValue(GeneralSettings.floatingFooterTrigger)
199 }
200 onActivated: function(index) {
201 GeneralSettings.floatingFooterTrigger = model.get(index).value
202 GeneralSettings.save()
203 }
204 }
205
206 ToolTipButton {
207 toolTipText: i18nc("@info:tooltip",
208 "What action shows the footer.<br>" +
209 "<strong>Every mouse movement</strong> — every mouse movement over the video area<br>" +
210 "<strong>Bottom mouse movement</strong> — mouse movement on the bottom of the video area")
211 }
212
213 }
214
215 Label {
216 text: i18nc("@label:spinbox", "Preview thumbnail")
217 Layout.alignment: Qt.AlignRight
218 }
219
220 CheckBox {
221 text: i18nc("@option:check", "Show preview thumbnail")
222 checked: GeneralSettings.showPreviewThumbnail
223 onClicked: {
224 GeneralSettings.showPreviewThumbnail = checked
225 GeneralSettings.save()
226 }
227
228 ToolTip.text: i18nc("@info:tooltip", "Shows a preview while hovering the seek/progress bar.")
229 ToolTip.visible: hovered
230 ToolTip.delay: 700
231 }
232
233 Item { Layout.preferredWidth: 1 }
234
235 RowLayout {
236 CheckBox {
237 text: i18nc("@option:check", "Use accurate preview")
238 checked: GeneralSettings.accuratePreviewThumbnail
239 enabled: GeneralSettings.showPreviewThumbnail
240 onClicked: {
241 GeneralSettings.accuratePreviewThumbnail = checked
242 GeneralSettings.save()
243 }
244 }
245
246 ToolTipButton {
247 toolTipText: i18nc("@info:tooltip", "Generating an accurate preview is slow")
248 icon.color: Kirigami.Theme.negativeTextColor
249
250 Layout.preferredHeight: Kirigami.Units.iconSizes.medium
251 }
252 }
253
254 Label {
255 text: i18nc("@label:spinbox", "Thumbnail width")
256 Layout.alignment: Qt.AlignRight
257 }
258
259 SpinBox {
260 id: previewThumbnailWidth
261
262 from: 100
263 to: 10000
264 value: GeneralSettings.previewThumbnailWidth
265 enabled: GeneralSettings.showPreviewThumbnail
266 onValueModified: {
267 GeneralSettings.previewThumbnailWidth = previewThumbnailWidth.value
268 GeneralSettings.save()
269 }
270 }
271
272 Label {
273 text: i18nc("@label", "Window")
274 Layout.alignment: Qt.AlignRight
275 }
276
277 RowLayout {
278 CheckBox {
279 text: i18nc("@option:check", "Resize to fit video")
280 checked: GeneralSettings.resizeWindowToVideo
281 enabled: !SystemUtils.isPlatformWayland()
282 onClicked: {
283 GeneralSettings.resizeWindowToVideo = checked
284 GeneralSettings.save()
285 }
286 }
287
288 ToolTipButton {
289 toolTipText: SystemUtils.isPlatformWayland()
290 ? i18nc("@info:tooltip","Not supported on Wayland.")
291 : i18nc("@info:tooltip", "The window is resized according to the video resolution.<br>" +
292 "The maximum size is not constrained, this is left to the operating system.")
293
294 Layout.preferredHeight: Kirigami.Units.iconSizes.medium
295 }
296 }
297
298 Item { Layout.preferredWidth: 1 }
299 RowLayout {
300 CheckBox {
301 text: i18nc("@option:check", "Start in fullscreen mode")
302 checked: GeneralSettings.fullscreenOnStartUp
303 onClicked: {
304 GeneralSettings.fullscreenOnStartUp = checked
305 GeneralSettings.save()
306 }
307 }
308
309 ToolTipButton {
310 toolTipText: i18nc("@info:tooltip", "Enter fullscreen mode when the application starts.<br>" +
311 "This takes precedence over Resize to fit video, and Remember window size and position settings.")
312
313 Layout.preferredHeight: Kirigami.Units.iconSizes.medium
314 }
315 }
316
317 Item { Layout.preferredWidth: 1 }
318
319 RowLayout {
320 CheckBox {
321 text: i18nc("@option:check", "Remember window size and position")
322 checked: GeneralSettings.rememberWindowGeometry
323 enabled: !GeneralSettings.resizeWindowToVideo
324 onClicked: {
325 GeneralSettings.rememberWindowGeometry = checked
326 GeneralSettings.save()
327 }
328 }
329
330 ToolTipButton {
331 readonly property
332 string waylandMessage: SystemUtils.isPlatformWayland()
333 ? i18nc("@info:tooltip extra wayland info for the “Remember window size and position” setting",
334 "<b>Restoring position is not supported on Wayland.</b><br><br>")
335 : ""
336 toolTipText: i18nc("@info:tooltip", "Changes to the window’s size and position "
337 +"are saved and used for newly opened windows.<br><br>"
338 +"%1The “Resize to fit video” setting takes precedence.", waylandMessage)
339 icon.color: SystemUtils.isPlatformWayland() ? Kirigami.Theme.negativeTextColor : Kirigami.Theme.textColor
340
341 Layout.preferredHeight: Kirigami.Units.iconSizes.medium
342 }
343 }
344
345 Item { Layout.preferredWidth: 1 }
346
347 CheckBox {
348 text: i18nc("@option:check", "Show menubar")
349 checked: GeneralSettings.showMenuBar
350 onClicked: {
351 GeneralSettings.showMenuBar = checked
352 GeneralSettings.save()
353 }
354 }
355
356 Item { Layout.preferredWidth: 1 }
357
358 CheckBox {
359 text: i18nc("@option:check", "Show toolbar")
360 checked: GeneralSettings.showHeader
361 onClicked: {
362 GeneralSettings.showHeader = checked
363 GeneralSettings.save()
364 }
365 }
366
367 Item { Layout.preferredWidth: 1 }
368
369 CheckBox {
370 text: i18nc("@option:check", "Show chapter markers")
371 checked: GeneralSettings.showChapterMarkers
372 onClicked: {
373 GeneralSettings.showChapterMarkers = checked
374 GeneralSettings.save()
375 }
376 }
377
378 Item { Layout.preferredWidth: 1 }
379
380 CheckBox {
381 text: i18nc("@option:check", "Show progress on taskbar icon")
382 checked: GeneralSettings.showTaskbarProgress
383 onClicked: {
384 GeneralSettings.showTaskbarProgress = checked
385 GeneralSettings.save()
386 }
387 }
388
389 Label {
390 text: i18nc("@label:listbox", "Color scheme")
391 Layout.alignment: Qt.AlignRight
392 }
393
394 ComboBox {
395 id: colorThemeSwitcher
396
397 textRole: "display"
398 model: HarunaApp.colorSchemesModel
399 delegate: ItemDelegate {
400 id: delegate
401
402 required property var model
403
404 Kirigami.Theme.colorSet: Kirigami.Theme.View
405 width: ListView.view.width
406 highlighted: delegate.model.display === GeneralSettings.colorScheme
407 contentItem: RowLayout {
408 Kirigami.Icon {
409 source: delegate.model.decoration
410 Layout.preferredHeight: Kirigami.Units.iconSizes.small
411 Layout.preferredWidth: Kirigami.Units.iconSizes.small
412 }
413 Label {
414 text: delegate.model.display
415 color: delegate.highlighted ? Kirigami.Theme.highlightedTextColor : Kirigami.Theme.textColor
416 Layout.fillWidth: true
417 }
418 }
419 }
420
421 onActivated: function(index) {
422 GeneralSettings.colorScheme = colorThemeSwitcher.textAt(index)
423 GeneralSettings.save()
424 }
425
426 Component.onCompleted: {
427 currentIndex = find(GeneralSettings.colorScheme)
428 if (currentIndex === -1) {
429 currentIndex = find("Default")
430 }
431 }
432 }
433
434 Label {
435 text: i18nc("@label:listbox", "GUI style")
436 Layout.alignment: Qt.AlignRight
437 }
438
439 ComboBox {
440 id: guiStyleComboBox
441
442 textRole: "text"
443 valueRole: "value"
444 model: ListModel {
445 id: stylesModel
446 }
447
448 onActivated: function(index) {
449 GeneralSettings.guiStyle = model.get(index).value
450 HarunaApp.setGuiStyle(GeneralSettings.guiStyle)
451 // some themes can cause a crash
452 // the timer prevents saving the crashing theme,
453 // which would cause the app to crash on startup
454 saveGuiStyleTimer.start()
455 }
456
457 Timer {
458 id: saveGuiStyleTimer
459
460 interval: 1000
461 running: false
462 repeat: false
463 onTriggered: GeneralSettings.save()
464 }
465
466 Component.onCompleted: {
467 const defaultStyle = {
468 text: i18nc("@item:listbox default GUI style", "Default"),
469 value: "Default"
470 }
471 stylesModel.append(defaultStyle)
472
473
474 // populate the model with the available styles
475 const styles = HarunaApp.availableGuiStyles()
476 for (let i = 0; i < styles.length; ++i) {
477 const style = {
478 text: styles[i],
479 value: styles[i]
480 }
481 stylesModel.append(style)
482 }
483
484 // set the saved style as the current item in the combo box
485 currentIndex = indexOfValue(GeneralSettings.guiStyle)
486 }
487 }
488
489 Item {
490 Layout.preferredWidth: Kirigami.Units.gridUnit
491 Layout.preferredHeight: Kirigami.Units.gridUnit
492 }
493 }
494 }