| 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 KPRESSBUTTON_H |
| 24 |
#define KPRESSBUTTON_H |
| 25 |
#include "gui_g.h" |
| 26 |
#include <QPushButton> |
| 27 |
#include <QWidget> |
| 28 |
namespace kdk |
| 29 |
{ |
| 30 |
|
| 31 |
/** |
| 32 |
* @defgroup PushbuttonModule |
| 33 |
*/ |
| 34 |
class KPressButtonPrivate; |
| 35 |
|
| 36 |
/** |
| 37 |
* @brief 按压按钮,可根据情况设置loading状态 |
| 38 |
* @since 1.2.0 |
| 39 |
*/ |
| 40 |
class GUI_EXPORT KPressButton : public QPushButton |
| 41 |
{ |
| 42 |
Q_OBJECT |
| 43 |
public: |
| 44 |
enum ButtonType { |
| 45 |
NormalType, |
| 46 |
CircleType |
| 47 |
}; |
| 48 |
|
| 49 |
KPressButton(QWidget *parent = 0); |
| 50 |
|
| 51 |
/** |
| 52 |
* @brief 设置圆角 |
| 53 |
* @param radius |
| 54 |
*/ |
| 55 |
void setBorderRadius(int radius); |
| 56 |
|
| 57 |
/** |
| 58 |
* @brief 设置圆角 |
| 59 |
* @param buttomLeft |
| 60 |
* @param topLeft |
| 61 |
* @param topRight |
| 62 |
* @param bottomRight |
| 63 |
*/ |
| 64 |
void setBorderRadius(int bottomLeft, int topLeft, int topRight, int bottomRight); |
| 65 |
|
| 66 |
/** |
| 67 |
* @brief 设置是否可选中 |
| 68 |
* @param flag |
| 69 |
*/ |
| 70 |
void setCheckable(bool); |
| 71 |
|
| 72 |
/** |
| 73 |
* @brief 返回是否可选中 |
| 74 |
* @return |
| 75 |
*/ |
| 76 |
bool isCheckable() const; |
| 77 |
|
| 78 |
/** |
| 79 |
* @brief 设置是否选中 |
| 80 |
* @return |
| 81 |
*/ |
| 82 |
void setChecked(bool); |
| 83 |
|
| 84 |
/** |
| 85 |
* @brief 返回是否选中 |
| 86 |
* @return |
| 87 |
*/ |
| 88 |
bool isChecked() const; |
| 89 |
|
| 90 |
/** |
| 91 |
* @brief 设置button类型 |
| 92 |
* @param type |
| 93 |
*/ |
| 94 |
void setButtonType(ButtonType type); |
| 95 |
|
| 96 |
/** |
| 97 |
* @brief 返回button类型 |
| 98 |
* @return |
| 99 |
*/ |
| 100 |
KPressButton::ButtonType buttonType(); |
| 101 |
|
| 102 |
/** |
| 103 |
* @brief 设置是否启用loading状态 |
| 104 |
* @param flag |
| 105 |
*/ |
| 106 |
void setLoaingStatus(bool flag); |
| 107 |
|
| 108 |
/** |
| 109 |
* @brief 返回是否启用loading状态 |
| 110 |
* @return |
| 111 |
*/ |
| 112 |
bool isLoading(); |
| 113 |
|
| 114 |
/** |
| 115 |
* @brief 设置是否启用透明度 |
| 116 |
* @param flag |
| 117 |
*/ |
| 118 |
void setTranslucent(bool flag); |
| 119 |
|
| 120 |
/** |
| 121 |
* @brief 返回是否启用透明度 |
| 122 |
* @return |
| 123 |
*/ |
| 124 |
bool isTranslucent(); |
| 125 |
|
| 126 |
protected: |
| 127 |
void paintEvent(QPaintEvent *event) override; |
| 128 |
|
| 129 |
private: |
| 130 |
Q_DECLARE_PRIVATE(KPressButton) |
| 131 |
KPressButtonPrivate *const d_ptr; |
| 132 |
}; |
| 133 |
|
| 134 |
} |
| 135 |
#endif // KPRESSBUTTON_H |