diff --git a/src/emotemanager.cpp b/src/emotemanager.cpp
index 1c11948cc..c6db0ca2e 100644
--- a/src/emotemanager.cpp
+++ b/src/emotemanager.cpp
@@ -78,7 +78,8 @@ void EmoteManager::reloadBTTVChannelEmotes(const QString &channelName, std::weak
link = link.replace("{{id}}", id).replace("{{image}}", "1x");
auto emote = this->getBTTVChannelEmoteFromCaches().getOrAdd(id, [this, &code, &link] {
- return EmoteData(new LazyLoadedImage(link, 1, code, code + "\nChannel BTTV Emote"));
+ return EmoteData(
+ new LazyLoadedImage(link, 1, code, code + "
Channel BTTV Emote"));
});
this->bttvChannelEmotes.insert(code, emote);
@@ -127,7 +128,7 @@ void EmoteManager::reloadFFZChannelEmotes(const QString &channelName, std::weak_
auto emote =
this->getFFZChannelEmoteFromCaches().getOrAdd(id, [this, &code, &url1] {
return EmoteData(
- new LazyLoadedImage(url1, 1, code, code + "\nGlobal FFZ Emote"));
+ new LazyLoadedImage(url1, 1, code, code + "
Global FFZ Emote"));
});
this->ffzChannelEmotes.insert(code, emote);
@@ -222,7 +223,7 @@ void EmoteManager::loadEmojis()
code + ".png";
this->emojis.insert(code, EmoteData(new LazyLoadedImage(url, 0.35, ":" + shortCode + ":",
- ":" + shortCode + ":")));
+ ":" + shortCode + ":
Emoji")));
// TODO(pajlada): The vectors in emojiFirstByte need to be sorted by
// emojiData.code.length()
@@ -430,7 +431,7 @@ void EmoteManager::loadBTTVEmotes()
QString url = tmp.replace("{{id}}", id).replace("{{image}}", "1x");
this->bttvGlobalEmotes.insert(
- code, new LazyLoadedImage(url, 1, code, code + "\nGlobal BTTV Emote"));
+ code, new LazyLoadedImage(url, 1, code, code + "
Global BTTV Emote"));
codes.push_back(code.toStdString());
}
@@ -475,7 +476,7 @@ void EmoteManager::loadFFZEmotes()
QString url1 = "http:" + urls.value("1").toString();
this->ffzGlobalEmotes.insert(
- code, new LazyLoadedImage(url1, 1, code, code + "\nGlobal FFZ Emote"));
+ code, new LazyLoadedImage(url1, 1, code, code + "
Global FFZ Emote"));
codes.push_back(code.toStdString());
}
@@ -495,7 +496,7 @@ EmoteData EmoteManager::getTwitchEmoteById(long id, const QString &emoteName)
return _twitchEmoteFromCache.getOrAdd(id, [this, &emoteName, &id] {
qreal scale;
QString url = getTwitchEmoteLink(id, scale);
- return new LazyLoadedImage(url, scale, emoteName, emoteName + "\nTwitch Emote");
+ return new LazyLoadedImage(url, scale, emoteName, emoteName + "
Twitch Emote");
});
}
diff --git a/src/messages/message.cpp b/src/messages/message.cpp
index 1a47eb28a..353d32733 100644
--- a/src/messages/message.cpp
+++ b/src/messages/message.cpp
@@ -101,7 +101,7 @@ Message *Message::createSystemMessage(const QString &text)
AddCurrentTimestamp(message);
- Word word(text, Word::Type::Default, MessageColor(MessageColor::Type::System), text, text);
+ Word word(text, Word::Type::Default, MessageColor(MessageColor::Type::System), text, QString());
message->getWords().push_back(word);
@@ -142,7 +142,7 @@ Message *Message::createTimeoutMessage(const QString &username, const QString &d
}
text.append(".");
- Word word(text, Word::Type::Default, MessageColor(MessageColor::Type::System), text, text);
+ Word word(text, Word::Type::Default, MessageColor(MessageColor::Type::System), text, QString());
message->getWords().push_back(word);
diff --git a/src/messages/word.hpp b/src/messages/word.hpp
index caf6878e8..cfab92c0b 100644
--- a/src/messages/word.hpp
+++ b/src/messages/word.hpp
@@ -93,9 +93,9 @@ public:
}
explicit Word(LazyLoadedImage *_image, Type getType, const QString ©text,
- const QString &getTooltip, const Link &getLink = Link());
+ const QString &tooltip, const Link &getLink = Link());
explicit Word(const QString &_text, Type getType, const MessageColor &getColor,
- const QString ©text, const QString &getTooltip, const Link &getLink = Link());
+ const QString ©text, const QString &tooltip, const Link &getLink = Link());
LazyLoadedImage &getImage() const;
const QString &getText() const;
diff --git a/src/twitch/twitchmessagebuilder.cpp b/src/twitch/twitchmessagebuilder.cpp
index 41295b890..85bc01658 100644
--- a/src/twitch/twitchmessagebuilder.cpp
+++ b/src/twitch/twitchmessagebuilder.cpp
@@ -225,12 +225,10 @@ SharedMessage TwitchMessageBuilder::parse()
this->appendWord(Word(string, Word::Text, textColor, string, QString(), link));
} else { // is emoji
- static QString emojiTooltip("Emoji");
-
this->appendWord(Word(emoteData.image, Word::EmojiImage, emoteData.image->getName(),
- emojiTooltip));
+ emoteData.image->getTooltip()));
Word(emoteData.image->getName(), Word::EmojiText, textColor,
- emoteData.image->getName(), emojiTooltip);
+ emoteData.image->getName(), emoteData.image->getTooltip());
}
}
diff --git a/src/widgets/helper/channelview.cpp b/src/widgets/helper/channelview.cpp
index 245066d62..b4b366734 100644
--- a/src/widgets/helper/channelview.cpp
+++ b/src/widgets/helper/channelview.cpp
@@ -16,6 +16,7 @@
#include
#include
#include
+#include
#include
#include
@@ -748,13 +749,40 @@ void ChannelView::mouseMoveEvent(QMouseEvent *event)
this->repaint();
}
+ static QTimer *tooltipTimer = new QTimer();
+
// check if word underneath cursor
const messages::Word *hoverWord;
if ((hoverWord = message->tryGetWordPart(relativePos)) == nullptr) {
this->setCursor(Qt::ArrowCursor);
+ tooltipTimer->stop();
+ QToolTip::hideText();
return;
}
+ const auto &tooltip = hoverWord->getTooltip();
+
+ static QString targetTooltip;
+ static QPoint tooltipPos;
+ connect(tooltipTimer, &QTimer::timeout, []() {
+ assert(!targetTooltip.isEmpty());
+ QToolTip::showText(tooltipPos, targetTooltip); //
+ });
+
+ tooltipTimer->setSingleShot(true);
+ tooltipTimer->setInterval(500);
+
+ if (!tooltip.isEmpty()) {
+ tooltipPos = event->globalPos();
+ targetTooltip = ""
+ "" +
+ tooltip + "
";
+ tooltipTimer->start();
+ } else {
+ tooltipTimer->stop();
+ QToolTip::hideText();
+ }
+
// check if word has a link
if (hoverWord->getLink().isValid()) {
this->setCursor(Qt::PointingHandCursor);