mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
re-enable link resolver, but fix the underlying issue in the "link changed" signal.
The feature itself still doesn't work for me, but this code does the same thing. only thing that's really different is it also disconnects the signal properly once the TextLayoutElement is deleted
This commit is contained in:
parent
afee4d9d37
commit
0f44a2e0f4
5 changed files with 18 additions and 5 deletions
|
@ -183,8 +183,7 @@ void TextElement::addToContainer(MessageLayoutContainer &container,
|
|||
// Should update it in MessageLayoutElement too!
|
||||
if (this->getLink().type == Link::Url)
|
||||
{
|
||||
this->linkChanged.connect(
|
||||
[this, e]() { e->setLink(this->getLink()); });
|
||||
static_cast<TextLayoutElement *>(e)->listenToLinkChanges();
|
||||
}
|
||||
return e;
|
||||
};
|
||||
|
|
|
@ -135,10 +135,11 @@ public:
|
|||
virtual void addToContainer(MessageLayoutContainer &container,
|
||||
MessageElementFlags flags) = 0;
|
||||
|
||||
pajlada::Signals::NoArgSignal linkChanged;
|
||||
|
||||
protected:
|
||||
MessageElement(MessageElementFlags flags);
|
||||
bool trailingSpace = true;
|
||||
pajlada::Signals::NoArgSignal linkChanged;
|
||||
|
||||
private:
|
||||
QString text_;
|
||||
|
|
|
@ -181,6 +181,17 @@ TextLayoutElement::TextLayoutElement(MessageElement &_creator, QString &_text,
|
|||
this->setText(_text);
|
||||
}
|
||||
|
||||
void TextLayoutElement::listenToLinkChanges()
|
||||
{
|
||||
this->managedConnections_.emplace_back(
|
||||
static_cast<TextElement &>(this->getCreator())
|
||||
.linkChanged.connect([this]() {
|
||||
// log("Old link: {}", this->getCreator().getLink().value);
|
||||
// log("This link: {}", this->getLink().value);
|
||||
this->setLink(this->getCreator().getLink()); //
|
||||
}));
|
||||
}
|
||||
|
||||
void TextLayoutElement::addCopyTextToString(QString &str, int from,
|
||||
int to) const
|
||||
{
|
||||
|
|
|
@ -83,6 +83,8 @@ public:
|
|||
const QSize &size, QColor color, FontStyle style,
|
||||
float scale);
|
||||
|
||||
void listenToLinkChanges();
|
||||
|
||||
protected:
|
||||
void addCopyTextToString(QString &str, int from = 0,
|
||||
int to = INT_MAX) const override;
|
||||
|
@ -96,6 +98,8 @@ private:
|
|||
QColor color;
|
||||
FontStyle style;
|
||||
float scale;
|
||||
|
||||
std::vector<pajlada::Signals::ScopedConnection> managedConnections_;
|
||||
};
|
||||
|
||||
// TEXT ICON
|
||||
|
|
|
@ -12,8 +12,6 @@ namespace chatterino {
|
|||
void LinkResolver::getLinkInfo(
|
||||
const QString url, std::function<void(QString, Link)> successCallback)
|
||||
{
|
||||
return;
|
||||
|
||||
QString requestUrl("https://braize.pajlada.com/chatterino/link_resolver/" +
|
||||
QUrl::toPercentEncoding(url, "", "/:"));
|
||||
|
||||
|
|
Loading…
Reference in a new issue