Warning, /multimedia/kasts/src/qml/Settings/GeneralSettingsPage.qml is written in an unsupported language. File is not indexed.

0001 /**
0002  * SPDX-FileCopyrightText: 2020 Tobias Fella <tobias.fella@kde.org>
0003  * SPDX-FileCopyrightText: 2021-2023 Bart De Vries <bart@mogwai.be>
0004  *
0005  * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0006  */
0007 
0008 import QtQuick
0009 import QtQuick.Controls as Controls
0010 import QtQuick.Layouts
0011 
0012 import org.kde.kirigami as Kirigami
0013 import org.kde.kirigamiaddons.formcard as FormCard
0014 import org.kde.kmediasession
0015 
0016 import org.kde.kasts
0017 import org.kde.kasts.settings
0018 
0019 FormCard.FormCardPage {
0020     id: root
0021 
0022     FormCard.FormHeader {
0023         title: i18n("Appearance")
0024         Layout.fillWidth: true
0025     }
0026 
0027     FormCard.FormCard {
0028         Layout.fillWidth: true
0029 
0030         FormCard.FormComboBoxDelegate {
0031             Layout.fillWidth: true
0032             id: colorTheme
0033             text: i18n("Color theme")
0034             textRole: "display"
0035             valueRole: "display"
0036             model: ColorSchemer.model
0037             Component.onCompleted: currentIndex = ColorSchemer.indexForScheme(SettingsManager.colorScheme);
0038             onCurrentValueChanged: {
0039                 ColorSchemer.apply(currentIndex);
0040                 SettingsManager.colorScheme = ColorSchemer.nameForIndex(currentIndex);
0041                 SettingsManager.save();
0042             }
0043         }
0044 
0045         FormCard.FormDelegateSeparator {}
0046 
0047         FormCard.FormCheckDelegate {
0048             id: alwaysShowFeedTitles
0049             text: i18n("Always show podcast titles in subscription view")
0050             checked: SettingsManager.alwaysShowFeedTitles
0051             onToggled: {
0052                 SettingsManager.alwaysShowFeedTitles = checked;
0053                 SettingsManager.save();
0054             }
0055         }
0056 
0057         FormCard.FormDelegateSeparator {}
0058 
0059         FormCard.FormCheckDelegate {
0060             id: showTrayIcon
0061             visible: SystrayIcon.available
0062             enabled: SystrayIcon.available
0063             text: i18n("Show icon in system tray")
0064             checked: SettingsManager.showTrayIcon
0065             onToggled: {
0066                 SettingsManager.showTrayIcon = checked;
0067                 SettingsManager.save();
0068             }
0069         }
0070 
0071         FormCard.FormCheckDelegate {
0072             id: minimizeToTray
0073             visible: SystrayIcon.available
0074             enabled: SettingsManager.showTrayIcon && SystrayIcon.available
0075             text: i18n("Minimize to tray instead of closing")
0076             checked: SettingsManager.minimizeToTray
0077             onToggled: {
0078                 SettingsManager.minimizeToTray = checked;
0079                 SettingsManager.save();
0080             }
0081         }
0082 
0083         FormCard.FormComboBoxDelegate {
0084             id: trayIconType
0085             visible: SystrayIcon.available
0086             enabled: SettingsManager.showTrayIcon && SystrayIcon.available
0087             text: i18nc("Label for selecting the color of the tray icon", "Tray icon type")
0088 
0089             textRole: "text"
0090             valueRole: "value"
0091 
0092             model: [{"text": i18nc("Label describing style of tray icon", "Colorful"), "value": 0},
0093                     {"text": i18nc("Label describing style of tray icon", "Light"), "value": 1},
0094                     {"text": i18nc("Label describing style of tray icon", "Dark"), "value": 2}]
0095             Component.onCompleted: currentIndex = indexOfValue(SettingsManager.trayIconType)
0096             onActivated: {
0097                 SettingsManager.trayIconType = currentValue;
0098                 SettingsManager.save();
0099             }
0100         }
0101     }
0102 
0103     FormCard.FormHeader {
0104         title: i18n("Playback settings")
0105         Layout.fillWidth: true
0106     }
0107 
0108     FormCard.FormCard {
0109         Layout.fillWidth: true
0110 
0111         FormCard.FormComboBoxDelegate {
0112             id: selectAudioBackend
0113             text: i18nc("Label for setting to select audio playback backend", "Select audio backend")
0114 
0115             textRole: "text"
0116             valueRole: "value"
0117 
0118             model: ListModel {
0119                 id: backendModel
0120             }
0121 
0122             Component.onCompleted: {
0123                 // have to use Number because QML doesn't know about enum names
0124                 for (var index in AudioManager.availableBackends) {
0125                     backendModel.append({"text": AudioManager.backendName(AudioManager.availableBackends[index]),
0126                                          "value": Number(AudioManager.availableBackends[index])});
0127 
0128                     if (Number(AudioManager.availableBackends[index]) === AudioManager.currentBackend) {
0129                         currentIndex = index;
0130                     }
0131                 }
0132             }
0133 
0134             onActivated: {
0135                 AudioManager.currentBackend = currentValue;
0136             }
0137         }
0138 
0139         FormCard.FormDelegateSeparator {}
0140 
0141         FormCard.FormCheckDelegate {
0142             id: showTimeLeft
0143             Kirigami.FormData.label: i18nc("Label for settings related to the play time, e.g. whether the total track time is shown or a countdown of the remaining play time", "Play time:")
0144             checked: SettingsManager.toggleRemainingTime
0145             text: i18n("Show time left instead of total track time")
0146             onToggled: {
0147                 SettingsManager.toggleRemainingTime = checked;
0148                 SettingsManager.save();
0149             }
0150         }
0151         FormCard.FormCheckDelegate {
0152             id: adjustTimeLeft
0153             checked: SettingsManager.adjustTimeLeft
0154             enabled: SettingsManager.toggleRemainingTime
0155             text: i18n("Adjust time left based on current playback speed")
0156             onToggled: {
0157                 SettingsManager.adjustTimeLeft = checked;
0158                 SettingsManager.save();
0159             }
0160         }
0161         FormCard.FormCheckDelegate {
0162             id: prioritizeStreaming
0163             checked: SettingsManager.prioritizeStreaming
0164             text: i18n("Prioritize streaming over downloading")
0165             onToggled: {
0166                 SettingsManager.prioritizeStreaming = checked;
0167                 SettingsManager.save();
0168             }
0169         }
0170         FormCard.FormDelegateSeparator {
0171             below: prioritizeStreaming
0172             above: skipForwardStep
0173         }
0174         FormCard.FormTextDelegate {
0175             id: skipForwardStep
0176             text: i18nc("@label:spinbox", "Skip forward interval (in seconds)")
0177             trailing: Controls.SpinBox {
0178                 Layout.rightMargin: Kirigami.Units.gridUnit
0179                 value: SettingsManager.skipForward
0180                 from: 1
0181                 to: 300
0182                 onValueModified: {
0183                     SettingsManager.skipForward = value;
0184                     SettingsManager.save();
0185                 }
0186             }
0187         }
0188         FormCard.FormTextDelegate {
0189             id: skipBackwardInterval
0190             text: i18nc("@label:spinbox", "Skip backward interval (in seconds)")
0191             trailing: Controls.SpinBox {
0192                 Layout.rightMargin: Kirigami.Units.gridUnit
0193                 value: SettingsManager.skipBackward
0194                 from: 1
0195                 to: 300
0196                 onValueModified: {
0197                     SettingsManager.skipBackward = value;
0198                     SettingsManager.save();
0199                 }
0200             }
0201         }
0202     }
0203 
0204     FormCard.FormHeader {
0205         title: i18n("Queue settings")
0206         Layout.fillWidth: true
0207     }
0208 
0209     FormCard.FormCard {
0210         Layout.fillWidth: true
0211 
0212         FormCard.FormCheckDelegate {
0213             id: continuePlayingNextEntry
0214             checked: SettingsManager.continuePlayingNextEntry
0215             text: i18n("Continue playing next episode after current one finishes")
0216             onToggled: {
0217                 SettingsManager.continuePlayingNextEntry = checked;
0218                 SettingsManager.save();
0219             }
0220         }
0221         FormCard.FormCheckDelegate {
0222             id: refreshOnStartup
0223             Kirigami.FormData.label: i18nc("Label for settings related to podcast updates", "Update Settings:")
0224             checked: SettingsManager.refreshOnStartup
0225             text: i18n("Automatically fetch podcast updates on startup")
0226             onToggled: {
0227                 SettingsManager.refreshOnStartup = checked;
0228                 SettingsManager.save();
0229             }
0230         }
0231         FormCard.FormCheckDelegate {
0232             id: doFullUpdate
0233             checked: SettingsManager.doFullUpdate
0234             text: i18n("Update existing episode data on refresh (slower)")
0235             onToggled: {
0236                 SettingsManager.doFullUpdate = checked;
0237                 SettingsManager.save();
0238             }
0239         }
0240 
0241         FormCard.FormCheckDelegate {
0242             id: autoQueue
0243             checked: SettingsManager.autoQueue
0244             text: i18n("Automatically queue new episodes")
0245 
0246             onToggled: {
0247                 SettingsManager.autoQueue = checked;
0248                 if (!checked) {
0249                     autoDownload.checked = false;
0250                     SettingsManager.autoDownload = false;
0251                 }
0252                 SettingsManager.save();
0253             }
0254         }
0255 
0256         FormCard.FormCheckDelegate {
0257             id: autoDownload
0258             checked: SettingsManager.autoDownload
0259             text: i18n("Automatically download new episodes")
0260 
0261             enabled: autoQueue.checked
0262             onToggled: {
0263                 SettingsManager.autoDownload = checked;
0264                 SettingsManager.save();
0265             }
0266         }
0267 
0268         FormCard.FormDelegateSeparator { above: autoDownload; below: episodeBehavior }
0269 
0270         FormCard.FormComboBoxDelegate {
0271             id: episodeBehavior
0272             text: i18n("Played episode behavior")
0273             textRole: "text"
0274             valueRole: "value"
0275             model: [{"text": i18n("Do not delete"), "value": 0},
0276                     {"text": i18n("Delete immediately"), "value": 1},
0277                     {"text": i18n("Delete at next startup"), "value": 2}]
0278             Component.onCompleted: currentIndex = indexOfValue(SettingsManager.autoDeleteOnPlayed)
0279             onActivated: {
0280                 SettingsManager.autoDeleteOnPlayed = currentValue;
0281                 SettingsManager.save();
0282             }
0283         }
0284 
0285         FormCard.FormDelegateSeparator { above: episodeBehavior; below: markAsPlayedGracePeriod }
0286 
0287         FormCard.FormTextDelegate {
0288             id: markAsPlayedGracePeriod
0289             text: i18nc("@label:spinbox", "Mark episodes as played when the given time is remaining (in seconds)")
0290             textItem.wrapMode: Text.Wrap
0291             trailing: Controls.SpinBox {
0292                 Layout.rightMargin: Kirigami.Units.gridUnit
0293                 value: SettingsManager.markAsPlayedBeforeEnd
0294                 from: 0
0295                 to: 300
0296                 onValueModified: {
0297                     SettingsManager.markAsPlayedBeforeEnd = value;
0298                     SettingsManager.save();
0299                 }
0300             }
0301         }
0302 
0303         FormCard.FormDelegateSeparator { above: markAsPlayedGracePeriod; below: resetPositionOnPlayed }
0304 
0305         FormCard.FormCheckDelegate {
0306             id: resetPositionOnPlayed
0307             checked: SettingsManager.resetPositionOnPlayed
0308             text: i18n("Reset play position after an episode is played")
0309             onToggled: {
0310                 SettingsManager.resetPositionOnPlayed = checked;
0311                 SettingsManager.save();
0312             }
0313         }
0314     }
0315 
0316     FormCard.FormHeader {
0317         title: i18n("When adding new podcasts")
0318         Layout.fillWidth: true
0319     }
0320 
0321     FormCard.FormCard {
0322         Layout.fillWidth: true
0323 
0324         FormCard.FormRadioDelegate {
0325             checked: SettingsManager.markUnreadOnNewFeed === 0
0326             text: i18n("Mark all episodes as played")
0327             onToggled: {
0328                 SettingsManager.markUnreadOnNewFeed = 0;
0329                 SettingsManager.save();
0330             }
0331         }
0332 
0333 
0334         FormCard.FormRadioDelegate {
0335             id: markCustomUnreadNumberButton
0336             checked: SettingsManager.markUnreadOnNewFeed === 1
0337             text: i18n("Mark most recent episodes as unplayed")
0338             onToggled: {
0339                 SettingsManager.markUnreadOnNewFeed = 1;
0340                 SettingsManager.save();
0341             }
0342 
0343             trailing: Controls.SpinBox {
0344                 Layout.rightMargin: Kirigami.Units.gridUnit
0345                 id: markCustomUnreadNumberSpinBox
0346                 enabled: markCustomUnreadNumberButton.checked
0347                 value: SettingsManager.markUnreadOnNewFeedCustomAmount
0348                 from: 0
0349                 to: 100
0350 
0351                 onValueModified: {
0352                     SettingsManager.markUnreadOnNewFeedCustomAmount = value;
0353                     SettingsManager.save();
0354                 }
0355             }
0356         }
0357 
0358         FormCard.FormRadioDelegate {
0359             checked: SettingsManager.markUnreadOnNewFeed === 2
0360             text: i18n("Mark all episodes as unplayed")
0361             onToggled: {
0362                 SettingsManager.markUnreadOnNewFeed = 2;
0363                 SettingsManager.save();
0364             }
0365         }
0366     }
0367 
0368     FormCard.FormHeader {
0369         title: i18n("Article")
0370         Layout.fillWidth: true
0371     }
0372 
0373     FormCard.FormCard {
0374         Layout.fillWidth: true
0375 
0376         FormCard.FormTextDelegate {
0377             id: fontSize
0378             text: i18n("Font size")
0379 
0380             trailing: Controls.SpinBox {
0381                 id: articleFontSizeSpinBox
0382 
0383                 enabled: !useSystemFontCheckBox.checked
0384                 value: SettingsManager.articleFontSize
0385                 Kirigami.FormData.label: i18n("Font size:")
0386                 from: 6
0387                 to: 20
0388 
0389                 onValueModified: {
0390                     SettingsManager.articleFontSize = value;
0391                     SettingsManager.save();
0392                 }
0393             }
0394         }
0395 
0396         FormCard.FormDelegateSeparator { above: fontSize; below: useSystemFontCheckBox }
0397 
0398         FormCard.FormCheckDelegate {
0399             id: useSystemFontCheckBox
0400             checked: SettingsManager.articleFontUseSystem
0401             text: i18n("Use system default")
0402 
0403             onToggled: {
0404                 SettingsManager.articleFontUseSystem = checked;
0405                 SettingsManager.save();
0406             }
0407         }
0408     }
0409 }