Make QGuiApplication::exec() run within NSApplicationMain()

We follow the same pattern as for iOS and Windows ports, making
sure the user's main() runs in a platform friendly environment. In
this particular case, it means calling the user's main() during the
call of NSApplicationMain(), and calling the user's main() function
(renamed to qMain() as in Windows) after receiving
NSApplicationDidFinishLaunchingNotification. In practice, this means
that NSApp is running when qMain() is called, and therefore when
QCoreApplication::exec() is called.

For those command-line utilities running on QGuiApplication, or any
deriving class, and that do not provide a bundle, we override the main
bundle's dictionary and get NSApplicationMain() to run as usual.

Added cocoa/cocoamain "subdir" to build libqtcocoamain.a (together with
cocoa/cocoaplugin -- plugins/platforms/cocoa is made a subdirs project).
This library is linked against all GUI Qt apps and provides the actual
main() function. It also catches the launching NSApplication notifications,
and calls the user's qMain() function. Note that this will happen in the
same cases when the user's application will run with the Cocoa QPA plugin.

Launch related code in QCocoaApplicationDelegate is moved to libqtcocoamain,
QNSApplication is removed (but sendEvent: redirection still there), and
code in QCocoaEventDispatcher dealing with calling [NSApp run] and related
has been removed since it's become unreachable.

ChangeLog: [Qt for Mac] Make QGuiApplication::exec() run within NSApplicationMain()
Change-Id: I790e5138c29aac2e0215a9147d0148fece40ca22
Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
Make Qt process native and timer events on Cocoa applications

Since we don't spin any QEventLoop, we need to make sure events posted
by the window system interface are processed.

Change-Id: I0e7b541d86a7a14f2ecd3702e7cbdbdee9920859
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@digia.com>
Cocoa: Fix QFontDialog, QColorDialog auto-tests

The new Cocoa event dispatcher made apparent some deficiencies in the
way the dialog helpers were being hidden. In particular, we would not stop
a dialog helper's modal loop when closing the dialog, resulting in the
auto-tests hanging. Also, since the QApplication event loop is runnig with
[NSApp run] in the stack, the previous workarounds are no longer needed.

Task-number: QTBUG-24321
Change-Id: Ifba713c286638d78a699c319a15683d09714f06f
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@digia.com>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>