summary refs log tree commit diff
path: root/src/timeline/TimelineItem.h
diff options
context:
space:
mode:
authorredsky17 <joedonofry@gmail.com>2019-02-08 01:58:00 +0000
committerredsky17 <joedonofry@gmail.com>2019-02-08 01:58:00 +0000
commit13663ad5f894f035a47efd5704e84f07d68b3df2 (patch)
tree9ae1c461e5b93ab7c110b5880b9f38003349cde3 /src/timeline/TimelineItem.h
parentMerge branch 'ui-enhancements' (diff)
downloadnheko-13663ad5f894f035a47efd5704e84f07d68b3df2.tar.xz
Improve color generation performance
Colors are generated asynchronously now and the TimelineItem is
updated when the color generation finishes.  This allows the UI
to stay responsive while new colors are being generated.
Diffstat (limited to '')
-rw-r--r--src/timeline/TimelineItem.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/timeline/TimelineItem.h b/src/timeline/TimelineItem.h
index f81aa658..7bf6a076 100644
--- a/src/timeline/TimelineItem.h
+++ b/src/timeline/TimelineItem.h
@@ -26,6 +26,8 @@
 #include <QSettings>
 #include <QTimer>
 
+#include <QtConcurrent>
+
 #include "AvatarProvider.h"
 #include "RoomInfoListItem.h"
 #include "Utils.h"
@@ -204,6 +206,8 @@ public:
                      const QString &room_id,
                      QWidget *parent);
 
+        ~TimelineItem();
+
         void setBackgroundColor(const QColor &color) { backgroundColor_ = color; }
         QColor backgroundColor() const { return backgroundColor_; }
 
@@ -229,6 +233,7 @@ signals:
 
 public slots:
         void refreshAuthorColor();
+        void finishedGeneratingColor();
 
 protected:
         void paintEvent(QPaintEvent *event) override;
@@ -264,6 +269,8 @@ private:
         //! has been acknowledged by the server.
         bool isReceived_ = false;
 
+        QFutureWatcher<QString> *colorGenerating_;
+
         QString replaceEmoji(const QString &body);
         QString event_id_;
         QString room_id_;