Skip to content

Commit

Permalink
Added minimize to tray setting
Browse files Browse the repository at this point in the history
  • Loading branch information
BartoszCichecki committed Apr 23, 2024
1 parent c4fcdd7 commit 96cb17d
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 1 deletion.
1 change: 1 addition & 0 deletions LenovoLegionToolkit.Lib/Settings/ApplicationSettings.cs
Expand Up @@ -28,6 +28,7 @@ public class ApplicationSettingsStore
public RGBColor? AccentColor { get; set; }
public AccentColorSource AccentColorSource { get; set; }
public Dictionary<PowerModeState, Guid> PowerPlans { get; set; } = [];
public bool MinimizeToTray { get; set; } = true;
public bool MinimizeOnClose { get; set; }
public WindowSize? WindowSize { get; set; }
public bool DontShowNotifications { get; set; }
Expand Down
12 changes: 12 additions & 0 deletions LenovoLegionToolkit.WPF/Pages/SettingsPage.xaml
Expand Up @@ -82,6 +82,18 @@
Visibility="Hidden" />
</custom:CardControl>

<custom:CardControl Margin="0,0,0,8">
<custom:CardControl.Header>
<controls:CardHeaderControl Title="{x:Static resources:Resource.SettingsPage_MinimizeToTray_Title}" Subtitle="{x:Static resources:Resource.SettingsPage_MinimizeToTray_Message}" />
</custom:CardControl.Header>
<wpfui:ToggleSwitch
x:Name="_minimizeToTrayToggle"
Margin="0,0,0,8"
AutomationProperties.Name="{x:Static resources:Resource.SettingsPage_MinimizeToTray_Title}"
Click="MinimizeToTrayToggle_Click"
Visibility="Hidden" />
</custom:CardControl>

<custom:CardControl Margin="0,0,0,24">
<custom:CardControl.Header>
<controls:CardHeaderControl Title="{x:Static resources:Resource.SettingsPage_MinimizeOnClose_Title}" Subtitle="{x:Static resources:Resource.SettingsPage_MinimizeOnClose_Message}" />
Expand Down
15 changes: 15 additions & 0 deletions LenovoLegionToolkit.WPF/Pages/SettingsPage.xaml.cs
Expand Up @@ -81,6 +81,7 @@ private async Task RefreshAsync()
_accentColorSourceComboBox.SetItems(Enum.GetValues<AccentColorSource>(), _settings.Store.AccentColorSource, t => t.GetDisplayName());

_autorunComboBox.SetItems(Enum.GetValues<AutorunState>(), Autorun.State, t => t.GetDisplayName());
_minimizeToTrayToggle.IsChecked = _settings.Store.MinimizeToTray;
_minimizeOnCloseToggle.IsChecked = _settings.Store.MinimizeOnClose;

var vantageStatus = await _vantageDisabler.GetStatusAsync();
Expand Down Expand Up @@ -118,6 +119,7 @@ private async Task RefreshAsync()

_themeComboBox.Visibility = Visibility.Visible;
_autorunComboBox.Visibility = Visibility.Visible;
_minimizeToTrayToggle.Visibility = Visibility.Visible;
_minimizeOnCloseToggle.Visibility = Visibility.Visible;
_vantageToggle.Visibility = Visibility.Visible;
_legionZoneToggle.Visibility = Visibility.Visible;
Expand Down Expand Up @@ -233,6 +235,19 @@ private void SmartKeyDoublePressActionCard_Click(object sender, RoutedEventArgs
window.ShowDialog();
}

private void MinimizeToTrayToggle_Click(object sender, RoutedEventArgs e)
{
if (_isRefreshing)
return;

var state = _minimizeToTrayToggle.IsChecked;
if (state is null)
return;

_settings.Store.MinimizeToTray = state.Value;
_settings.SynchronizeStore();
}

private void MinimizeOnCloseToggle_Click(object sender, RoutedEventArgs e)
{
if (_isRefreshing)
Expand Down
18 changes: 18 additions & 0 deletions LenovoLegionToolkit.WPF/Resources/Resource.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions LenovoLegionToolkit.WPF/Resources/Resource.resx
Expand Up @@ -2056,4 +2056,10 @@ Supported formats are: {1}.</value>
<data name="RunAutomationStepControl_ProcessWaitUntilFinished_Description" xml:space="preserve">
<value>Wait until program or script finishes executing</value>
</data>
<data name="SettingsPage_MinimizeToTray_Title" xml:space="preserve">
<value>Minimize to tray</value>
</data>
<data name="SettingsPage_MinimizeToTray_Message" xml:space="preserve">
<value>Always minimize to tray instead of taskbar.</value>
</data>
</root>
5 changes: 4 additions & 1 deletion LenovoLegionToolkit.WPF/Windows/MainWindow.xaml.cs
Expand Up @@ -263,7 +263,10 @@ public void ShowUpdateWindow()

public void SendToTray()
{
if (!_applicationSettings.Store.MinimizeToTray)
return;

Hide();
ShowInTaskbar = false;
ShowInTaskbar = true;
}
}

0 comments on commit 96cb17d

Please sign in to comment.