diff --git a/src/App.Commands.cs b/src/App.Commands.cs
index 18016a1c..1a40f5ce 100644
--- a/src/App.Commands.cs
+++ b/src/App.Commands.cs
@@ -37,7 +37,7 @@ namespace SourceGit
}
}
- public static readonly Command OpenPreferenceCommand = new Command(_ => OpenDialog(new Views.Preference()));
+ public static readonly Command OpenPreferenceCommand = new Command(_ => { OpenDialog(new Views.Preference()); });
public static readonly Command OpenHotkeysCommand = new Command(_ => OpenDialog(new Views.Hotkeys()));
public static readonly Command OpenAppDataDirCommand = new Command(_ => Native.OS.OpenInFileManager(Native.OS.DataDir));
public static readonly Command OpenAboutCommand = new Command(_ => OpenDialog(new Views.About()));
diff --git a/src/App.axaml b/src/App.axaml
index 55aacb89..b12f5fa6 100644
--- a/src/App.axaml
+++ b/src/App.axaml
@@ -41,4 +41,5 @@
+
diff --git a/src/App.axaml.cs b/src/App.axaml.cs
index 3d1547c9..cdd7f371 100644
--- a/src/App.axaml.cs
+++ b/src/App.axaml.cs
@@ -14,6 +14,8 @@ using Avalonia.Data.Core.Plugins;
using Avalonia.Markup.Xaml;
using Avalonia.Media;
using Avalonia.Media.Fonts;
+using Avalonia.Media.Imaging;
+using Avalonia.Platform;
using Avalonia.Platform.Storage;
using Avalonia.Styling;
using Avalonia.Threading;
@@ -85,6 +87,7 @@ namespace SourceGit
SetLocale(pref.Locale);
SetTheme(pref.Theme, pref.ThemeOverrides);
SetFonts(pref.DefaultFontFamily, pref.MonospaceFontFamily, pref.OnlyUseMonoFontInEditor);
+ SetupTrayIcon(pref.SystemTrayIcon);
}
public override void OnFrameworkInitializationCompleted()
@@ -192,6 +195,26 @@ namespace SourceGit
}
}
+ public static void SetupTrayIcon(bool enable)
+ {
+ if (enable)
+ {
+ var icons = new TrayIcons {
+ new TrayIcon {
+ Icon = new WindowIcon(new Bitmap(AssetLoader.Open(new Uri("avares://SourceGit/App.ico")))),
+ Menu = [
+ new NativeMenuItem(Text("Open")),
+ new NativeMenuItem(Text("Preference")) {Command = OpenPreferenceCommand},
+ new NativeMenuItemSeparator(),
+ new NativeMenuItem(Text("Quit")) {Command = QuitCommand},
+ ]
+ }
+ };
+
+ TrayIcon.SetIcons(Current, icons);
+ }
+ }
+
public static void SetFonts(string defaultFont, string monospaceFont, bool onlyUseMonospaceFontInEditor)
{
var app = Current as App;
diff --git a/src/Resources/Locales/en_US.axaml b/src/Resources/Locales/en_US.axaml
index befad68a..495ad402 100644
--- a/src/Resources/Locales/en_US.axaml
+++ b/src/Resources/Locales/en_US.axaml
@@ -420,7 +420,8 @@
Select parent node for:
Name:
Git has NOT been configured. Please to go [Preference] and configure it first.
- Open Data Storage Directory
+ Open SourceGit
+ Open Storage Directory
Open with...
Optional.
Create New Page
diff --git a/src/ViewModels/Preference.cs b/src/ViewModels/Preference.cs
index 04f0fa91..94c44831 100644
--- a/src/ViewModels/Preference.cs
+++ b/src/ViewModels/Preference.cs
@@ -333,6 +333,12 @@ namespace SourceGit.ViewModels
set => SetProperty(ref _lastCheckUpdateTime, value);
}
+ public bool SystemTrayIcon
+ {
+ get => _systemTrayIcon;
+ set => SetProperty(ref _systemTrayIcon, value);
+ }
+
public bool IsGitConfigured()
{
var path = GitInstallPath;
@@ -663,5 +669,7 @@ namespace SourceGit.ViewModels
private string _externalMergeToolPath = string.Empty;
private uint _statisticsSampleColor = 0xFF00FF00;
+
+ private bool _systemTrayIcon = false;
}
}