From 9a75cd0dda3cc900c9e27a80ac0045c8053dfac2 Mon Sep 17 00:00:00 2001 From: Jason Henriquez Date: Tue, 23 Apr 2024 22:32:26 -0500 Subject: [PATCH 01/25] Implement settings section sorting --- src/renderer/store/modules/settings.js | 1 + src/renderer/views/Settings/Settings.css | 3 +- src/renderer/views/Settings/Settings.js | 90 +++++++++++++++++++++++- src/renderer/views/Settings/Settings.vue | 64 +++++++---------- static/locales/en-US.yaml | 1 + 5 files changed, 120 insertions(+), 39 deletions(-) diff --git a/src/renderer/store/modules/settings.js b/src/renderer/store/modules/settings.js index 1ef666e522d0..cb5c46ffea5a 100644 --- a/src/renderer/store/modules/settings.js +++ b/src/renderer/store/modules/settings.js @@ -296,6 +296,7 @@ const state = { screenshotAskPath: false, screenshotFolderPath: '', screenshotFilenamePattern: '%Y%M%D-%H%N%S', + settingsSectionSortEnabled: false, fetchSubscriptionsAutomatically: true, settingsPassword: '', allowDashAv1Formats: false, diff --git a/src/renderer/views/Settings/Settings.css b/src/renderer/views/Settings/Settings.css index d433f8cf483c..a796ede90747 100644 --- a/src/renderer/views/Settings/Settings.css +++ b/src/renderer/views/Settings/Settings.css @@ -12,9 +12,10 @@ hr { } } -.switchColumnGrid { +.switchRow { inline-size: 85%; margin-inline: auto; + display: flex; } .settingsToggle { diff --git a/src/renderer/views/Settings/Settings.js b/src/renderer/views/Settings/Settings.js index 9bc64c6a9e68..5ee1abb31635 100644 --- a/src/renderer/views/Settings/Settings.js +++ b/src/renderer/views/Settings/Settings.js @@ -40,10 +40,76 @@ export default defineComponent({ data: function () { return { usingElectron: process.env.IS_ELECTRON, - unlocked: false + unlocked: false, + settingsComponentsData: [ + { + type: 'general-settings', + title: this.$t('Settings.General Settings.General Settings') + }, + { + type: 'theme-settings', + title: this.$t('Settings.Theme Settings.Theme Settings') + }, + { + type: 'player-settings', + title: this.$t('Settings.Player Settings.Player Settings') + }, + { + type: 'external-player-settings', + title: this.$t('Settings.External Player Settings.External Player Settings'), + usingElectron: true + }, + { + type: 'subscription-settings', + title: this.$t('Settings.Subscription Settings.Subscription Settings') + }, + { + type: 'distraction-settings', + title: this.$t('Settings.Distraction Free Settings.Distraction Free Settings') + }, + { + type: 'privacy-settings', + title: this.$t('Settings.Privacy Settings.Privacy Settings') + }, + { + type: 'data-settings', + title: this.$t('Settings.Data Settings.Data Settings') + }, + { + type: 'proxy-settings', + title: this.$t('Settings.Proxy Settings.Proxy Settings'), + usingElectron: true + }, + { + type: 'download-settings', + title: this.$t('Settings.Download Settings.Download Settings'), + usingElectron: true + }, + { + type: 'parental-control-settings', + title: this.$t('Settings.Parental Control Settings.Parental Control Settings') + }, + { + type: 'sponsor-block-settings', + title: this.$t('Settings.SponsorBlock Settings.SponsorBlock Settings'), + }, + { + type: 'experimental-settings', + title: this.$t('Settings.Experimental Settings.Experimental Settings'), + usingElectron: true + }, + { + type: 'password-settings', + title: this.$t('Settings.Password Settings.Password Settings') + }, + ] } }, computed: { + locale: function() { + return this.$i18n.locale.replace('_', '-') + }, + settingsPassword: function () { return this.$store.getters.getSettingsPassword }, @@ -51,6 +117,27 @@ export default defineComponent({ allSettingsSectionsExpandedByDefault: function () { return this.$store.getters.getAllSettingsSectionsExpandedByDefault }, + + settingsSectionSortEnabled: function () { + return this.$store.getters.getSettingsSectionSortEnabled + }, + + settingsSectionComponents: function () { + let settingsSections + if (!this.usingElectron) { + settingsSections = this.settingsComponentsData.filter((settingsComponent) => !settingsComponent.usingElectron) + } else { + settingsSections = this.settingsComponentsData + } + + if (this.settingsSectionSortEnabled) { + return settingsSections.toSorted((a, b) => + a.title.toLowerCase().localeCompare(b.title.toLowerCase(), this.locale) + ) + } + + return settingsSections + }, }, created: function () { if (this.settingsPassword === '') { @@ -60,6 +147,7 @@ export default defineComponent({ methods: { ...mapActions([ 'updateAllSettingsSectionsExpandedByDefault', + 'updateSettingsSectionSortEnabled' ]) } }) diff --git a/src/renderer/views/Settings/Settings.vue b/src/renderer/views/Settings/Settings.vue index 04f83fabf0b9..fd4931d03829 100644 --- a/src/renderer/views/Settings/Settings.vue +++ b/src/renderer/views/Settings/Settings.vue @@ -1,44 +1,34 @@