From 4b25f3fa1f7cdbee225b6b8aebe3102f5201e217 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Thu, 14 Apr 2011 14:58:25 +0200 Subject: [PATCH] Reverting merge request 916 Revert "Introduce menubar plugin system" This reverts commits 56c3de426d97ab7c8fb..f7b60fffb673b182e63 (cherry picked from commit c6514537a8568050f5812a2b55fcf47a3ec2fce1) --- src/gui/widgets/qabstractmenubarimpl_p.cpp | 44 ++++++++++++++++++++++ ...nubarinterface_p.h => qabstractmenubarimpl_p.h} | 26 ++++--------- src/gui/widgets/qmenubar.cpp | 9 +++-- src/gui/widgets/qmenubar_p.h | 4 +- src/gui/widgets/qmenubarimpl.cpp | 34 ++++------------- src/gui/widgets/qmenubarimpl_p.h | 8 ++-- src/gui/widgets/widgets.pri | 3 +- 7 files changed, 70 insertions(+), 58 deletions(-) create mode 100644 src/gui/widgets/qabstractmenubarimpl_p.cpp rename src/gui/widgets/{qabstractmenubarinterface_p.h => qabstractmenubarimpl_p.h} (80%) diff --git a/src/gui/widgets/qabstractmenubarimpl_p.cpp b/src/gui/widgets/qabstractmenubarimpl_p.cpp new file mode 100644 index 0000000..bc16030 --- /dev/null +++ b/src/gui/widgets/qabstractmenubarimpl_p.cpp @@ -0,0 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include + +QAbstractMenuBarImpl::~QAbstractMenuBarImpl() +{} diff --git a/src/gui/widgets/qabstractmenubarinterface_p.h b/src/gui/widgets/qabstractmenubarimpl_p.h similarity index 80% rename from src/gui/widgets/qabstractmenubarinterface_p.h rename to src/gui/widgets/qabstractmenubarimpl_p.h index a014bc1..d001008 100644 --- a/src/gui/widgets/qabstractmenubarinterface_p.h +++ b/src/gui/widgets/qabstractmenubarimpl_p.h @@ -38,12 +38,10 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -#ifndef QABSTRACTMENUBARINTERFACE_P_H -#define QABSTRACTMENUBARINTERFACE_P_H +#ifndef QABSTRACTMENUBARIMPL_P_H +#define QABSTRACTMENUBARIMPL_P_H -#include #include -#include #ifndef QT_NO_MENUBAR @@ -56,29 +54,19 @@ class QMenuBar; class QObject; class QWidget; -class QAbstractMenuBarInterface; - -struct QMenuBarImplFactoryInterface : public QFactoryInterface -{ - virtual QAbstractMenuBarInterface* createImpl() = 0; -}; - -#define QMenuBarImplFactoryInterface_iid "com.nokia.qt.QMenuBarImplFactoryInterface" -Q_DECLARE_INTERFACE(QMenuBarImplFactoryInterface, QMenuBarImplFactoryInterface_iid) - /** * The platform-specific implementation of a menubar */ -class QAbstractMenuBarInterface +class Q_GUI_EXPORT QAbstractMenuBarImpl { public: - QAbstractMenuBarInterface() {} - virtual ~QAbstractMenuBarInterface() {} + virtual ~QAbstractMenuBarImpl(); // QMenuBarPrivate::init() virtual void init(QMenuBar *) = 0; - virtual void setVisible(bool visible) = 0; + // QMenuBar::setVisible() + virtual bool allowSetVisible() const = 0; virtual void actionEvent(QActionEvent *) = 0; @@ -113,4 +101,4 @@ QT_END_NAMESPACE #endif // QT_NO_MENUBAR -#endif // QABSTRACTMENUBARINTERFACE_P_H +#endif // QABSTRACTMENUBARIMPL_P_H diff --git a/src/gui/widgets/qmenubar.cpp b/src/gui/widgets/qmenubar.cpp index 357c0fa..4a31132 100644 --- a/src/gui/widgets/qmenubar.cpp +++ b/src/gui/widgets/qmenubar.cpp @@ -55,7 +55,6 @@ #include #include #include -#include #ifndef QT_NO_MENUBAR @@ -729,8 +728,7 @@ void QMenuBarPrivate::init() Q_Q(QMenuBar); q->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum); q->setAttribute(Qt::WA_CustomWhatsThis); - - impl = qt_guiMenuBarImplFactory()->createImpl(); + impl = new QMenuBarImpl; impl->init(q); q->setBackgroundRole(QPalette::Button); @@ -1055,7 +1053,10 @@ void QMenuBar::paintEvent(QPaintEvent *e) void QMenuBar::setVisible(bool visible) { Q_D(QMenuBar); - d->impl->setVisible(visible); + if (!d->impl->allowSetVisible()) { + return; + } + QWidget::setVisible(visible); } /*! diff --git a/src/gui/widgets/qmenubar_p.h b/src/gui/widgets/qmenubar_p.h index 427cd30..b49e039 100644 --- a/src/gui/widgets/qmenubar_p.h +++ b/src/gui/widgets/qmenubar_p.h @@ -61,7 +61,7 @@ #include "qguifunctions_wince.h" #endif -#include "qabstractmenubarinterface_p.h" +#include "qabstractmenubarimpl_p.h" #ifndef QT_NO_MENUBAR #ifdef Q_WS_S60 @@ -160,7 +160,7 @@ public: #ifdef QT3_SUPPORT bool doAutoResize; #endif - QAbstractMenuBarInterface *impl; + QAbstractMenuBarImpl *impl; #ifdef QT_SOFTKEYS_ENABLED QAction *menuBarAction; #endif diff --git a/src/gui/widgets/qmenubarimpl.cpp b/src/gui/widgets/qmenubarimpl.cpp index d402507..cbe9198 100644 --- a/src/gui/widgets/qmenubarimpl.cpp +++ b/src/gui/widgets/qmenubarimpl.cpp @@ -49,8 +49,6 @@ #include "qmenu.h" #include "qmenubar.h" -#include - QT_BEGIN_NAMESPACE QMenuBarImpl::~QMenuBarImpl() @@ -90,16 +88,20 @@ void QMenuBarImpl::init(QMenuBar *_menuBar) #endif } -void QMenuBarImpl::setVisible(bool visible) +bool QMenuBarImpl::allowSetVisible() const { #if defined(Q_WS_MAC) || defined(Q_OS_WINCE) || defined(Q_WS_S60) + // FIXME: Port this to a setVisible() method + /* if (isNativeMenuBar()) { if (!visible) - menuBar->QWidget::setVisible(false); + QWidget::setVisible(false); return; } + */ + return !isNativeMenuBar(); #endif - menuBar->QWidget::setVisible(visible); + return true; } void QMenuBarImpl::actionEvent(QActionEvent *e) @@ -237,28 +239,6 @@ bool QMenuBarImpl::menuBarEventFilter(QObject *, QEvent *) return false; } -struct QMenuBarImplFactory : public QMenuBarImplFactoryInterface -{ - QAbstractMenuBarInterface* 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 749c395..c4ab2df 100644 --- a/src/gui/widgets/qmenubarimpl_p.h +++ b/src/gui/widgets/qmenubarimpl_p.h @@ -44,20 +44,20 @@ #ifndef QT_NO_MENUBAR -#include "qabstractmenubarinterface_p.h" +#include "qabstractmenubarimpl_p.h" QT_BEGIN_NAMESPACE class QMenuBar; -class QMenuBarImpl : public QAbstractMenuBarInterface +class QMenuBarImpl : public QAbstractMenuBarImpl { public: ~QMenuBarImpl(); virtual void init(QMenuBar *); - virtual void setVisible(bool visible); + virtual bool allowSetVisible() const; virtual void actionEvent(QActionEvent *e); @@ -176,8 +176,6 @@ private: #endif }; -QMenuBarImplFactoryInterface *qt_guiMenuBarImplFactory(); - QT_END_NAMESPACE #endif // QT_NO_MENUBAR diff --git a/src/gui/widgets/widgets.pri b/src/gui/widgets/widgets.pri index 97d23f7..e5d6890 100644 --- a/src/gui/widgets/widgets.pri +++ b/src/gui/widgets/widgets.pri @@ -4,7 +4,7 @@ HEADERS += \ widgets/qbuttongroup.h \ widgets/qabstractbutton.h \ widgets/qabstractbutton_p.h \ - widgets/qabstractmenubarinterface_p.h \ + widgets/qabstractmenubarimpl_p.h \ widgets/qabstractslider.h \ widgets/qabstractslider_p.h \ widgets/qabstractspinbox.h \ @@ -85,6 +85,7 @@ HEADERS += \ widgets/qprintpreviewwidget.h SOURCES += \ widgets/qabstractbutton.cpp \ + widgets/qabstractmenubarimpl_p.cpp \ widgets/qabstractslider.cpp \ widgets/qabstractspinbox.cpp \ widgets/qcalendarwidget.cpp \ -- 2.7.4