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

Minimize CKAN to tray and automatic refreshing #2565

Merged
merged 4 commits into from
Nov 6, 2018

Conversation

Olympic1
Copy link
Member

@Olympic1 Olympic1 commented Nov 3, 2018

Changes

Core

Added an automatic refreshing of CKAN that happens after N minutes. This option can be set via the settings menu and is stored in the windows registry. This behaviour starts when the GUI is loaded and can be paused via the respective options, or by setting the rate to 0.

GUI

The GUI settings window's updates section is halved and a new behaviour section is added next to it to save some space:

settingswindow

  • The Enable tray icon shows a CKAN icon in the tray. The window is still shown on the taskbar.
  • The Minimize to tray allows minimizing to the tray. The window is hidden from the taskbar.
  • The refresh rate to set an interval in minutes to refresh the modlist automatically.
  • The pause refreshing pauses the automatic refreshing. This is disabled when RefreshRate is set to 0.

When the GUI is minimized, you can double click the icon to bring back the GUI.
Also right clicking the icon shows a menu:

traymenu

  • The updates option shows the amount of available updates. This is disabled when none are available and is clickable when there are. Clicking the option selects all of the available updates.
  • Refresh refreshes the modlist
  • Pause pauses the automatic refreshing. This is disabled when RefreshRate is set to 0.
  • Open CKAN opens the GUI
  • Open KSP Directory opens the current KSP directory
  • CKAN Settings opens the settings menu
  • Quit closes CKAN

When an update becomes available, it pops up a balloon notifying you that there is an update. Clicking it installs it. (Thanks @HebaruSan)

Other

  • Removed a duplicate StartPosition in the settings window
  • Redone the tab order in the settings window
  • Moved Refresh on startup from updates to more settings

Closes #2377.

@Olympic1 Olympic1 added Enhancement GUI Issues affecting the interactive GUI Core (ckan.dll) Issues affecting the core part of CKAN Pull request labels Nov 3, 2018
@ReiDaTecnologia
Copy link

Thanks for taking you time and effort in my suggestion and i really hope this PR get accepted!

@HebaruSan
Copy link
Member

I get this on trying to open the settings on Windows:

System.NullReferenceException: Object reference not set to an instance of an object.
   at CKAN.Main.UpdateRefreshTimer()
   at CKAN.SettingsDialog.UpdateRefreshRate()
   at CKAN.SettingsDialog.RefreshTextBox_TextChanged(Object sender, EventArgs e)
   at System.Windows.Forms.Control.OnTextChanged(EventArgs e)
   at System.Windows.Forms.Control.set_Text(String value)
   at System.Windows.Forms.TextBoxBase.set_Text(String value)
   at System.Windows.Forms.TextBox.set_Text(String value)
   at CKAN.SettingsDialog.UpdateRefreshRate()
   at CKAN.SettingsDialog.UpdateDialog()
   at CKAN.SettingsDialog.SettingsDialog_Load(Object sender, EventArgs e)
   at System.Windows.Forms.Form.OnLoad(EventArgs e)
   at System.Windows.Forms.Form.OnCreateControl()
   at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
   at System.Windows.Forms.Control.CreateControl()
   at System.Windows.Forms.Control.WmShowWindow(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.Form.WmShowWindow(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

@HebaruSan
Copy link
Member

HebaruSan commented Nov 4, 2018

If you open CKAN, go to settings, and enable a timer, the timer doesn't start. You have to close and re-launch. This (and the above crash) is because the timer is only started in RunRefreshTimer, which is only called in OnLoad, and no timer is created if the setting is 0.

@HebaruSan
Copy link
Member

If you maximize, then minimize, then right click the tray icon and "Open CKAN", it doesn't re-maximize it. Instead it goes back to the window size before you maximized.

@HebaruSan
Copy link
Member

Submitted Olympic1#3 with some fixes and one enhancement.

@Olympic1
Copy link
Member Author

Olympic1 commented Nov 4, 2018

Merged, I will look into the Maximize issue

@HebaruSan
Copy link
Member

HebaruSan commented Nov 4, 2018

The maximize thing is because WindowState stores FormWindowState.Maximized when the window is maximized, so setting it to FormWindowState.Normal resets it to non-maximized. So we either need to remember that we were maxmized, or use some other method to un-minimize.

Maybe we could borrow configuration.IsWindowMaximised?

WindowState = configuration.IsWindowMaximised ? FormWindowState.Maximized : FormWindowState.Normal;

@HebaruSan
Copy link
Member

Currently configuration.IsWindowMaximised is only set at exit. We need to set it at minimize as well for that latest fix to work.

@Olympic1
Copy link
Member Author

Olympic1 commented Nov 4, 2018

UpdateTrayState(), where the fix is in, is called when the GUI is resized, minimized or maxmized.

@HebaruSan
Copy link
Member

HebaruSan commented Nov 5, 2018

UpdateTrayState doesn't set configuration.IsWindowMaximised, so it'll use whatever value was loaded from disk at startup.

EDIT: Not correct, see below.

@Olympic1
Copy link
Member Author

Olympic1 commented Nov 5, 2018

Tested this extensively now. When the tray icon is disabled, it uses the default behaviour as before, saving the WindowState when closing. When the tray icon is enabled, it saves the WindowState every time the window is resized, maximized or minimized.

@HebaruSan
Copy link
Member

OK, I added some instrumentation to figure this out. What's happening is that IsWindowMaximised is set to true when the window is maximized, but then minimizing it sets IsWindowMaximised back to false.

Maybe you're testing with minimizeToTray set to true? I have it as false. That ought to make a difference since the assignment happens in the else block of the if statement checking minimizeToTray && WindowState == FormWindowState.Minimized.

@HebaruSan
Copy link
Member

Submitted fix at Olympic1#4.

@Olympic1
Copy link
Member Author

Olympic1 commented Nov 5, 2018

Thought that I tried that previously, but apparantly not. Thanks

@HebaruSan
Copy link
Member

GitHub says it can't rebase and merge, but I don't see actual conflicts.
I'm going to try pushing a rebase manually; cross your fingers.

@HebaruSan HebaruSan merged commit 732a38b into KSP-CKAN:master Nov 6, 2018
@Olympic1 Olympic1 deleted the feature/minimize-to-tray branch November 6, 2018 21:13
@politas
Copy link
Member

politas commented Nov 14, 2018

Well, doesn't seem to work at all on my Mate desktop.

politas added a commit that referenced this pull request Nov 14, 2018
@HebaruSan
Copy link
Member

(I just rebooted back to Linux.)

I get a blank space in my app indicator bar in GNOME Shell (just to the left of Steam):

image

Right clicking it brings up the menu but mostly off the screen:

image

So maybe Mono doesn't like something about the image, and we might have to move the menu and fix its colors for dark themes.

@politas, if you right click where an app indicator might appear while the setting is enabled, can you get the menu to show up?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Core (ckan.dll) Issues affecting the core part of CKAN Enhancement GUI Issues affecting the interactive GUI Pull request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Suggestion] CKAN in the System Tray & CKAN/Mod Update Notifier
4 participants