Skip to content

Commit

Permalink
设置页面添加关闭窗口行为设置 (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
Richasy authored Sep 25, 2024
1 parent 3e168ae commit 423cd03
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8" ?>
<local:SettingSectionBase
x:Class="RodelAgent.UI.Controls.Settings.CloseBehaviorSettingSection"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:base="using:Richasy.WinUI.Share.Base"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:ext="using:RodelAgent.UI.Extensions"
xmlns:ic="using:FluentIcons.WinUI"
xmlns:local="using:RodelAgent.UI.Controls.Settings"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">

<base:SettingsCard Description="{ext:Locale Name=HideWhenCloseDescription}" Header="{ext:Locale Name=HideWhenClose}">
<base:SettingsCard.HeaderIcon>
<ic:SymbolIcon Symbol="DismissCircle" />
</base:SettingsCard.HeaderIcon>
<ToggleSwitch IsOn="{x:Bind ViewModel.HiddenWhenCloseWindow, Mode=TwoWay}" />
</base:SettingsCard>
</local:SettingSectionBase>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright (c) Rodel. All rights reserved.

namespace RodelAgent.UI.Controls.Settings;

/// <summary>
/// 关闭行为设置部分.
/// </summary>
public sealed partial class CloseBehaviorSettingSection : SettingSectionBase
{
/// <summary>
/// Initializes a new instance of the <see cref="CloseBehaviorSettingSection"/> class.
/// </summary>
public CloseBehaviorSettingSection() => InitializeComponent();
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<settings:LanguageSettingSection ViewModel="{x:Bind ViewModel}" />
<settings:AppLogSettingSection ViewModel="{x:Bind ViewModel}" />
<settings:LibrarySettingSection ViewModel="{x:Bind ViewModel}" />
<settings:CloseBehaviorSettingSection ViewModel="{x:Bind ViewModel}" />
<TextBlock
Margin="0,12,0,4"
HorizontalAlignment="Left"
Expand Down
6 changes: 6 additions & 0 deletions src/Desktop/RodelAgent.UI/Resources/en-US/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -1253,4 +1253,10 @@ Choose a library folder and let's get started!</value>
<data name="UserCancelGenerate" xml:space="preserve">
<value>The generate was canceled by the user</value>
</data>
<data name="HideWhenClose" xml:space="preserve">
<value>Hide when closed</value>
</data>
<data name="HideWhenCloseDescription" xml:space="preserve">
<value>Hide the app when the window is closed instead of quitting</value>
</data>
</root>
6 changes: 6 additions & 0 deletions src/Desktop/RodelAgent.UI/Resources/zh-Hans-CN/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -1253,4 +1253,10 @@
<data name="UserCancelGenerate" xml:space="preserve">
<value>生成操作被用户取消</value>
</data>
<data name="HideWhenClose" xml:space="preserve">
<value>关闭时隐藏</value>
</data>
<data name="HideWhenCloseDescription" xml:space="preserve">
<value>关闭窗口时隐藏应用而非退出</value>
</data>
</root>
4 changes: 4 additions & 0 deletions src/Desktop/RodelAgent.UI/RodelAgent.UI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@
<None Remove="Controls\Settings\AzureOpenAIDrawConfigSettingSection.xaml" />
<None Remove="Controls\Settings\AzureSpeechConfigSettingSection.xaml" />
<None Remove="Controls\Settings\AzureTranslateConfigSettingSection.xaml" />
<None Remove="Controls\Settings\CloseBehaviorSettingSection.xaml" />
<None Remove="Controls\Settings\DouBaoChatConfigSettingSection.xaml" />
<None Remove="Controls\Settings\HunYuanChatConfigSettingSection.xaml" />
<None Remove="Controls\Settings\HunYuanDrawConfigSettingSection.xaml" />
Expand Down Expand Up @@ -663,6 +664,9 @@
<Page Update="Controls\Internal\PromptTestExtraBody.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Update="Controls\Settings\CloseBehaviorSettingSection.xaml">
<Generator>MSBuild:Compile</Generator>
</Page>
<None Update="NLog.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ public sealed partial class SettingsPageViewModel
[ObservableProperty]
private string _appLanguage;

[ObservableProperty]
private bool _hiddenWhenCloseWindow;

/// <summary>
/// 在线聊天服务.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ private void InitializeGenericSettings()
Copyright = string.Format(copyrightTemplate, BuildYear);

WorkingDirectory = SettingsToolkit.ReadLocalSetting(SettingNames.WorkingDirectory, string.Empty);

HiddenWhenCloseWindow = SettingsToolkit.ReadLocalSetting(SettingNames.HideWhenCloseWindow, false);
ShouldRecordTranslate = SettingsToolkit.ReadLocalSetting(SettingNames.ShouldRecordTranslate, false);
}

Expand Down Expand Up @@ -166,4 +166,7 @@ partial void OnUseStreamOutputChanged(bool value)

partial void OnShouldRecordTranslateChanged(bool value)
=> SettingsToolkit.WriteLocalSetting(SettingNames.ShouldRecordTranslate, value);

partial void OnHiddenWhenCloseWindowChanged(bool value)
=> SettingsToolkit.WriteLocalSetting(SettingNames.HideWhenCloseWindow, value);
}

0 comments on commit 423cd03

Please sign in to comment.