Debian Codegraph @

kysdk-qtwidgets/src/kaddfilebutton.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: Zhenyu Wang <[email protected]>
20 *
21 */
22
23 #ifndef KADDFILEBUTTON_H
24 #define KADDFILEBUTTON_H
25
26 #include "gui_g.h"
27 #include <QFileDialog>
28 #include <QPushButton>
29
30 namespace kdk
31 {
32
33 /** @defgroup PushbuttonModule
34 */
35
36 class KAddFileButtonPrivate;
37
38 /**
39 * @brief 选择文件的按钮
40 * @since 2.4.1.0
41 */
42 class GUI_EXPORT KAddFileButton : public QPushButton
43 {
44 Q_OBJECT
45 public:
46 KAddFileButton(QWidget *parent = nullptr);
47
48 /**
49 * @brief 设置文本
50 * @param str
51 */
52 void setText(QString str);
53
54 /**
55 * @brief 获取filedialog
56 * @return QFileDialog
57 */
58 QFileDialog *fileDialog();
59
60 /**
61 * @brief 将文件对话框中使用的过滤器设置为给定的过滤器。
62 * @param filter
63 */
64 void setNameFilter(const QString &filter);
65
66 /**
67 * @brief 设置文件对话框中使用的过滤器。
68 * @param filters
69 */
70 void setNameFilters(const QStringList &filters);
71
72 protected:
73 void paintEvent(QPaintEvent *event);
74 bool eventFilter(QObject *watched, QEvent *event);
75 void mouseMoveEvent(QMouseEvent *event);
76 void mousePressEvent(QMouseEvent *event);
77 void mouseReleaseEvent(QMouseEvent *event);
78
79 private:
80 KAddFileButtonPrivate *const d_ptr;
81 Q_DECLARE_PRIVATE(KAddFileButton)
82 };
83
84 }
85
86 #endif // KADDFILEBUTTON_H