Merge-request: 1254
Reviewed-by: Gabriel de Dietrich <gabriel.dietrich-de@nokia.com>
(cherry picked from commit
31ff55bbeb84f10e75e997c75a63deda83e62507)
Change-Id: I0644514299c16cabe19d1e6d024dd652b2d7bc4e
Reviewed-on: http://codereview.qt.nokia.com/3933
Reviewed-by: Gabriel de Dietrich <gabriel.dietrich-de@nokia.com>
#ifndef QABSTRACTPLATFORMMENUBAR_P_H
#define QABSTRACTPLATFORMMENUBAR_P_H
+#include <qfactoryinterface.h>
#include <qglobal.h>
+#include <qplugin.h>
#ifndef QT_NO_MENUBAR
class QObject;
class QWidget;
+class QAbstractPlatformMenuBar;
+
+struct QPlatformMenuBarFactoryInterface : public QFactoryInterface
+{
+ virtual QAbstractPlatformMenuBar *create() = 0;
+};
+
+#define QPlatformMenuBarFactoryInterface_iid "com.nokia.qt.QPlatformMenuBarFactoryInterface"
+Q_DECLARE_INTERFACE(QPlatformMenuBarFactoryInterface, QPlatformMenuBarFactoryInterface_iid)
+
/*!
The platform-specific implementation of a menubar
*/
#include <qtoolbar.h>
#include <qtoolbutton.h>
#include <qwhatsthis.h>
+#ifdef Q_WS_X11
+#include <qpluginloader.h>
+#endif
#ifndef QT_NO_MENUBAR
}
#endif
#ifdef Q_WS_X11
- platformMenuBar = new QX11MenuBar;
+ platformMenuBar = qt_guiPlatformMenuBarFactory()->create();
platformMenuBar->init(q);
#endif
#include "qmenu.h"
#include "qmenubar.h"
+#include <private/qfactoryloader_p.h>
+
QT_BEGIN_NAMESPACE
QX11MenuBar::~QX11MenuBar()
return false;
}
+struct QX11MenuBarFactory : public QPlatformMenuBarFactoryInterface
+{
+ QAbstractPlatformMenuBar *create() { return new QX11MenuBar; }
+ virtual QStringList keys() const { return QStringList(); }
+};
+
+QPlatformMenuBarFactoryInterface *qt_guiPlatformMenuBarFactory()
+{
+ static QPlatformMenuBarFactoryInterface *factory = 0;
+ if (!factory) {
+#ifndef QT_NO_LIBRARY
+ QFactoryLoader loader(QPlatformMenuBarFactoryInterface_iid, QLatin1String("/menubar"));
+ factory = qobject_cast<QPlatformMenuBarFactoryInterface *>(loader.instance(QLatin1String("default")));
+#endif // QT_NO_LIBRARY
+ if(!factory) {
+ static QX11MenuBarFactory def;
+ factory = &def;
+ }
+ }
+ return factory;
+}
+
QT_END_NAMESPACE
#endif // QT_NO_MENUBAR
int nativeMenuBar : 3; // Only has values -1, 0, and 1
};
+QPlatformMenuBarFactoryInterface *qt_guiPlatformMenuBarFactory();
+
QT_END_NAMESPACE
#endif // QT_NO_MENUBAR