Minor QPlatformMenu API cleanup.

Make the QPlatformMenu* classes abstract with
pure virtual functions. Delete qplatformmenu_qpa.cpp.
QtGui no longer has to carry the empty implementations.

Change the inheritance tree - Make QPlatformMenu
and QPlatformMenuBar inherit QObject instead of
QMenuItem. Add (now) missing virtual functions to
QPlatformMenu. The effect of this change is to 
reduce the number of pure virtuals the platform 
has to implement.

Change QPlatformMenuBar::syncMenu to take a
QPlatformMenu pointer instead of a QPlatformMenuItem*
pointer.

Fix a couple of header/unused variable
compiler warnings.

Change-Id: I77450e40c6aae26f3e1aca204603acebd242c036
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
This commit is contained in:
Morten Johan Sorvig 2012-05-21 15:33:42 +02:00 committed by Qt by Nokia
parent 62fafaf16a
commit 98dbaecf7f
7 changed files with 37 additions and 192 deletions

View File

@ -80,7 +80,6 @@ SOURCES += \
kernel/qplatformcursor_qpa.cpp \
kernel/qplatformclipboard_qpa.cpp \
kernel/qplatformnativeinterface_qpa.cpp \
kernel/qplatformmenu_qpa.cpp \
kernel/qsessionmanager_qpa.cpp \
kernel/qsurfaceformat.cpp \
kernel/qguiapplication.cpp \

56
src/gui/kernel/qplatformmenu.h Normal file → Executable file
View File

@ -69,50 +69,56 @@ public:
enum MenuRole { NoRole = 0, TextHeuristicRole, ApplicationSpecificRole, AboutQtRole,
AboutRole, PreferencesRole, QuitRole };
virtual void setTag(quintptr tag);
virtual quintptr tag() const;
virtual void setTag(quintptr tag) = 0;
virtual quintptr tag()const = 0;
virtual void setText(const QString &text);
virtual void setIcon(const QImage &icon);
virtual void setMenu(QPlatformMenu *menu);
virtual void setVisible(bool isVisible);
virtual void setIsSeparator(bool isSeparator);
virtual void setFont(const QFont &font);
virtual void setRole(MenuRole role);
virtual void setChecked(bool isChecked);
virtual void setShortcut(const QKeySequence& shortcut);
virtual void setEnabled(bool enabled);
virtual void setText(const QString &text) = 0;
virtual void setIcon(const QImage &icon) = 0;
virtual void setMenu(QPlatformMenu *menu) = 0;
virtual void setVisible(bool isVisible) = 0;
virtual void setIsSeparator(bool isSeparator) = 0;
virtual void setFont(const QFont &font) = 0;
virtual void setRole(MenuRole role) = 0;
virtual void setChecked(bool isChecked) = 0;
virtual void setShortcut(const QKeySequence& shortcut) = 0;
virtual void setEnabled(bool enabled) = 0;
Q_SIGNALS:
void activated();
void hovered();
};
class Q_GUI_EXPORT QPlatformMenu : public QPlatformMenuItem // Some (but not all) of the PlatformMenuItem API applies to QPlatformMenu as well.
class Q_GUI_EXPORT QPlatformMenu : public QObject
{
Q_OBJECT
public:
virtual void insertMenuItem(QPlatformMenuItem *menuItem, QPlatformMenuItem *before);
virtual void removeMenuItem(QPlatformMenuItem *menuItem);
virtual void syncMenuItem(QPlatformMenuItem *menuItem);
virtual void syncSeparatorsCollapsible(bool enable);
virtual void insertMenuItem(QPlatformMenuItem *menuItem, QPlatformMenuItem *before) = 0;
virtual void removeMenuItem(QPlatformMenuItem *menuItem) = 0;
virtual void syncMenuItem(QPlatformMenuItem *menuItem) = 0;
virtual void syncSeparatorsCollapsible(bool enable) = 0;
virtual QPlatformMenuItem *menuItemAt(int position) const;
virtual QPlatformMenuItem *menuItemForTag(quintptr tag) const;
virtual void setTag(quintptr tag) = 0;
virtual quintptr tag()const = 0;
virtual void setText(const QString &text) = 0;
virtual void setEnabled(bool enabled) = 0;
virtual QPlatformMenuItem *menuItemAt(int position) const = 0;
virtual QPlatformMenuItem *menuItemForTag(quintptr tag) const = 0;
Q_SIGNALS:
void aboutToShow();
void aboutToHide();
};
class Q_GUI_EXPORT QPlatformMenuBar : public QPlatformMenu
class Q_GUI_EXPORT QPlatformMenuBar : public QObject
{
Q_OBJECT
public:
virtual void insertMenu(QPlatformMenu *menu, QPlatformMenu *before);
virtual void removeMenu(QPlatformMenu *menu);
virtual void syncMenu(QPlatformMenuItem *menuItem);
virtual void handleReparent(QWindow *newParentWindow);
virtual void insertMenu(QPlatformMenu *menu, QPlatformMenu *before) = 0;
virtual void removeMenu(QPlatformMenu *menu) = 0;
virtual void syncMenu(QPlatformMenu *menuItem) = 0;
virtual void handleReparent(QWindow *newParentWindow) = 0;
virtual QPlatformMenu *menuForTag(quintptr tag) const;
virtual QPlatformMenu *menuForTag(quintptr tag) const = 0;
};
QT_END_NAMESPACE

View File

@ -1,161 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author James Turner <james.turner@kdab.com>
** Contact: http://www.qt-project.org/
**
** This file is part of the QtGui module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** 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.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU General
** Public License version 3.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of this
** file. Please review the following information to ensure the GNU General
** Public License version 3.0 requirements will be met:
** http://www.gnu.org/copyleft/gpl.html.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "qplatformmenu.h"
QT_BEGIN_NAMESPACE
void QPlatformMenuItem::setText(const QString &text)
{
}
void QPlatformMenuItem::setIcon(const QImage &icon)
{
}
void QPlatformMenuItem::setMenu(QPlatformMenu *menu)
{
}
void QPlatformMenuItem::setVisible(bool isVisible)
{
}
void QPlatformMenuItem::setIsSeparator(bool isSeparator)
{
}
void QPlatformMenuItem::setFont(const QFont &font)
{
}
void QPlatformMenuItem::setRole(QPlatformMenuItem::MenuRole role)
{
}
void QPlatformMenuItem::setChecked(bool isChecked)
{
}
void QPlatformMenuItem::setShortcut(const QKeySequence& shortcut)
{
}
void QPlatformMenuItem::setEnabled(bool enabled)
{
}
void QPlatformMenuItem::setTag(quintptr tag)
{
}
quintptr QPlatformMenuItem::tag() const
{
return 0;
}
void QPlatformMenu::insertMenuItem(QPlatformMenuItem *menuItem, QPlatformMenuItem* before)
{
}
void QPlatformMenu::removeMenuItem(QPlatformMenuItem *menuItem)
{
}
void QPlatformMenu::syncMenuItem(QPlatformMenuItem *menuItem)
{
}
void QPlatformMenu::syncSeparatorsCollapsible(bool enable)
{
}
QPlatformMenuItem* QPlatformMenu::menuItemAt(int position) const
{
return 0;
}
QPlatformMenuItem* QPlatformMenu::menuItemForTag(quintptr tag) const
{
return 0;
}
void QPlatformMenuBar::insertMenu(QPlatformMenu *menuItem, QPlatformMenu* before)
{
}
void QPlatformMenuBar::removeMenu(QPlatformMenu *menuItem)
{
}
void QPlatformMenuBar::syncMenu(QPlatformMenuItem *menuItem)
{
}
void QPlatformMenuBar::handleReparent(QWindow *newParentWindow)
{
}
QPlatformMenu *QPlatformMenuBar::menuForTag(quintptr tag) const
{
Q_UNUSED(tag);
return 0;
}
QT_END_NAMESPACE

View File

@ -58,7 +58,7 @@ public:
virtual void insertMenu(QPlatformMenu *menu, QPlatformMenu* before);
virtual void removeMenu(QPlatformMenu *menu);
virtual void syncMenu(QPlatformMenuItem *menuItem);
virtual void syncMenu(QPlatformMenu *menuItem);
virtual void handleReparent(QWindow *newParentWindow);
virtual QPlatformMenu *menuForTag(quintptr tag) const;

View File

@ -113,9 +113,9 @@ void QCocoaMenuBar::removeMenu(QPlatformMenu *platformMenu)
[m_nativeMenu removeItemAtIndex: realIndex];
}
void QCocoaMenuBar::syncMenu(QPlatformMenuItem *menuItem)
void QCocoaMenuBar::syncMenu(QPlatformMenu *menu)
{
Q_UNUSED(menuItem);
Q_UNUSED(menu);
}
void QCocoaMenuBar::handleReparent(QWindow *newParentWindow)

View File

@ -92,6 +92,7 @@ void *QCocoaNativeInterface::NSPrintInfoForPrintEngine(QPrintEngine *printEngine
void QCocoaNativeInterface::onAppFocusWindowChanged(QWindow *window)
{
Q_UNUSED(window);
QCocoaMenuBar::updateMenuBarImmediately();
}

View File

@ -52,8 +52,8 @@
#include "qcocoamenubar.h"
#include <QtGui/private/qguiapplication_p.h>
#include <QtGui/QPlatformIntegration>
#include <QtGui/QPlatformNativeInterface>
#include <qpa/qplatformintegration.h>
#include <qpa/qplatformnativeinterface.h>
QT_BEGIN_NAMESPACE