1 /****************************************************************************
2 **
3 ** DQt - D bindings for the Qt Toolkit
4 **
5 ** GNU Lesser General Public License Usage
6 ** This file may be used under the terms of the GNU Lesser
7 ** General Public License version 3 as published by the Free Software
8 ** Foundation and appearing in the file LICENSE.LGPL3 included in the
9 ** packaging of this file. Please review the following information to
10 ** ensure the GNU Lesser General Public License version 3 requirements
11 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
12 **
13 ****************************************************************************/
14 module qt.widgets.dialogbuttonbox;
15 extern(C++):
16 
17 import qt.config;
18 import qt.core.coreevent;
19 import qt.core.flags;
20 import qt.core.list;
21 import qt.core.namespace;
22 import qt.core.string;
23 import qt.helpers;
24 import qt.widgets.abstractbutton;
25 import qt.widgets.pushbutton;
26 import qt.widgets.widget;
27 
28 /+ QT_REQUIRE_CONFIG(dialogbuttonbox);
29 
30 
31 
32 class QAbstractButton;
33 class QPushButton; +/
34 extern(C++, class) struct QDialogButtonBoxPrivate;
35 
36 class /+ Q_WIDGETS_EXPORT +/ QDialogButtonBox : QWidget
37 {
38     mixin(Q_OBJECT);
39     /+ Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation)
40     Q_PROPERTY(StandardButtons standardButtons READ standardButtons WRITE setStandardButtons)
41     Q_PROPERTY(bool centerButtons READ centerButtons WRITE setCenterButtons) +/
42 
43 public:
44     enum ButtonRole {
45         // keep this in sync with QMessageBox::ButtonRole and QPlatformDialogHelper::ButtonRole
46         InvalidRole = -1,
47         AcceptRole,
48         RejectRole,
49         DestructiveRole,
50         ActionRole,
51         HelpRole,
52         YesRole,
53         NoRole,
54         ResetRole,
55         ApplyRole,
56 
57         NRoles
58     }
59 
60     enum StandardButton {
61         // keep this in sync with QMessageBox::StandardButton and QPlatformDialogHelper::StandardButton
62         NoButton           = 0x00000000,
63         Ok                 = 0x00000400,
64         Save               = 0x00000800,
65         SaveAll            = 0x00001000,
66         Open               = 0x00002000,
67         Yes                = 0x00004000,
68         YesToAll           = 0x00008000,
69         No                 = 0x00010000,
70         NoToAll            = 0x00020000,
71         Abort              = 0x00040000,
72         Retry              = 0x00080000,
73         Ignore             = 0x00100000,
74         Close              = 0x00200000,
75         Cancel             = 0x00400000,
76         Discard            = 0x00800000,
77         Help               = 0x01000000,
78         Apply              = 0x02000000,
79         Reset              = 0x04000000,
80         RestoreDefaults    = 0x08000000,
81 
82 /+ #ifndef Q_MOC_RUN +/
83         FirstButton        = StandardButton.Ok,
84         LastButton         = StandardButton.RestoreDefaults
85 /+ #endif +/
86     }
87 
88     /+ Q_DECLARE_FLAGS(StandardButtons, StandardButton) +/
89 alias StandardButtons = QFlags!(StandardButton);    /+ Q_FLAG(StandardButtons) +/
90 
91     enum ButtonLayout {
92         // keep this in sync with QPlatformDialogHelper::ButtonLayout
93         WinLayout,
94         MacLayout,
95         KdeLayout,
96         GnomeLayout,
97         // MacModelessLayout,
98         AndroidLayout = ButtonLayout.GnomeLayout + 2 // ### Qt 6: reorder
99     }
100 
101     this(QWidget parent = null);
102     this(/+ Qt:: +/qt.core.namespace.Orientation orientation, QWidget parent = null);
103     /+ explicit +/this(StandardButtons buttons, QWidget parent = null);
104     this(StandardButtons buttons, /+ Qt:: +/qt.core.namespace.Orientation orientation,
105                          QWidget parent = null);
106     ~this();
107 
108     final void setOrientation(/+ Qt:: +/qt.core.namespace.Orientation orientation);
109     final /+ Qt:: +/qt.core.namespace.Orientation orientation() const;
110 
111     final void addButton(QAbstractButton button, ButtonRole role);
112     final QPushButton addButton(ref const(QString) text, ButtonRole role);
113     final QPushButton addButton(StandardButton button);
114     final void removeButton(QAbstractButton button);
115     final void clear();
116 
117     final QList!(QAbstractButton) buttons() const;
118     final ButtonRole buttonRole(QAbstractButton button) const;
119 
120     final void setStandardButtons(StandardButtons buttons);
121     final StandardButtons standardButtons() const;
122     final StandardButton standardButton(QAbstractButton button) const;
123     final QPushButton button(StandardButton which) const;
124 
125     final void setCenterButtons(bool center);
126     final bool centerButtons() const;
127 
128 /+ Q_SIGNALS +/public:
129     @QSignal final void clicked(QAbstractButton button);
130     @QSignal final void accepted();
131     @QSignal final void helpRequested();
132     @QSignal final void rejected();
133 
134 protected:
135     override void changeEvent(QEvent event);
136     override bool event(QEvent event);
137 
138 private:
139     /+ Q_DISABLE_COPY(QDialogButtonBox) +/
140     /+ Q_DECLARE_PRIVATE(QDialogButtonBox) +/
141     /+ Q_PRIVATE_SLOT(d_func(), void _q_handleButtonClicked())
142     Q_PRIVATE_SLOT(d_func(), void _q_handleButtonDestroyed()) +/
143 }
144 /+pragma(inline, true) QFlags!(QDialogButtonBox.StandardButtons.enum_type) operator |(QDialogButtonBox.StandardButtons.enum_type f1, QDialogButtonBox.StandardButtons.enum_type f2)/+noexcept+/{return QFlags!(QDialogButtonBox.StandardButtons.enum_type)(f1)|f2;}+/
145 /+pragma(inline, true) QFlags!(QDialogButtonBox.StandardButtons.enum_type) operator |(QDialogButtonBox.StandardButtons.enum_type f1, QFlags!(QDialogButtonBox.StandardButtons.enum_type) f2)/+noexcept+/{return f2|f1;}+/
146 /+pragma(inline, true) QIncompatibleFlag operator |(QDialogButtonBox.StandardButtons.enum_type f1, int f2)/+noexcept+/{return QIncompatibleFlag(int(f1)|f2);}+/
147 
148 /+ Q_DECLARE_OPERATORS_FOR_FLAGS(QDialogButtonBox::StandardButtons) +/