mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-21 20:24:59 +00:00
feature: move main menu to macOS system menu bar
This commit is contained in:
parent
764cf24284
commit
e0d35409b4
7 changed files with 66 additions and 34 deletions
|
@ -5,6 +5,7 @@ using System.Reflection;
|
|||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
|
@ -18,9 +19,27 @@ using Avalonia.Threading;
|
|||
|
||||
namespace SourceGit
|
||||
{
|
||||
public class SimpleCommand : ICommand
|
||||
{
|
||||
public event EventHandler CanExecuteChanged
|
||||
{
|
||||
add { }
|
||||
remove { }
|
||||
}
|
||||
|
||||
public SimpleCommand(Action action)
|
||||
{
|
||||
_action = action;
|
||||
}
|
||||
|
||||
public bool CanExecute(object parameter) => _action != null;
|
||||
public void Execute(object parameter) => _action?.Invoke();
|
||||
|
||||
private Action _action = null;
|
||||
}
|
||||
|
||||
public partial class App : Application
|
||||
{
|
||||
|
||||
[STAThread]
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
|
@ -67,6 +86,31 @@ namespace SourceGit
|
|||
return builder;
|
||||
}
|
||||
|
||||
public static readonly SimpleCommand OpenPreferenceCommand = new SimpleCommand(() =>
|
||||
{
|
||||
var dialog = new Views.Preference();
|
||||
dialog.ShowDialog(GetTopLevel() as Window);
|
||||
});
|
||||
|
||||
public static readonly SimpleCommand OpenHotkeysCommand = new SimpleCommand(() =>
|
||||
{
|
||||
var dialog = new Views.Hotkeys();
|
||||
dialog.ShowDialog(GetTopLevel() as Window);
|
||||
});
|
||||
|
||||
public static readonly SimpleCommand OpenAboutCommand = new SimpleCommand(() =>
|
||||
{
|
||||
var dialog = new Views.About();
|
||||
dialog.ShowDialog(GetTopLevel() as Window);
|
||||
});
|
||||
|
||||
public static readonly SimpleCommand CheckForUpdateCommand = new SimpleCommand(() =>
|
||||
{
|
||||
Check4Update(true);
|
||||
});
|
||||
|
||||
public static readonly SimpleCommand QuitCommand = new SimpleCommand(Quit);
|
||||
|
||||
public static void RaiseException(string context, string message)
|
||||
{
|
||||
if (Current is App app && app._notificationReceiver != null)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue