Debian Codegraph @

kysdk-qtwidgets/src/kborderlessbutton.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 KBORDERLESSBUTTON_H
24 #define KBORDERLESSBUTTON_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 KBorderlessButtonPrivate;
40
41 /**
42 * @brief 无边框按钮
43 * @since 1.0.0
44 */
45 class GUI_EXPORT KBorderlessButton : public QPushButton
46 {
47 Q_OBJECT
48
49 public:
50 KBorderlessButton(QWidget *parent = nullptr);
51 KBorderlessButton(const QString &text, QWidget *parent = nullptr);
52 KBorderlessButton(const QIcon &icon, const QString &text, QWidget *parent = nullptr);
53 KBorderlessButton(const QIcon &icon, QWidget *parent = nullptr);
54 ~KBorderlessButton();
55
56 /**
57 * @brief 设置按钮图标
58 * @param icon
59 */
60 void setIcon(const QIcon &icon);
61
62 protected:
63 bool eventFilter(QObject *watched, QEvent *event);
64 void paintEvent(QPaintEvent *event);
65 QSize sizeHint() const;
66
67 private:
68 KBorderlessButtonPrivate *const d_ptr;
69 Q_DECLARE_PRIVATE(KBorderlessButton)
70 Q_PRIVATE_SLOT(d_ptr, void changeTheme())
71 };
72 }
73 /**
74 * @example testPushbutton/widget.h
75 * @example testPushbutton/widget.cpp
76 * @}
77 */
78 #endif