1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the QtWidgets module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPL3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or (at your option) the GNU General
28** Public license version 3 or any later version approved by the KDE Free
29** Qt Foundation. The licenses are as published by the Free Software
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31** included in the packaging of this file. Please review the following
32** information to ensure the GNU General Public License requirements will
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34** https://www.gnu.org/licenses/gpl-3.0.html.
35**
36** $QT_END_LICENSE$
37**
38****************************************************************************/
39
40#ifndef QINPUTDIALOG_H
41#define QINPUTDIALOG_H
42
43#include <QtWidgets/qtwidgetsglobal.h>
44#include <QtCore/qstring.h>
45#include <QtWidgets/qlineedit.h>
46
47#include <QtWidgets/qdialog.h>
48
49QT_REQUIRE_CONFIG(inputdialog);
50
51QT_BEGIN_NAMESPACE
52
53class QInputDialogPrivate;
54
55class Q_WIDGETS_EXPORT QInputDialog : public QDialog
56{
57 Q_OBJECT
58 Q_DECLARE_PRIVATE(QInputDialog)
59// Q_ENUMS(InputMode InputDialogOption)
60 QDOC_PROPERTY(InputMode inputMode READ inputMode WRITE setInputMode)
61 QDOC_PROPERTY(QString labelText READ labelText WRITE setLabelText)
62 QDOC_PROPERTY(InputDialogOptions options READ options WRITE setOptions)
63 QDOC_PROPERTY(QString textValue READ textValue WRITE setTextValue NOTIFY textValueChanged)
64 QDOC_PROPERTY(int intValue READ intValue WRITE setIntValue NOTIFY intValueChanged)
65 QDOC_PROPERTY(int doubleValue READ doubleValue WRITE setDoubleValue NOTIFY doubleValueChanged)
66 QDOC_PROPERTY(QLineEdit::EchoMode textEchoMode READ textEchoMode WRITE setTextEchoMode)
67 QDOC_PROPERTY(bool comboBoxEditable READ isComboBoxEditable WRITE setComboBoxEditable)
68 QDOC_PROPERTY(QStringList comboBoxItems READ comboBoxItems WRITE setComboBoxItems)
69 QDOC_PROPERTY(int intMinimum READ intMinimum WRITE setIntMinimum)
70 QDOC_PROPERTY(int intMaximum READ intMaximum WRITE setIntMaximum)
71 QDOC_PROPERTY(int intStep READ intStep WRITE setIntStep)
72 QDOC_PROPERTY(double doubleMinimum READ doubleMinimum WRITE setDoubleMinimum)
73 QDOC_PROPERTY(double doubleMaximum READ doubleMaximum WRITE setDoubleMaximum)
74 QDOC_PROPERTY(int doubleDecimals READ doubleDecimals WRITE setDoubleDecimals)
75 QDOC_PROPERTY(QString okButtonText READ okButtonText WRITE setOkButtonText)
76 QDOC_PROPERTY(QString cancelButtonText READ cancelButtonText WRITE setCancelButtonText)
77 QDOC_PROPERTY(double doubleStep READ doubleStep WRITE setDoubleStep)
78
79public:
80 enum InputDialogOption {
81 NoButtons = 0x00000001,
82 UseListViewForComboBoxItems = 0x00000002,
83 UsePlainTextEditForTextInput = 0x00000004
84 };
85
86 Q_DECLARE_FLAGS(InputDialogOptions, InputDialogOption)
87
88 enum InputMode {
89 TextInput,
90 IntInput,
91 DoubleInput
92 };
93
94 QInputDialog(QWidget *parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags());
95 ~QInputDialog();
96
97 void setInputMode(InputMode mode);
98 InputMode inputMode() const;
99
100 void setLabelText(const QString &text);
101 QString labelText() const;
102
103 void setOption(InputDialogOption option, bool on = true);
104 bool testOption(InputDialogOption option) const;
105 void setOptions(InputDialogOptions options);
106 InputDialogOptions options() const;
107
108 void setTextValue(const QString &text);
109 QString textValue() const;
110
111 void setTextEchoMode(QLineEdit::EchoMode mode);
112 QLineEdit::EchoMode textEchoMode() const;
113
114 void setComboBoxEditable(bool editable);
115 bool isComboBoxEditable() const;
116
117 void setComboBoxItems(const QStringList &items);
118 QStringList comboBoxItems() const;
119
120 void setIntValue(int value);
121 int intValue() const;
122
123 void setIntMinimum(int min);
124 int intMinimum() const;
125
126 void setIntMaximum(int max);
127 int intMaximum() const;
128
129 void setIntRange(int min, int max);
130
131 void setIntStep(int step);
132 int intStep() const;
133
134 void setDoubleValue(double value);
135 double doubleValue() const;
136
137 void setDoubleMinimum(double min);
138 double doubleMinimum() const;
139
140 void setDoubleMaximum(double max);
141 double doubleMaximum() const;
142
143 void setDoubleRange(double min, double max);
144
145 void setDoubleDecimals(int decimals);
146 int doubleDecimals() const;
147
148 void setOkButtonText(const QString &text);
149 QString okButtonText() const;
150
151 void setCancelButtonText(const QString &text);
152 QString cancelButtonText() const;
153
154 using QDialog::open;
155 void open(QObject *receiver, const char *member);
156
157 QSize minimumSizeHint() const override;
158 QSize sizeHint() const override;
159
160 void setVisible(bool visible) override;
161
162 static QString getText(QWidget *parent, const QString &title, const QString &label,
163 QLineEdit::EchoMode echo = QLineEdit::Normal,
164 const QString &text = QString(), bool *ok = nullptr,
165 Qt::WindowFlags flags = Qt::WindowFlags(),
166 Qt::InputMethodHints inputMethodHints = Qt::ImhNone);
167 static QString getMultiLineText(QWidget *parent, const QString &title, const QString &label,
168 const QString &text = QString(), bool *ok = nullptr,
169 Qt::WindowFlags flags = Qt::WindowFlags(),
170 Qt::InputMethodHints inputMethodHints = Qt::ImhNone);
171 static QString getItem(QWidget *parent, const QString &title, const QString &label,
172 const QStringList &items, int current = 0, bool editable = true,
173 bool *ok = nullptr, Qt::WindowFlags flags = Qt::WindowFlags(),
174 Qt::InputMethodHints inputMethodHints = Qt::ImhNone);
175
176 static int getInt(QWidget *parent, const QString &title, const QString &label, int value = 0,
177 int minValue = -2147483647, int maxValue = 2147483647,
178 int step = 1, bool *ok = nullptr, Qt::WindowFlags flags = Qt::WindowFlags());
179
180#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) || defined(Q_QDOC)
181 static double getDouble(QWidget *parent, const QString &title, const QString &label, double value = 0,
182 double minValue = -2147483647, double maxValue = 2147483647,
183 int decimals = 1, bool *ok = nullptr, Qt::WindowFlags flags = Qt::WindowFlags(),
184 double step = 1);
185#else
186 static double getDouble(QWidget *parent, const QString &title, const QString &label,
187 double value = 0, double minValue = -2147483647,
188 double maxValue = 2147483647, int decimals = 1, bool *ok = nullptr,
189 Qt::WindowFlags flags = Qt::WindowFlags());
190 static double getDouble(QWidget *parent, const QString &title, const QString &label,
191 double value, double minValue, double maxValue, int decimals, bool *ok,
192 Qt::WindowFlags flags, double step);
193#endif
194
195#if QT_DEPRECATED_SINCE(5, 0)
196 QT_DEPRECATED static inline int getInteger(QWidget *parent, const QString &title, const QString &label, int value = 0,
197 int minValue = -2147483647, int maxValue = 2147483647,
198 int step = 1, bool *ok = nullptr, Qt::WindowFlags flags = Qt::WindowFlags())
199 {
200 return getInt(parent, title, label, value, minValue, maxValue, step, ok, flags);
201 }
202#endif
203
204 void setDoubleStep(double step);
205 double doubleStep() const;
206
207Q_SIGNALS:
208 // ### emit signals!
209 void textValueChanged(const QString &text);
210 void textValueSelected(const QString &text);
211 void intValueChanged(int value);
212 void intValueSelected(int value);
213 void doubleValueChanged(double value);
214 void doubleValueSelected(double value);
215
216public:
217 void done(int result) override;
218
219private:
220 Q_DISABLE_COPY(QInputDialog)
221 Q_PRIVATE_SLOT(d_func(), void _q_textChanged(const QString&))
222 Q_PRIVATE_SLOT(d_func(), void _q_plainTextEditTextChanged())
223 Q_PRIVATE_SLOT(d_func(), void _q_currentRowChanged(const QModelIndex&, const QModelIndex&))
224};
225
226Q_DECLARE_OPERATORS_FOR_FLAGS(QInputDialog::InputDialogOptions)
227
228QT_END_NAMESPACE
229
230#endif // QINPUTDIALOG_H
231

source code of qtbase/src/widgets/dialogs/qinputdialog.h