| 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 |
SubtitlesFolders { |
| 25 |
id: subtitleFolders |
| 26 |
implicitWidth: root.width |
| 27 |
Layout.fillWidth: true |
| 28 |
Layout.columnSpan: 2 |
| 29 |
} |
| 30 |
|
| 31 |
Item { Layout.preferredWidth: 1; Layout.preferredHeight: 1 } |
| 32 |
|
| 33 |
CheckBox { |
| 34 |
id: autoSelectSubtitles |
| 35 |
|
| 36 |
text: i18nc("@label:check", "Auto select track") |
| 37 |
checked: SubtitlesSettings.autoSelectSubtitles |
| 38 |
|
| 39 |
onClicked: { |
| 40 |
SubtitlesSettings.autoSelectSubtitles = checked |
| 41 |
SubtitlesSettings.save() |
| 42 |
} |
| 43 |
|
| 44 |
ToolTip { |
| 45 |
text: i18nc("@info:tooltip", "When checked a subtitle track will be automatically selected and displayed") |
| 46 |
} |
| 47 |
} |
| 48 |
|
| 49 |
Label { |
| 50 |
text: i18nc("@label:textbox", "Preferred language") |
| 51 |
Layout.alignment: Qt.AlignRight |
| 52 |
} |
| 53 |
|
| 54 |
TextField { |
| 55 |
id: preferredLanguage |
| 56 |
|
| 57 |
text: SubtitlesSettings.preferredLanguage |
| 58 |
placeholderText: "eng, ger etc." |
| 59 |
Layout.fillWidth: true |
| 60 |
onEditingFinished: save() |
| 61 |
enabled: autoSelectSubtitles.checked |
| 62 |
|
| 63 |
Connections { |
| 64 |
target: root |
| 65 |
function onSave() { |
| 66 |
preferredLanguage.save() |
| 67 |
} |
| 68 |
} |
| 69 |
|
| 70 |
function save() : void { |
| 71 |
SubtitlesSettings.preferredLanguage = text |
| 72 |
SubtitlesSettings.save() |
| 73 |
} |
| 74 |
} |
| 75 |
|
| 76 |
Label { |
| 77 |
text: i18nc("@label:spinbox", "Preferred track") |
| 78 |
Layout.alignment: Qt.AlignRight |
| 79 |
} |
| 80 |
|
| 81 |
SpinBox { |
| 82 |
from: 0 |
| 83 |
to: 100 |
| 84 |
value: SubtitlesSettings.preferredTrack |
| 85 |
editable: true |
| 86 |
enabled: autoSelectSubtitles.checked |
| 87 |
onValueModified: { |
| 88 |
SubtitlesSettings.preferredTrack = value |
| 89 |
SubtitlesSettings.save() |
| 90 |
} |
| 91 |
} |
| 92 |
|
| 93 |
Item { Layout.preferredWidth: 1; Layout.preferredHeight: 1 } |
| 94 |
CheckBox { |
| 95 |
checked: SubtitlesSettings.allowOnBlackBorders |
| 96 |
text: i18nc("@option:check", "Allow subtitles in black borders") |
| 97 |
onClicked: { |
| 98 |
SubtitlesSettings.allowOnBlackBorders = checked |
| 99 |
SubtitlesSettings.save() |
| 100 |
} |
| 101 |
|
| 102 |
ToolTip { |
| 103 |
text: i18nc("@info:tooltip", "When checked the subtitles can be rendered outside the video, in the black borders. Might not work for all .ass subtitles.") |
| 104 |
} |
| 105 |
} |
| 106 |
|
| 107 |
SettingsHeader { |
| 108 |
text: i18nc("@title", "Styling") |
| 109 |
Layout.columnSpan: 2 |
| 110 |
Layout.fillWidth: true |
| 111 |
} |
| 112 |
|
| 113 |
Label { |
| 114 |
text: i18nc("@label:listbox", "Font family") |
| 115 |
Layout.alignment: Qt.AlignRight |
| 116 |
} |
| 117 |
|
| 118 |
RowLayout { |
| 119 |
Layout.fillWidth: true |
| 120 |
|
| 121 |
ComboBox { |
| 122 |
id: subtitleFont |
| 123 |
|
| 124 |
property string defaultFamily: "Sans Serif" |
| 125 |
|
| 126 |
model: SystemUtils.getFonts() |
| 127 |
onActivated: function(index) { |
| 128 |
setFontFamily() |
| 129 |
} |
| 130 |
|
| 131 |
Component.onCompleted: currentIndex = indexOfValue(SubtitlesSettings.fontFamily) |
| 132 |
Layout.fillWidth: true |
| 133 |
|
| 134 |
function setFontFamily() { |
| 135 |
SubtitlesSettings.fontFamily = currentText |
| 136 |
SubtitlesSettings.save() |
| 137 |
} |
| 138 |
} |
| 139 |
|
| 140 |
Button { |
| 141 |
icon.name: "edit-reset" |
| 142 |
onClicked: { |
| 143 |
const index = subtitleFont.find(subtitleFont.defaultFamily) |
| 144 |
subtitleFont.currentIndex = index |
| 145 |
subtitleFont.setFontFamily() |
| 146 |
} |
| 147 |
|
| 148 |
ToolTip { |
| 149 |
text: i18nc("@info:tooltip", "Reset to default value") |
| 150 |
} |
| 151 |
} |
| 152 |
} |
| 153 |
|
| 154 |
Label { |
| 155 |
text: i18nc("@label:spinbox", "Font size") |
| 156 |
Layout.alignment: Qt.AlignRight |
| 157 |
} |
| 158 |
|
| 159 |
SpinBox { |
| 160 |
from: 0 |
| 161 |
to: 1000 |
| 162 |
value: SubtitlesSettings.fontSize |
| 163 |
onValueModified: { |
| 164 |
SubtitlesSettings.fontSize = value |
| 165 |
SubtitlesSettings.save() |
| 166 |
} |
| 167 |
} |
| 168 |
|
| 169 |
Label { |
| 170 |
text: i18nc("@label", "Font style") |
| 171 |
Layout.alignment: Qt.AlignRight |
| 172 |
} |
| 173 |
|
| 174 |
CheckBox { |
| 175 |
text: i18nc("@option:check", "Bold") |
| 176 |
checked: SubtitlesSettings.isBold |
| 177 |
onClicked: { |
| 178 |
SubtitlesSettings.isBold = checked |
| 179 |
SubtitlesSettings.save() |
| 180 |
} |
| 181 |
} |
| 182 |
|
| 183 |
Item { Layout.preferredWidth: 1 } |
| 184 |
|
| 185 |
CheckBox { |
| 186 |
text: i18nc("@option:check", "Italic") |
| 187 |
checked: SubtitlesSettings.isItalic |
| 188 |
onClicked: { |
| 189 |
SubtitlesSettings.isItalic = checked |
| 190 |
SubtitlesSettings.save() |
| 191 |
} |
| 192 |
} |
| 193 |
|
| 194 |
Label { |
| 195 |
text: i18nc("@label:textbox", "Font color") |
| 196 |
Layout.alignment: Qt.AlignRight |
| 197 |
} |
| 198 |
|
| 199 |
RowLayout { |
| 200 |
Layout.fillWidth: true |
| 201 |
|
| 202 |
|
| 203 |
ColorPickerButton { |
| 204 |
id: subtitleColorPicker |
| 205 |
|
| 206 |
color: SubtitlesSettings.fontColor |
| 207 |
onColorChosen: function (color) { |
| 208 |
subtitleColor.text = color |
| 209 |
} |
| 210 |
|
| 211 |
Layout.preferredHeight: subtitleColor.height |
| 212 |
Layout.preferredWidth: subtitleColor.height |
| 213 |
} |
| 214 |
|
| 215 |
TextField { |
| 216 |
id: subtitleColor |
| 217 |
|
| 218 |
property string defaultColor: "#FFFFFFFF" |
| 219 |
|
| 220 |
text: SubtitlesSettings.fontColor |
| 221 |
|
| 222 |
onTextChanged: { |
| 223 |
save() |
| 224 |
} |
| 225 |
|
| 226 |
Connections { |
| 227 |
target: root |
| 228 |
function onSave() { |
| 229 |
subtitleColor.save() |
| 230 |
} |
| 231 |
} |
| 232 |
|
| 233 |
function save() : void { |
| 234 |
subtitleColorPicker.color = text |
| 235 |
SubtitlesSettings.fontColor = text |
| 236 |
SubtitlesSettings.save() |
| 237 |
} |
| 238 |
} |
| 239 |
|
| 240 |
Button { |
| 241 |
icon.name: "edit-reset" |
| 242 |
onClicked: subtitleColor.text = subtitleColor.defaultColor |
| 243 |
|
| 244 |
ToolTip { |
| 245 |
text: i18nc("@info:tooltip", "Reset to default value") |
| 246 |
} |
| 247 |
} |
| 248 |
} |
| 249 |
|
| 250 |
Label { |
| 251 |
text: i18nc("@label:textbox", "Shadow color") |
| 252 |
Layout.alignment: Qt.AlignRight |
| 253 |
} |
| 254 |
|
| 255 |
RowLayout { |
| 256 |
Layout.fillWidth: true |
| 257 |
|
| 258 |
ColorPickerButton { |
| 259 |
id: shadowColorPicker |
| 260 |
|
| 261 |
color: SubtitlesSettings.shadowColor |
| 262 |
onColorChosen: function (color) { |
| 263 |
shadowColor.text = color |
| 264 |
} |
| 265 |
|
| 266 |
Layout.preferredHeight: shadowColor.height |
| 267 |
Layout.preferredWidth: shadowColor.height |
| 268 |
} |
| 269 |
|
| 270 |
TextField { |
| 271 |
id: shadowColor |
| 272 |
|
| 273 |
property string defaultColor: "#80F0F0F0" |
| 274 |
|
| 275 |
text: SubtitlesSettings.shadowColor |
| 276 |
|
| 277 |
onTextChanged: { |
| 278 |
save() |
| 279 |
} |
| 280 |
|
| 281 |
Connections { |
| 282 |
target: root |
| 283 |
function onSave() { |
| 284 |
shadowColor.save() |
| 285 |
} |
| 286 |
} |
| 287 |
|
| 288 |
function save() : void { |
| 289 |
shadowColorPicker.color = text |
| 290 |
SubtitlesSettings.shadowColor = text |
| 291 |
SubtitlesSettings.save() |
| 292 |
} |
| 293 |
} |
| 294 |
|
| 295 |
Button { |
| 296 |
icon.name: "edit-reset" |
| 297 |
onClicked: shadowColor.text = shadowColor.defaultColor |
| 298 |
|
| 299 |
ToolTip { |
| 300 |
text: i18nc("@info:tooltip", "Reset to default value") |
| 301 |
} |
| 302 |
} |
| 303 |
} |
| 304 |
|
| 305 |
Label { |
| 306 |
text: i18nc("@label:spinbox", "Shadow offset") |
| 307 |
Layout.alignment: Qt.AlignRight |
| 308 |
} |
| 309 |
|
| 310 |
SpinBox { |
| 311 |
from: 0 |
| 312 |
to: 25 |
| 313 |
value: SubtitlesSettings.shadowOffset |
| 314 |
editable: true |
| 315 |
onValueModified: { |
| 316 |
SubtitlesSettings.shadowOffset = value |
| 317 |
SubtitlesSettings.save() |
| 318 |
} |
| 319 |
|
| 320 |
ToolTip { |
| 321 |
text: i18nc("@info:tooltip", "Set to 0 (zero) to disable.") |
| 322 |
} |
| 323 |
} |
| 324 |
|
| 325 |
Label { |
| 326 |
text: i18nc("@label:textbox", "Border color") |
| 327 |
Layout.alignment: Qt.AlignRight |
| 328 |
} |
| 329 |
|
| 330 |
RowLayout { |
| 331 |
Layout.fillWidth: true |
| 332 |
|
| 333 |
ColorPickerButton { |
| 334 |
id: borderColorPicker |
| 335 |
|
| 336 |
color: SubtitlesSettings.borderColor |
| 337 |
onColorChosen: function (color) { |
| 338 |
borderColor.text = color |
| 339 |
} |
| 340 |
|
| 341 |
Layout.preferredHeight: borderColor.height |
| 342 |
Layout.preferredWidth: borderColor.height |
| 343 |
} |
| 344 |
|
| 345 |
TextField { |
| 346 |
id: borderColor |
| 347 |
|
| 348 |
property string defaultColor: "#FF000000" |
| 349 |
|
| 350 |
text: SubtitlesSettings.borderColor |
| 351 |
|
| 352 |
onTextChanged: { |
| 353 |
save() |
| 354 |
} |
| 355 |
|
| 356 |
Connections { |
| 357 |
target: root |
| 358 |
function onSave() { |
| 359 |
borderColor.save() |
| 360 |
} |
| 361 |
} |
| 362 |
|
| 363 |
function save() : void { |
| 364 |
borderColorPicker.color = text |
| 365 |
SubtitlesSettings.borderColor = text |
| 366 |
SubtitlesSettings.save() |
| 367 |
} |
| 368 |
} |
| 369 |
|
| 370 |
Button { |
| 371 |
icon.name: "edit-reset" |
| 372 |
onClicked: borderColor.text = borderColor.defaultColor |
| 373 |
|
| 374 |
ToolTip { |
| 375 |
text: i18nc("@info:tooltip", "Reset to default value") |
| 376 |
} |
| 377 |
} |
| 378 |
} |
| 379 |
|
| 380 |
Label { |
| 381 |
text: i18nc("@label:spinbox", "Border width") |
| 382 |
Layout.alignment: Qt.AlignRight |
| 383 |
} |
| 384 |
|
| 385 |
SpinBox { |
| 386 |
from: 0 |
| 387 |
to: 25 |
| 388 |
value: SubtitlesSettings.borderSize |
| 389 |
editable: true |
| 390 |
onValueModified: { |
| 391 |
SubtitlesSettings.borderSize = value |
| 392 |
SubtitlesSettings.save() |
| 393 |
} |
| 394 |
|
| 395 |
ToolTip { |
| 396 |
text: i18nc("@info:tooltip", "Set to 0 (zero) to disable.") |
| 397 |
} |
| 398 |
} |
| 399 |
|
| 400 |
Label { |
| 401 |
text: i18nc("@label:listbox", "Border style") |
| 402 |
Layout.alignment: Qt.AlignRight |
| 403 |
} |
| 404 |
|
| 405 |
ComboBox { |
| 406 |
textRole: "text" |
| 407 |
valueRole: "value" |
| 408 |
model: ListModel { |
| 409 |
id: borderStyleModel |
| 410 |
} |
| 411 |
Component.onCompleted: { |
| 412 |
const outlineAndShadow = { |
| 413 |
text: i18nc("@item:listbox border style", "Outline and Shadow"), |
| 414 |
value: "outline-and-shadow" |
| 415 |
} |
| 416 |
borderStyleModel.append(outlineAndShadow) |
| 417 |
|
| 418 |
const opaqueBox = { |
| 419 |
text: i18nc("@item:listbox border style", "Opaque Box"), |
| 420 |
value: "opaque-box" |
| 421 |
} |
| 422 |
borderStyleModel.append(opaqueBox) |
| 423 |
|
| 424 |
const bgBox = { |
| 425 |
text: i18nc("@item:listbox border style", "Background Box"), |
| 426 |
value: "background-box" |
| 427 |
} |
| 428 |
borderStyleModel.append(bgBox) |
| 429 |
|
| 430 |
currentIndex = indexOfValue(SubtitlesSettings.borderStyle) |
| 431 |
} |
| 432 |
|
| 433 |
onActivated: function(index) { |
| 434 |
SubtitlesSettings.borderStyle = model.get(index).value |
| 435 |
SubtitlesSettings.save() |
| 436 |
} |
| 437 |
} |
| 438 |
|
| 439 |
Item { |
| 440 |
Layout.preferredWidth: Kirigami.Units.gridUnit |
| 441 |
Layout.preferredHeight: Kirigami.Units.gridUnit |
| 442 |
} |
| 443 |
} |
| 444 |
} |