Introduce Qt::AA_PluginApplication replacing Qt::AA_MacPluginApplication.

Reuse the enumeration value for a generic Qt::AA_PluginApplication
attribute since there are also initializations in platform ports other
than OS X that need to be suppressed in the plugin case.

Task-number: QTBUG-47556
Task-number: QTBUG-45762
Change-Id: I885f75030a251ccf66597aae3580499d012934e7
Reviewed-by: Jan Arve Sæther <jan-arve.saether@theqtcompany.com>
This commit is contained in:
Friedemann Kleint 2015-08-31 13:16:21 +02:00
parent d3f0bee885
commit a869e4772b
5 changed files with 21 additions and 12 deletions

View File

@ -482,7 +482,8 @@ public:
AA_DontShowIconsInMenus = 2, AA_DontShowIconsInMenus = 2,
AA_NativeWindows = 3, AA_NativeWindows = 3,
AA_DontCreateNativeWidgetSiblings = 4, AA_DontCreateNativeWidgetSiblings = 4,
AA_MacPluginApplication = 5, AA_PluginApplication = 5,
AA_MacPluginApplication = AA_PluginApplication, // ### Qt 6: remove me
AA_DontUseNativeMenuBar = 6, AA_DontUseNativeMenuBar = 6,
AA_MacDontSwapCtrlAndMeta = 7, AA_MacDontSwapCtrlAndMeta = 7,
AA_Use96Dpi = 8, AA_Use96Dpi = 8,

View File

@ -120,13 +120,21 @@
widgets stay non-native unless specifically set by the widgets stay non-native unless specifically set by the
Qt::WA_NativeWindow attribute. Qt::WA_NativeWindow attribute.
\value AA_MacPluginApplication Stops the Qt mac application from doing \value AA_PluginApplication Indicates that Qt is used to author a plugin. Depending
specific initializations that do not necessarily make sense when using Qt on the operating system, it suppresses specific initializations that do not
to author a plugin. This includes avoiding loading our nib for the main necessarily make sense in the plugin case.
menu and not taking possession of the native menu bar. When setting this
For example on OS X, this includes avoiding loading our nib for the main
menu and not taking possession of the native menu bar. Setting this
attribute to true will also set the AA_DontUseNativeMenuBar attribute attribute to true will also set the AA_DontUseNativeMenuBar attribute
to true. It also disables native event filters. to true. It also disables native event filters.
This attribute has been added in Qt 5.7. It must be set before
\l {QGuiApplication}{Q(Gui)Application} is constructed.
\value AA_MacPluginApplication This attribute has been deprecated.
Use AA_PluginApplication instead.
\value AA_DontUseNativeMenuBar All menubars created while this attribute is \value AA_DontUseNativeMenuBar All menubars created while this attribute is
set to true won't be used as a native menubar (e.g, the menubar at set to true won't be used as a native menubar (e.g, the menubar at
the top of the main screen on OS X or at the bottom in Windows CE). the top of the main screen on OS X or at the bottom in Windows CE).

View File

@ -2697,7 +2697,7 @@ void QCoreApplication::removeLibraryPath(const QString &path)
i.e. MSG or XCB event structs. i.e. MSG or XCB event structs.
\note Native event filters will be disabled when the application the \note Native event filters will be disabled when the application the
Qt::AA_MacPluginApplication attribute is set. Qt::AA_PluginApplication attribute is set.
For maximum portability, you should always try to use QEvent For maximum portability, you should always try to use QEvent
and QObject::installEventFilter() whenever possible. and QObject::installEventFilter() whenever possible.
@ -2708,8 +2708,8 @@ void QCoreApplication::removeLibraryPath(const QString &path)
*/ */
void QCoreApplication::installNativeEventFilter(QAbstractNativeEventFilter *filterObj) void QCoreApplication::installNativeEventFilter(QAbstractNativeEventFilter *filterObj)
{ {
if (QCoreApplication::testAttribute(Qt::AA_MacPluginApplication)) { if (QCoreApplication::testAttribute(Qt::AA_PluginApplication)) {
qWarning("Native event filters are not applied when the Qt::AA_MacPluginApplication attribute is set"); qWarning("Native event filters are not applied when the Qt::AA_PluginApplication attribute is set");
return; return;
} }

View File

@ -181,7 +181,7 @@ QT_BEGIN_NAMESPACE
void qt_redirectNSApplicationSendEvent() void qt_redirectNSApplicationSendEvent()
{ {
if (QCoreApplication::testAttribute(Qt::AA_MacPluginApplication)) if (QCoreApplication::testAttribute(Qt::AA_PluginApplication))
// In a plugin we cannot chain sendEvent hooks: a second plugin could // In a plugin we cannot chain sendEvent hooks: a second plugin could
// store the implementation of the first, which during the program flow // store the implementation of the first, which during the program flow
// can be unloaded. // can be unloaded.
@ -207,7 +207,7 @@ void qt_redirectNSApplicationSendEvent()
void qt_resetNSApplicationSendEvent() void qt_resetNSApplicationSendEvent()
{ {
if (QCoreApplication::testAttribute(Qt::AA_MacPluginApplication)) if (QCoreApplication::testAttribute(Qt::AA_PluginApplication))
return; return;

View File

@ -316,7 +316,7 @@ QCocoaIntegration::QCocoaIntegration(const QStringList &paramList)
// ### For AA_MacPluginApplication we don't want to load the menu nib. // ### For AA_MacPluginApplication we don't want to load the menu nib.
// Qt 4 also does not set the application delegate, so that behavior // Qt 4 also does not set the application delegate, so that behavior
// is matched here. // is matched here.
if (!QCoreApplication::testAttribute(Qt::AA_MacPluginApplication)) { if (!QCoreApplication::testAttribute(Qt::AA_PluginApplication)) {
// Set app delegate, link to the current delegate (if any) // Set app delegate, link to the current delegate (if any)
QCocoaApplicationDelegate *newDelegate = [QCocoaApplicationDelegate sharedDelegate]; QCocoaApplicationDelegate *newDelegate = [QCocoaApplicationDelegate sharedDelegate];
@ -343,7 +343,7 @@ QCocoaIntegration::~QCocoaIntegration()
qt_resetNSApplicationSendEvent(); qt_resetNSApplicationSendEvent();
QMacAutoReleasePool pool; QMacAutoReleasePool pool;
if (!QCoreApplication::testAttribute(Qt::AA_MacPluginApplication)) { if (!QCoreApplication::testAttribute(Qt::AA_PluginApplication)) {
// remove the apple event handlers installed by QCocoaApplicationDelegate // remove the apple event handlers installed by QCocoaApplicationDelegate
QCocoaApplicationDelegate *delegate = [QCocoaApplicationDelegate sharedDelegate]; QCocoaApplicationDelegate *delegate = [QCocoaApplicationDelegate sharedDelegate];
[delegate removeAppleEventHandlers]; [delegate removeAppleEventHandlers];