Skip to content

File overlaymessage.h#

File List > capture > overlaymessage.h

Go to the documentation of this file.


#pragma once

#include <QLabel>
#include <QStack>

class OverlayMessage : public QLabel
{
public:
    OverlayMessage() = delete;

    static void init(QWidget* parent, const QRect& targetArea);
    static void push(const QString& msg);
    static void pop();
    static void setVisibility(bool visible);
    static OverlayMessage* instance();

    static void pushKeyMap(const QList<QPair<QString, QString>>& map);
    static QString compileFromKeyMap(const QList<QPair<QString, QString>>& map);

private:
    QStack<QString> m_messageStack;
    QRect m_targetArea;
    QColor m_fillColor, m_textColor;
    static OverlayMessage* m_instance;

    OverlayMessage(QWidget* parent, const QRect& center);

    void paintEvent(QPaintEvent*) override;

    QRect boundingRect() const;
    void updateGeometry();
};