Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-11 09:24:09

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 // Qt-Security score:significant reason:default
0004 
0005 #ifndef QDIALOGBUTTONBOX_H
0006 #define QDIALOGBUTTONBOX_H
0007 
0008 #include <QtWidgets/qtwidgetsglobal.h>
0009 #include <QtWidgets/qwidget.h>
0010 
0011 QT_REQUIRE_CONFIG(dialogbuttonbox);
0012 
0013 QT_BEGIN_NAMESPACE
0014 
0015 
0016 class QAbstractButton;
0017 class QPushButton;
0018 class QDialogButtonBoxPrivate;
0019 
0020 class Q_WIDGETS_EXPORT QDialogButtonBox : public QWidget
0021 {
0022     Q_OBJECT
0023     Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation)
0024     Q_PROPERTY(StandardButtons standardButtons READ standardButtons WRITE setStandardButtons)
0025     Q_PROPERTY(bool centerButtons READ centerButtons WRITE setCenterButtons)
0026 
0027 public:
0028     enum ButtonRole {
0029         // keep this in sync with QMessageBox::ButtonRole and QPlatformDialogHelper::ButtonRole
0030         InvalidRole = -1,
0031         AcceptRole,
0032         RejectRole,
0033         DestructiveRole,
0034         ActionRole,
0035         HelpRole,
0036         YesRole,
0037         NoRole,
0038         ResetRole,
0039         ApplyRole,
0040 
0041         NRoles
0042     };
0043 
0044     enum StandardButton {
0045         // keep this in sync with QMessageBox::StandardButton and QPlatformDialogHelper::StandardButton
0046         NoButton           = 0x00000000,
0047         Ok                 = 0x00000400,
0048         Save               = 0x00000800,
0049         SaveAll            = 0x00001000,
0050         Open               = 0x00002000,
0051         Yes                = 0x00004000,
0052         YesToAll           = 0x00008000,
0053         No                 = 0x00010000,
0054         NoToAll            = 0x00020000,
0055         Abort              = 0x00040000,
0056         Retry              = 0x00080000,
0057         Ignore             = 0x00100000,
0058         Close              = 0x00200000,
0059         Cancel             = 0x00400000,
0060         Discard            = 0x00800000,
0061         Help               = 0x01000000,
0062         Apply              = 0x02000000,
0063         Reset              = 0x04000000,
0064         RestoreDefaults    = 0x08000000,
0065 
0066 #ifndef Q_MOC_RUN
0067         FirstButton        = Ok,
0068         LastButton         = RestoreDefaults
0069 #endif
0070     };
0071 
0072     Q_DECLARE_FLAGS(StandardButtons, StandardButton)
0073     Q_FLAG(StandardButtons)
0074 
0075     enum ButtonLayout {
0076         // keep this in sync with QPlatformDialogHelper::ButtonLayout
0077         WinLayout,
0078         MacLayout,
0079         KdeLayout,
0080         GnomeLayout,
0081         AndroidLayout
0082     };
0083 
0084     QDialogButtonBox(QWidget *parent = nullptr);
0085     QDialogButtonBox(Qt::Orientation orientation, QWidget *parent = nullptr);
0086     explicit QDialogButtonBox(StandardButtons buttons, QWidget *parent = nullptr);
0087     QDialogButtonBox(StandardButtons buttons, Qt::Orientation orientation,
0088                      QWidget *parent = nullptr);
0089     ~QDialogButtonBox();
0090 
0091     void setOrientation(Qt::Orientation orientation);
0092     Qt::Orientation orientation() const;
0093 
0094     void addButton(QAbstractButton *button, ButtonRole role);
0095     QPushButton *addButton(const QString &text, ButtonRole role);
0096     QPushButton *addButton(StandardButton button);
0097     void removeButton(QAbstractButton *button);
0098     void clear();
0099 
0100     QList<QAbstractButton *> buttons() const;
0101     ButtonRole buttonRole(QAbstractButton *button) const;
0102 
0103     void setStandardButtons(StandardButtons buttons);
0104     StandardButtons standardButtons() const;
0105     StandardButton standardButton(QAbstractButton *button) const;
0106     QPushButton *button(StandardButton which) const;
0107 
0108     void setCenterButtons(bool center);
0109     bool centerButtons() const;
0110 
0111 Q_SIGNALS:
0112     void clicked(QAbstractButton *button);
0113     void accepted();
0114     void helpRequested();
0115     void rejected();
0116 
0117 protected:
0118     void changeEvent(QEvent *event) override;
0119     bool event(QEvent *event) override;
0120 
0121 private:
0122     Q_DISABLE_COPY(QDialogButtonBox)
0123     Q_DECLARE_PRIVATE(QDialogButtonBox)
0124 };
0125 
0126 Q_DECLARE_OPERATORS_FOR_FLAGS(QDialogButtonBox::StandardButtons)
0127 
0128 QT_END_NAMESPACE
0129 
0130 #endif // QDIALOGBUTTONBOX_H