Skip to content

Commit d9f4b5c

Browse files
committed
added "Hide Menu" option
1 parent 90a7510 commit d9f4b5c

2 files changed

Lines changed: 30 additions & 0 deletions

File tree

OpenHardwareMonitor/UI/MainForm.Designer.cs

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

OpenHardwareMonitor/UI/MainForm.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public sealed partial class MainForm : Form
4242
private readonly UserRadioGroup _sensorValuesTimeWindow;
4343
private readonly PersistentSettings _settings;
4444
private readonly UserOption _showGadget;
45+
private readonly UserOption _hideMenu;
4546
private readonly StartupManager _startupManager = new();
4647
private readonly SystemTray _systemTray;
4748
private readonly UpdateVisitor _updateVisitor = new();
@@ -252,6 +253,14 @@ public MainForm()
252253
_gadget.Visible = _showGadget.Value;
253254
};
254255

256+
_hideMenu = new UserOption("hideMenuMenuItem", false, hideMenuMenuItem, _settings);
257+
_hideMenu.Changed += delegate
258+
{
259+
mainMenu.Visible = !_hideMenu.Value;
260+
};
261+
mainMenu.LostFocus += (_, _) => { if (_hideMenu.Value) mainMenu.Visible = false; };
262+
KeyPreview = true;
263+
255264
UnitManager.IsFahrenheitUsed = _settings.GetValue("TemperatureInFahrenheit", UnitManager.IsFahrenheitUsed);
256265
fahrenheitMenuItem.Checked = UnitManager.IsFahrenheitUsed;
257266
celsiusMenuItem.Checked= !fahrenheitMenuItem.Checked;
@@ -445,6 +454,18 @@ public MainForm()
445454
Microsoft.Win32.SystemEvents.PowerModeChanged += PowerModeChanged;
446455
}
447456

457+
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
458+
{
459+
if (keyData.HasFlag(Keys.Alt) && _hideMenu.Value)
460+
{
461+
mainMenu.Visible = !mainMenu.Visible;
462+
mainMenu.Focus();
463+
return true;
464+
}
465+
466+
return base.ProcessCmdKey(ref msg, keyData);
467+
}
468+
448469
private void StopFileHardwareMenuFromClosing(object sender, ToolStripDropDownClosingEventArgs e)
449470
{
450471
if (e.CloseReason == ToolStripDropDownCloseReason.ItemClicked)

0 commit comments

Comments
 (0)