| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
#pragma once |
| 5 |
|
| 6 |
#include <QColor> |
| 7 |
#include <QPixmap> |
| 8 |
#include <QWidget> |
| 9 |
|
| 10 |
class QEnterEvent; |
| 11 |
class QEvent; |
| 12 |
class QMouseEvent; |
| 13 |
class QPaintEvent; |
| 14 |
class QPoint; |
| 15 |
class QString; |
| 16 |
|
| 17 |
class BalloonTip : public QWidget |
| 18 |
{ |
| 19 |
Q_OBJECT |
| 20 |
|
| 21 |
struct PrivateTag |
| 22 |
{ |
| 23 |
}; |
| 24 |
|
| 25 |
public: |
| 26 |
enum class ShowArrow |
| 27 |
{ |
| 28 |
Yes, |
| 29 |
No |
| 30 |
}; |
| 31 |
static void ShowBalloon(const QString& title, const QString& message, |
| 32 |
const QPoint& target_arrow_tip_position, QWidget* parent, |
| 33 |
ShowArrow show_arrow = ShowArrow::Yes, int border_width = 1); |
| 34 |
static void HideBalloon(); |
| 35 |
static bool IsCursorInsideWidgetBoundingBox(const QWidget& widget); |
| 36 |
static bool IsCursorOnBalloonTip(); |
| 37 |
static bool IsWidgetBalloonTipActive(const QWidget& widget); |
| 38 |
|
| 39 |
BalloonTip(PrivateTag, const QString& title, QString message, QWidget* parent); |
| 40 |
|
| 41 |
protected: |
| 42 |
void enterEvent(QEnterEvent* event) override; |
| 43 |
void leaveEvent(QEvent* event) override; |
| 44 |
void mouseMoveEvent(QMouseEvent* event) override; |
| 45 |
void paintEvent(QPaintEvent* event) override; |
| 46 |
|
| 47 |
private: |
| 48 |
void UpdateBoundsAndRedraw(const QPoint& target_arrow_tip_position, ShowArrow show_arrow, |
| 49 |
int border_width); |
| 50 |
|
| 51 |
QColor m_border_color; |
| 52 |
QPixmap m_pixmap; |
| 53 |
}; |