Skip to content

Commit

Permalink
feat: Add setting to toggle off 'close to tray'
Browse files Browse the repository at this point in the history
by default this is enabled
  • Loading branch information
lulzsun committed Jan 8, 2025
1 parent a0bb5f0 commit 050b198
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 8 deletions.
4 changes: 3 additions & 1 deletion Classes/Utils/JSONObjects.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,10 @@ public bool launchStartup {
#endif
}
}
private bool _startMinimized = false;
private bool _startMinimized;
public bool startMinimized { get { return _startMinimized; } set { _startMinimized = value; } }
private bool _closeToTray = true;
public bool closeToTray { get { return _closeToTray; } set { _closeToTray = value; } }
private string _theme = "System";
public string theme { get { return _theme; } set { _theme = value; } }
private string _update = "automatic"; // ??? why is there a warning
Expand Down
17 changes: 10 additions & 7 deletions Classes/WindowsInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,18 @@ private async void WebMessageReceivedAsync(object sender, CoreWebView2WebMessage
}

private void WindowsInterface_FormClosing(object sender, FormClosingEventArgs e) {
if (e.CloseReason == CloseReason.UserClosing) {
if (e.CloseReason != CloseReason.UserClosing) {
return;
}
if (SettingsService.Settings.generalSettings.closeToTray) {
e.Cancel = true;
this.WindowState = FormWindowState.Minimized;
this.FormBorderStyle = FormBorderStyle.SizableToolWindow;
this.Opacity = 0;
this.ShowInTaskbar = false;
label1.Visible = false;
DisposeWebView2();
}
this.WindowState = FormWindowState.Minimized;
this.FormBorderStyle = FormBorderStyle.SizableToolWindow;
this.Opacity = 0;
this.ShowInTaskbar = false;
label1.Visible = false;
DisposeWebView2();
}

FormWindowState _PreviousWindowState;
Expand Down
1 change: 1 addition & 0 deletions ClientApp/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ declare global {
interface GeneralSettings {
launchStartup: boolean;
startMinimized: boolean;
closeToTray: boolean;
theme: string;
update: string;
updateChannel: string;
Expand Down
13 changes: 13 additions & 0 deletions ClientApp/src/pages/Settings/General.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,19 @@ export const General: React.FC<Props> = ({ settings, updateSettings }) => {
/>
<span className='ml-2 text-gray-700 dark:text-gray-400'>{t('settingsGeneralItem03')}</span>
</label>
<label className='inline-flex items-center'>
<input
type='checkbox'
className='form-checkbox h-4 w-4 text-gray-600'
defaultChecked={settings === undefined ? false : settings.closeToTray}
onChange={(e) => {
settings!.closeToTray = e.target.checked;
updateSettings();
}}
/>
{/* This setting does not have translations, this is temporary */}
<span className='ml-2 text-gray-700 dark:text-gray-400'>Close to Tray</span>
</label>

<h1 className='font-semibold text-2xl mt-4'>{t('settingsGeneralItem04')}</h1>
<DropDownMenu
Expand Down

0 comments on commit 050b198

Please sign in to comment.