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.inputdialog;
15 extern(C++):
16 
17 import qt.config;
18 import qt.core.flags;
19 import qt.core.namespace;
20 import qt.core.object;
21 import qt.core.size;
22 import qt.core.string;
23 import qt.core.stringlist;
24 import qt.helpers;
25 import qt.widgets.dialog;
26 import qt.widgets.lineedit;
27 import qt.widgets.widget;
28 
29 /+ QT_REQUIRE_CONFIG(inputdialog); +/
30 
31 
32 extern(C++, class) struct QInputDialogPrivate;
33 
34 class /+ Q_WIDGETS_EXPORT +/ QInputDialog : QDialog
35 {
36     mixin(Q_OBJECT);
37     /+ Q_DECLARE_PRIVATE(QInputDialog) +/
38 //  Q_ENUMS(InputMode InputDialogOption)
39     /+ QDOC_PROPERTY(InputMode inputMode READ inputMode WRITE setInputMode)
40     QDOC_PROPERTY(QString labelText READ labelText WRITE setLabelText)
41     QDOC_PROPERTY(InputDialogOptions options READ options WRITE setOptions)
42     QDOC_PROPERTY(QString textValue READ textValue WRITE setTextValue NOTIFY textValueChanged)
43     QDOC_PROPERTY(int intValue READ intValue WRITE setIntValue NOTIFY intValueChanged)
44     QDOC_PROPERTY(int doubleValue READ doubleValue WRITE setDoubleValue NOTIFY doubleValueChanged)
45     QDOC_PROPERTY(QLineEdit::EchoMode textEchoMode READ textEchoMode WRITE setTextEchoMode)
46     QDOC_PROPERTY(bool comboBoxEditable READ isComboBoxEditable WRITE setComboBoxEditable)
47     QDOC_PROPERTY(QStringList comboBoxItems READ comboBoxItems WRITE setComboBoxItems)
48     QDOC_PROPERTY(int intMinimum READ intMinimum WRITE setIntMinimum)
49     QDOC_PROPERTY(int intMaximum READ intMaximum WRITE setIntMaximum)
50     QDOC_PROPERTY(int intStep READ intStep WRITE setIntStep)
51     QDOC_PROPERTY(double doubleMinimum READ doubleMinimum WRITE setDoubleMinimum)
52     QDOC_PROPERTY(double doubleMaximum READ doubleMaximum WRITE setDoubleMaximum)
53     QDOC_PROPERTY(int doubleDecimals READ doubleDecimals WRITE setDoubleDecimals)
54     QDOC_PROPERTY(QString okButtonText READ okButtonText WRITE setOkButtonText)
55     QDOC_PROPERTY(QString cancelButtonText READ cancelButtonText WRITE setCancelButtonText)
56     QDOC_PROPERTY(double doubleStep READ doubleStep WRITE setDoubleStep) +/
57 
58 public:
59     enum InputDialogOption {
60         NoButtons                    = 0x00000001,
61         UseListViewForComboBoxItems  = 0x00000002,
62         UsePlainTextEditForTextInput = 0x00000004
63     }
64 
65     /+ Q_DECLARE_FLAGS(InputDialogOptions, InputDialogOption) +/
66 alias InputDialogOptions = QFlags!(InputDialogOption);
67     enum InputMode {
68         TextInput,
69         IntInput,
70         DoubleInput
71     }
72 
73     this(QWidget parent = null, /+ Qt:: +/qt.core.namespace.WindowFlags flags = /+ Qt:: +/qt.core.namespace.WindowFlags());
74     ~this();
75 
76     final void setInputMode(InputMode mode);
77     final InputMode inputMode() const;
78 
79     final void setLabelText(ref const(QString) text);
80     final QString labelText() const;
81 
82     final void setOption(InputDialogOption option, bool on = true);
83     final bool testOption(InputDialogOption option) const;
84     final void setOptions(InputDialogOptions options);
85     final InputDialogOptions options() const;
86 
87     final void setTextValue(ref const(QString) text);
88     final QString textValue() const;
89 
90     final void setTextEchoMode(QLineEdit.EchoMode mode);
91     final QLineEdit.EchoMode textEchoMode() const;
92 
93     final void setComboBoxEditable(bool editable);
94     final bool isComboBoxEditable() const;
95 
96     final void setComboBoxItems(ref const(QStringList) items);
97     final QStringList comboBoxItems() const;
98 
99     final void setIntValue(int value);
100     final int intValue() const;
101 
102     final void setIntMinimum(int min);
103     final int intMinimum() const;
104 
105     final void setIntMaximum(int max);
106     final int intMaximum() const;
107 
108     final void setIntRange(int min, int max);
109 
110     final void setIntStep(int step);
111     final int intStep() const;
112 
113     final void setDoubleValue(double value);
114     final double doubleValue() const;
115 
116     final void setDoubleMinimum(double min);
117     final double doubleMinimum() const;
118 
119     final void setDoubleMaximum(double max);
120     final double doubleMaximum() const;
121 
122     final void setDoubleRange(double min, double max);
123 
124     final void setDoubleDecimals(int decimals);
125     final int doubleDecimals() const;
126 
127     final void setOkButtonText(ref const(QString) text);
128     final QString okButtonText() const;
129 
130     final void setCancelButtonText(ref const(QString) text);
131     final QString cancelButtonText() const;
132 
133     /+ using QDialog::open; +/
134     final void open(QObject receiver, const(char)* member);
135 
136     override QSize minimumSizeHint() const;
137     override QSize sizeHint() const;
138 
139     override void setVisible(bool visible);
140 
141     static QString getText(QWidget parent, ref const(QString) title, ref const(QString) label,
142                                QLineEdit.EchoMode echo = QLineEdit.EchoMode.Normal,
143                                ref const(QString) text = globalInitVar!QString, bool* ok = null,
144                                /+ Qt:: +/qt.core.namespace.WindowFlags flags = /+ Qt:: +/qt.core.namespace.WindowFlags(),
145                                /+ Qt:: +/qt.core.namespace.InputMethodHints inputMethodHints = /+ Qt:: +/qt.core.namespace.InputMethodHint.ImhNone);
146     static QString getText(QWidget parent, const(QString) title, const(QString) label,
147                                QLineEdit.EchoMode echo = QLineEdit.EchoMode.Normal,
148                                const(QString) text = globalInitVar!QString, bool* ok = null,
149                                /+ Qt:: +/qt.core.namespace.WindowFlags flags = /+ Qt:: +/qt.core.namespace.WindowFlags(),
150                                /+ Qt:: +/qt.core.namespace.InputMethodHints inputMethodHints = /+ Qt:: +/qt.core.namespace.InputMethodHint.ImhNone)
151     {
152         return getText(parent, title, label, echo, text, ok, flags, inputMethodHints);
153     }
154     static QString getMultiLineText(QWidget parent, ref const(QString) title, ref const(QString) label,
155                                         ref const(QString) text = globalInitVar!QString, bool* ok = null,
156                                         /+ Qt:: +/qt.core.namespace.WindowFlags flags = /+ Qt:: +/qt.core.namespace.WindowFlags(),
157                                         /+ Qt:: +/qt.core.namespace.InputMethodHints inputMethodHints = /+ Qt:: +/qt.core.namespace.InputMethodHint.ImhNone);
158     static QString getItem(QWidget parent, ref const(QString) title, ref const(QString) label,
159                                ref const(QStringList) items, int current = 0, bool editable = true,
160                                bool* ok = null, /+ Qt:: +/qt.core.namespace.WindowFlags flags = /+ Qt:: +/qt.core.namespace.WindowFlags(),
161                                /+ Qt:: +/qt.core.namespace.InputMethodHints inputMethodHints = /+ Qt:: +/qt.core.namespace.InputMethodHint.ImhNone);
162 
163     static int getInt(QWidget parent, ref const(QString) title, ref const(QString) label, int value = 0,
164                           int minValue = -2147483647, int maxValue = 2147483647,
165                           int step = 1, bool* ok = null, /+ Qt:: +/qt.core.namespace.WindowFlags flags = /+ Qt:: +/qt.core.namespace.WindowFlags());
166 
167 /+ #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) || defined(Q_QDOC)
168     static double getDouble(QWidget *parent, const QString &title, const QString &label, double value = 0,
169                             double minValue = -2147483647, double maxValue = 2147483647,
170                             int decimals = 1, bool *ok = nullptr, Qt::WindowFlags flags = Qt::WindowFlags(),
171                             double step = 1);
172 #else +/
173     static double getDouble(QWidget parent, ref const(QString) title, ref const(QString) label,
174                                 double value = 0, double minValue = -2147483647,
175                                 double maxValue = 2147483647, int decimals = 1, bool* ok = null,
176                                 /+ Qt:: +/qt.core.namespace.WindowFlags flags = /+ Qt:: +/qt.core.namespace.WindowFlags());
177     static double getDouble(QWidget parent, ref const(QString) title, ref const(QString) label,
178                                 double value, double minValue, double maxValue, int decimals, bool* ok,
179                                 /+ Qt:: +/qt.core.namespace.WindowFlags flags, double step);
180 /+ #endif
181 
182 #if QT_DEPRECATED_SINCE(5, 0)
183     QT_DEPRECATED static inline int getInteger(QWidget *parent, const QString &title, const QString &label, int value = 0,
184                           int minValue = -2147483647, int maxValue = 2147483647,
185                           int step = 1, bool *ok = nullptr, Qt::WindowFlags flags = Qt::WindowFlags())
186     {
187         return getInt(parent, title, label, value, minValue, maxValue, step, ok, flags);
188     }
189 #endif +/
190 
191     final void setDoubleStep(double step);
192     final double doubleStep() const;
193 
194 /+ Q_SIGNALS +/public:
195     // ### emit signals!
196     @QSignal final void textValueChanged(ref const(QString) text);
197     @QSignal final void textValueSelected(ref const(QString) text);
198     @QSignal final void intValueChanged(int value);
199     @QSignal final void intValueSelected(int value);
200     @QSignal final void doubleValueChanged(double value);
201     @QSignal final void doubleValueSelected(double value);
202 
203 public:
204     override void done(int result);
205 
206 private:
207     /+ Q_DISABLE_COPY(QInputDialog) +/
208     /+ Q_PRIVATE_SLOT(d_func(), void _q_textChanged(const QString&))
209     Q_PRIVATE_SLOT(d_func(), void _q_plainTextEditTextChanged())
210     Q_PRIVATE_SLOT(d_func(), void _q_currentRowChanged(const QModelIndex&, const QModelIndex&)) +/
211 }
212 /+pragma(inline, true) QFlags!(QInputDialog.InputDialogOptions.enum_type) operator |(QInputDialog.InputDialogOptions.enum_type f1, QInputDialog.InputDialogOptions.enum_type f2)/+noexcept+/{return QFlags!(QInputDialog.InputDialogOptions.enum_type)(f1)|f2;}+/
213 /+pragma(inline, true) QFlags!(QInputDialog.InputDialogOptions.enum_type) operator |(QInputDialog.InputDialogOptions.enum_type f1, QFlags!(QInputDialog.InputDialogOptions.enum_type) f2)/+noexcept+/{return f2|f1;}+/
214 /+pragma(inline, true) QIncompatibleFlag operator |(QInputDialog.InputDialogOptions.enum_type f1, int f2)/+noexcept+/{return QIncompatibleFlag(int(f1)|f2);}+/
215 
216 /+ Q_DECLARE_OPERATORS_FOR_FLAGS(QInputDialog::InputDialogOptions) +/