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!
|
// Should update it in MessageLayoutElement too!
|
||||||
if (this->getLink().type == Link::Url)
|
if (this->getLink().type == Link::Url)
|
||||||
{
|
{
|
||||||
this->linkChanged.connect(
|
static_cast<TextLayoutElement *>(e)->listenToLinkChanges();
|
||||||
[this, e]() { e->setLink(this->getLink()); });
|
|
||||||
}
|
}
|
||||||
return e;
|
return e;
|
||||||
};
|
};
|
||||||
|
|
|
@ -135,10 +135,11 @@ public:
|
||||||
virtual void addToContainer(MessageLayoutContainer &container,
|
virtual void addToContainer(MessageLayoutContainer &container,
|
||||||
MessageElementFlags flags) = 0;
|
MessageElementFlags flags) = 0;
|
||||||
|
|
||||||
|
pajlada::Signals::NoArgSignal linkChanged;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
MessageElement(MessageElementFlags flags);
|
MessageElement(MessageElementFlags flags);
|
||||||
bool trailingSpace = true;
|
bool trailingSpace = true;
|
||||||
pajlada::Signals::NoArgSignal linkChanged;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString text_;
|
QString text_;
|
||||||
|
|
|
@ -181,6 +181,17 @@ TextLayoutElement::TextLayoutElement(MessageElement &_creator, QString &_text,
|
||||||
this->setText(_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,
|
void TextLayoutElement::addCopyTextToString(QString &str, int from,
|
||||||
int to) const
|
int to) const
|
||||||
{
|
{
|
||||||
|
|
|
@ -83,6 +83,8 @@ public:
|
||||||
const QSize &size, QColor color, FontStyle style,
|
const QSize &size, QColor color, FontStyle style,
|
||||||
float scale);
|
float scale);
|
||||||
|
|
||||||
|
void listenToLinkChanges();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void addCopyTextToString(QString &str, int from = 0,
|
void addCopyTextToString(QString &str, int from = 0,
|
||||||
int to = INT_MAX) const override;
|
int to = INT_MAX) const override;
|
||||||
|
@ -96,6 +98,8 @@ private:
|
||||||
QColor color;
|
QColor color;
|
||||||
FontStyle style;
|
FontStyle style;
|
||||||
float scale;
|
float scale;
|
||||||
|
|
||||||
|
std::vector<pajlada::Signals::ScopedConnection> managedConnections_;
|
||||||
};
|
};
|
||||||
|
|
||||||
// TEXT ICON
|
// TEXT ICON
|
||||||
|
|
|
@ -12,8 +12,6 @@ namespace chatterino {
|
||||||
void LinkResolver::getLinkInfo(
|
void LinkResolver::getLinkInfo(
|
||||||
const QString url, std::function<void(QString, Link)> successCallback)
|
const QString url, std::function<void(QString, Link)> successCallback)
|
||||||
{
|
{
|
||||||
return;
|
|
||||||
|
|
||||||
QString requestUrl("https://braize.pajlada.com/chatterino/link_resolver/" +
|
QString requestUrl("https://braize.pajlada.com/chatterino/link_resolver/" +
|
||||||
QUrl::toPercentEncoding(url, "", "/:"));
|
QUrl::toPercentEncoding(url, "", "/:"));
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue