summary refs log tree commit diff
path: root/src/ui/TextLabel.h
diff options
context:
space:
mode:
authorKonstantinos Sideris <sideris.konstantin@gmail.com>2018-09-26 15:17:14 +0300
committerKonstantinos Sideris <sideris.konstantin@gmail.com>2018-09-26 15:17:14 +0300
commitc64a1bf7592cac57032080c36e4514d4de2a8a95 (patch)
tree529d3f77c1d1639776b2cf47a3e06d33a04d0b64 /src/ui/TextLabel.h
parentLint (diff)
downloadnheko-c64a1bf7592cac57032080c36e4514d4de2a8a95.tar.xz
Move TextLabel into its own file
Diffstat (limited to 'src/ui/TextLabel.h')
-rw-r--r--src/ui/TextLabel.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/ui/TextLabel.h b/src/ui/TextLabel.h
new file mode 100644
index 00000000..da6e9c4b
--- /dev/null
+++ b/src/ui/TextLabel.h
@@ -0,0 +1,38 @@
+#pragma once
+
+#include <QSize>
+#include <QString>
+#include <QTextBrowser>
+#include <QUrl>
+
+class QMouseEvent;
+class QFocusEvent;
+class QWheelEvent;
+
+class TextLabel : public QTextBrowser
+{
+        Q_OBJECT
+
+public:
+        TextLabel(const QString &text, QWidget *parent = nullptr);
+        TextLabel(QWidget *parent = nullptr);
+
+        void wheelEvent(QWheelEvent *event) override;
+        void clearLinks() { link_.clear(); }
+
+protected:
+        void mousePressEvent(QMouseEvent *e) override;
+        void mouseReleaseEvent(QMouseEvent *e) override;
+        void focusOutEvent(QFocusEvent *e) override;
+
+private slots:
+        void adjustHeight(const QSizeF &size) { setFixedHeight(size.height()); }
+        void handleLinkActivation(const QUrl &link);
+
+signals:
+        void userProfileTriggered(const QString &user_id);
+        void linkActivated(const QUrl &link);
+
+private:
+        QString link_;
+};