mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
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:
parent
073192b4e5
commit
5c55f62600
|
@ -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)
|
||||||
|
|
|
@ -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 = {
|
||||||
|
|
|
@ -1672,81 +1672,88 @@ 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 ||
|
auto showThumbnailSetting =
|
||||||
getSettings()->emotesTooltipPreview.getValue() == 1)
|
getSettings()->emotesTooltipPreview.getValue();
|
||||||
|
|
||||||
|
bool showThumbnail =
|
||||||
|
showThumbnailSetting == ThumbnailPreviewMode::AlwaysShow ||
|
||||||
|
(showThumbnailSetting == ThumbnailPreviewMode::ShowOnShift &&
|
||||||
|
event->modifiers() == Qt::ShiftModifier);
|
||||||
|
|
||||||
|
if (emoteElement)
|
||||||
{
|
{
|
||||||
if (emoteElement)
|
tooltipWidget->setOne({
|
||||||
|
showThumbnail
|
||||||
|
? emoteElement->getEmote()->images.getImage(3.0)
|
||||||
|
: nullptr,
|
||||||
|
element->getTooltip(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (layeredEmoteElement)
|
||||||
|
{
|
||||||
|
auto &layeredEmotes = layeredEmoteElement->getEmotes();
|
||||||
|
// Should never be empty but ensure it
|
||||||
|
if (!layeredEmotes.empty())
|
||||||
{
|
{
|
||||||
tooltipWidget->setOne({
|
std::vector<TooltipEntry> entries;
|
||||||
emoteElement->getEmote()->images.getImage(3.0),
|
entries.reserve(layeredEmotes.size());
|
||||||
element->getTooltip(),
|
|
||||||
});
|
auto &emoteTooltips =
|
||||||
}
|
layeredEmoteElement->getEmoteTooltips();
|
||||||
else if (layeredEmoteElement)
|
|
||||||
{
|
// Someone performing some tomfoolery could put an emote with tens,
|
||||||
auto &layeredEmotes = layeredEmoteElement->getEmotes();
|
// if not hundreds of zero-width emotes on a single emote. If the
|
||||||
// Should never be empty but ensure it
|
// tooltip may take up more than three rows, truncate everything else.
|
||||||
if (!layeredEmotes.empty())
|
bool truncating = false;
|
||||||
|
size_t upperLimit = layeredEmotes.size();
|
||||||
|
if (layeredEmotes.size() > TOOLTIP_EMOTE_ENTRIES_LIMIT)
|
||||||
{
|
{
|
||||||
std::vector<TooltipEntry> entries;
|
upperLimit = TOOLTIP_EMOTE_ENTRIES_LIMIT - 1;
|
||||||
entries.reserve(layeredEmotes.size());
|
truncating = true;
|
||||||
|
|
||||||
auto &emoteTooltips =
|
|
||||||
layeredEmoteElement->getEmoteTooltips();
|
|
||||||
|
|
||||||
// Someone performing some tomfoolery could put an emote with tens,
|
|
||||||
// if not hundreds of zero-width emotes on a single emote. If the
|
|
||||||
// tooltip may take up more than three rows, truncate everything else.
|
|
||||||
bool truncating = false;
|
|
||||||
size_t upperLimit = layeredEmotes.size();
|
|
||||||
if (layeredEmotes.size() > TOOLTIP_EMOTE_ENTRIES_LIMIT)
|
|
||||||
{
|
|
||||||
upperLimit = TOOLTIP_EMOTE_ENTRIES_LIMIT - 1;
|
|
||||||
truncating = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (size_t i = 0; i < upperLimit; ++i)
|
|
||||||
{
|
|
||||||
const auto &emote = layeredEmotes[i].ptr;
|
|
||||||
if (i == 0)
|
|
||||||
{
|
|
||||||
// First entry gets a large image and full description
|
|
||||||
entries.push_back({emote->images.getImage(3.0),
|
|
||||||
emoteTooltips[i]});
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Every other entry gets a small image and just the emote name
|
|
||||||
entries.push_back({emote->images.getImage(1.0),
|
|
||||||
emote->name.string});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (truncating)
|
|
||||||
{
|
|
||||||
entries.push_back({nullptr, "..."});
|
|
||||||
}
|
|
||||||
|
|
||||||
auto style = layeredEmotes.size() > 2
|
|
||||||
? TooltipStyle::Grid
|
|
||||||
: TooltipStyle::Vertical;
|
|
||||||
tooltipWidget->set(entries, style);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else if (badgeElement)
|
for (size_t i = 0; i < upperLimit; ++i)
|
||||||
{
|
{
|
||||||
tooltipWidget->setOne({
|
const auto &emote = layeredEmotes[i].ptr;
|
||||||
badgeElement->getEmote()->images.getImage(3.0),
|
if (i == 0)
|
||||||
element->getTooltip(),
|
{
|
||||||
});
|
// First entry gets a large image and full description
|
||||||
|
entries.push_back({showThumbnail
|
||||||
|
? emote->images.getImage(3.0)
|
||||||
|
: nullptr,
|
||||||
|
emoteTooltips[i]});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Every other entry gets a small image and just the emote name
|
||||||
|
entries.push_back({showThumbnail
|
||||||
|
? emote->images.getImage(1.0)
|
||||||
|
: nullptr,
|
||||||
|
emote->name.string});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (truncating)
|
||||||
|
{
|
||||||
|
entries.push_back({nullptr, "..."});
|
||||||
|
}
|
||||||
|
|
||||||
|
auto style = layeredEmotes.size() > 2
|
||||||
|
? TooltipStyle::Grid
|
||||||
|
: TooltipStyle::Vertical;
|
||||||
|
tooltipWidget->set(entries, style);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else if (badgeElement)
|
||||||
{
|
{
|
||||||
tooltipWidget->clearEntries();
|
tooltipWidget->setOne({
|
||||||
|
showThumbnail
|
||||||
|
? badgeElement->getEmote()->images.getImage(3.0)
|
||||||
|
: nullptr,
|
||||||
|
element->getTooltip(),
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -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",
|
||||||
|
|
Loading…
Reference in a new issue