Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:09:36

0001 // Copyright (C) 2016 The Qt Company Ltd.
0002 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
0003 
0004 #ifndef QMENUBAR_H
0005 #define QMENUBAR_H
0006 
0007 #include <QtWidgets/qtwidgetsglobal.h>
0008 #include <QtWidgets/qmenu.h>
0009 
0010 QT_REQUIRE_CONFIG(menubar);
0011 
0012 QT_BEGIN_NAMESPACE
0013 
0014 class QMenuBarPrivate;
0015 class QStyleOptionMenuItem;
0016 class QWindowsStyle;
0017 class QPlatformMenuBar;
0018 
0019 class Q_WIDGETS_EXPORT QMenuBar : public QWidget
0020 {
0021     Q_OBJECT
0022 
0023     Q_PROPERTY(bool defaultUp READ isDefaultUp WRITE setDefaultUp)
0024     Q_PROPERTY(bool nativeMenuBar READ isNativeMenuBar WRITE setNativeMenuBar)
0025 
0026 public:
0027     explicit QMenuBar(QWidget *parent = nullptr);
0028     ~QMenuBar();
0029 
0030     using QWidget::addAction;
0031 #if QT_WIDGETS_REMOVED_SINCE(6, 3)
0032     QAction *addAction(const QString &text);
0033     QAction *addAction(const QString &text, const QObject *receiver, const char* member);
0034 #endif
0035 
0036     QAction *addMenu(QMenu *menu);
0037     QMenu *addMenu(const QString &title);
0038     QMenu *addMenu(const QIcon &icon, const QString &title);
0039 
0040 
0041     QAction *addSeparator();
0042     QAction *insertSeparator(QAction *before);
0043 
0044     QAction *insertMenu(QAction *before, QMenu *menu);
0045 
0046     void clear();
0047 
0048     QAction *activeAction() const;
0049     void setActiveAction(QAction *action);
0050 
0051     void setDefaultUp(bool);
0052     bool isDefaultUp() const;
0053 
0054     QSize sizeHint() const override;
0055     QSize minimumSizeHint() const override;
0056     int heightForWidth(int) const override;
0057 
0058     QRect actionGeometry(QAction *) const;
0059     QAction *actionAt(const QPoint &) const;
0060 
0061     void setCornerWidget(QWidget *w, Qt::Corner corner = Qt::TopRightCorner);
0062     QWidget *cornerWidget(Qt::Corner corner = Qt::TopRightCorner) const;
0063 
0064 #if defined(Q_OS_MACOS) || defined(Q_QDOC)
0065     NSMenu* toNSMenu();
0066 #endif
0067 
0068     bool isNativeMenuBar() const;
0069     void setNativeMenuBar(bool nativeMenuBar);
0070     QPlatformMenuBar *platformMenuBar();
0071 public Q_SLOTS:
0072     void setVisible(bool visible) override;
0073 
0074 Q_SIGNALS:
0075     void triggered(QAction *action);
0076     void hovered(QAction *action);
0077 
0078 protected:
0079     void changeEvent(QEvent *) override;
0080     void keyPressEvent(QKeyEvent *) override;
0081     void mouseReleaseEvent(QMouseEvent *) override;
0082     void mousePressEvent(QMouseEvent *) override;
0083     void mouseMoveEvent(QMouseEvent *) override;
0084     void leaveEvent(QEvent *) override;
0085     void paintEvent(QPaintEvent *) override;
0086     void resizeEvent(QResizeEvent *) override;
0087     void actionEvent(QActionEvent *) override;
0088     void focusOutEvent(QFocusEvent *) override;
0089     void focusInEvent(QFocusEvent *) override;
0090     void timerEvent(QTimerEvent *) override;
0091     bool eventFilter(QObject *, QEvent *) override;
0092     bool event(QEvent *) override;
0093     virtual void initStyleOption(QStyleOptionMenuItem *option, const QAction *action) const;
0094 
0095 private:
0096     Q_DECLARE_PRIVATE(QMenuBar)
0097     Q_DISABLE_COPY(QMenuBar)
0098     Q_PRIVATE_SLOT(d_func(), void _q_actionTriggered())
0099     Q_PRIVATE_SLOT(d_func(), void _q_actionHovered())
0100     Q_PRIVATE_SLOT(d_func(), void _q_internalShortcutActivated(int))
0101     Q_PRIVATE_SLOT(d_func(), void _q_updateLayout())
0102 
0103     friend class QMenu;
0104     friend class QMenuPrivate;
0105     friend class QWindowsStyle;
0106 };
0107 
0108 QT_END_NAMESPACE
0109 
0110 #endif // QMENUBAR_H