diff options
| author | 2023-03-07 21:11:06 +0600 | |
|---|---|---|
| committer | 2023-03-07 21:11:06 +0600 | |
| commit | d830bfc8ce7c6763d074beafdde7cab1835d31f9 (patch) | |
| tree | 179f81f3b42779b1f6fb69deed6b69dab39f4f89 /src/widgets/scrolltext/scrolltext.h | |
| download | whatsie-d830bfc8ce7c6763d074beafdde7cab1835d31f9.tar.gz whatsie-d830bfc8ce7c6763d074beafdde7cab1835d31f9.zip | |
Import Upstream version 4.12.0upstream/4.12.0
Diffstat (limited to 'src/widgets/scrolltext/scrolltext.h')
| -rw-r--r-- | src/widgets/scrolltext/scrolltext.h | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/widgets/scrolltext/scrolltext.h b/src/widgets/scrolltext/scrolltext.h new file mode 100644 index 0000000..a660615 --- /dev/null +++ b/src/widgets/scrolltext/scrolltext.h @@ -0,0 +1,53 @@ +#ifndef SCROLLTEXT_H +#define SCROLLTEXT_H + +#include <QWidget> +#include <QStaticText> +#include <QTimer> + + +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 = 0); + +public slots: + QString text() const; + void setText(QString text); + + QString separator() const; + void setSeparator(QString separator); + void setLeftMargin(int pixels); + void pause(); + void resume(); + + +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; + bool scrolledOnce = false; + +private slots: + virtual void timer_timeout(); + void pauseAfterOneRotation(int scrollPos); +}; + +#endif // SCROLLTEXT_H |
