diff options
author | James Turner <james.turner@kdab.com> | 2012-02-27 13:04:45 +0000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-05-19 01:45:04 +0200 |
commit | 1f55af8e54dc4841441ab1adf7759baace9452fa (patch) | |
tree | 42beff251511100aad43ad31fdb276d67b43e59f /src/widgets/kernel | |
parent | 864e9963843f209f61c72123df05743bcbf1e139 (diff) |
QPA menu abstraction, originally based on Morten's work
Create a QPA abstraction for native menus, derived from the
Cocoa support in 4.8, but with the expectation to support
other platforms too. Update the QtWidget QMenu and QMenuBar
code to maintain their QPA equivalents if they exist.
Change-Id: Id605de3da8811dc832bf48b35f9107778ad320ff
Reviewed-by: Morten Johan Sørvig <morten.sorvig@nokia.com>
Diffstat (limited to 'src/widgets/kernel')
-rw-r--r-- | src/widgets/kernel/kernel.pri | 9 | ||||
-rw-r--r-- | src/widgets/kernel/qaction.h | 3 | ||||
-rw-r--r-- | src/widgets/kernel/qplatformmenu.h | 94 | ||||
-rw-r--r-- | src/widgets/kernel/qplatformmenu_qpa.cpp | 113 |
4 files changed, 6 insertions, 213 deletions
diff --git a/src/widgets/kernel/kernel.pri b/src/widgets/kernel/kernel.pri index c4853bd369..ac363c5f7a 100644 --- a/src/widgets/kernel/kernel.pri +++ b/src/widgets/kernel/kernel.pri @@ -36,8 +36,7 @@ HEADERS += \ kernel/qsoftkeymanager_p.h \ kernel/qsoftkeymanager_common_p.h \ kernel/qdesktopwidget_qpa_p.h \ - kernel/qwidgetwindow_qpa_p.h \ - kernel/qplatformmenu.h + kernel/qwidgetwindow_qpa_p.h SOURCES += \ kernel/qaction.cpp \ @@ -66,8 +65,8 @@ SOURCES += \ kernel/qapplication_qpa.cpp \ kernel/qdesktopwidget_qpa.cpp \ kernel/qwidget_qpa.cpp \ - kernel/qwidgetwindow_qpa.cpp \ - kernel/qplatformmenu_qpa.cpp + kernel/qwidgetwindow_qpa.cpp + # TODO false:!x11:mac { @@ -75,7 +74,7 @@ false:!x11:mac { kernel/qclipboard_mac.cpp \ kernel/qmime_mac.cpp \ kernel/qt_mac.cpp \ - kernel/qkeymapper_mac.cpp + kernel/qkeymapper_mac.cpp OBJECTIVE_HEADERS += \ qcocoawindow_mac_p.h \ diff --git a/src/widgets/kernel/qaction.h b/src/widgets/kernel/qaction.h index bb7de852c1..ea3138fb23 100644 --- a/src/widgets/kernel/qaction.h +++ b/src/widgets/kernel/qaction.h @@ -90,7 +90,8 @@ class Q_WIDGETS_EXPORT QAction : public QObject Q_PROPERTY(Priority priority READ priority WRITE setPriority) public: - enum MenuRole { NoRole, TextHeuristicRole, ApplicationSpecificRole, AboutQtRole, + // note this is copied into qplatformmenu.h, which must stay in sync + enum MenuRole { NoRole = 0, TextHeuristicRole, ApplicationSpecificRole, AboutQtRole, AboutRole, PreferencesRole, QuitRole }; enum SoftKeyRole { NoSoftKey, PositiveSoftKey, NegativeSoftKey, SelectSoftKey }; diff --git a/src/widgets/kernel/qplatformmenu.h b/src/widgets/kernel/qplatformmenu.h deleted file mode 100644 index cbd7eae6ac..0000000000 --- a/src/widgets/kernel/qplatformmenu.h +++ /dev/null @@ -1,94 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** 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$ -** -****************************************************************************/ - -#ifndef QPLATFORMMENU_H -#define QPLATFORMMENU_H - -#include <QtCore/qglobal.h> -#include <QtCore/qpointer.h> -#include <QtWidgets/qaction.h> - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -class QMenuPrivate; -class Q_WIDGETS_EXPORT QPlatformMenuAction -{ -public: - virtual ~QPlatformMenuAction(); - QPointer<QAction> action; -}; - -class Q_WIDGETS_EXPORT QPlatformMenu { -public: - QPlatformMenu(); - virtual ~QPlatformMenu(); - - virtual bool merged(const QAction *action) const = 0; - - virtual void addAction(QAction *action, QAction *before) = 0; - virtual void removeAction(QAction *action) = 0; - virtual void syncAction(QAction *action) = 0; - - virtual void setMenuEnabled(bool enable); - virtual void syncSeparatorsCollapsible(bool enable); -}; - -class Q_WIDGETS_EXPORT QPlatformMenuBar { -public: - QPlatformMenuBar(); - virtual ~QPlatformMenuBar(); - - virtual void addAction(QAction *action, QAction *before = 0) = 0; - virtual void syncAction(QAction *action) = 0; - virtual void removeAction(QAction *action) = 0; - - virtual void handleReparent(QWidget *newParent); -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif - diff --git a/src/widgets/kernel/qplatformmenu_qpa.cpp b/src/widgets/kernel/qplatformmenu_qpa.cpp deleted file mode 100644 index f28560e560..0000000000 --- a/src/widgets/kernel/qplatformmenu_qpa.cpp +++ /dev/null @@ -1,113 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtWidgets 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 - -/*! - \class QPlatformMenuAction - \since 5.0 - \internal - \preliminary - \ingroup qpa - - \brief The QPlatformMenuAction class provides an abstraction for menu actions. - */ - -QPlatformMenuAction::~QPlatformMenuAction() -{ - -} - -/*! - \class QPlatformMenu - \since 5.0 - \internal - \preliminary - \ingroup qpa - - \brief The QPlatformMenu class provides an abstraction for menus. - */ -QPlatformMenu::QPlatformMenu() -{ -} - -QPlatformMenu::~QPlatformMenu() -{ - -} - -void QPlatformMenu::setMenuEnabled(bool enable) -{ - Q_UNUSED(enable); -} - -void QPlatformMenu::syncSeparatorsCollapsible(bool enable) -{ - Q_UNUSED(enable); -} - -/*! - \class QPlatformMenuBar - \since 5.0 - \internal - \preliminary - \ingroup qpa - - \brief The QPlatformMenuBar class provides an abstraction for menu bars. - */ -QPlatformMenuBar::QPlatformMenuBar() -{ - -} - -QPlatformMenuBar::~QPlatformMenuBar() -{ - -} - -void QPlatformMenuBar::handleReparent(QWidget *newParent) -{ - Q_UNUSED(newParent); -} - -QT_END_NAMESPACE |