diff --git a/src/gui/widgets/qabstractmenubarimpl_p.h b/src/gui/widgets/qabstractmenubarimpl_p.h index d0010082ea..76eef2890d 100644 --- a/src/gui/widgets/qabstractmenubarimpl_p.h +++ b/src/gui/widgets/qabstractmenubarimpl_p.h @@ -41,7 +41,9 @@ #ifndef QABSTRACTMENUBARIMPL_P_H #define QABSTRACTMENUBARIMPL_P_H +#include #include +#include #ifndef QT_NO_MENUBAR @@ -54,6 +56,16 @@ class QMenuBar; class QObject; class QWidget; +class QAbstractMenuBarImpl; + +struct QMenuBarImplFactoryInterface : public QFactoryInterface +{ + virtual QAbstractMenuBarImpl* createImpl() = 0; +}; + +#define QMenuBarImplFactoryInterface_iid "com.nokia.qt.QMenuBarImplFactoryInterface" +Q_DECLARE_INTERFACE(QMenuBarImplFactoryInterface, QMenuBarImplFactoryInterface_iid) + /** * The platform-specific implementation of a menubar */ diff --git a/src/gui/widgets/qmenubar.cpp b/src/gui/widgets/qmenubar.cpp index 0d13574c67..ec19908169 100644 --- a/src/gui/widgets/qmenubar.cpp +++ b/src/gui/widgets/qmenubar.cpp @@ -55,6 +55,7 @@ #include #include #include +#include #ifndef QT_NO_MENUBAR @@ -728,7 +729,8 @@ void QMenuBarPrivate::init() Q_Q(QMenuBar); q->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum); q->setAttribute(Qt::WA_CustomWhatsThis); - impl = new QMenuBarImpl; + + impl = qt_guiMenuBarImplFactory()->createImpl(); impl->init(q); q->setBackgroundRole(QPalette::Button); diff --git a/src/gui/widgets/qmenubarimpl.cpp b/src/gui/widgets/qmenubarimpl.cpp index 195f0ea232..4844e4eb72 100644 --- a/src/gui/widgets/qmenubarimpl.cpp +++ b/src/gui/widgets/qmenubarimpl.cpp @@ -48,6 +48,8 @@ #include "qmenu.h" #include "qmenubar.h" +#include + QT_BEGIN_NAMESPACE QMenuBarImpl::~QMenuBarImpl() @@ -239,6 +241,28 @@ bool QMenuBarImpl::menuBarEventFilter(QObject *, QEvent *) return false; } +struct QMenuBarImplFactory : public QMenuBarImplFactoryInterface +{ + QAbstractMenuBarImpl* createImpl() { return new QMenuBarImpl; } + virtual QStringList keys() const { return QStringList(); } +}; + +QMenuBarImplFactoryInterface *qt_guiMenuBarImplFactory() +{ + static QMenuBarImplFactoryInterface *factory = 0; + if (!factory) { +#ifndef QT_NO_LIBRARY + QFactoryLoader loader(QMenuBarImplFactoryInterface_iid, QLatin1String("/menubar")); + factory = qobject_cast(loader.instance(QLatin1String("default"))); +#endif // QT_NO_LIBRARY + if(!factory) { + static QMenuBarImplFactory def; + factory = &def; + } + } + return factory; +} + QT_END_NAMESPACE #endif // QT_NO_MENUBAR diff --git a/src/gui/widgets/qmenubarimpl_p.h b/src/gui/widgets/qmenubarimpl_p.h index e770b5b3ea..0546eb22f7 100644 --- a/src/gui/widgets/qmenubarimpl_p.h +++ b/src/gui/widgets/qmenubarimpl_p.h @@ -175,6 +175,8 @@ private: #endif }; +QMenuBarImplFactoryInterface *qt_guiMenuBarImplFactory(); + QT_END_NAMESPACE #endif // QT_NO_MENUBAR