#ifndef VALIDATION_BUBBLE_H
#define VALIDATION_BUBBLE_H

#include <QWidget>
#include <QPointer>

class QLabel;
class QTimer;

// ValidationBubble: persistent bubble style error tip anchored to a target widget.
// Call showMessage(target, text) to display; hide() to dismiss. Automatically hides when target is destroyed.
class ValidationBubble : public QWidget {
    Q_OBJECT
public:
    explicit ValidationBubble(QWidget *parent = nullptr);
    void showMessage(QWidget *target, const QString &text);
    void clear();
protected:
    bool eventFilter(QObject *obj, QEvent *event) override;
private:
    QPointer<QWidget> m_target;
    QLabel *m_label{nullptr};
    void reposition();
};

#endif // VALIDATION_BUBBLE_H
