Fix emote & badge tooltips not showing up when thumbnails were hidden (#4509)

Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
This commit is contained in:
kornes
2023-04-08 13:43:38 +00:00
committed by GitHub
parent 073192b4e5
commit 5c55f62600
4 changed files with 106 additions and 74 deletions
+1
View File
@@ -17,6 +17,7 @@
- Bugfix: Fixed blocked user list sticking around when switching from a logged in user to being logged out. (#4437) - Bugfix: Fixed blocked user list sticking around when switching from a logged in user to being logged out. (#4437)
- Bugfix: Fixed search popup ignoring setting for message scrollback limit. (#4496) - Bugfix: Fixed search popup ignoring setting for message scrollback limit. (#4496)
- Bugfix: Fixed a memory leak that occurred when loading message history. This was mostly noticeable with unstable internet connections where reconnections were frequent or long-running instances of Chatterino. (#4499) - Bugfix: Fixed a memory leak that occurred when loading message history. This was mostly noticeable with unstable internet connections where reconnections were frequent or long-running instances of Chatterino. (#4499)
- Bugfix: Fixed emote & badge tooltips not showing up when thumbnails were hidden. (#4509)
- Dev: Disabling precompiled headers on Windows is now tested in CI. (#4472) - Dev: Disabling precompiled headers on Windows is now tested in CI. (#4472)
- Dev: Themes are now stored as JSON files in `resources/themes`. (#4471) - Dev: Themes are now stored as JSON files in `resources/themes`. (#4471)
- Dev: Ignore unhandled BTTV user-events. (#4438) - Dev: Ignore unhandled BTTV user-events. (#4438)
+12 -2
View File
@@ -74,6 +74,14 @@ enum HelixTimegateOverride : int {
AlwaysUseHelix = 3, AlwaysUseHelix = 3,
}; };
enum ThumbnailPreviewMode : int {
DontShow = 0,
AlwaysShow = 1,
ShowOnShift = 2,
};
/// Settings which are availlable for reading and writing on the gui thread. /// Settings which are availlable for reading and writing on the gui thread.
// These settings are still accessed concurrently in the code but it is bad practice. // These settings are still accessed concurrently in the code but it is bad practice.
class Settings : public ABSettings, public ConcurrentSettings class Settings : public ABSettings, public ConcurrentSettings
@@ -217,7 +225,6 @@ public:
FloatSetting emoteScale = {"/emotes/scale", 1.f}; FloatSetting emoteScale = {"/emotes/scale", 1.f};
BoolSetting showUnlistedSevenTVEmotes = { BoolSetting showUnlistedSevenTVEmotes = {
"/emotes/showUnlistedSevenTVEmotes", false}; "/emotes/showUnlistedSevenTVEmotes", false};
QStringSetting emojiSet = {"/emotes/emojiSet", "Twitter"}; QStringSetting emojiSet = {"/emotes/emojiSet", "Twitter"};
BoolSetting stackBits = {"/emotes/stackBits", false}; BoolSetting stackBits = {"/emotes/stackBits", false};
@@ -478,9 +485,12 @@ public:
HelixTimegateOverride::Timegate, HelixTimegateOverride::Timegate,
}; };
IntSetting emotesTooltipPreview = {"/misc/emotesTooltipPreview", 1};
BoolSetting openLinksIncognito = {"/misc/openLinksIncognito", 0}; BoolSetting openLinksIncognito = {"/misc/openLinksIncognito", 0};
EnumSetting<ThumbnailPreviewMode> emotesTooltipPreview = {
"/misc/emotesTooltipPreview",
ThumbnailPreviewMode::AlwaysShow,
};
QStringSetting cachePath = {"/cache/path", ""}; QStringSetting cachePath = {"/cache/path", ""};
BoolSetting restartOnCrash = {"/misc/restartOnCrash", false}; BoolSetting restartOnCrash = {"/misc/restartOnCrash", false};
BoolSetting attachExtensionToAnyProcess = { BoolSetting attachExtensionToAnyProcess = {
+21 -14
View File
@@ -1672,16 +1672,22 @@ void ChannelView::mouseMoveEvent(QMouseEvent *event)
{ {
auto badgeElement = dynamic_cast<const BadgeElement *>(element); auto badgeElement = dynamic_cast<const BadgeElement *>(element);
if ((badgeElement || emoteElement || layeredEmoteElement) && if (badgeElement || emoteElement || layeredEmoteElement)
getSettings()->emotesTooltipPreview.getValue())
{
if (event->modifiers() == Qt::ShiftModifier ||
getSettings()->emotesTooltipPreview.getValue() == 1)
{ {
auto showThumbnailSetting =
getSettings()->emotesTooltipPreview.getValue();
bool showThumbnail =
showThumbnailSetting == ThumbnailPreviewMode::AlwaysShow ||
(showThumbnailSetting == ThumbnailPreviewMode::ShowOnShift &&
event->modifiers() == Qt::ShiftModifier);
if (emoteElement) if (emoteElement)
{ {
tooltipWidget->setOne({ tooltipWidget->setOne({
emoteElement->getEmote()->images.getImage(3.0), showThumbnail
? emoteElement->getEmote()->images.getImage(3.0)
: nullptr,
element->getTooltip(), element->getTooltip(),
}); });
} }
@@ -1714,13 +1720,17 @@ void ChannelView::mouseMoveEvent(QMouseEvent *event)
if (i == 0) if (i == 0)
{ {
// First entry gets a large image and full description // First entry gets a large image and full description
entries.push_back({emote->images.getImage(3.0), entries.push_back({showThumbnail
? emote->images.getImage(3.0)
: nullptr,
emoteTooltips[i]}); emoteTooltips[i]});
} }
else else
{ {
// Every other entry gets a small image and just the emote name // Every other entry gets a small image and just the emote name
entries.push_back({emote->images.getImage(1.0), entries.push_back({showThumbnail
? emote->images.getImage(1.0)
: nullptr,
emote->name.string}); emote->name.string});
} }
} }
@@ -1739,17 +1749,14 @@ void ChannelView::mouseMoveEvent(QMouseEvent *event)
else if (badgeElement) else if (badgeElement)
{ {
tooltipWidget->setOne({ tooltipWidget->setOne({
badgeElement->getEmote()->images.getImage(3.0), showThumbnail
? badgeElement->getEmote()->images.getImage(3.0)
: nullptr,
element->getTooltip(), element->getTooltip(),
}); });
} }
} }
else else
{
tooltipWidget->clearEntries();
}
}
else
{ {
if (element->getTooltip() == "No link info loaded") if (element->getTooltip() == "No link info loaded")
{ {
+19 -5
View File
@@ -416,16 +416,30 @@ void GeneralPage::initLayout(GeneralPageView &layout)
}); });
}, },
false); false);
layout.addDropdown<int>( layout.addDropdown<std::underlying_type<ThumbnailPreviewMode>::type>(
"Show info on hover", {"Don't show", "Always show", "Hold shift"}, "Show emote & badge thumbnail on hover",
{
"Don't show",
"Always show",
"Hold shift",
},
s.emotesTooltipPreview, s.emotesTooltipPreview,
[](int index) { [](auto val) {
return index; switch (val)
{
case ThumbnailPreviewMode::DontShow:
return "Don't show";
case ThumbnailPreviewMode::AlwaysShow:
return "Always show";
case ThumbnailPreviewMode::ShowOnShift:
return "Hold shift";
}
return "";
}, },
[](auto args) { [](auto args) {
return args.index; return args.index;
}, },
false, "Show emote name, provider, and author on hover."); false);
layout.addDropdown("Emoji style", layout.addDropdown("Emoji style",
{ {
"Twitter", "Twitter",