DtkWidget
DTK Widget module
载入中...
搜索中...
未找到
dinputdialog.h
1// SPDX-FileCopyrightText: 2015 - 2022 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: LGPL-3.0-or-later
4
5#ifndef DINPUTDIALOG_H
6#define DINPUTDIALOG_H
7
8#include <QInputDialog>
9
10#include <DDialog>
11#include <DLineEdit>
12#include <DObject>
13
14DWIDGET_BEGIN_NAMESPACE
15
16class DInputDialogPrivate;
17class DInputDialog : public DDialog
18{
19 Q_OBJECT
20
21 Q_PROPERTY(InputMode inputMode READ inputMode WRITE setInputMode)
22 Q_PROPERTY(QString textValue READ textValue WRITE setTextValue NOTIFY textValueChanged)
23 Q_PROPERTY(int intValue READ intValue WRITE setIntValue NOTIFY intValueChanged)
24 Q_PROPERTY(int doubleValue READ doubleValue WRITE setDoubleValue NOTIFY doubleValueChanged)
25 Q_PROPERTY(QLineEdit::EchoMode textEchoMode READ textEchoMode WRITE setTextEchoMode)
26 Q_PROPERTY(bool comboBoxEditable READ isComboBoxEditable WRITE setComboBoxEditable)
27 Q_PROPERTY(QStringList comboBoxItems READ comboBoxItems WRITE setComboBoxItems)
28 Q_PROPERTY(int comboBoxCurrentIndex READ comboBoxCurrentIndex WRITE setComboBoxCurrentIndex NOTIFY comboBoxCurrentIndexChanged)
29 Q_PROPERTY(int intMinimum READ intMinimum WRITE setIntMinimum)
30 Q_PROPERTY(int intMaximum READ intMaximum WRITE setIntMaximum)
31 Q_PROPERTY(int intStep READ intStep WRITE setIntStep)
32 Q_PROPERTY(double doubleMinimum READ doubleMinimum WRITE setDoubleMinimum)
33 Q_PROPERTY(double doubleMaximum READ doubleMaximum WRITE setDoubleMaximum)
34 Q_PROPERTY(int doubleDecimals READ doubleDecimals WRITE setDoubleDecimals)
35 Q_PROPERTY(QString okButtonText READ okButtonText WRITE setOkButtonText)
36 Q_PROPERTY(QString cancelButtonText READ cancelButtonText WRITE setCancelButtonText)
37 Q_PROPERTY(bool textAlert READ isTextAlert WRITE setTextAlert NOTIFY textAlertChanged)
38
39public:
40 enum InputMode {
41 TextInput,
43 IntInput,
44 DoubleInput
45 };
46
47 explicit DInputDialog(QWidget *parent = 0);
48
49 Q_SLOT void setInputMode(InputMode mode);
50 InputMode inputMode() const;
51
52 Q_SLOT void setTextValue(const QString &text);
53 QString textValue() const;
54
55 Q_SLOT void setTextEchoMode(QLineEdit::EchoMode mode);
56 QLineEdit::EchoMode textEchoMode() const;
57
58 Q_SLOT void setComboBoxEditable(bool editable);
59 bool isComboBoxEditable() const;
60
61 Q_SLOT void setComboBoxItems(const QStringList &items);
62 QStringList comboBoxItems() const;
63
64 Q_SLOT void setComboBoxCurrentIndex(int comboBoxCurrentIndex);
65 int comboBoxCurrentIndex() const;
66
67 Q_SLOT void setIntValue(int value);
68 int intValue() const;
69
70 Q_SLOT void setIntMinimum(int min);
71 int intMinimum() const;
72
73 Q_SLOT void setIntMaximum(int max);
74 int intMaximum() const;
75
76 Q_SLOT void setIntRange(int min, int max);
77
78 Q_SLOT void setIntStep(int step);
79 int intStep() const;
80
81 Q_SLOT void setDoubleValue(double value);
82 double doubleValue() const;
83
84 Q_SLOT void setDoubleMinimum(double min);
85 double doubleMinimum() const;
86
87 Q_SLOT void setDoubleMaximum(double max);
88 double doubleMaximum() const;
89
90 Q_SLOT void setDoubleRange(double min, double max);
91
92 Q_SLOT void setDoubleDecimals(int decimals);
93 int doubleDecimals() const;
94
95 Q_SLOT void setOkButtonText(const QString &text);
96 QString okButtonText() const;
97
98 Q_SLOT void setOkButtonEnabled(const bool enable);
99 bool okButtonIsEnabled() const;
100
101 Q_SLOT void setCancelButtonText(const QString &text);
102 QString cancelButtonText() const;
103
104 Q_SLOT void setTextAlert(bool textAlert);
105 bool isTextAlert() const;
106
107 static QString getText(QWidget *parent, const QString &title, const QString &message,
108 QLineEdit::EchoMode echo = QLineEdit::Normal,
109 const QString &text = QString(), bool *ok = 0, Qt::WindowFlags flags = Qt::WindowFlags{0},
110 Qt::InputMethodHints inputMethodHints = Qt::ImhNone);
111
112 static QString getItem(QWidget *parent, const QString &title, const QString &message,
113 const QStringList &items, int current = 0, bool editable = true,
114 bool *ok = 0, Qt::WindowFlags flags = Qt::WindowFlags{0},
115 Qt::InputMethodHints inputMethodHints = Qt::ImhNone);
116
117 static int getInt(QWidget *parent, const QString &title, const QString &message, int value = 0,
118 int minValue = -2147483647, int maxValue = 2147483647,
119 int step = 1, bool *ok = 0, Qt::WindowFlags flags = Qt::WindowFlags{0});
120 static double getDouble(QWidget *parent, const QString &title, const QString &message, double value = 0,
121 double minValue = -2147483647, double maxValue = 2147483647,
122 int decimals = 1, bool *ok = 0, Qt::WindowFlags flags = Qt::WindowFlags{0});
123
124protected:
125 void showEvent(QShowEvent *e);
126
127Q_SIGNALS:
128 // ### Q_EMIT signals!
129 void textValueChanged(const QString &text);
130 void textValueSelected(const QString &text);
131 void intValueChanged(int value);
132 void intValueSelected(int value);
133 void doubleValueChanged(double value);
134 void doubleValueSelected(double value);
137 void comboBoxCurrentIndexChanged(int comboBoxCurrentIndex);
138 void textAlertChanged(bool textAlert);
139
140private:
141 D_DECLARE_PRIVATE(DInputDialog)
142};
143
144DWIDGET_END_NAMESPACE
145
146#endif // DINPUTDIALOG_H
Definition combobox.h:10
DDialog 旨在提供简要的讯问式对话框的快速实现。提供了包含标题,对话框内容,默认图标,用以添加按钮的布局和一个可以自由添加内容的内容布局。
Definition ddialog.h:22
快速创建一个获取可输入数据的对话框.
Definition dinputdialog.h:18
void textAlertChanged(bool textAlert)
当属性 DInputDialog::textAlert 发生变化时调用此信号
void okButtonClicked()
确认按钮被点击时调用此信号
void textValueChanged(const QString &text)
当属性 DInputDialog::textValue 发生变化时调用此信号
void doubleValueSelected(double value)
确认按钮被点击时调用此信号
void doubleValueChanged(double value)
当属性 DInputDialog::doubleValue 发生变化时调用此信号
void textValueSelected(const QString &text)
确认按钮被点击时调用此信号.
void intValueSelected(int value)
确认按钮被点击时调用此信号
void cancelButtonClicked()
取消按钮被点击时调用此信号
void comboBoxCurrentIndexChanged(int comboBoxCurrentIndex)
当属性 DInputDialog::comboBoxCurrentIndex 发生变化时调用此信号
void intValueChanged(int value)
当属性 DInputDialog::intValue 发生变化时调用此信号