mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
UI - Fixed Tray Icon on Linux
This commit is contained in:
parent
1210dc3f63
commit
45e810c3ac
@ -9,4 +9,22 @@
|
|||||||
<Application.Styles>
|
<Application.Styles>
|
||||||
<StyleInclude Source="avares://Artemis.UI/Styles/Artemis.axaml" />
|
<StyleInclude Source="avares://Artemis.UI/Styles/Artemis.axaml" />
|
||||||
</Application.Styles>
|
</Application.Styles>
|
||||||
|
|
||||||
|
<TrayIcon.Icons>
|
||||||
|
<TrayIcons>
|
||||||
|
<TrayIcon Icon="avares://Artemis.UI/Assets/Images/Logo/application.ico" ToolTipText="Artemis">
|
||||||
|
<TrayIcon.Menu>
|
||||||
|
<NativeMenu>
|
||||||
|
<NativeMenuItem Header="Home" Command="{Binding OpenScreen}" CommandParameter="Home" />
|
||||||
|
<NativeMenuItem Header="Workshop" Command="{Binding OpenScreen}" CommandParameter="Workshop" />
|
||||||
|
<NativeMenuItem Header="Surface Editor" Command="{Binding OpenScreen}" CommandParameter="Surface Editor" />
|
||||||
|
<NativeMenuItem Header="Settings" Command="{Binding OpenScreen}" CommandParameter="Settings" />
|
||||||
|
<NativeMenuItemSeparator />
|
||||||
|
<NativeMenuItem Header="Debugger" Command="{Binding OpenDebugger}" />
|
||||||
|
<NativeMenuItem Header="Exit" Command="{Binding Exit}" />
|
||||||
|
</NativeMenu>
|
||||||
|
</TrayIcon.Menu>
|
||||||
|
</TrayIcon>
|
||||||
|
</TrayIcons>
|
||||||
|
</TrayIcon.Icons>
|
||||||
</Application>
|
</Application>
|
||||||
@ -9,4 +9,22 @@
|
|||||||
<Application.Styles>
|
<Application.Styles>
|
||||||
<StyleInclude Source="avares://Artemis.UI/Styles/Artemis.axaml" />
|
<StyleInclude Source="avares://Artemis.UI/Styles/Artemis.axaml" />
|
||||||
</Application.Styles>
|
</Application.Styles>
|
||||||
|
|
||||||
|
<TrayIcon.Icons>
|
||||||
|
<TrayIcons>
|
||||||
|
<TrayIcon Icon="avares://Artemis.UI/Assets/Images/Logo/application.ico" ToolTipText="Artemis">
|
||||||
|
<TrayIcon.Menu>
|
||||||
|
<NativeMenu>
|
||||||
|
<NativeMenuItem Header="Home" Command="{Binding OpenScreen}" CommandParameter="Home" />
|
||||||
|
<NativeMenuItem Header="Workshop" Command="{Binding OpenScreen}" CommandParameter="Workshop" />
|
||||||
|
<NativeMenuItem Header="Surface Editor" Command="{Binding OpenScreen}" CommandParameter="Surface Editor" />
|
||||||
|
<NativeMenuItem Header="Settings" Command="{Binding OpenScreen}" CommandParameter="Settings" />
|
||||||
|
<NativeMenuItemSeparator />
|
||||||
|
<NativeMenuItem Header="Debugger" Command="{Binding OpenDebugger}" />
|
||||||
|
<NativeMenuItem Header="Exit" Command="{Binding Exit}" />
|
||||||
|
</NativeMenu>
|
||||||
|
</TrayIcon.Menu>
|
||||||
|
</TrayIcon>
|
||||||
|
</TrayIcons>
|
||||||
|
</TrayIcon.Icons>
|
||||||
</Application>
|
</Application>
|
||||||
@ -9,4 +9,22 @@
|
|||||||
<Application.Styles>
|
<Application.Styles>
|
||||||
<StyleInclude Source="avares://Artemis.UI/Styles/Artemis.axaml" />
|
<StyleInclude Source="avares://Artemis.UI/Styles/Artemis.axaml" />
|
||||||
</Application.Styles>
|
</Application.Styles>
|
||||||
|
|
||||||
|
<TrayIcon.Icons>
|
||||||
|
<TrayIcons>
|
||||||
|
<TrayIcon Icon="avares://Artemis.UI/Assets/Images/Logo/application.ico" ToolTipText="Artemis">
|
||||||
|
<TrayIcon.Menu>
|
||||||
|
<NativeMenu>
|
||||||
|
<NativeMenuItem Header="Home" Command="{Binding OpenScreen}" CommandParameter="Home" />
|
||||||
|
<NativeMenuItem Header="Workshop" Command="{Binding OpenScreen}" CommandParameter="Workshop" />
|
||||||
|
<NativeMenuItem Header="Surface Editor" Command="{Binding OpenScreen}" CommandParameter="Surface Editor" />
|
||||||
|
<NativeMenuItem Header="Settings" Command="{Binding OpenScreen}" CommandParameter="Settings" />
|
||||||
|
<NativeMenuItemSeparator />
|
||||||
|
<NativeMenuItem Header="Debugger" Command="{Binding OpenDebugger}" />
|
||||||
|
<NativeMenuItem Header="Exit" Command="{Binding Exit}" />
|
||||||
|
</NativeMenu>
|
||||||
|
</TrayIcon.Menu>
|
||||||
|
</TrayIcon>
|
||||||
|
</TrayIcons>
|
||||||
|
</TrayIcon.Icons>
|
||||||
</Application>
|
</Application>
|
||||||
|
|||||||
@ -1,12 +0,0 @@
|
|||||||
<ResourceDictionary xmlns="https://github.com/avaloniaui"
|
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
|
||||||
<NativeMenu x:Key="TrayIconMenu">
|
|
||||||
<NativeMenuItem Header="Home" Command="{Binding OpenScreen}" CommandParameter="Home" />
|
|
||||||
<NativeMenuItem Header="Workshop" Command="{Binding OpenScreen}" CommandParameter="Workshop" />
|
|
||||||
<NativeMenuItem Header="Surface Editor" Command="{Binding OpenScreen}" CommandParameter="Surface Editor" />
|
|
||||||
<NativeMenuItem Header="Settings" Command="{Binding OpenScreen}" CommandParameter="Settings" />
|
|
||||||
<NativeMenuItemSeparator />
|
|
||||||
<NativeMenuItem Header="Debugger" Command="{Binding OpenDebugger}" />
|
|
||||||
<NativeMenuItem Header="Exit" Command="{Binding Exit}" />
|
|
||||||
</NativeMenu>
|
|
||||||
</ResourceDictionary>
|
|
||||||
@ -30,8 +30,6 @@ namespace Artemis.UI.Screens.Root
|
|||||||
private readonly ISidebarVmFactory _sidebarVmFactory;
|
private readonly ISidebarVmFactory _sidebarVmFactory;
|
||||||
private readonly IWindowService _windowService;
|
private readonly IWindowService _windowService;
|
||||||
private SidebarViewModel? _sidebarViewModel;
|
private SidebarViewModel? _sidebarViewModel;
|
||||||
private TrayIcon? _trayIcon;
|
|
||||||
private TrayIcons? _trayIcons;
|
|
||||||
private ViewModelBase? _titleBarViewModel;
|
private ViewModelBase? _titleBarViewModel;
|
||||||
|
|
||||||
public RootViewModel(ICoreService coreService,
|
public RootViewModel(ICoreService coreService,
|
||||||
@ -78,7 +76,6 @@ namespace Artemis.UI.Screens.Root
|
|||||||
TitleBarViewModel = _defaultTitleBarViewModel;
|
TitleBarViewModel = _defaultTitleBarViewModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public SidebarViewModel? SidebarViewModel
|
public SidebarViewModel? SidebarViewModel
|
||||||
{
|
{
|
||||||
get => _sidebarViewModel;
|
get => _sidebarViewModel;
|
||||||
@ -105,12 +102,6 @@ namespace Artemis.UI.Screens.Root
|
|||||||
bool minimized = _coreService.StartupArguments.Contains("--minimized");
|
bool minimized = _coreService.StartupArguments.Contains("--minimized");
|
||||||
bool showOnAutoRun = _settingsService.GetSetting("UI.ShowOnStartup", true).Value;
|
bool showOnAutoRun = _settingsService.GetSetting("UI.ShowOnStartup", true).Value;
|
||||||
|
|
||||||
// Always show the tray icon if ShowOnStartup is false or the user has no way to open the main window
|
|
||||||
bool showTrayIcon = !showOnAutoRun || _settingsService.GetSetting("UI.ShowTrayIcon", true).Value;
|
|
||||||
|
|
||||||
if (showTrayIcon)
|
|
||||||
ShowTrayIcon();
|
|
||||||
|
|
||||||
if (autoRunning && !showOnAutoRun || minimized)
|
if (autoRunning && !showOnAutoRun || minimized)
|
||||||
{
|
{
|
||||||
// TODO: Auto-update
|
// TODO: Auto-update
|
||||||
@ -127,27 +118,6 @@ namespace Artemis.UI.Screens.Root
|
|||||||
_windowService.ShowWindow<SplashViewModel>();
|
_windowService.ShowWindow<SplashViewModel>();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ShowTrayIcon()
|
|
||||||
{
|
|
||||||
_trayIcon = new TrayIcon
|
|
||||||
{
|
|
||||||
Icon = new WindowIcon(_assetLoader.Open(new Uri("avares://Artemis.UI/Assets/Images/Logo/application.ico"))),
|
|
||||||
Command = ReactiveCommand.Create(OpenMainWindow)
|
|
||||||
};
|
|
||||||
_trayIcon.Menu = (NativeMenu?) Application.Current!.FindResource("TrayIconMenu");
|
|
||||||
_trayIcons = new TrayIcons {_trayIcon};
|
|
||||||
TrayIcon.SetIcons(Application.Current!, _trayIcons);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void HideTrayIcon()
|
|
||||||
{
|
|
||||||
_trayIcon?.Dispose();
|
|
||||||
TrayIcon.SetIcons(Application.Current!, null!);
|
|
||||||
|
|
||||||
_trayIcon = null;
|
|
||||||
_trayIcons = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public RoutingState Router { get; }
|
public RoutingState Router { get; }
|
||||||
|
|
||||||
|
|||||||
@ -1,13 +1,6 @@
|
|||||||
<Styles xmlns="https://github.com/avaloniaui"
|
<Styles xmlns="https://github.com/avaloniaui"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:styling="clr-namespace:FluentAvalonia.Styling;assembly=FluentAvalonia">
|
xmlns:styling="clr-namespace:FluentAvalonia.Styling;assembly=FluentAvalonia">
|
||||||
<Styles.Resources>
|
|
||||||
<ResourceDictionary>
|
|
||||||
<ResourceDictionary.MergedDictionaries>
|
|
||||||
<ResourceInclude Source="/ArtemisTrayIcon.axaml"/>
|
|
||||||
</ResourceDictionary.MergedDictionaries>
|
|
||||||
</ResourceDictionary>
|
|
||||||
</Styles.Resources>
|
|
||||||
<!-- Third party styles -->
|
<!-- Third party styles -->
|
||||||
<styling:FluentAvaloniaTheme PreferSystemTheme="False" RequestedTheme="Dark"/>
|
<styling:FluentAvaloniaTheme PreferSystemTheme="False" RequestedTheme="Dark"/>
|
||||||
<!-- <FluentTheme Mode="Dark"></FluentTheme> -->
|
<!-- <FluentTheme Mode="Dark"></FluentTheme> -->
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user