Warning, /multimedia/haruna/src/qml/Settings/GeneralSettings.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.settings 0014 0015 SettingsBasePage { 0016 id: root 0017 0018 hasHelp: true 0019 helpFile: ":/GeneralSettings.html" 0020 docPage: "help:/haruna/GeneralSettings.html" 0021 0022 GridLayout { 0023 id: content 0024 0025 columns: 2 0026 0027 // OSD Font Size 0028 Label { 0029 text: i18nc("@label:spinbox", "Osd font size") 0030 Layout.alignment: Qt.AlignRight 0031 } 0032 0033 SpinBox { 0034 id: osdFontSize 0035 0036 // used to prevent osd showing when opening the page 0037 property bool completed: false 0038 0039 editable: true 0040 from: 0 0041 to: 100 0042 value: GeneralSettings.osdFontSize 0043 onValueChanged: { 0044 if (completed) { 0045 osd.label.font.pointSize = osdFontSize.value 0046 osd.message("Test osd font size") 0047 GeneralSettings.osdFontSize = osdFontSize.value 0048 GeneralSettings.save() 0049 } 0050 } 0051 Component.onCompleted: completed = true 0052 } 0053 0054 Label { 0055 text: i18nc("@label:textbox", "File dialog location") 0056 Layout.alignment: Qt.AlignRight 0057 } 0058 0059 TextField { 0060 id: fileDialogLocation 0061 0062 text: GeneralSettings.fileDialogLocation 0063 Layout.fillWidth: true 0064 onEditingFinished: save() 0065 0066 Connections { 0067 target: root 0068 function onSave() { 0069 fileDialogLocation.save() 0070 } 0071 } 0072 0073 ToolTip { 0074 text: i18nc("@info:tooltip", "If empty the file dialog will remember the last opened location.") 0075 } 0076 0077 function save() { 0078 GeneralSettings.fileDialogLocation = fileDialogLocation.text 0079 GeneralSettings.save() 0080 } 0081 } 0082 0083 Label { 0084 text: i18nc("@label:spinbox", "Maximum recent files") 0085 Layout.alignment: Qt.AlignRight 0086 } 0087 0088 SpinBox { 0089 id: maxRecentFiles 0090 0091 from: 0 0092 to: 100 0093 value: GeneralSettings.maxRecentFiles 0094 onValueChanged: { 0095 GeneralSettings.maxRecentFiles = maxRecentFiles.value 0096 GeneralSettings.save() 0097 recentFilesModel.populate() 0098 } 0099 0100 ToolTip { 0101 text: i18nc("@info:tooltip", "How many recent files to store. Enter 0 (zero) to disable.") 0102 } 0103 } 0104 0105 Item { width: 1 } 0106 0107 RowLayout { 0108 CheckBox { 0109 text: i18nc("@option:check", "Allow only one instance") 0110 checked: GeneralSettings.useSingleInstance 0111 onCheckedChanged: { 0112 GeneralSettings.useSingleInstance = checked 0113 GeneralSettings.save() 0114 } 0115 } 0116 0117 ToolButton { 0118 icon.name: "documentinfo" 0119 checkable: true 0120 checked: false 0121 Layout.preferredHeight: Kirigami.Units.iconSizes.medium 0122 0123 ToolTip { 0124 text: i18nc("@info:tooltip", 0125 "Trying to open another Haruna instance will do nothing.\n"+ 0126 "Trying to open another file with Haruna will open the file in the running instance.") 0127 visible: parent.checked 0128 delay: 0 0129 timeout: -1 0130 closePolicy: Popup.NoAutoClose 0131 } 0132 } 0133 } 0134 0135 Item { width: 1 } 0136 0137 RowLayout { 0138 CheckBox { 0139 text: i18nc("@option:check", "Add file to playlist") 0140 checked: GeneralSettings.appendVideoToSingleInstance 0141 enabled: GeneralSettings.useSingleInstance 0142 onCheckedChanged: { 0143 GeneralSettings.appendVideoToSingleInstance = checked 0144 GeneralSettings.save() 0145 } 0146 } 0147 0148 ToolButton { 0149 icon.name: "documentinfo" 0150 checkable: true 0151 checked: false 0152 Layout.preferredHeight: Kirigami.Units.iconSizes.medium 0153 0154 ToolTip { 0155 text: i18nc("@info:tooltip", "File will be added to the end of the playlist") 0156 visible: parent.checked 0157 delay: 0 0158 timeout: -1 0159 closePolicy: Popup.NoAutoClose 0160 } 0161 } 0162 } 0163 SettingsHeader { 0164 text: i18nc("@title", "Interface") 0165 Layout.columnSpan: 2 0166 Layout.fillWidth: true 0167 } 0168 0169 Label { 0170 text: i18nc("@label:spinbox", "Preview thumbnail") 0171 Layout.alignment: Qt.AlignRight 0172 } 0173 0174 CheckBox { 0175 text: i18nc("@option:check", "Show preview thumbnail") 0176 checked: GeneralSettings.showPreviewThumbnail 0177 onCheckedChanged: { 0178 GeneralSettings.showPreviewThumbnail = checked 0179 GeneralSettings.save() 0180 } 0181 } 0182 0183 Item { width: 1 } 0184 0185 RowLayout { 0186 CheckBox { 0187 text: i18nc("@option:check", "Use accurate preview") 0188 checked: GeneralSettings.accuratePreviewThumbnail 0189 enabled: GeneralSettings.showPreviewThumbnail 0190 onCheckedChanged: { 0191 GeneralSettings.accuratePreviewThumbnail = checked 0192 GeneralSettings.save() 0193 } 0194 } 0195 0196 ToolButton { 0197 icon.name: "documentinfo" 0198 icon.color: Kirigami.Theme.negativeTextColor 0199 checkable: true 0200 checked: false 0201 Layout.preferredHeight: Kirigami.Units.iconSizes.medium 0202 0203 ToolTip { 0204 text: i18nc("@info:tooltip", "Generating an accurate preview is slow") 0205 visible: parent.checked 0206 delay: 0 0207 timeout: -1 0208 closePolicy: Popup.NoAutoClose 0209 } 0210 } 0211 } 0212 0213 Item { width: 1 } 0214 0215 SpinBox { 0216 id: previewThumbnailWidth 0217 0218 from: 100 0219 to: 10000 0220 value: GeneralSettings.previewThumbnailWidth 0221 enabled: GeneralSettings.showPreviewThumbnail 0222 onValueChanged: { 0223 GeneralSettings.previewThumbnailWidth = previewThumbnailWidth.value 0224 GeneralSettings.save() 0225 } 0226 } 0227 0228 Label { 0229 text: i18nc("@label:spinbox", "Window") 0230 Layout.alignment: Qt.AlignRight 0231 } 0232 0233 RowLayout { 0234 CheckBox { 0235 text: i18nc("@option:check", "Resize to fit video") 0236 checked: GeneralSettings.resizeWindowToVideo 0237 onCheckedChanged: { 0238 GeneralSettings.resizeWindowToVideo = checked 0239 GeneralSettings.save() 0240 window.resizeWindow() 0241 } 0242 } 0243 0244 ToolButton { 0245 icon.name: "documentinfo" 0246 checkable: true 0247 checked: false 0248 Layout.preferredHeight: Kirigami.Units.iconSizes.medium 0249 0250 ToolTip { 0251 text: i18nc("@info:tooltip", "The window is resized according to the video resolution.\n" + 0252 "The maximum size is not constrained, this is left to the operating system.") 0253 visible: parent.checked 0254 delay: 0 0255 timeout: -1 0256 closePolicy: Popup.NoAutoClose 0257 } 0258 } 0259 } 0260 0261 Item { width: 1 } 0262 0263 RowLayout { 0264 CheckBox { 0265 text: i18nc("@option:check", "Remember window size and position") 0266 checked: GeneralSettings.rememberWindowGeometry 0267 onCheckedChanged: { 0268 GeneralSettings.rememberWindowGeometry = checked 0269 GeneralSettings.save() 0270 } 0271 } 0272 0273 ToolButton { 0274 icon.name: "documentinfo" 0275 checkable: true 0276 checked: false 0277 Layout.preferredHeight: Kirigami.Units.iconSizes.medium 0278 0279 ToolTip { 0280 text: i18nc("@info:tooltip", "When window size and position are changed the new values " + 0281 "are saved and used to restore the application " + 0282 "to the same size and position when a new instance is opened.\n\n"+ 0283 "The \"Resize to fit video\" setting takes precedence.\n") 0284 visible: parent.checked 0285 delay: 0 0286 timeout: -1 0287 closePolicy: Popup.NoAutoClose 0288 } 0289 } 0290 } 0291 0292 Item { width: 1 } 0293 0294 CheckBox { 0295 text: i18nc("@option:check", "Show menubar") 0296 checked: GeneralSettings.showMenuBar 0297 onCheckedChanged: { 0298 GeneralSettings.showMenuBar = checked 0299 GeneralSettings.save() 0300 } 0301 } 0302 0303 Item { width: 1 } 0304 0305 CheckBox { 0306 text: i18nc("@option:check", "Show toolbar") 0307 checked: GeneralSettings.showHeader 0308 onCheckedChanged: { 0309 GeneralSettings.showHeader = checked 0310 GeneralSettings.save() 0311 } 0312 } 0313 0314 Item { width: 1 } 0315 0316 CheckBox { 0317 text: i18nc("@option:check", "Show chapter markers") 0318 checked: GeneralSettings.showChapterMarkers 0319 onCheckedChanged: { 0320 GeneralSettings.showChapterMarkers = checked 0321 GeneralSettings.save() 0322 } 0323 } 0324 0325 Label { 0326 text: i18nc("@label:listbox", "Color scheme") 0327 Layout.alignment: Qt.AlignRight 0328 } 0329 0330 ComboBox { 0331 id: colorThemeSwitcher 0332 0333 textRole: "display" 0334 model: app.colorSchemesModel 0335 delegate: ItemDelegate { 0336 Kirigami.Theme.colorSet: Kirigami.Theme.View 0337 width: colorThemeSwitcher.width 0338 highlighted: model.display === GeneralSettings.colorScheme 0339 contentItem: RowLayout { 0340 Kirigami.Icon { 0341 source: model.decoration 0342 Layout.preferredHeight: Kirigami.Units.iconSizes.small 0343 Layout.preferredWidth: Kirigami.Units.iconSizes.small 0344 } 0345 Label { 0346 text: model.display 0347 color: highlighted ? Kirigami.Theme.highlightedTextColor : Kirigami.Theme.textColor 0348 Layout.fillWidth: true 0349 } 0350 } 0351 } 0352 0353 onActivated: function(index) { 0354 GeneralSettings.colorScheme = colorThemeSwitcher.textAt(index) 0355 GeneralSettings.save() 0356 app.activateColorScheme(GeneralSettings.colorScheme) 0357 } 0358 0359 Component.onCompleted: { 0360 currentIndex = find(GeneralSettings.colorScheme) 0361 if (currentIndex === -1) { 0362 currentIndex = find("Default") 0363 } 0364 } 0365 } 0366 0367 Label { 0368 text: i18nc("@label:listbox", "GUI style") 0369 Layout.alignment: Qt.AlignRight 0370 } 0371 0372 ComboBox { 0373 id: guiStyleComboBox 0374 0375 textRole: "key" 0376 model: ListModel { 0377 id: stylesModel 0378 0379 ListElement { key: "Default"; } 0380 } 0381 0382 onActivated: function(index) { 0383 GeneralSettings.guiStyle = model.get(index).key 0384 app.setGuiStyle(GeneralSettings.guiStyle) 0385 // some themes can cause a crash 0386 // the timer prevents saving the crashing theme, 0387 // which would cause the app to crash on startup 0388 saveGuiStyleTimer.start() 0389 } 0390 0391 Timer { 0392 id: saveGuiStyleTimer 0393 0394 interval: 1000 0395 running: false 0396 repeat: false 0397 onTriggered: GeneralSettings.save() 0398 } 0399 0400 Component.onCompleted: { 0401 // populate the model with the available styles 0402 for (let i = 0; i < app.availableGuiStyles().length; ++i) { 0403 stylesModel.append({key: app.availableGuiStyles()[i]}) 0404 } 0405 0406 // set the saved style as the current item in the combo box 0407 for (let j = 0; j < stylesModel.count; ++j) { 0408 if (stylesModel.get(j).key === GeneralSettings.guiStyle) { 0409 currentIndex = j 0410 break 0411 } 0412 } 0413 } 0414 } 0415 0416 Item { width: 1 } 0417 0418 CheckBox { 0419 text: i18nc("@option:check", "Use Breeze icon theme") 0420 checked: GeneralSettings.useBreezeIconTheme 0421 onCheckedChanged: { 0422 GeneralSettings.useBreezeIconTheme = checked 0423 GeneralSettings.save() 0424 } 0425 0426 ToolTip { 0427 text: i18nc("@info:tooltip", "Sets the icon theme to breeze.\nRequires restart.") 0428 } 0429 } 0430 0431 Item { 0432 width: Kirigami.Units.gridUnit 0433 height: Kirigami.Units.gridUnit 0434 } 0435 } 0436 }