Back to home page

EIC code displayed by LXR

 
 

    


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

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 QTOOLBUTTON_H
0005 #define QTOOLBUTTON_H
0006 
0007 #include <QtWidgets/qtwidgetsglobal.h>
0008 
0009 #include <QtWidgets/qabstractbutton.h>
0010 
0011 QT_REQUIRE_CONFIG(toolbutton);
0012 
0013 QT_BEGIN_NAMESPACE
0014 
0015 class QToolButtonPrivate;
0016 class QMenu;
0017 class QStyleOptionToolButton;
0018 
0019 class Q_WIDGETS_EXPORT QToolButton : public QAbstractButton
0020 {
0021     Q_OBJECT
0022     Q_ENUMS(Qt::ToolButtonStyle Qt::ArrowType)
0023 #if QT_CONFIG(menu)
0024     Q_PROPERTY(ToolButtonPopupMode popupMode READ popupMode WRITE setPopupMode)
0025 #endif
0026     Q_PROPERTY(Qt::ToolButtonStyle toolButtonStyle READ toolButtonStyle WRITE setToolButtonStyle)
0027     Q_PROPERTY(bool autoRaise READ autoRaise WRITE setAutoRaise)
0028     Q_PROPERTY(Qt::ArrowType arrowType READ arrowType WRITE setArrowType)
0029 
0030 public:
0031     enum ToolButtonPopupMode {
0032         DelayedPopup,
0033         MenuButtonPopup,
0034         InstantPopup
0035     };
0036     Q_ENUM(ToolButtonPopupMode)
0037 
0038     explicit QToolButton(QWidget *parent = nullptr);
0039     ~QToolButton();
0040 
0041     QSize sizeHint() const override;
0042     QSize minimumSizeHint() const override;
0043 
0044     Qt::ToolButtonStyle toolButtonStyle() const;
0045 
0046     Qt::ArrowType arrowType() const;
0047     void setArrowType(Qt::ArrowType type);
0048 
0049 #if QT_CONFIG(menu)
0050     void setMenu(QMenu* menu);
0051     QMenu* menu() const;
0052 
0053     void setPopupMode(ToolButtonPopupMode mode);
0054     ToolButtonPopupMode popupMode() const;
0055 #endif
0056 
0057     QAction *defaultAction() const;
0058 
0059     void setAutoRaise(bool enable);
0060     bool autoRaise() const;
0061 
0062 public Q_SLOTS:
0063 #if QT_CONFIG(menu)
0064     void showMenu();
0065 #endif
0066     void setToolButtonStyle(Qt::ToolButtonStyle style);
0067     void setDefaultAction(QAction *);
0068 
0069 Q_SIGNALS:
0070     void triggered(QAction *);
0071 
0072 protected:
0073     bool event(QEvent *e) override;
0074     void mousePressEvent(QMouseEvent *) override;
0075     void mouseReleaseEvent(QMouseEvent *) override;
0076     void paintEvent(QPaintEvent *) override;
0077     void actionEvent(QActionEvent *) override;
0078 
0079     void enterEvent(QEnterEvent *) override;
0080     void leaveEvent(QEvent *) override;
0081     void timerEvent(QTimerEvent *) override;
0082     void changeEvent(QEvent *) override;
0083 
0084     bool hitButton(const QPoint &pos) const override;
0085     void checkStateSet() override;
0086     void nextCheckState() override;
0087     virtual void initStyleOption(QStyleOptionToolButton *option) const;
0088 
0089 private:
0090     Q_DISABLE_COPY(QToolButton)
0091     Q_DECLARE_PRIVATE(QToolButton)
0092 };
0093 
0094 QT_END_NAMESPACE
0095 
0096 #endif // QTOOLBUTTON_H