Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide tray icon at exit via ctrl-C #3639

Merged
merged 1 commit into from
Aug 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions GUI/Main/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ public GameInstanceManager Manager

public GUIUser currentUser;

private bool enableTrayIcon;
private bool minimizeToTray;

public static Main Instance { get; private set; }

public Main(string[] cmdlineArgs, GameInstanceManager mgr, bool showConsole)
Expand Down Expand Up @@ -391,6 +388,11 @@ protected override void OnLoad(EventArgs e)

bool autoUpdating = CheckForCKANUpdate();
CheckTrayState();
Console.CancelKeyPress += (sender, evt) =>
{
// Hide tray icon on Ctrl-C
minimizeNotifyIcon.Visible = false;
};
InitRefreshTimer();

URLHandlers.RegisterURLHandler(configuration, currentUser);
Expand Down Expand Up @@ -462,7 +464,7 @@ protected override void OnFormClosing(FormClosingEventArgs e)
// Copy metadata panel split height to app settings
configuration.ModInfoPosition = ModInfo.ModMetaSplitPosition;

// Save settings.
// Save settings
configuration.Save();

if (needRegistrySave)
Expand Down Expand Up @@ -530,7 +532,7 @@ private void CKANSettingsToolStripMenuItem_Click(object sender, EventArgs e)
{
// Flipping enabled here hides the main form itself.
Enabled = false;
new SettingsDialog(currentUser).ShowDialog();
new SettingsDialog(currentUser).ShowDialog(this);
Enabled = true;
}

Expand Down
1 change: 1 addition & 0 deletions GUI/Main/Main.resx
Original file line number Diff line number Diff line change
Expand Up @@ -174,4 +174,5 @@
<data name="cKANSettingsToolStripMenuItem1.Text" xml:space="preserve"><value>CKAN Settings</value></data>
<data name="quitToolStripMenuItem.Text" xml:space="preserve"><value>Quit</value></data>
<data name="viewPlayTimeStripMenuItem.Text" xml:space="preserve"><value>Play time...</value></data>
<data name="minimizeNotifyIcon.Text" xml:space="preserve"><value>CKAN</value></data>
</root>
2 changes: 1 addition & 1 deletion GUI/Main/MainInstall.cs
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ private void PostInstallMods(object sender, RunWorkerCompletedEventArgs e)
}
// Now pretend they clicked the menu option for the settings
Enabled = false;
new SettingsDialog(currentUser).ShowDialog();
new SettingsDialog(currentUser).ShowDialog(this);
Enabled = true;
}
break;
Expand Down
5 changes: 4 additions & 1 deletion GUI/Main/MainTrayIcon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ public partial class Main
{
#region Tray Behaviour

private bool enableTrayIcon;
private bool minimizeToTray;

public void CheckTrayState()
{
enableTrayIcon = configuration.EnableTrayIcon;
Expand Down Expand Up @@ -112,7 +115,7 @@ private void openCKANToolStripMenuItem_Click(object sender, EventArgs e)
private void cKANSettingsToolStripMenuItem1_Click(object sender, EventArgs e)
{
OpenWindow();
new SettingsDialog(currentUser).ShowDialog();
new SettingsDialog(currentUser).ShowDialog(this);
}

private void minimizedContextMenuStrip_Opening(object sender, CancelEventArgs e)
Expand Down