Debian Codegraph @

kysdk-qtwidgets/src/ksearchlineedit.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 KSEARCHBAR_H
24 #define KSEARCHBAR_H
25
26 #include "gui_g.h"
27 #include "ktoolbutton.h"
28 #include <QLineEdit>
29 #include <QWidget>
30
31 namespace kdk
32 {
33
34 /** @defgroup InputBoxModule
35 * @{
36 */
37
38 class KSearchLineEditPrivate;
39
40 /**
41 * @brief 搜索输入框,可搜索匹配条件的item
42 * @since 1.0.0
43 */
44 class GUI_EXPORT KSearchLineEdit : public QLineEdit
45 {
46 Q_OBJECT
47
48 public:
49 explicit KSearchLineEdit(QWidget *parent = nullptr);
50 ~KSearchLineEdit();
51
52 /**
53 * @brief 设置是否可用
54 */
55 void setEnabled(bool);
56
57 /**
58 * @brief 返回是否可用
59 * @return
60 */
61 bool isEnabled();
62
63 /**
64 * @brief 设置是否显示清除按钮
65 * @return
66 */
67 void setClearButtonEnabled(bool enable);
68
69 /**
70 * @brief 返回是否显示清除按钮
71 * @return
72 */
73 bool isClearButtonEnabled() const;
74
75 /**
76 * @brief 返回placeholder
77 * @return
78 */
79 QString placeholderText() const;
80
81 /**
82 * @brief 设置placeholder
83 * @return
84 */
85 void setPlaceholderText(const QString &);
86
87 /**
88 * @brief 返回placeholder的对齐方式
89 * @return
90 */
91 Qt::Alignment placeholderAlignment() const;
92
93 /**
94 * @brief 设置placeholder的对齐方式
95 * @return
96 */
97 void setPlaceholderAlignment(Qt::Alignment flag);
98
99 /**
100 * @brief 设置输入文本的对齐方式
101 * @return
102 */
103 Qt::Alignment alignment() const;
104
105 /**
106 * @brief 设置输入文本的对齐方式返回
107 * @return
108 */
109 void setAlignment(Qt::Alignment flag);
110
111 /**
112 * @brief 设置是否启用半透明效果
113 * @since 1.2.0
114 * @param flag
115 */
116 void setTranslucent(bool flag);
117
118 /**
119 * @brief 获取是否启用半透明效果
120 * @since 1.2.0
121 * @return flag
122 */
123 bool isTranslucent();
124
125 /**
126 * @brief 重新加载style
127 * @since 2.0.2.1
128 */
129 void reloadStyle();
130
131 /**
132 * @brief 获取自定义按钮
133 * @return
134 * @since 2.4.1.0
135 */
136 KToolButton *customButton();
137
138 /**
139 * @brief 是否启用渐变色
140 * @param flag
141 * @since 2.4.1.0
142 */
143 void setGradation(bool flag);
144
145 /**
146 * @brief 设置智能语义按钮是否可见
147 * @param flag
148 * @since 2.4.1.0
149 */
150 void setCustomButtonVisible(bool flag);
151
152 /**
153 * @brief 返回智能语义按钮是否可见
154 * @return bool
155 * @since 2.4.1.0
156 */
157 bool isCustomButtonVisible();
158
159 public Q_SLOTS:
160 void clear();
161
162 protected:
163 bool eventFilter(QObject *watched, QEvent *event);
164 void resizeEvent(QResizeEvent *event);
165 void setVisible(bool visible);
166 void paintEvent(QPaintEvent *event);
167 QSize sizeHint() const override;
168
169 private:
170 Q_DECLARE_PRIVATE(KSearchLineEdit)
171 KSearchLineEditPrivate *d_ptr;
172 };
173
174 }
175 /**
176 * @example testsearchlinedit/widget.h
177 * @example testsearchlinedit/widget.cpp
178 * @}
179 */
180
181 #endif // KSEARCHBAR_H