Warning, /multimedia/haruna/src/qml/Settings/PlaybackSettings.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 * SPDX-FileCopyrightText: 2020 George Florea Bănuș <georgefb899@gmail.com> 0003 * 0004 * SPDX-License-Identifier: GPL-3.0-or-later 0005 */ 0006 0007 import QtQuick 0008 import QtQuick.Layouts 0009 import QtQuick.Controls 0010 0011 import org.kde.kirigami as Kirigami 0012 import org.kde.haruna 0013 import org.kde.haruna.mpvproperties 0014 import org.kde.haruna.settings 0015 0016 SettingsBasePage { 0017 id: root 0018 0019 hasHelp: true 0020 helpFile: ":/PlaybackSettings.html" 0021 docPage: "help:/haruna/PlaybackSettings.html" 0022 0023 GridLayout { 0024 id: content 0025 0026 columns: 2 0027 0028 // Seek Small Step 0029 Label { 0030 text: i18nc("@label:spinbox", "Seek small step") 0031 Layout.alignment: Qt.AlignRight 0032 } 0033 0034 SpinBox { 0035 id: seekSmallStep 0036 editable: true 0037 from: 0 0038 to: 100 0039 value: PlaybackSettings.seekSmallStep 0040 onValueChanged: { 0041 PlaybackSettings.seekSmallStep = seekSmallStep.value 0042 PlaybackSettings.save() 0043 } 0044 } 0045 0046 // Seek Medium Step 0047 Label { 0048 text: i18nc("@label:spinbox", "Seek medium step") 0049 Layout.alignment: Qt.AlignRight 0050 } 0051 0052 RowLayout { 0053 0054 SpinBox { 0055 id: seekMediumStep 0056 editable: true 0057 from: 0 0058 to: 100 0059 value: PlaybackSettings.seekMediumStep 0060 onValueChanged: { 0061 PlaybackSettings.seekMediumStep = seekMediumStep.value 0062 PlaybackSettings.save() 0063 } 0064 } 0065 0066 ToolButton { 0067 icon.name: "documentinfo" 0068 checkable: true 0069 checked: false 0070 0071 Layout.preferredHeight: seekMediumStep.height 0072 0073 ToolTip { 0074 text: i18nc("@info:tooltip", "This is also used for mouse wheel seeking, when mouse is over the progress bar") 0075 visible: parent.checked 0076 delay: 0 0077 timeout: -1 0078 closePolicy: Popup.NoAutoClose 0079 } 0080 } 0081 } 0082 0083 // Seek Big Step 0084 Label { 0085 text: i18nc("@label:spinbox", "Seek big step") 0086 Layout.alignment: Qt.AlignRight 0087 } 0088 0089 SpinBox { 0090 id: seekBigStep 0091 editable: true 0092 from: 0 0093 to: 100 0094 value: PlaybackSettings.seekBigStep 0095 onValueChanged: { 0096 PlaybackSettings.seekBigStep = seekBigStep.value 0097 PlaybackSettings.save() 0098 } 0099 } 0100 0101 Item { width: 1 } 0102 0103 CheckBox { 0104 id: pauseOnMinimizeCheckBox 0105 0106 text: i18nc("@option:check", "Pause on minimize") 0107 checked: PlaybackSettings.pauseWhileMinimized 0108 onCheckedChanged: { 0109 PlaybackSettings.pauseWhileMinimized = checked 0110 PlaybackSettings.save() 0111 } 0112 0113 ToolTip { 0114 text: i18nc("@info:tooltip", "Pauses the player while the window is minimized, playback resumes when restored.") 0115 } 0116 } 0117 0118 Label { 0119 text: i18nc("@label:spinbox", "Resume playback") 0120 Layout.alignment: Qt.AlignRight 0121 } 0122 0123 CheckBox { 0124 id: loadLastPlayedFileCheckBox 0125 0126 text: i18nc("@option:check", "Open last played file on startup") 0127 checked: PlaybackSettings.openLastPlayedFile 0128 onCheckedChanged: { 0129 PlaybackSettings.openLastPlayedFile = checked 0130 PlaybackSettings.save() 0131 } 0132 } 0133 0134 Item { width: 1 } 0135 0136 CheckBox { 0137 id: seekToLastPositionCheckBox 0138 0139 text: i18nc("@option:check", "Seek to last playback position") 0140 checked: PlaybackSettings.seekToLastPosition 0141 onCheckedChanged: { 0142 PlaybackSettings.seekToLastPosition = checked 0143 PlaybackSettings.save() 0144 } 0145 0146 ToolTip { 0147 text: i18nc("@info:tooltip", "When opening a file that was played before, seek at the position it was last time.") 0148 } 0149 } 0150 0151 Item { width: 1 } 0152 0153 CheckBox { 0154 id: playOnResumeCheckBox 0155 0156 text: i18nc("@option:check", "Start playing") 0157 checked: PlaybackSettings.playOnResume 0158 enabled: seekToLastPositionCheckBox.checked 0159 onCheckedChanged: { 0160 PlaybackSettings.playOnResume = checked 0161 PlaybackSettings.save() 0162 } 0163 0164 ToolTip { 0165 text: i18nc("@info:tooltip", "When opening a file that was played before, start playing it automatically.") 0166 } 0167 } 0168 0169 Label { 0170 text: i18nc("@label", "Hardware decoding") 0171 Layout.alignment: Qt.AlignRight 0172 } 0173 0174 CheckBox { 0175 id: hwDecodingCheckBox 0176 text: checked ? i18nc("@option:check", "Enabled") : i18nc("@option:check", "Disabled") 0177 checked: PlaybackSettings.useHWDecoding 0178 onCheckedChanged: { 0179 PlaybackSettings.useHWDecoding = checked 0180 PlaybackSettings.save() 0181 } 0182 } 0183 0184 Item { width: 1 } 0185 0186 ComboBox { 0187 id: hwDecodingComboBox 0188 0189 enabled: hwDecodingCheckBox.checked 0190 textRole: "key" 0191 model: ListModel { 0192 id: hwDecModel 0193 ListElement { key: "auto"; } 0194 ListElement { key: "auto-safe"; } 0195 ListElement { key: "vaapi"; } 0196 ListElement { key: "nvdec"; } 0197 ListElement { key: "videotoolbox"; } 0198 ListElement { key: "vdpau"; } 0199 ListElement { key: "cuda"; } 0200 ListElement { key: "d3d11va"; } 0201 ListElement { key: "mmal"; } 0202 } 0203 0204 onActivated: function(index) { 0205 PlaybackSettings.hWDecoding = model.get(index).key 0206 PlaybackSettings.save() 0207 mpv.setProperty(MpvProperties.HardwareDecoding, PlaybackSettings.hWDecoding) 0208 } 0209 0210 Component.onCompleted: { 0211 for (let i = 0; i < hwDecModel.count; ++i) { 0212 if (hwDecModel.get(i).key === PlaybackSettings.hWDecoding) { 0213 currentIndex = i 0214 break 0215 } 0216 } 0217 } 0218 } 0219 0220 Label { 0221 text: i18nc("@label:spinbox", "Remember time position") 0222 Layout.alignment: Qt.AlignRight 0223 } 0224 0225 RowLayout { 0226 SpinBox { 0227 id: timePositionSaving 0228 from: -1 0229 to: 9999 0230 value: PlaybackSettings.minDurationToSavePosition 0231 0232 onValueChanged: { 0233 PlaybackSettings.minDurationToSavePosition = value 0234 PlaybackSettings.save() 0235 } 0236 } 0237 0238 LabelWithTooltip { 0239 text: { 0240 if (timePositionSaving.value === -1) { 0241 return i18nc("@info", "Disabled") 0242 } else if (timePositionSaving.value === 0) { 0243 return i18nc("@info", "For all files") 0244 } else { 0245 return i18ncp("@info", 0246 "For files longer than %1 minute", 0247 "For files longer than %1 minutes", 0248 timePositionSaving.value) 0249 } 0250 } 0251 elide: Text.ElideRight 0252 Layout.fillWidth: true 0253 } 0254 } 0255 0256 Item { width: 1 } 0257 0258 RowLayout { 0259 enabled: timePositionSaving.value >= 0 0260 SpinBox { 0261 id: timePositionSaveInterval 0262 from: 1 0263 to: 300 0264 value: PlaybackSettings.savePositionInterval 0265 0266 onValueChanged: { 0267 PlaybackSettings.savePositionInterval = value 0268 PlaybackSettings.save() 0269 } 0270 } 0271 0272 LabelWithTooltip { 0273 text: i18ncp("@info", 0274 "Save position every %1 second", 0275 "Save position every %1 seconds", 0276 timePositionSaveInterval.value) 0277 elide: Text.ElideRight 0278 Layout.fillWidth: true 0279 } 0280 } 0281 0282 Label { 0283 text: i18nc("@label", "Skip chapters") 0284 Layout.alignment: Qt.AlignRight 0285 } 0286 0287 CheckBox { 0288 id: skipChaptersCheckBox 0289 text: checked ? i18nc("@option:check", "Enabled") : i18nc("@option:check", "Disabled") 0290 checked: PlaybackSettings.skipChapters 0291 onCheckedChanged: { 0292 PlaybackSettings.skipChapters = checked 0293 PlaybackSettings.save() 0294 } 0295 } 0296 0297 Item { width: 1 } 0298 0299 CheckBox { 0300 text: i18nc("@option:check", "Show osd message on skip") 0301 enabled: skipChaptersCheckBox.checked 0302 checked: PlaybackSettings.showOsdOnSkipChapters 0303 onCheckedChanged: { 0304 PlaybackSettings.showOsdOnSkipChapters = checked 0305 PlaybackSettings.save() 0306 } 0307 } 0308 0309 Label { 0310 text: i18nc("@label:textbox", "Skip words") 0311 enabled: skipChaptersCheckBox.checked 0312 Layout.alignment: Qt.AlignRight 0313 } 0314 0315 TextField { 0316 id: chaptersToSkip 0317 0318 text: PlaybackSettings.chaptersToSkip 0319 placeholderText: i18nc("placeholder text", "op, ed, chapter 1") 0320 enabled: skipChaptersCheckBox.checked 0321 Layout.fillWidth: true 0322 onEditingFinished: save() 0323 0324 Connections { 0325 target: root 0326 function onSave() { 0327 chaptersToSkip.save() 0328 } 0329 } 0330 0331 ToolTip { 0332 text: i18nc("@info:tooltip", "Skip chapters containing these words. Comma separated list.") 0333 } 0334 0335 function save() { 0336 PlaybackSettings.chaptersToSkip = text 0337 PlaybackSettings.save() 0338 } 0339 } 0340 0341 // ------------------------------------ 0342 // Youtube-dl format settings 0343 // ------------------------------------ 0344 0345 SettingsHeader { 0346 text: i18nc("@title", "Youtube-dl") 0347 Layout.columnSpan: 2 0348 Layout.fillWidth: true 0349 } 0350 0351 Label { 0352 text: i18n("Format selection") 0353 Layout.alignment: Qt.AlignRight 0354 } 0355 0356 ComboBox { 0357 id: ytdlFormatComboBox 0358 property string hCurrentvalue: "" 0359 textRole: "key" 0360 model: ListModel { 0361 id: leftButtonModel 0362 ListElement { key: "Custom"; value: "" } 0363 ListElement { key: "Default"; value: "bestvideo+bestaudio/best" } 0364 ListElement { key: "2160"; value: "bestvideo[height<=2160]+bestaudio/best" } 0365 ListElement { key: "1440"; value: "bestvideo[height<=1440]+bestaudio/best" } 0366 ListElement { key: "1080"; value: "bestvideo[height<=1080]+bestaudio/best" } 0367 ListElement { key: "720"; value: "bestvideo[height<=720]+bestaudio/best" } 0368 ListElement { key: "480"; value: "bestvideo[height<=480]+bestaudio/best" } 0369 } 0370 ToolTip { 0371 text: i18nc("@info:tooltip", "Selects the best video with a height lower than or equal to the selected value.") 0372 } 0373 0374 onActivated: function(index) { 0375 hCurrentvalue = model.get(index).value 0376 if (index === 0) { 0377 ytdlFormatField.text = PlaybackSettings.ytdlFormat 0378 } 0379 if(index > 0) { 0380 ytdlFormatField.focus = true 0381 ytdlFormatField.text = model.get(index).value 0382 } 0383 PlaybackSettings.ytdlFormat = ytdlFormatField.text 0384 PlaybackSettings.save() 0385 mpv.setProperty(MpvProperties.YtdlFormat, PlaybackSettings.ytdlFormat) 0386 } 0387 0388 Component.onCompleted: { 0389 let i = hIndexOfValue(PlaybackSettings.ytdlFormat) 0390 currentIndex = (i === -1) ? 0 : i 0391 } 0392 0393 function hIndexOfValue(value) { 0394 switch(value) { 0395 case "bestvideo+bestaudio/best": 0396 return 1 0397 case "bestvideo[height<=2160]+bestaudio/best": 0398 return 2 0399 case "bestvideo[height<=1440]+bestaudio/best": 0400 return 3 0401 case "bestvideo[height<=1080]+bestaudio/best": 0402 return 4 0403 case "bestvideo[height<=720]+bestaudio/best": 0404 return 5 0405 case "bestvideo[height<=480]+bestaudio/best": 0406 return 6 0407 } 0408 return 0 0409 } 0410 } 0411 0412 Item { width: 1 } 0413 0414 TextField { 0415 id: ytdlFormatField 0416 0417 text: PlaybackSettings.ytdlFormat 0418 placeholderText: i18nc("placeholder text", "bestvideo+bestaudio/best") 0419 Layout.fillWidth: true 0420 onEditingFinished: save() 0421 0422 onTextChanged: { 0423 if (ytdlFormatComboBox.hCurrentvalue !== ytdlFormatField.text) { 0424 ytdlFormatComboBox.currentIndex = 0 0425 return; 0426 } 0427 if (ytdlFormatComboBox.hIndexOfValue(ytdlFormatField.text) !== -1) { 0428 ytdlFormatComboBox.currentIndex = ytdlFormatComboBox.hIndexOfValue(ytdlFormatField.text) 0429 return; 0430 } 0431 } 0432 0433 Connections { 0434 target: root 0435 function onSave() { 0436 ytdlFormatField.save() 0437 } 0438 } 0439 0440 function save() { 0441 PlaybackSettings.ytdlFormat = text 0442 PlaybackSettings.save() 0443 } 0444 } 0445 0446 // ------------------------------------ 0447 // END - Youtube-dl format settings 0448 // ------------------------------------ 0449 0450 Item { 0451 width: Kirigami.Units.gridUnit 0452 height: Kirigami.Units.gridUnit 0453 } 0454 } 0455 }