AssistantPopup: Improve positioning

Take cursor position into account when deciding where to position
the popup
Largely refactor code around AssistantPopup

High-level change log:
- AssistantPopup is now responsible for showing/hiding itself
- No more obscure logic inside UiController that involves timers and
  previous states
- UiController always has a AssistantPopup instantiated
- AssistantPopup::reset is single-point-of-entry for creating a popup
- AssistantPopupConfig is more stand-alone now
- QEvent::WindowDeactivate events now give focus back to the editor view
- In general: less states!

This gives a lot more defined semantics to the whole popup behavior.
Let's work from that.
Code cleanup: Reorder functions, constify
Minor: Remove unneeded static_cast
Merge remote-tracking branch 'origin/1.7'