Debian Codegraph @

kysdk-qtwidgets/src/kpasswordedit.h

raw
1 /*
2 * libkysdk-qtwidgets's Library
3 *
4 * Copyright (C) 2023, KylinSoft Co., Ltd.
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 3 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this library. If not, see <https://www.gnu.org/licenses/>.
18 *
19 * Authors: Zhen Sun <[email protected]>
20 *
21 */
22
23 #ifndef KPASSWORDEDIT_H
24 #define KPASSWORDEDIT_H
25
26 #include "gui_g.h"
27 #include <QLineEdit>
28
29 namespace kdk
30 {
31
32 /** @defgroup InputBoxModule
33 * @{
34 */
35
36 /**
37 * @brief 支持三种状态
38 * @since 1.0.0
39 */
40 enum LoginState {
41 Ordinary,
42 LoginSuccess,
43 LoginFailed
44 };
45 class KPasswordEditPrivate;
46
47 /**
48 * @brief 密码输入框,继承于QLineEdit,支持三种不同状态显示
49 */
50 class GUI_EXPORT KPasswordEdit : public QLineEdit
51 {
52 Q_OBJECT
53
54 public:
55 KPasswordEdit(QWidget *parent);
56
57 /**
58 * @brief 设置状态
59 * @param state
60 */
61 void setState(LoginState state);
62
63 /**
64 * @brief 返回状态
65 * @return
66 */
67 LoginState state();
68
69 /**
70 * @brief 设置加载状态
71 * @param flag
72 */
73 void setLoading(bool flag);
74
75 /**
76 * @brief 判断是否处于加载状态
77 * @return
78 */
79 bool isLoading();
80
81 /**
82 * @brief 返回placeholderText
83 * @return
84 */
85 QString placeholderText();
86
87 /**
88 * @brief 设置PlaceholderText
89 * @param text
90 */
91 void setPlaceholderText(QString &text);
92
93 /**
94 * @brief 设置是否启用ClearButton
95 * @param enable
96 */
97 void setClearButtonEnabled(bool enable);
98
99 /**
100 * @brief 返回是否启用了ClearButton
101 * @return
102 */
103 bool isClearButtonEnabled() const;
104
105 /**
106 * @brief 设置EchoModeBtn是否可见
107 * @return
108 * @since 1.2.0
109 */
110 void setEchoModeBtnVisible(bool enable);
111
112 /**
113 * @brief 返回EchoModeBtn是否可见
114 * @return
115 * @since 1.2.0
116 */
117 bool echoModeBtnVisible();
118
119 /**
120 * @brief 设置ClearBtn是否可见
121 * @return
122 * @since 1.2.0
123 */
124 void setClearBtnVisible(bool enable);
125
126 /**
127 * @brief 返回ClearBtn是否可见
128 * @return
129 * @since 1.2.0
130 */
131 bool clearBtnVisible();
132
133 /**
134 * @brief 设置KLineEdit是否可用
135 * @return
136 */
137 void setEnabled(bool);
138
139 /**
140 * @brief setEchoMode
141 * @since 1.2.0
142 */
143 void setEchoMode(EchoMode mode);
144
145 /**
146 * @brief 设置是否走默认palette
147 * @param flag
148 * @since 1.2.0
149 */
150 void setUseCustomPalette(bool flag);
151
152 protected:
153 void resizeEvent(QResizeEvent *event);
154 bool eventFilter(QObject *watched, QEvent *event);
155 QSize sizeHint() const override;
156
157 private:
158 Q_DECLARE_PRIVATE(KPasswordEdit)
159 KPasswordEditPrivate *const d_ptr;
160 };
161 }
162 /**
163 * @example testpasswordedit/widget.h
164 * @example testpasswordedit/widget.cpp
165 * @}
166 */
167
168 #endif // KPASSWORDEDIT_H