| 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 |
// Seek Small Step |
| 24 |
Label { |
| 25 |
text: i18nc("@label:spinbox", "Seek small step") |
| 26 |
Layout.alignment: Qt.AlignRight |
| 27 |
} |
| 28 |
|
| 29 |
RowLayout { |
| 30 |
|
| 31 |
SpinBox { |
| 32 |
id: seekSmallStep |
| 33 |
editable: true |
| 34 |
from: 0 |
| 35 |
to: 100 |
| 36 |
value: PlaybackSettings.seekSmallStep |
| 37 |
onValueModified: { |
| 38 |
PlaybackSettings.seekSmallStep = seekSmallStep.value |
| 39 |
PlaybackSettings.save() |
| 40 |
} |
| 41 |
} |
| 42 |
|
| 43 |
ToolTipButton { |
| 44 |
toolTipText: i18nc("@info:tooltip seek small step setting", |
| 45 |
"How much to seek when triggering the corresponding action. Seek mode is " + |
| 46 |
"<a href='https://mpv.io/manual/stable/#command-interface-seek-<target>-[<flags>]'>exact</a>") |
| 47 |
} |
| 48 |
} |
| 49 |
|
| 50 |
// Seek Medium Step |
| 51 |
Label { |
| 52 |
text: i18nc("@label:spinbox", "Seek medium step") |
| 53 |
Layout.alignment: Qt.AlignRight |
| 54 |
} |
| 55 |
|
| 56 |
RowLayout { |
| 57 |
|
| 58 |
SpinBox { |
| 59 |
id: seekMediumStep |
| 60 |
editable: true |
| 61 |
from: 0 |
| 62 |
to: 100 |
| 63 |
value: PlaybackSettings.seekMediumStep |
| 64 |
onValueModified: { |
| 65 |
PlaybackSettings.seekMediumStep = seekMediumStep.value |
| 66 |
PlaybackSettings.save() |
| 67 |
} |
| 68 |
} |
| 69 |
|
| 70 |
ToolTipButton { |
| 71 |
toolTipText: i18nc("@info:tooltip seek medium step setting", |
| 72 |
"How much to seek when triggering the corresponding action. Seek mode is " + |
| 73 |
"<a href='https://mpv.io/manual/stable/#command-interface-seek-<target>-[<flags>]'>exact</a>.<br>" + |
| 74 |
"This is also used for mouse wheel seeking, when mouse is over the progress bar.") |
| 75 |
} |
| 76 |
} |
| 77 |
|
| 78 |
// Seek Big Step |
| 79 |
Label { |
| 80 |
text: i18nc("@label:spinbox", "Seek big step") |
| 81 |
Layout.alignment: Qt.AlignRight |
| 82 |
} |
| 83 |
|
| 84 |
RowLayout { |
| 85 |
SpinBox { |
| 86 |
id: seekBigStep |
| 87 |
editable: true |
| 88 |
from: 0 |
| 89 |
to: 100 |
| 90 |
value: PlaybackSettings.seekBigStep |
| 91 |
onValueModified: { |
| 92 |
PlaybackSettings.seekBigStep = seekBigStep.value |
| 93 |
PlaybackSettings.save() |
| 94 |
} |
| 95 |
} |
| 96 |
|
| 97 |
ToolTipButton { |
| 98 |
toolTipText: i18nc("@info:tooltip seek big step setting", |
| 99 |
"How much to seek when triggering the corresponding action. Seek mode is " + |
| 100 |
"<a href='https://mpv.io/manual/stable/#command-interface-seek-<target>-[<flags>]'>exact</a>") |
| 101 |
} |
| 102 |
} |
| 103 |
|
| 104 |
Label { |
| 105 |
text: i18nc("@label", "Hardware decoding") |
| 106 |
Layout.alignment: Qt.AlignRight |
| 107 |
} |
| 108 |
|
| 109 |
RowLayout { |
| 110 |
ComboBox { |
| 111 |
id: hwDecodingComboBox |
| 112 |
|
| 113 |
textRole: "key" |
| 114 |
model: ListModel { |
| 115 |
id: hwDecModel |
| 116 |
ListElement { key: "disabled"; } |
| 117 |
ListElement { key: "auto"; } |
| 118 |
ListElement { key: "auto-safe"; } |
| 119 |
ListElement { key: "vaapi"; } |
| 120 |
ListElement { key: "nvdec"; } |
| 121 |
ListElement { key: "cuda"; } |
| 122 |
ListElement { key: "videotoolbox"; } |
| 123 |
ListElement { key: "d3d11va"; } |
| 124 |
} |
| 125 |
|
| 126 |
onActivated: function(index) { |
| 127 |
PlaybackSettings.hWDecoding = model.get(index).key === "disabled" |
| 128 |
? "no" |
| 129 |
: model.get(index).key |
| 130 |
PlaybackSettings.save() |
| 131 |
} |
| 132 |
|
| 133 |
Component.onCompleted: { |
| 134 |
for (let i = 0; i < hwDecModel.count; ++i) { |
| 135 |
if (hwDecModel.get(i).key === PlaybackSettings.hWDecoding) { |
| 136 |
currentIndex = i |
| 137 |
break |
| 138 |
} |
| 139 |
} |
| 140 |
} |
| 141 |
} |
| 142 |
|
| 143 |
ToolTipButton { |
| 144 |
toolTipWidth: 450 |
| 145 |
toolTipHeight: 300 |
| 146 |
toolTipText: i18nc("@info:tooltip hardware decoding setting", |
| 147 |
"Specify the hardware video decoding API that should be used if possible. " + |
| 148 |
"Whether hardware decoding is actually done depends on the video codec. " + |
| 149 |
"If hardware decoding is not possible, mpv will fall back on software decoding.<br><br>" + |
| 150 |
"<ul><li><strong>auto</strong> tries to automatically enable hardware decoding using the first available method.</li>" + |
| 151 |
"<li><strong>auto-safe</strong> similar to auto, but allows only whitelisted methods that are considered “safe”.</li>" + |
| 152 |
"<li><strong>vaapi</strong> works with Intel and AMD GPUs only. It also requires the opengl EGL backend.</li>" + |
| 153 |
"<li><strong>nvdec</strong> the newest, and recommended method to do hardware decoding on Nvidia GPUs.</li>" + |
| 154 |
"<li><strong>cuda</strong> an older implementation of hardware decoding on Nvidia GPUs.</li>" + |
| 155 |
"<li><strong>videotoolbox</strong></li>" + |
| 156 |
"<li><strong>d3d11va</strong></li>" + |
| 157 |
"</ul>" + |
| 158 |
"<br><br>" + |
| 159 |
"You can read more about hardware decoding here: " + |
| 160 |
"<a href='https://mpv.io/manual/stable/#options-hwdec'>https://mpv.io/manual/stable/#options-hwdec</a>" + |
| 161 |
"<br><br>" + |
| 162 |
"You can set another hardware decoder by creating a startup custom command <strong>set hwdec <i>decoder_name</i></strong>.") |
| 163 |
} |
| 164 |
} |
| 165 |
|
| 166 |
Item { Layout.preferredWidth: 1 } |
| 167 |
|
| 168 |
CheckBox { |
| 169 |
id: loadLastPlayedFileCheckBox |
| 170 |
|
| 171 |
text: i18nc("@option:check", "Open last played file on startup") |
| 172 |
checked: PlaybackSettings.openLastPlayedFile |
| 173 |
onClicked: { |
| 174 |
PlaybackSettings.openLastPlayedFile = checked |
| 175 |
PlaybackSettings.save() |
| 176 |
} |
| 177 |
|
| 178 |
ToolTip { |
| 179 |
text: i18nc("@info:tooltip open last played file setting", |
| 180 |
"On startup it opens the file that was playing when the application was closed.") |
| 181 |
} |
| 182 |
} |
| 183 |
|
| 184 |
Item { Layout.preferredWidth: 1 } |
| 185 |
|
| 186 |
CheckBox { |
| 187 |
id: pauseOnMinimizeCheckBox |
| 188 |
|
| 189 |
text: i18nc("@option:check", "Pause on minimize") |
| 190 |
checked: PlaybackSettings.pauseWhileMinimized |
| 191 |
onClicked: { |
| 192 |
PlaybackSettings.pauseWhileMinimized = checked |
| 193 |
PlaybackSettings.save() |
| 194 |
} |
| 195 |
|
| 196 |
ToolTip { |
| 197 |
text: i18nc("@info:tooltip pause on minimize setting", |
| 198 |
"Pauses the player while the window is minimized, playback resumes when restored.") |
| 199 |
} |
| 200 |
} |
| 201 |
|
| 202 |
// ------------------------------------ |
| 203 |
// Playback position |
| 204 |
// ------------------------------------ |
| 205 |
|
| 206 |
SettingsHeader { |
| 207 |
text: i18nc("@title", "Playback position") |
| 208 |
Layout.columnSpan: 2 |
| 209 |
Layout.fillWidth: true |
| 210 |
} |
| 211 |
|
| 212 |
Item { Layout.preferredWidth: 1 } |
| 213 |
|
| 214 |
CheckBox { |
| 215 |
id: saveFilePositionCheckBox |
| 216 |
|
| 217 |
text: i18nc("@option:check", "Restore playback position") |
| 218 |
checked: PlaybackSettings.restoreFilePosition |
| 219 |
onClicked: { |
| 220 |
PlaybackSettings.restoreFilePosition = checked |
| 221 |
PlaybackSettings.save() |
| 222 |
} |
| 223 |
ToolTip { |
| 224 |
text: i18ncp("@info:tooltip save playback position", |
| 225 |
// singular |
| 226 |
"Saves the file position during playback, opening the same file again will seek to the saved position.\n" |
| 227 |
+"Position is saved every %1 second, except for the last 10 seconds of the video.", |
| 228 |
// plural |
| 229 |
"Saves the file position during playback, opening the same file again will seek to the saved position.\n" |
| 230 |
+"Position is saved every %1 seconds, except for the last 10 seconds of the video.", |
| 231 |
timePositionSaveInterval.value) |
| 232 |
} |
| 233 |
} |
| 234 |
|
| 235 |
Item { Layout.preferredWidth: 1 } |
| 236 |
|
| 237 |
CheckBox { |
| 238 |
id: playOnResumeCheckBox |
| 239 |
|
| 240 |
text: i18nc("@option:check", "Start playing") |
| 241 |
checked: PlaybackSettings.playOnResume |
| 242 |
enabled: saveFilePositionCheckBox.checked |
| 243 |
onClicked: { |
| 244 |
PlaybackSettings.playOnResume = checked |
| 245 |
PlaybackSettings.save() |
| 246 |
} |
| 247 |
|
| 248 |
ToolTip { |
| 249 |
text: i18nc("@info:tooltip start playing setting", |
| 250 |
"The file will be playing after restoring the playback position") |
| 251 |
} |
| 252 |
} |
| 253 |
|
| 254 |
Item { Layout.preferredWidth: 1 } |
| 255 |
|
| 256 |
RowLayout { |
| 257 |
enabled: saveFilePositionCheckBox.checked |
| 258 |
SpinBox { |
| 259 |
id: timePositionSaving |
| 260 |
from: 0 |
| 261 |
to: 9999 |
| 262 |
value: PlaybackSettings.minDurationToSavePosition |
| 263 |
|
| 264 |
onValueModified: { |
| 265 |
PlaybackSettings.minDurationToSavePosition = value |
| 266 |
PlaybackSettings.save() |
| 267 |
} |
| 268 |
} |
| 269 |
|
| 270 |
Label { |
| 271 |
text: { |
| 272 |
if (timePositionSaving.value === 0) { |
| 273 |
return i18nc("@info", "For any duration") |
| 274 |
} else { |
| 275 |
return i18ncp("@info", |
| 276 |
"If duration is longer than %1 minute", |
| 277 |
"If duration is longer than %1 minutes", |
| 278 |
timePositionSaving.value) |
| 279 |
} |
| 280 |
} |
| 281 |
elide: Text.ElideRight |
| 282 |
} |
| 283 |
ToolTipButton { |
| 284 |
toolTipText: i18nc("@info:tooltip restore playback position > duration", |
| 285 |
"Position for remote files is restored regardless of duration.") |
| 286 |
} |
| 287 |
} |
| 288 |
|
| 289 |
Item { Layout.preferredWidth: 1 } |
| 290 |
|
| 291 |
RowLayout { |
| 292 |
enabled: saveFilePositionCheckBox.checked |
| 293 |
SpinBox { |
| 294 |
id: timePositionSaveInterval |
| 295 |
from: 1 |
| 296 |
to: 300 |
| 297 |
value: PlaybackSettings.savePositionInterval |
| 298 |
|
| 299 |
onValueModified: { |
| 300 |
PlaybackSettings.savePositionInterval = value |
| 301 |
PlaybackSettings.save() |
| 302 |
} |
| 303 |
} |
| 304 |
|
| 305 |
LabelWithTooltip { |
| 306 |
text: i18ncp("@info:tooltip restore playback position > save interval", |
| 307 |
"Save position every %1 second", |
| 308 |
"Save position every %1 seconds", |
| 309 |
timePositionSaveInterval.value) |
| 310 |
elide: Text.ElideRight |
| 311 |
Layout.fillWidth: true |
| 312 |
} |
| 313 |
} |
| 314 |
|
| 315 |
// ------------------------------------ |
| 316 |
// Chapters |
| 317 |
// ------------------------------------ |
| 318 |
|
| 319 |
SettingsHeader { |
| 320 |
text: i18nc("@title", "Chapters") |
| 321 |
Layout.columnSpan: 2 |
| 322 |
Layout.fillWidth: true |
| 323 |
} |
| 324 |
|
| 325 |
Item { Layout.preferredWidth: 1 } |
| 326 |
|
| 327 |
CheckBox { |
| 328 |
id: skipChaptersCheckBox |
| 329 |
text: i18nc("@option:check", "Skip chapters") |
| 330 |
checked: PlaybackSettings.skipChapters |
| 331 |
onClicked: { |
| 332 |
PlaybackSettings.skipChapters = checked |
| 333 |
PlaybackSettings.save() |
| 334 |
} |
| 335 |
|
| 336 |
ToolTip.text: i18nc("@info:tooltip skip chapters setting", |
| 337 |
"When enabled it automatically skips chapters containing certain words/characters.") |
| 338 |
ToolTip.visible: hovered |
| 339 |
ToolTip.delay: 700 |
| 340 |
} |
| 341 |
|
| 342 |
Item { Layout.preferredWidth: 1 } |
| 343 |
|
| 344 |
CheckBox { |
| 345 |
text: i18nc("@option:check", "Show OSD message on skip") |
| 346 |
enabled: skipChaptersCheckBox.checked |
| 347 |
checked: PlaybackSettings.showOsdOnSkipChapters |
| 348 |
onClicked: { |
| 349 |
PlaybackSettings.showOsdOnSkipChapters = checked |
| 350 |
PlaybackSettings.save() |
| 351 |
} |
| 352 |
|
| 353 |
ToolTip.text: i18nc("@info:tooltip show OSD message on skip setting", |
| 354 |
"When skipping chapters an osd message will show the title of the skipped chapter.") |
| 355 |
ToolTip.visible: hovered |
| 356 |
ToolTip.delay: 700 |
| 357 |
} |
| 358 |
|
| 359 |
Label { |
| 360 |
text: i18nc("@label:textbox", "Keywords") |
| 361 |
enabled: skipChaptersCheckBox.checked |
| 362 |
Layout.alignment: Qt.AlignRight |
| 363 |
} |
| 364 |
|
| 365 |
TextField { |
| 366 |
id: chaptersToSkip |
| 367 |
|
| 368 |
text: PlaybackSettings.chaptersToSkip |
| 369 |
placeholderText: i18nc("placeholder text", "op, ed, chapter 1") |
| 370 |
enabled: skipChaptersCheckBox.checked |
| 371 |
Layout.fillWidth: true |
| 372 |
onEditingFinished: save() |
| 373 |
|
| 374 |
ToolTip.text: i18nc("@info:tooltip skip words setting", |
| 375 |
"Skip chapters containing these words. Comma separated list. " + |
| 376 |
"The match is not exact, meaning <strong>op</strong> will match words containing it like <strong><u>op</u>ening</strong>.") |
| 377 |
ToolTip.visible: hovered |
| 378 |
ToolTip.delay: 700 |
| 379 |
|
| 380 |
Connections { |
| 381 |
target: root |
| 382 |
function onSave() { |
| 383 |
chaptersToSkip.save() |
| 384 |
} |
| 385 |
} |
| 386 |
|
| 387 |
function save() : void { |
| 388 |
PlaybackSettings.chaptersToSkip = text |
| 389 |
PlaybackSettings.save() |
| 390 |
} |
| 391 |
} |
| 392 |
|
| 393 |
|
| 394 |
// ------------------------------------ |
| 395 |
// Youtube-dl format settings |
| 396 |
// ------------------------------------ |
| 397 |
|
| 398 |
SettingsHeader { |
| 399 |
text: i18nc("@title", "Youtube-dl") |
| 400 |
Layout.columnSpan: 2 |
| 401 |
Layout.fillWidth: true |
| 402 |
} |
| 403 |
|
| 404 |
Label { |
| 405 |
text: i18n("Format selection") |
| 406 |
Layout.alignment: Qt.AlignRight |
| 407 |
} |
| 408 |
|
| 409 |
ComboBox { |
| 410 |
id: ytdlFormatComboBox |
| 411 |
|
| 412 |
textRole: "text" |
| 413 |
valueRole: "value" |
| 414 |
model: ListModel { |
| 415 |
id: formatModel |
| 416 |
} |
| 417 |
|
| 418 |
onActivated: function(index) { |
| 419 |
if (index === 0) { |
| 420 |
PlaybackSettings.ytdlFormat = PlaybackSettings.ytdlFormatCustom |
| 421 |
} else { |
| 422 |
PlaybackSettings.ytdlFormat = ytdlFormatComboBox.valueAt(currentIndex) |
| 423 |
} |
| 424 |
|
| 425 |
PlaybackSettings.save() |
| 426 |
} |
| 427 |
|
| 428 |
Component.onCompleted: { |
| 429 |
const customSelection = { |
| 430 |
text: i18nc("@item:listbox the custom youtube-dl format selection", "Custom"), |
| 431 |
value: "" |
| 432 |
} |
| 433 |
formatModel.append(customSelection) |
| 434 |
|
| 435 |
const defaultSelection = { |
| 436 |
text: i18nc("@item:listbox the default youtube-dl format selection", "Default"), |
| 437 |
value: "bestvideo+bestaudio/best" |
| 438 |
} |
| 439 |
formatModel.append(defaultSelection) |
| 440 |
|
| 441 |
formatModel.append({ text: "2160", value: "bestvideo[height<=2160]+bestaudio/best" }) |
| 442 |
formatModel.append({ text: "1440", value: "bestvideo[height<=1440]+bestaudio/best" }) |
| 443 |
formatModel.append({ text: "1080", value: "bestvideo[height<=1080]+bestaudio/best" }) |
| 444 |
formatModel.append({ text: "720", value: "bestvideo[height<=720]+bestaudio/best" }) |
| 445 |
formatModel.append({ text: "480", value: "bestvideo[height<=480]+bestaudio/best" }) |
| 446 |
|
| 447 |
currentIndex = hIndexOfValue(PlaybackSettings.ytdlFormat) |
| 448 |
} |
| 449 |
|
| 450 |
ToolTip.text: i18nc("@info:tooltip format selection setting", |
| 451 |
"Selects a video source that is closest to the selected format.") |
| 452 |
ToolTip.visible: hovered |
| 453 |
ToolTip.delay: 700 |
| 454 |
|
| 455 |
function hIndexOfValue(value) : int { |
| 456 |
switch(value) { |
| 457 |
case "bestvideo+bestaudio/best": |
| 458 |
return 1 |
| 459 |
case "bestvideo[height<=2160]+bestaudio/best": |
| 460 |
return 2 |
| 461 |
case "bestvideo[height<=1440]+bestaudio/best": |
| 462 |
return 3 |
| 463 |
case "bestvideo[height<=1080]+bestaudio/best": |
| 464 |
return 4 |
| 465 |
case "bestvideo[height<=720]+bestaudio/best": |
| 466 |
return 5 |
| 467 |
case "bestvideo[height<=480]+bestaudio/best": |
| 468 |
return 6 |
| 469 |
} |
| 470 |
return 0 |
| 471 |
} |
| 472 |
} |
| 473 |
|
| 474 |
Item { Layout.preferredWidth: 1 } |
| 475 |
|
| 476 |
TextField { |
| 477 |
id: ytdlCustomFormatField |
| 478 |
|
| 479 |
text: PlaybackSettings.ytdlFormatCustom |
| 480 |
visible: ytdlFormatComboBox.currentIndex === 0 |
| 481 |
placeholderText: "bestvideo+bestaudio/best" |
| 482 |
|
| 483 |
Layout.fillWidth: true |
| 484 |
|
| 485 |
onTextChanged: { |
| 486 |
PlaybackSettings.ytdlFormatCustom = ytdlCustomFormatField.text |
| 487 |
PlaybackSettings.ytdlFormat = ytdlCustomFormatField.text |
| 488 |
PlaybackSettings.save() |
| 489 |
} |
| 490 |
|
| 491 |
Connections { |
| 492 |
target: root |
| 493 |
function onSave() { |
| 494 |
PlaybackSettings.ytdlFormatCustom = ytdlCustomFormatField.text |
| 495 |
PlaybackSettings.save() |
| 496 |
} |
| 497 |
} |
| 498 |
} |
| 499 |
|
| 500 |
Kirigami.SelectableLabel { |
| 501 |
text: PlaybackSettings.ytdlFormat |
| 502 |
visible: ytdlFormatComboBox.currentIndex > 0 |
| 503 |
|
| 504 |
Layout.fillWidth: true |
| 505 |
} |
| 506 |
|
| 507 |
// ------------------------------------ |
| 508 |
// END - Youtube-dl format settings |
| 509 |
// ------------------------------------ |
| 510 |
|
| 511 |
Item { |
| 512 |
Layout.preferredWidth: Kirigami.Units.gridUnit |
| 513 |
Layout.preferredHeight: Kirigami.Units.gridUnit |
| 514 |
} |
| 515 |
} |
| 516 |
} |