| 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 KBubbleWidget_H |
| 24 |
#define KBubbleWidget_H |
| 25 |
|
| 26 |
#include <QBoxLayout> |
| 27 |
#include <QWidget> |
| 28 |
|
| 29 |
namespace kdk |
| 30 |
{ |
| 31 |
/** |
| 32 |
* @brief 指定气泡尾部显示的方向 |
| 33 |
*/ |
| 34 |
enum TailDirection { |
| 35 |
TopDirection, |
| 36 |
LeftDirection, |
| 37 |
BottomDirection, |
| 38 |
RightDirection, |
| 39 |
None |
| 40 |
}; |
| 41 |
|
| 42 |
/** |
| 43 |
* @brief 指定气泡尾部的显示位置 |
| 44 |
*/ |
| 45 |
enum TailLocation { |
| 46 |
LeftLocation, |
| 47 |
MiddleLocation, |
| 48 |
RightLocation |
| 49 |
}; |
| 50 |
|
| 51 |
/** |
| 52 |
* @defgroup FrameModule |
| 53 |
*/ |
| 54 |
|
| 55 |
class KBubbleWidgetPrivate; |
| 56 |
|
| 57 |
/** |
| 58 |
* @brief 提供了一个带三角形窗体。 |
| 59 |
* @since 2.0.2.1 |
| 60 |
*/ |
| 61 |
class KBubbleWidget : public QWidget |
| 62 |
{ |
| 63 |
Q_OBJECT |
| 64 |
|
| 65 |
public: |
| 66 |
KBubbleWidget(QWidget *parent = nullptr); |
| 67 |
|
| 68 |
/** |
| 69 |
* @brief 设置气泡尾部尺寸 |
| 70 |
* @param size |
| 71 |
*/ |
| 72 |
void setTailSize(const QSize &size); |
| 73 |
|
| 74 |
/** |
| 75 |
* @brief 获取气泡尾部尺寸 |
| 76 |
* @return |
| 77 |
*/ |
| 78 |
QSize tailSize(); |
| 79 |
|
| 80 |
/** |
| 81 |
* @brief 设置气泡尾部显示位置 |
| 82 |
* @param dirType |
| 83 |
* @param locType |
| 84 |
*/ |
| 85 |
void setTailPosition(TailDirection dirType, TailLocation locType = MiddleLocation); |
| 86 |
|
| 87 |
/** |
| 88 |
* @brief 获取气泡尾部显示方向 |
| 89 |
* @return 左、上、右、下 |
| 90 |
*/ |
| 91 |
TailDirection tailDirection(); |
| 92 |
|
| 93 |
/** |
| 94 |
* @brief 获取气泡尾部显示位置 |
| 95 |
* @return 居左、居中、居右 |
| 96 |
*/ |
| 97 |
TailLocation tailLocation(); |
| 98 |
|
| 99 |
/** |
| 100 |
* @brief 设置窗体圆角半径 |
| 101 |
* @param bottomLeft |
| 102 |
* @param topLeft |
| 103 |
* @param topRight |
| 104 |
* @param bottomRight |
| 105 |
*/ |
| 106 |
void setBorderRadius(int bottomLeft, int topLeft, int topRight, int bottomRight); |
| 107 |
|
| 108 |
/** |
| 109 |
* @brief 设置窗体圆角半径 |
| 110 |
* @param radius |
| 111 |
*/ |
| 112 |
void setBorderRadius(int radius); |
| 113 |
|
| 114 |
/** |
| 115 |
* @brief 设置是否启用毛玻璃效果 |
| 116 |
* @param flag |
| 117 |
*/ |
| 118 |
void setEnableBlur(bool flag); |
| 119 |
|
| 120 |
/** |
| 121 |
* @brief 获取是否已启用毛玻璃效果 |
| 122 |
* @return |
| 123 |
*/ |
| 124 |
bool enableBlur(); |
| 125 |
|
| 126 |
/** |
| 127 |
* @brief 设置透明度 |
| 128 |
* @param opacity |
| 129 |
*/ |
| 130 |
void setOpacity(qreal opacity); |
| 131 |
|
| 132 |
/** |
| 133 |
* @brief 获取透明度 |
| 134 |
* @return |
| 135 |
*/ |
| 136 |
qreal opacity(); |
| 137 |
|
| 138 |
/** |
| 139 |
* @brief 设置是否启用高亮背景色 |
| 140 |
* @param flag |
| 141 |
* @since 2.4.1.0 |
| 142 |
*/ |
| 143 |
void setHighlightBackground(bool flag); |
| 144 |
|
| 145 |
protected: |
| 146 |
void paintEvent(QPaintEvent *); |
| 147 |
|
| 148 |
private: |
| 149 |
Q_DECLARE_PRIVATE(KBubbleWidget) |
| 150 |
KBubbleWidgetPrivate *const d_ptr; |
| 151 |
}; |
| 152 |
|
| 153 |
} |
| 154 |
|
| 155 |
#endif // KBubbleWidget_H |