From 5bd4ee9154c368003163cfd6df01cdb17ba1e2a7 Mon Sep 17 00:00:00 2001 From: Bart De Vries Date: Tue, 23 Jan 2024 08:53:04 +0100 Subject: [PATCH] Split off appearance settings into a dedicated section --- src/CMakeLists.txt | 4 +- src/qml/Settings/AppearanceSettingsPage.qml | 151 ++++++++++++++++++++ src/qml/Settings/GeneralSettingsPage.qml | 123 ---------------- src/qml/Settings/SettingsPage.qml | 8 +- 4 files changed, 161 insertions(+), 125 deletions(-) create mode 100644 src/qml/Settings/AppearanceSettingsPage.qml diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2ec52b97..e4bdb8e6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -112,6 +112,7 @@ qt_add_qml_module(kasts URI org.kde.kasts qml/SyncPasswordOverlay.qml qml/Settings/SettingsPage.qml qml/Settings/GeneralSettingsPage.qml + qml/Settings/AppearanceSettingsPage.qml qml/Settings/NetworkSettingsPage.qml qml/Settings/StorageSettingsPage.qml qml/Settings/SynchronizationSettingsPage.qml @@ -305,7 +306,8 @@ if(ANDROID) kt-add-feeds state-sync network-connect - drive-harddisk-symbolic + drive-harddisk + preferences-desktop-theme-global dialog-ok dialog-cancel computer diff --git a/src/qml/Settings/AppearanceSettingsPage.qml b/src/qml/Settings/AppearanceSettingsPage.qml new file mode 100644 index 00000000..629c1853 --- /dev/null +++ b/src/qml/Settings/AppearanceSettingsPage.qml @@ -0,0 +1,151 @@ +/** + * SPDX-FileCopyrightText: 2020 Tobias Fella + * SPDX-FileCopyrightText: 2021-2023 Bart De Vries + * + * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL + */ + +import QtQuick +import QtQuick.Controls as Controls +import QtQuick.Layouts + +import org.kde.kirigami as Kirigami +import org.kde.kirigamiaddons.formcard as FormCard +import org.kde.kmediasession + +import org.kde.kasts +import org.kde.kasts.settings + +FormCard.FormCardPage { + id: root + + FormCard.FormHeader { + title: i18n("Appearance") + Layout.fillWidth: true + } + + FormCard.FormCard { + Layout.fillWidth: true + + FormCard.FormComboBoxDelegate { + Layout.fillWidth: true + id: colorTheme + text: i18n("Color theme") + textRole: "display" + valueRole: "display" + model: ColorSchemer.model + Component.onCompleted: currentIndex = ColorSchemer.indexForScheme(SettingsManager.colorScheme); + onCurrentValueChanged: { + ColorSchemer.apply(currentIndex); + SettingsManager.colorScheme = ColorSchemer.nameForIndex(currentIndex); + SettingsManager.save(); + } + } + + FormCard.FormDelegateSeparator {} + + FormCard.FormCheckDelegate { + id: alwaysShowFeedTitles + text: i18n("Always show podcast titles in subscription view") + checked: SettingsManager.alwaysShowFeedTitles + onToggled: { + SettingsManager.alwaysShowFeedTitles = checked; + SettingsManager.save(); + } + } + } + + FormCard.FormHeader { + title: i18nc("@title Title header for settings related to the tray icon", "Tray icon") + Layout.fillWidth: true + } + + FormCard.FormCard { + Layout.fillWidth: true + + FormCard.FormCheckDelegate { + id: showTrayIcon + visible: SystrayIcon.available + enabled: SystrayIcon.available + text: i18n("Show icon in system tray") + checked: SettingsManager.showTrayIcon + onToggled: { + SettingsManager.showTrayIcon = checked; + SettingsManager.save(); + } + } + + FormCard.FormCheckDelegate { + id: minimizeToTray + visible: SystrayIcon.available + enabled: SettingsManager.showTrayIcon && SystrayIcon.available + text: i18n("Minimize to tray instead of closing") + checked: SettingsManager.minimizeToTray + onToggled: { + SettingsManager.minimizeToTray = checked; + SettingsManager.save(); + } + } + + FormCard.FormComboBoxDelegate { + id: trayIconType + visible: SystrayIcon.available + enabled: SettingsManager.showTrayIcon && SystrayIcon.available + text: i18nc("Label for selecting the color of the tray icon", "Tray icon type") + + textRole: "text" + valueRole: "value" + + model: [{"text": i18nc("Label describing style of tray icon", "Colorful"), "value": 0}, + {"text": i18nc("Label describing style of tray icon", "Light"), "value": 1}, + {"text": i18nc("Label describing style of tray icon", "Dark"), "value": 2}] + Component.onCompleted: currentIndex = indexOfValue(SettingsManager.trayIconType) + onActivated: { + SettingsManager.trayIconType = currentValue; + SettingsManager.save(); + } + } + } + + FormCard.FormHeader { + title: i18n("Text") + Layout.fillWidth: true + } + + FormCard.FormCard { + Layout.fillWidth: true + + FormCard.FormCheckDelegate { + id: useSystemFontCheckBox + checked: SettingsManager.articleFontUseSystem + text: i18n("Use system default") + + onToggled: { + SettingsManager.articleFontUseSystem = checked; + SettingsManager.save(); + } + } + + FormCard.FormDelegateSeparator { below: fontSize; above: useSystemFontCheckBox } + + FormCard.FormTextDelegate { + id: fontSize + text: i18n("Font size") + + trailing: Controls.SpinBox { + id: articleFontSizeSpinBox + + enabled: !useSystemFontCheckBox.checked + value: SettingsManager.articleFontSize + Kirigami.FormData.label: i18n("Font size:") + from: 6 + to: 20 + + onValueModified: { + SettingsManager.articleFontSize = value; + SettingsManager.save(); + } + } + } + } +} diff --git a/src/qml/Settings/GeneralSettingsPage.qml b/src/qml/Settings/GeneralSettingsPage.qml index e574aac7..07b582ab 100644 --- a/src/qml/Settings/GeneralSettingsPage.qml +++ b/src/qml/Settings/GeneralSettingsPage.qml @@ -19,87 +19,6 @@ import org.kde.kasts.settings FormCard.FormCardPage { id: root - FormCard.FormHeader { - title: i18n("Appearance") - Layout.fillWidth: true - } - - FormCard.FormCard { - Layout.fillWidth: true - - FormCard.FormComboBoxDelegate { - Layout.fillWidth: true - id: colorTheme - text: i18n("Color theme") - textRole: "display" - valueRole: "display" - model: ColorSchemer.model - Component.onCompleted: currentIndex = ColorSchemer.indexForScheme(SettingsManager.colorScheme); - onCurrentValueChanged: { - ColorSchemer.apply(currentIndex); - SettingsManager.colorScheme = ColorSchemer.nameForIndex(currentIndex); - SettingsManager.save(); - } - } - - FormCard.FormDelegateSeparator {} - - FormCard.FormCheckDelegate { - id: alwaysShowFeedTitles - text: i18n("Always show podcast titles in subscription view") - checked: SettingsManager.alwaysShowFeedTitles - onToggled: { - SettingsManager.alwaysShowFeedTitles = checked; - SettingsManager.save(); - } - } - - FormCard.FormDelegateSeparator {} - - FormCard.FormCheckDelegate { - id: showTrayIcon - visible: SystrayIcon.available - enabled: SystrayIcon.available - text: i18n("Show icon in system tray") - checked: SettingsManager.showTrayIcon - onToggled: { - SettingsManager.showTrayIcon = checked; - SettingsManager.save(); - } - } - - FormCard.FormCheckDelegate { - id: minimizeToTray - visible: SystrayIcon.available - enabled: SettingsManager.showTrayIcon && SystrayIcon.available - text: i18n("Minimize to tray instead of closing") - checked: SettingsManager.minimizeToTray - onToggled: { - SettingsManager.minimizeToTray = checked; - SettingsManager.save(); - } - } - - FormCard.FormComboBoxDelegate { - id: trayIconType - visible: SystrayIcon.available - enabled: SettingsManager.showTrayIcon && SystrayIcon.available - text: i18nc("Label for selecting the color of the tray icon", "Tray icon type") - - textRole: "text" - valueRole: "value" - - model: [{"text": i18nc("Label describing style of tray icon", "Colorful"), "value": 0}, - {"text": i18nc("Label describing style of tray icon", "Light"), "value": 1}, - {"text": i18nc("Label describing style of tray icon", "Dark"), "value": 2}] - Component.onCompleted: currentIndex = indexOfValue(SettingsManager.trayIconType) - onActivated: { - SettingsManager.trayIconType = currentValue; - SettingsManager.save(); - } - } - } - FormCard.FormHeader { title: i18n("Playback settings") Layout.fillWidth: true @@ -364,46 +283,4 @@ FormCard.FormCardPage { } } } - - FormCard.FormHeader { - title: i18n("Article") - Layout.fillWidth: true - } - - FormCard.FormCard { - Layout.fillWidth: true - - FormCard.FormTextDelegate { - id: fontSize - text: i18n("Font size") - - trailing: Controls.SpinBox { - id: articleFontSizeSpinBox - - enabled: !useSystemFontCheckBox.checked - value: SettingsManager.articleFontSize - Kirigami.FormData.label: i18n("Font size:") - from: 6 - to: 20 - - onValueModified: { - SettingsManager.articleFontSize = value; - SettingsManager.save(); - } - } - } - - FormCard.FormDelegateSeparator { above: fontSize; below: useSystemFontCheckBox } - - FormCard.FormCheckDelegate { - id: useSystemFontCheckBox - checked: SettingsManager.articleFontUseSystem - text: i18n("Use system default") - - onToggled: { - SettingsManager.articleFontUseSystem = checked; - SettingsManager.save(); - } - } - } } diff --git a/src/qml/Settings/SettingsPage.qml b/src/qml/Settings/SettingsPage.qml index 0ccf09d4..1386952b 100644 --- a/src/qml/Settings/SettingsPage.qml +++ b/src/qml/Settings/SettingsPage.qml @@ -19,10 +19,16 @@ KirigamiSettings.CategorizedSettings { icon.name: "kasts" page: "qrc:/qt/qml/org/kde/kasts/qml/Settings/GeneralSettingsPage.qml" }, + KirigamiSettings.SettingAction { + text: i18n("Appearance") + actionName: "Appearance" + icon.name: "preferences-desktop-theme-global" + page: "qrc:/qt/qml/org/kde/kasts/qml/Settings/AppearanceSettingsPage.qml" + }, KirigamiSettings.SettingAction { text: i18n("Storage") actionName: "Storage" - icon.name: "drive-harddisk-symbolic" + icon.name: "drive-harddisk" page: "qrc:/qt/qml/org/kde/kasts/qml/Settings/StorageSettingsPage.qml" }, KirigamiSettings.SettingAction {