| 1 | /**************************************************************************** | 
| 2 | ** | 
| 3 | ** Copyright (C) 2016 The Qt Company Ltd. | 
| 4 | ** Contact: https://www.qt.io/licensing/ | 
| 5 | ** | 
| 6 | ** This file is part of the QtWidgets module of the Qt Toolkit. | 
| 7 | ** | 
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ | 
| 9 | ** Commercial License Usage | 
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | 
| 11 | ** accordance with the commercial license agreement provided with the | 
| 12 | ** Software or, alternatively, in accordance with the terms contained in | 
| 13 | ** a written agreement between you and The Qt Company. For licensing terms | 
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further | 
| 15 | ** information use the contact form at https://www.qt.io/contact-us. | 
| 16 | ** | 
| 17 | ** GNU Lesser General Public License Usage | 
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | 
| 19 | ** General Public License version 3 as published by the Free Software | 
| 20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | 
| 21 | ** packaging of this file. Please review the following information to | 
| 22 | ** ensure the GNU Lesser General Public License version 3 requirements | 
| 23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | 
| 24 | ** | 
| 25 | ** GNU General Public License Usage | 
| 26 | ** Alternatively, this file may be used under the terms of the GNU | 
| 27 | ** General Public License version 2.0 or (at your option) the GNU General | 
| 28 | ** Public license version 3 or any later version approved by the KDE Free | 
| 29 | ** Qt Foundation. The licenses are as published by the Free Software | 
| 30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | 
| 31 | ** included in the packaging of this file. Please review the following | 
| 32 | ** information to ensure the GNU General Public License requirements will | 
| 33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | 
| 34 | ** https://www.gnu.org/licenses/gpl-3.0.html. | 
| 35 | ** | 
| 36 | ** $QT_END_LICENSE$ | 
| 37 | ** | 
| 38 | ****************************************************************************/ | 
| 39 |  | 
| 40 | #ifndef QMENUBAR_H | 
| 41 | #define  | 
| 42 |  | 
| 43 | #include <QtWidgets/qtwidgetsglobal.h> | 
| 44 | #include <QtWidgets/qmenu.h> | 
| 45 |  | 
| 46 | QT_REQUIRE_CONFIG(menubar); | 
| 47 |  | 
| 48 | QT_BEGIN_NAMESPACE | 
| 49 |  | 
| 50 | class ; | 
| 51 | class ; | 
| 52 | class QWindowsStyle; | 
| 53 | class ; | 
| 54 |  | 
| 55 | class Q_WIDGETS_EXPORT  : public QWidget | 
| 56 | { | 
| 57 |     Q_OBJECT | 
| 58 |  | 
| 59 |     Q_PROPERTY(bool defaultUp READ isDefaultUp WRITE setDefaultUp) | 
| 60 |     Q_PROPERTY(bool nativeMenuBar READ isNativeMenuBar WRITE setNativeMenuBar) | 
| 61 |  | 
| 62 | public: | 
| 63 |     explicit (QWidget *parent = nullptr); | 
| 64 |     (); | 
| 65 |  | 
| 66 |     using QWidget::addAction; | 
| 67 |     QAction *(const QString &text); | 
| 68 |     QAction *(const QString &text, const QObject *receiver, const char* member); | 
| 69 |  | 
| 70 | #ifdef Q_CLANG_QDOC | 
| 71 |     template<typename Obj, typename PointerToMemberFunctionOrFunctor> | 
| 72 |     QAction *addAction(const QString &text, const Obj *receiver, PointerToMemberFunctionOrFunctor method); | 
| 73 |     template<typename Functor> | 
| 74 |     QAction *addAction(const QString &text, Functor functor); | 
| 75 | #else | 
| 76 |     // addAction(QString): Connect to a QObject slot / functor or function pointer (with context) | 
| 77 |     template<typename Obj, typename Func1> | 
| 78 |     inline typename std::enable_if<!std::is_same<const char*, Func1>::value | 
| 79 |         && QtPrivate::IsPointerToTypeDerivedFromQObject<Obj*>::Value, QAction *>::type | 
| 80 |         (const QString &text, const Obj *object, Func1 slot) | 
| 81 |     { | 
| 82 |         QAction *result = addAction(text); | 
| 83 |         connect(result, &QAction::triggered, object, std::move(slot)); | 
| 84 |         return result; | 
| 85 |     } | 
| 86 |     // addAction(QString): Connect to a functor or function pointer (without context) | 
| 87 |     template <typename Func1> | 
| 88 |     inline QAction *(const QString &text, Func1 slot) | 
| 89 |     { | 
| 90 |         QAction *result = addAction(text); | 
| 91 |         connect(result, &QAction::triggered, std::move(slot)); | 
| 92 |         return result; | 
| 93 |     } | 
| 94 | #endif // !Q_CLANG_QDOC | 
| 95 |  | 
| 96 |     QAction *(QMenu *); | 
| 97 |     QMenu *(const QString &title); | 
| 98 |     QMenu *(const QIcon &icon, const QString &title); | 
| 99 |  | 
| 100 |  | 
| 101 |     QAction *(); | 
| 102 |     QAction *(QAction *before); | 
| 103 |  | 
| 104 |     QAction *(QAction *before, QMenu *); | 
| 105 |  | 
| 106 |     void (); | 
| 107 |  | 
| 108 |     QAction *() const; | 
| 109 |     void (QAction *action); | 
| 110 |  | 
| 111 |     void (bool); | 
| 112 |     bool () const; | 
| 113 |  | 
| 114 |     QSize () const override; | 
| 115 |     QSize () const override; | 
| 116 |     int (int) const override; | 
| 117 |  | 
| 118 |     QRect (QAction *) const; | 
| 119 |     QAction *(const QPoint &) const; | 
| 120 |  | 
| 121 |     void (QWidget *w, Qt::Corner corner = Qt::TopRightCorner); | 
| 122 |     QWidget *(Qt::Corner corner = Qt::TopRightCorner) const; | 
| 123 |  | 
| 124 | #if defined(Q_OS_MACOS) || defined(Q_CLANG_QDOC) | 
| 125 |     NSMenu* toNSMenu(); | 
| 126 | #endif | 
| 127 |  | 
| 128 |     bool () const; | 
| 129 |     void (bool ); | 
| 130 |     QPlatformMenuBar *(); | 
| 131 | public Q_SLOTS: | 
| 132 |     void (bool visible) override; | 
| 133 |  | 
| 134 | Q_SIGNALS: | 
| 135 |     void (QAction *action); | 
| 136 |     void (QAction *action); | 
| 137 |  | 
| 138 | protected: | 
| 139 |     void (QEvent *) override; | 
| 140 |     void (QKeyEvent *) override; | 
| 141 |     void (QMouseEvent *) override; | 
| 142 |     void (QMouseEvent *) override; | 
| 143 |     void (QMouseEvent *) override; | 
| 144 |     void (QEvent *) override; | 
| 145 |     void (QPaintEvent *) override; | 
| 146 |     void (QResizeEvent *) override; | 
| 147 |     void (QActionEvent *) override; | 
| 148 |     void (QFocusEvent *) override; | 
| 149 |     void (QFocusEvent *) override; | 
| 150 |     void (QTimerEvent *) override; | 
| 151 |     bool (QObject *, QEvent *) override; | 
| 152 |     bool (QEvent *) override; | 
| 153 |     void (QStyleOptionMenuItem *option, const QAction *action) const; | 
| 154 |  | 
| 155 | private: | 
| 156 |     Q_DECLARE_PRIVATE(QMenuBar) | 
| 157 |     Q_DISABLE_COPY() | 
| 158 |     Q_PRIVATE_SLOT(d_func(), void _q_actionTriggered()) | 
| 159 |     Q_PRIVATE_SLOT(d_func(), void _q_actionHovered()) | 
| 160 |     Q_PRIVATE_SLOT(d_func(), void _q_internalShortcutActivated(int)) | 
| 161 |     Q_PRIVATE_SLOT(d_func(), void _q_updateLayout()) | 
| 162 |  | 
| 163 |     friend class QMenu; | 
| 164 |     friend class QMenuPrivate; | 
| 165 |     friend class QWindowsStyle; | 
| 166 | }; | 
| 167 |  | 
| 168 | QT_END_NAMESPACE | 
| 169 |  | 
| 170 | #endif // QMENUBAR_H | 
| 171 |  |