persist selected theme to AppState
This commit is contained in:
@@ -13,6 +13,7 @@ public class IdeSettings
|
||||
public string? DebuggerExecutablePath { get; set; }
|
||||
public bool DebuggerUseSharpDbg { get; set; } = true;
|
||||
public float UiScale { get; set; } = 1.0f;
|
||||
public string Theme { get; set; } = "Dark";
|
||||
}
|
||||
|
||||
public record RecentSln
|
||||
|
||||
@@ -28,6 +28,8 @@ public partial class SettingsWindow : Window
|
||||
_uiScaleSpinBox.Value = Singletons.AppState.IdeSettings.UiScale;
|
||||
_debuggerFilePathLineEdit.Text = Singletons.AppState.IdeSettings.DebuggerExecutablePath;
|
||||
_debuggerUseSharpDbgCheckButton.ButtonPressed = Singletons.AppState.IdeSettings.DebuggerUseSharpDbg;
|
||||
var themeOptionIndex = _themeOptionButton.GetOptionIndexOrNullForString(Singletons.AppState.IdeSettings.Theme);
|
||||
if (themeOptionIndex is not null) _themeOptionButton.Selected = themeOptionIndex.Value;
|
||||
}
|
||||
|
||||
private void OnUiScaleSpinBoxValueChanged(double value)
|
||||
@@ -52,6 +54,7 @@ public partial class SettingsWindow : Window
|
||||
private void OnThemeItemSelected(long index)
|
||||
{
|
||||
var selectedTheme = _themeOptionButton.GetItemText((int)index);
|
||||
Singletons.AppState.IdeSettings.Theme = selectedTheme;
|
||||
this.SetIdeTheme(selectedTheme);
|
||||
}
|
||||
}
|
||||
@@ -87,6 +87,21 @@ public static class NodeExtensions
|
||||
}
|
||||
}
|
||||
|
||||
extension(OptionButton optionButton)
|
||||
{
|
||||
public int? GetOptionIndexOrNullForString(string optionString)
|
||||
{
|
||||
for (var i = 0; i < optionButton.GetItemCount(); i++)
|
||||
{
|
||||
if (optionButton.GetItemText(i) == optionString)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
extension(TreeItem treeItem)
|
||||
{
|
||||
public T? GetTypedMetadata<T>(int column) where T : RefCounted?
|
||||
|
||||
Reference in New Issue
Block a user