Debian Codegraph @

kysdk-qtwidgets/src/kborderbutton.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 KBORDERBUTTON_H
24 #define KBORDERBUTTON_H
25
26 #include "gui_g.h"
27 #include <QEvent>
28 #include <QIcon>
29 #include <QPushButton>
30 #include <QWidget>
31
32 namespace kdk
33 {
34
35 /** @defgroup PushbuttonModule
36 * @{
37 */
38
39 class KBorderButtonPrivate;
40
41 /**
42 * @brief 带边框的按钮
43 * @since 1.0.0
44 */
45 class GUI_EXPORT KBorderButton : public QPushButton
46 {
47 Q_OBJECT
48 public:
49 KBorderButton(QWidget *parent = nullptr);
50 KBorderButton(const QString &text, QWidget *parent = nullptr);
51 KBorderButton(const QIcon &icon, const QString &text, QWidget *parent = nullptr);
52 KBorderButton(const QIcon &icon, QWidget *parent = nullptr);
53
54 /**
55 * @brief 设置按钮图标
56 * @param icon
57 */
58 void setIcon(const QIcon &icon);
59 ~KBorderButton();
60
61 protected:
62 bool eventFilter(QObject *watched, QEvent *event);
63 void paintEvent(QPaintEvent *event);
64 QSize sizeHint() const override;
65
66 private:
67 Q_DECLARE_PRIVATE(KBorderButton)
68 KBorderButtonPrivate *const d_ptr;
69 };
70 }
71 /**
72 * @example testPushbutton/widget.h
73 * @example testPushbutton/widget.cpp
74 * @}
75 */
76 #endif