diff options
Diffstat (limited to 'src/scrolltext.h')
| -rw-r--r-- | src/scrolltext.h | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/scrolltext.h b/src/scrolltext.h new file mode 100644 index 00000000..b7dd59f8 --- /dev/null +++ b/src/scrolltext.h @@ -0,0 +1,46 @@ +#pragma once + +#include <QDebug> +#include <QPainter> +#include <QStaticText> +#include <QTimer> +#include <QWidget> + +class ScrollText : public QWidget +{ + Q_OBJECT + + Q_PROPERTY(QString text READ text WRITE setText) + Q_PROPERTY(QString separator READ separator WRITE setSeparator) + +public: + explicit ScrollText(QWidget *parent = nullptr); + +public Q_SLOTS: + QString text() const; + void setText(QString text); + + QString separator() const; + void setSeparator(QString separator); + +protected: + virtual void paintEvent(QPaintEvent *); + virtual void resizeEvent(QResizeEvent *); + +private: + void updateText(); + QString _text; + QString _separator; + QStaticText staticText; + int singleTextWidth; + QSize wholeTextSize; + int leftMargin; + bool scrollEnabled; + int scrollPos; + QImage alphaChannel; + QImage buffer; + QTimer timer; + +private Q_SLOTS: + virtual void timer_timeout(); +}; |
