summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAurélien Gâteau <agateau@kde.org>2011-04-14 08:00:27 (GMT)
committerThierry Bastian <thierry.bastian@nokia.com>2011-04-14 08:00:27 (GMT)
commitbe0d346052d69693c2780e62401f3c0d4b0d89d4 (patch)
tree788f9a26f0f060f452f93503aa411cba11fc905c /src
parent0432a6b79d35ac7db909a81793417107ebfb668f (diff)
downloadQt-be0d346052d69693c2780e62401f3c0d4b0d89d4.zip
Qt-be0d346052d69693c2780e62401f3c0d4b0d89d4.tar.gz
Qt-be0d346052d69693c2780e62401f3c0d4b0d89d4.tar.bz2
Introduce menubar plugin system
Merge-request: 916 Reviewed-by: Thierry Bastian <thierry.bastian@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/gui/widgets/qabstractmenubarimpl_p.h12
-rw-r--r--src/gui/widgets/qmenubar.cpp4
-rw-r--r--src/gui/widgets/qmenubarimpl.cpp24
-rw-r--r--src/gui/widgets/qmenubarimpl_p.h2
4 files changed, 41 insertions, 1 deletions
diff --git a/src/gui/widgets/qabstractmenubarimpl_p.h b/src/gui/widgets/qabstractmenubarimpl_p.h
index d001008..76eef28 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 <qfactoryinterface.h>
#include <qglobal.h>
+#include <qplugin.h>
#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 0d13574..ec19908 100644
--- a/src/gui/widgets/qmenubar.cpp
+++ b/src/gui/widgets/qmenubar.cpp
@@ -55,6 +55,7 @@
#include <qtoolbar.h>
#include <qtoolbutton.h>
#include <qwhatsthis.h>
+#include <qpluginloader.h>
#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 195f0ea..4844e4e 100644
--- a/src/gui/widgets/qmenubarimpl.cpp
+++ b/src/gui/widgets/qmenubarimpl.cpp
@@ -48,6 +48,8 @@
#include "qmenu.h"
#include "qmenubar.h"
+#include <private/qfactoryloader_p.h>
+
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<QMenuBarImplFactoryInterface *>(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 e770b5b..0546eb2 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