Starting with Qt 4.4 which was released a few days ago Qt now honors the
setting in the Info.plist file of the application bundle. This is particularily useful to create bundled application which should not pop up in the global dock or menu, f.e. daemons which run in the background or applications like Quicksilver which are only accessible via a global key stroke or an icon in systray area of the menu bar.
Now, with guitone I recently had the problem that I wanted exactly this mode under OSX in its new “driver” mode, which lets you automate / script the access to internal dialogs (check the nvm.guitone.app-driver branch for more information), but it should not interfere with the “standalone” mode, i.e. the dock icon and menu bar should be of course shown there.
One way of accomplishing that would have been to create a separate binary just for this usage and only set the setting in this property list. However, even without knowing much of OSX’ Carbon API, I came up with a better solution, inspired by what Qt does itself deep inside qapplication_mac.cpp if it stumbles upon the LSUIElement entry:
GuitoneStandalone::GuitoneStandalone(int & argc, char** argv)
: GuitoneCore(argc, argv),
{
#ifdef Q_WS_MACX
ProcessSerialNumber psn;
if (GetCurrentProcess(&psn) == noErr)
{
TransformProcessType(&psn,
kProcessTransformToForegroundApplication);
}
#endif
…
}
This unconditionally transforms such a background application to a foreground application with a dock icon and menu bar. So all I had to do was to check my calling arguments if the driver interface should be used and if not, create the correct QApplication instance which brings the application to the foreground. Nice!
Now I only have to fix this one, very weird behaviour of QMetaMethod::invokeMethod which does not accept my argument list… *grumbles*