Make reply thread subtext easier to click (#4067)
Co-authored-by: Daniel Sage <24928223+dnsge@users.noreply.github.com> Co-authored-by: pajlada <rasmus.karlsson@pajlada.com>
This commit is contained in:
+1
-1
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
## Unversioned
|
## Unversioned
|
||||||
|
|
||||||
- Major: Added support for Twitch's Chat Replies. [Wiki Page](https://wiki.chatterino.com/Features/#message-replies) (#3722, #3989, #4041, #4047, #4055)
|
- Major: Added support for Twitch's Chat Replies. [Wiki Page](https://wiki.chatterino.com/Features/#message-replies) (#3722, #3989, #4041, #4047, #4055, #4067)
|
||||||
- Major: Added multi-channel searching to search dialog via keyboard shortcut. (Ctrl+Shift+F by default) (#3694, #3875)
|
- Major: Added multi-channel searching to search dialog via keyboard shortcut. (Ctrl+Shift+F by default) (#3694, #3875)
|
||||||
- Major: Added support for emotes and badges from [7TV](https://7tv.app). [Wiki Page](https://wiki.chatterino.com/Third_party_services/#7tv) (#4002, #4062)
|
- Major: Added support for emotes and badges from [7TV](https://7tv.app). [Wiki Page](https://wiki.chatterino.com/Third_party_services/#7tv) (#4002, #4062)
|
||||||
- Minor: Added highlights for `Elevated Messages`. (#4016)
|
- Minor: Added highlights for `Elevated Messages`. (#4016)
|
||||||
|
|||||||
@@ -468,11 +468,10 @@ void SingleLineTextElement::addToContainer(MessageLayoutContainer &container,
|
|||||||
};
|
};
|
||||||
|
|
||||||
static const auto ellipsis = QStringLiteral("...");
|
static const auto ellipsis = QStringLiteral("...");
|
||||||
auto addEllipsis = [&]() {
|
|
||||||
int ellipsisSize = metrics.horizontalAdvance(ellipsis);
|
// String to continuously append words onto until we place it in the container
|
||||||
container.addElementNoLineBreak(
|
// once we encounter an emote or reach the end of the message text. */
|
||||||
getTextLayoutElement(ellipsis, ellipsisSize, false));
|
QString currentText;
|
||||||
};
|
|
||||||
|
|
||||||
for (Word &word : this->words_)
|
for (Word &word : this->words_)
|
||||||
{
|
{
|
||||||
@@ -483,38 +482,15 @@ void SingleLineTextElement::addToContainer(MessageLayoutContainer &container,
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto &parsedWord = parsedWords[0];
|
auto &parsedWord = parsedWords[0];
|
||||||
if (parsedWord.type() == typeid(EmotePtr))
|
if (parsedWord.type() == typeid(QString))
|
||||||
{
|
{
|
||||||
auto emote = boost::get<EmotePtr>(parsedWord);
|
int nextWidth =
|
||||||
auto image =
|
metrics.horizontalAdvance(currentText + word.text);
|
||||||
emote->images.getImageOrLoaded(container.getScale());
|
|
||||||
if (!image->isEmpty())
|
|
||||||
{
|
|
||||||
auto emoteScale = getSettings()->emoteScale.getValue();
|
|
||||||
|
|
||||||
auto size = QSize(image->width(), image->height()) *
|
|
||||||
(emoteScale * container.getScale());
|
|
||||||
|
|
||||||
if (!container.fitsInLine(size.width()))
|
|
||||||
{
|
|
||||||
addEllipsis();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
container.addElementNoLineBreak(
|
|
||||||
(new ImageLayoutElement(*this, image, size))
|
|
||||||
->setLink(this->getLink()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (parsedWord.type() == typeid(QString))
|
|
||||||
{
|
|
||||||
word.width = metrics.horizontalAdvance(word.text);
|
|
||||||
|
|
||||||
// see if the text fits in the current line
|
// see if the text fits in the current line
|
||||||
if (container.fitsInLine(word.width))
|
if (container.fitsInLine(nextWidth))
|
||||||
{
|
{
|
||||||
container.addElementNoLineBreak(getTextLayoutElement(
|
currentText += (word.text + " ");
|
||||||
word.text, word.width, this->hasTrailingSpace()));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -526,12 +502,12 @@ void SingleLineTextElement::addToContainer(MessageLayoutContainer &container,
|
|||||||
// Try removing characters one by one until the word fits.
|
// Try removing characters one by one until the word fits.
|
||||||
QString truncatedWord =
|
QString truncatedWord =
|
||||||
word.text.chopped(cut) + ellipsis;
|
word.text.chopped(cut) + ellipsis;
|
||||||
int newSize = metrics.horizontalAdvance(truncatedWord);
|
int newSize = metrics.horizontalAdvance(currentText +
|
||||||
|
truncatedWord);
|
||||||
if (container.fitsInLine(newSize))
|
if (container.fitsInLine(newSize))
|
||||||
{
|
{
|
||||||
container.addElementNoLineBreak(
|
currentText += (truncatedWord);
|
||||||
getTextLayoutElement(truncatedWord, newSize,
|
|
||||||
false));
|
|
||||||
cutSuccess = true;
|
cutSuccess = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -541,12 +517,52 @@ void SingleLineTextElement::addToContainer(MessageLayoutContainer &container,
|
|||||||
{
|
{
|
||||||
// We weren't able to show any part of the current word, so
|
// We weren't able to show any part of the current word, so
|
||||||
// just append the ellipsis.
|
// just append the ellipsis.
|
||||||
addEllipsis();
|
currentText += ellipsis;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (parsedWord.type() == typeid(EmotePtr))
|
||||||
|
{
|
||||||
|
auto emote = boost::get<EmotePtr>(parsedWord);
|
||||||
|
auto image =
|
||||||
|
emote->images.getImageOrLoaded(container.getScale());
|
||||||
|
if (!image->isEmpty())
|
||||||
|
{
|
||||||
|
auto emoteScale = getSettings()->emoteScale.getValue();
|
||||||
|
|
||||||
|
int currentWidth = metrics.horizontalAdvance(currentText);
|
||||||
|
auto emoteSize = QSize(image->width(), image->height()) *
|
||||||
|
(emoteScale * container.getScale());
|
||||||
|
|
||||||
|
if (!container.fitsInLine(currentWidth + emoteSize.width()))
|
||||||
|
{
|
||||||
|
currentText += ellipsis;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add currently pending text to container, then add the emote after.
|
||||||
|
container.addElementNoLineBreak(
|
||||||
|
getTextLayoutElement(currentText, currentWidth, false));
|
||||||
|
currentText.clear();
|
||||||
|
|
||||||
|
container.addElementNoLineBreak(
|
||||||
|
(new ImageLayoutElement(*this, image, emoteSize))
|
||||||
|
->setLink(this->getLink()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add the last of the pending message text to the container.
|
||||||
|
if (!currentText.isEmpty())
|
||||||
|
{
|
||||||
|
// Remove trailing space.
|
||||||
|
currentText = currentText.trimmed();
|
||||||
|
|
||||||
|
int width = metrics.horizontalAdvance(currentText);
|
||||||
|
container.addElementNoLineBreak(
|
||||||
|
getTextLayoutElement(currentText, width, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
container.breakLine();
|
container.breakLine();
|
||||||
|
|||||||
Reference in New Issue
Block a user