Introduce menubar plugin system
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>bb10
parent
6c97b066a9
commit
baeed7c6c3
|
|
@ -41,7 +41,9 @@
|
|||
#ifndef QABSTRACTPLATFORMMENUBAR_P_H
|
||||
#define QABSTRACTPLATFORMMENUBAR_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 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
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -55,6 +55,9 @@
|
|||
#include <qtoolbar.h>
|
||||
#include <qtoolbutton.h>
|
||||
#include <qwhatsthis.h>
|
||||
#ifdef Q_WS_X11
|
||||
#include <qpluginloader.h>
|
||||
#endif
|
||||
|
||||
#ifndef QT_NO_MENUBAR
|
||||
|
||||
|
|
@ -761,7 +764,7 @@ void QMenuBarPrivate::init()
|
|||
}
|
||||
#endif
|
||||
#ifdef Q_WS_X11
|
||||
platformMenuBar = new QX11MenuBar;
|
||||
platformMenuBar = qt_guiPlatformMenuBarFactory()->create();
|
||||
platformMenuBar->init(q);
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -48,6 +48,8 @@
|
|||
#include "qmenu.h"
|
||||
#include "qmenubar.h"
|
||||
|
||||
#include <private/qfactoryloader_p.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QX11MenuBar::~QX11MenuBar()
|
||||
|
|
@ -109,6 +111,28 @@ bool QX11MenuBar::menuBarEventFilter(QObject *, QEvent *)
|
|||
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
|
||||
|
|
|
|||
|
|
@ -77,6 +77,8 @@ private:
|
|||
int nativeMenuBar : 3; // Only has values -1, 0, and 1
|
||||
};
|
||||
|
||||
QPlatformMenuBarFactoryInterface *qt_guiPlatformMenuBarFactory();
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QT_NO_MENUBAR
|
||||
|
|
|
|||
Loading…
Reference in New Issue