Merge branch 'master' into apa-notification-on-live

This commit is contained in:
pajlada
2018-09-16 17:43:53 +02:00
committed by GitHub
53 changed files with 628 additions and 227 deletions
+8
View File
@@ -310,6 +310,14 @@ void Image::load()
return Success;
});
req.onError([that = this, weak = weakOf(this)](auto result) -> bool {
auto shared = weak.lock();
if (!shared) return false;
shared->empty_ = true;
return true;
});
req.execute();
}
+7 -1
View File
@@ -34,7 +34,13 @@ struct Message : boost::noncopyable {
Message();
~Message();
MessageFlags flags;
// Making this a mutable means that we can update a messages flags,
// while still keeping Message constant. This means that a message's flag
// can be updated without the renderer being made aware, which might be bad.
// This is a temporary effort until we can figure out what the right
// const-correct way to deal with this is.
// This might bring race conditions with it
mutable MessageFlags flags;
QTime parseTime;
QString id;
QString searchText;
+15
View File
@@ -61,6 +61,12 @@ MessageElementFlags MessageElement::getFlags() const
return this->flags_;
}
MessageElement *MessageElement::updateLink()
{
this->linkChanged.invoke();
return this;
}
// IMAGE
ImageElement::ImageElement(ImagePtr image, MessageElementFlags flags)
: MessageElement(flags)
@@ -152,6 +158,15 @@ void TextElement::addToContainer(MessageLayoutContainer &container,
color, this->style_, container.getScale()))
->setLink(this->getLink());
e->setTrailingSpace(trailingSpace);
// If URL link was changed,
// Should update it in MessageLayoutElement too!
if (this->getLink().type == Link::Url) {
this->linkChanged.connect(
[this, e]() {
e->setLink(this->getLink());
});
}
return e;
};
+3
View File
@@ -12,6 +12,7 @@
#include <cstdint>
#include <memory>
#include <vector>
#include <pajlada/signals/signalholder.hpp>
namespace chatterino {
class Channel;
@@ -128,6 +129,7 @@ public:
const Link &getLink() const;
bool hasTrailingSpace() const;
MessageElementFlags getFlags() const;
MessageElement *updateLink();
virtual void addToContainer(MessageLayoutContainer &container,
MessageElementFlags flags) = 0;
@@ -135,6 +137,7 @@ public:
protected:
MessageElement(MessageElementFlags flags);
bool trailingSpace = true;
pajlada::Signals::NoArgSignal linkChanged;
private:
Link link_;