Warning, /multimedia/haruna/src/qml/Settings/SubtitlesSettings.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: false 0020 helpFile: "" 0021 0022 GridLayout { 0023 id: content 0024 0025 columns: 2 0026 0027 SubtitlesFolders { 0028 id: subtitleFolders 0029 implicitWidth: root.width 0030 Layout.fillWidth: true 0031 Layout.columnSpan: 2 0032 } 0033 0034 Label { 0035 text: i18nc("@label:textbox", "Preferred language") 0036 Layout.alignment: Qt.AlignRight 0037 } 0038 0039 TextField { 0040 id: preferredLanguage 0041 0042 text: SubtitlesSettings.preferredLanguage 0043 placeholderText: i18nc("placeholder text", "eng, ger etc.") 0044 Layout.fillWidth: true 0045 onEditingFinished: save() 0046 0047 Connections { 0048 target: root 0049 function onSave() { 0050 preferredLanguage.save() 0051 } 0052 } 0053 0054 function save() { 0055 SubtitlesSettings.preferredLanguage = text 0056 SubtitlesSettings.save() 0057 mpv.setProperty(MpvProperties.SubtitleLanguage, text.replace(/\s+/g, '')) 0058 } 0059 } 0060 0061 Label { 0062 text: i18nc("@label:spinbox", "Preferred track") 0063 Layout.alignment: Qt.AlignRight 0064 } 0065 0066 SpinBox { 0067 from: 0 0068 to: 100 0069 value: SubtitlesSettings.preferredTrack 0070 editable: true 0071 onValueChanged: { 0072 SubtitlesSettings.preferredTrack = value 0073 SubtitlesSettings.save() 0074 if (value === 0) { 0075 mpv.subtitleId = "auto" 0076 } else { 0077 mpv.subtitleId = value 0078 } 0079 } 0080 } 0081 0082 Item { width: 1; height: 1 } 0083 CheckBox { 0084 checked: SubtitlesSettings.allowOnBlackBorders 0085 text: i18nc("@option:check", "Allow subtitles in black borders") 0086 onCheckStateChanged: { 0087 SubtitlesSettings.allowOnBlackBorders = checked 0088 SubtitlesSettings.save() 0089 mpv.setProperty(MpvProperties.SubtitleUseMargins, checked ? "yes" : "no") 0090 mpv.setProperty(MpvProperties.SubtitleAssForceMargins, checked ? "yes" : "no") 0091 } 0092 0093 ToolTip { 0094 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.") 0095 } 0096 } 0097 0098 SettingsHeader { 0099 text: i18nc("@title", "Styling") 0100 Layout.columnSpan: 2 0101 Layout.fillWidth: true 0102 } 0103 0104 Label { 0105 text: i18nc("@label:listbox", "Font family") 0106 Layout.alignment: Qt.AlignRight 0107 } 0108 0109 RowLayout { 0110 Layout.fillWidth: true 0111 0112 ComboBox { 0113 id: subtitleFont 0114 0115 property string defaultFamily: "Sans Serif" 0116 0117 model: app.getFonts() 0118 onActivated: function(index) { 0119 SubtitlesSettings.fontFamily = currentText 0120 SubtitlesSettings.save() 0121 mpv.setProperty(MpvProperties.SubtitleFont, currentText) 0122 } 0123 0124 Component.onCompleted: currentIndex = indexOfValue(SubtitlesSettings.fontFamily) 0125 } 0126 0127 Button { 0128 icon.name: "edit-clear-all" 0129 onClicked: { 0130 const index = subtitleFont.find(subtitleFont.defaultFamily) 0131 subtitleFont.currentIndex = index 0132 } 0133 } 0134 } 0135 0136 Label { 0137 text: i18nc("@label:spinbox", "Font size") 0138 Layout.alignment: Qt.AlignRight 0139 } 0140 0141 SpinBox { 0142 from: 0 0143 to: 1000 0144 value: SubtitlesSettings.fontSize 0145 onValueChanged: { 0146 SubtitlesSettings.fontSize = value 0147 SubtitlesSettings.save() 0148 mpv.setProperty(MpvProperties.SubtitleFontSize, value) 0149 } 0150 } 0151 0152 Label { 0153 text: i18nc("@label", "Font style") 0154 Layout.alignment: Qt.AlignRight 0155 } 0156 0157 CheckBox { 0158 text: i18nc("@option:check", "Bold") 0159 checked: SubtitlesSettings.isBold 0160 onCheckedChanged: { 0161 SubtitlesSettings.isBold = checked 0162 SubtitlesSettings.save() 0163 mpv.setProperty(MpvProperties.SubtitleBold, checked) 0164 } 0165 } 0166 0167 Item { width: 1 } 0168 0169 CheckBox { 0170 text: i18nc("@option:check", "Italic") 0171 checked: SubtitlesSettings.isItalic 0172 onCheckedChanged: { 0173 SubtitlesSettings.isItalic = checked 0174 SubtitlesSettings.save() 0175 mpv.setProperty(MpvProperties.SubtitleItalic, checked) 0176 } 0177 } 0178 0179 Label { 0180 text: i18nc("@label:textbox", "Font color") 0181 Layout.alignment: Qt.AlignRight 0182 } 0183 0184 RowLayout { 0185 Layout.fillWidth: true 0186 0187 0188 ColorPickerButton { 0189 id: subtitleColorPicker 0190 0191 color: SubtitlesSettings.fontColor 0192 onColorChosen: function (color) { 0193 subtitleColor.text = color 0194 } 0195 0196 Layout.preferredHeight: subtitleColor.height 0197 Layout.preferredWidth: subtitleColor.height 0198 } 0199 0200 TextField { 0201 id: subtitleColor 0202 0203 property string defaultColor: "#FFFFFFFF" 0204 0205 text: SubtitlesSettings.fontColor 0206 0207 onTextChanged: { 0208 save() 0209 } 0210 0211 Connections { 0212 target: root 0213 function onSave() { 0214 subtitleColor.save() 0215 } 0216 } 0217 0218 function save() { 0219 subtitleColorPicker.color = text 0220 SubtitlesSettings.fontColor = text 0221 SubtitlesSettings.save() 0222 mpv.setProperty(MpvProperties.SubtitleColor, text) 0223 } 0224 } 0225 0226 Button { 0227 icon.name: "edit-clear-all" 0228 onClicked: subtitleColor.text = subtitleColor.defaultColor 0229 0230 ToolTip { 0231 text: i18nc("@info:tooltip", "Set default value") 0232 } 0233 } 0234 } 0235 0236 Label { 0237 text: i18nc("@label:textbox", "Shadow color") 0238 Layout.alignment: Qt.AlignRight 0239 } 0240 0241 RowLayout { 0242 Layout.fillWidth: true 0243 0244 ColorPickerButton { 0245 id: shadowColorPicker 0246 0247 color: SubtitlesSettings.shadowColor 0248 onColorChosen: function (color) { 0249 shadowColor.text = color 0250 } 0251 0252 Layout.preferredHeight: shadowColor.height 0253 Layout.preferredWidth: shadowColor.height 0254 } 0255 0256 TextField { 0257 id: shadowColor 0258 0259 property string defaultColor: "#80F0F0F0" 0260 0261 text: SubtitlesSettings.shadowColor 0262 0263 onTextChanged: { 0264 save() 0265 } 0266 0267 Connections { 0268 target: root 0269 function onSave() { 0270 shadowColor.save() 0271 } 0272 } 0273 0274 function save() { 0275 shadowColorPicker.color = text 0276 SubtitlesSettings.shadowColor = text 0277 SubtitlesSettings.save() 0278 mpv.setProperty(MpvProperties.SubtitleShadowColor, text) 0279 } 0280 } 0281 0282 Button { 0283 icon.name: "edit-clear-all" 0284 onClicked: shadowColor.text = shadowColor.defaultColor 0285 0286 ToolTip { 0287 text: i18nc("@info:tooltip", "Set default value") 0288 } 0289 } 0290 } 0291 0292 Label { 0293 text: i18nc("@label:spinbox", "Shadow offset") 0294 Layout.alignment: Qt.AlignRight 0295 } 0296 0297 SpinBox { 0298 from: 0 0299 to: 25 0300 value: SubtitlesSettings.shadowOffset 0301 editable: true 0302 onValueChanged: { 0303 SubtitlesSettings.shadowOffset = value 0304 SubtitlesSettings.save() 0305 mpv.setProperty(MpvProperties.SubtitleShadowOffset, value) 0306 } 0307 0308 ToolTip { 0309 text: i18nc("@info:tooltip", "Set to 0 (zero) to disable.") 0310 } 0311 } 0312 0313 Label { 0314 text: i18nc("@label:textbox", "Border color") 0315 Layout.alignment: Qt.AlignRight 0316 } 0317 0318 RowLayout { 0319 Layout.fillWidth: true 0320 0321 ColorPickerButton { 0322 id: borderColorPicker 0323 0324 color: SubtitlesSettings.borderColor 0325 onColorChosen: function (color) { 0326 borderColor.text = color 0327 } 0328 0329 Layout.preferredHeight: borderColor.height 0330 Layout.preferredWidth: borderColor.height 0331 } 0332 0333 TextField { 0334 id: borderColor 0335 0336 property string defaultColor: "#FF000000" 0337 0338 text: SubtitlesSettings.borderColor 0339 0340 onTextChanged: { 0341 save() 0342 } 0343 0344 Connections { 0345 target: root 0346 function onSave() { 0347 borderColor.save() 0348 } 0349 } 0350 0351 function save() { 0352 borderColorPicker.color = text 0353 SubtitlesSettings.borderColor = text 0354 SubtitlesSettings.save() 0355 mpv.setProperty(MpvProperties.SubtitleBorderColor, text) 0356 } 0357 } 0358 0359 Button { 0360 icon.name: "edit-clear-all" 0361 onClicked: borderColor.text = borderColor.defaultColor 0362 0363 ToolTip { 0364 text: i18nc("@info:tooltip", "Set default value") 0365 } 0366 } 0367 } 0368 0369 Label { 0370 text: i18nc("@label:spinbox", "Border width") 0371 Layout.alignment: Qt.AlignRight 0372 } 0373 0374 SpinBox { 0375 from: 0 0376 to: 25 0377 value: SubtitlesSettings.borderSize 0378 editable: true 0379 onValueChanged: { 0380 SubtitlesSettings.borderSize = value 0381 SubtitlesSettings.save() 0382 mpv.setProperty(MpvProperties.SubtitleBorderSize, value) 0383 } 0384 0385 ToolTip { 0386 text: i18nc("@info:tooltip", "Set to 0 (zero) to disable.") 0387 } 0388 } 0389 0390 Item { 0391 width: Kirigami.Units.gridUnit 0392 height: Kirigami.Units.gridUnit 0393 } 0394 } 0395 }