Skip to content

Commit

Permalink
Added a flag to disable custom tooltip (#673)
Browse files Browse the repository at this point in the history
  • Loading branch information
BartoszCichecki committed Apr 24, 2023
1 parent 449f037 commit 0e43bed
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
3 changes: 2 additions & 1 deletion LenovoLegionToolkit.WPF/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ private async void Application_Startup(object sender, StartupEventArgs e)

var mainWindow = new MainWindow
{
WindowStartupLocation = WindowStartupLocation.CenterScreen
WindowStartupLocation = WindowStartupLocation.CenterScreen,
TrayTooltipEnabled = !flags.DisableTrayTooltip
};
MainWindow = mainWindow;

Expand Down
2 changes: 2 additions & 0 deletions LenovoLegionToolkit.WPF/Flags.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class Flags
public bool IsTraceEnabled { get; }
public bool Minimized { get; }
public bool SkipCompatibilityCheck { get; }
public bool DisableTrayTooltip { get; }
public bool AllowAllPowerModesOnBattery { get; }
public bool ForceDisableRgbKeyboardSupport { get; }
public bool ForceDisableSpectrumKeyboardSupport { get; }
Expand All @@ -22,6 +23,7 @@ public Flags(IEnumerable<string> startupArgs)
IsTraceEnabled = args.Contains("--trace");
Minimized = args.Contains("--minimized");
SkipCompatibilityCheck = args.Contains("--skip-compat-check");
DisableTrayTooltip = args.Contains("--disable-tray-tooltip");
AllowAllPowerModesOnBattery = args.Contains("--allow-all-power-modes-on-battery");
ForceDisableRgbKeyboardSupport = args.Contains("--force-disable-rgbkb");
ForceDisableSpectrumKeyboardSupport = args.Contains("--force-disable-spectrumkb");
Expand Down
17 changes: 10 additions & 7 deletions LenovoLegionToolkit.WPF/Windows/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public partial class MainWindow

private readonly ContextMenuHelper _contextMenuHelper = new();

public bool TrayTooltipEnabled { get; init; } = true;

public bool SuppressClosingEventHandler { get; set; }

public Snackbar Snackbar => _snackbar;
Expand Down Expand Up @@ -54,17 +56,18 @@ private void InitializeTray()

_trayIcon.ToolTipText = Resource.AppName;

_trayIcon.PreviewTrayToolTipOpen += (_, _) =>
if (TrayTooltipEnabled)
{
_trayIcon.TrayToolTip ??= new StatusTrayPopup();
_trayIcon.TrayToolTipResolved.Style = null;
_trayIcon.TrayToolTipResolved.VerticalOffset = -8;
};
_trayIcon.PreviewTrayToolTipOpen += (_, _) =>
{
_trayIcon.TrayToolTip ??= new StatusTrayPopup();
_trayIcon.TrayToolTipResolved.Style = null;
_trayIcon.TrayToolTipResolved.VerticalOffset = -8;
};
}

_trayIcon.PreviewTrayContextMenuOpen += (_, _) => _trayIcon.ContextMenu ??= _contextMenuHelper.ContextMenu;

_trayIcon.TrayLeftMouseUp += (_, _) => BringToForeground();

_trayIcon.NoLeftClickDelay = true;
}

Expand Down

0 comments on commit 0e43bed

Please sign in to comment.