aboutsummaryrefslogtreecommitdiff
path: root/src/widgets/scrolltext/scrolltext.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets/scrolltext/scrolltext.h')
-rw-r--r--src/widgets/scrolltext/scrolltext.h53
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