Make download-manager a per-window object.

Fixes #228.
downloads: Check if reply is open when doing delayed write.

This fixes a "QIODevice::read: device not open" warning when closing the window
while a download is active.
Leave insert mode when tab is changed.
Open new window if no existing window is found on IPC.
Don't open a new window if only commands are sent via IPC.

Fixes #237.