Unite preferences (#4133)

* One preference file

* Set default before converting types
This commit is contained in:
KamaleiZestri
2026-03-02 13:05:43 -06:00
committed by GitHub
parent a2e2395ce9
commit ddc10b0935
8 changed files with 109 additions and 86 deletions

View File

@@ -8,20 +8,14 @@ function Invoke-WinutilThemeChange {
modifying various UI elements such as colors, margins, corner radii, font families, etc.
If the '-init' switch is used, it initializes the theme based on the system's current dark mode setting.
.PARAMETER init
A switch parameter. If set to $true, the function initializes the theme based on the systems current dark mode setting.
.EXAMPLE
Invoke-WinutilThemeChange
# Toggles the theme between 'Light' and 'Dark'.
.EXAMPLE
Invoke-WinutilThemeChange -init
# Initializes the theme based on the system's dark mode and applies the shared theme.
#>
param (
[switch]$init = $false,
[string]$theme
[string]$theme = "Auto"
)
function Set-WinutilTheme {
@@ -129,48 +123,30 @@ function Invoke-WinutilThemeChange {
}
}
$LightPreferencePath = "$winutildir\LightTheme.ini"
$DarkPreferencePath = "$winutildir\DarkTheme.ini"
$sync.preferences.theme = $theme
Set-Preferences -save
Set-WinutilTheme -currentTheme "shared"
if ($init) {
Set-WinutilTheme -currentTheme "shared"
if (Test-Path $LightPreferencePath) {
$theme = "Light"
}
elseif (Test-Path $DarkPreferencePath) {
$theme = "Dark"
}
else {
$theme = "Auto"
}
}
switch ($theme) {
switch ($sync.preferences.theme) {
"Auto" {
$systemUsesDarkMode = Get-WinUtilToggleStatus WPFToggleDarkMode
if ($systemUsesDarkMode) {
Set-WinutilTheme -currentTheme "Dark"
$theme = "Dark"
}
else{
Set-WinutilTheme -currentTheme "Light"
$theme = "Light"
}
Set-WinutilTheme -currentTheme $theme
$themeButtonIcon = [char]0xF08C
Remove-Item $LightPreferencePath -Force -ErrorAction SilentlyContinue
Remove-Item $DarkPreferencePath -Force -ErrorAction SilentlyContinue
}
"Dark" {
Set-WinutilTheme -currentTheme $theme
Set-WinutilTheme -currentTheme $sync.preferences.theme
$themeButtonIcon = [char]0xE708
$null = New-Item $DarkPreferencePath -Force
Remove-Item $LightPreferencePath -Force -ErrorAction SilentlyContinue
}
"Light" {
Set-WinutilTheme -currentTheme $theme
Set-WinutilTheme -currentTheme $sync.preferences.theme
$themeButtonIcon = [char]0xE706
$null = New-Item $LightPreferencePath -Force
Remove-Item $DarkPreferencePath -Force -ErrorAction SilentlyContinue
}
}