Close popup windows when application state changes

Nobody is telling the popup to close. If it was, that was probably as a
side effect of the Qt::Popup flag on some platforms. Certainly not on
Windows.

We check for the application state as the application may use a popup
to signal the user about some event happening, and we don't want to close
the popup as soon as the user makes the application active again.

Task-number: QTBUG-36474
Change-Id: If41f7bec696105e3c7d8897e9af5fc075c7b8933
Reviewed-by: J-P Nurmi <jpnurmi@digia.com>
Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com>
Merge remote-tracking branch 'origin/release' into stable

Change-Id: Ib619455982ebb154ba5344765b11da5c04091409