Fixed emoji display in filenames from document views.

This commit is contained in:
23rd 2024-09-29 05:19:16 +03:00 committed by John Preston
parent 3f34c0ce37
commit a37f512949
2 changed files with 15 additions and 17 deletions

View file

@ -746,8 +746,7 @@ struct HistoryDocumentCaptioned : public RuntimeComponent<HistoryDocumentCaption
}; };
struct HistoryDocumentNamed : public RuntimeComponent<HistoryDocumentNamed, HistoryView::Document> { struct HistoryDocumentNamed : public RuntimeComponent<HistoryDocumentNamed, HistoryView::Document> {
QString name; Ui::Text::String name;
int namew = 0;
}; };
struct HistoryDocumentVoicePlayback { struct HistoryDocumentVoicePlayback {

View file

@ -303,7 +303,7 @@ Document::Document(
createComponents(); createComponents();
if (const auto named = Get<HistoryDocumentNamed>()) { if (const auto named = Get<HistoryDocumentNamed>()) {
fillNamedFromData(named); fillNamedFromData(named);
_tooltipFilename.setTooltipText(named->name); _tooltipFilename.setTooltipText(named->name.toString());
} }
if ((_data->isVoiceMessage() || isRound) if ((_data->isVoiceMessage() || isRound)
@ -406,9 +406,9 @@ void Document::createComponents() {
} }
void Document::fillNamedFromData(not_null<HistoryDocumentNamed*> named) { void Document::fillNamedFromData(not_null<HistoryDocumentNamed*> named) {
const auto nameString = named->name = CleanTagSymbols( named->name.setText(
Ui::Text::FormatSongNameFor(_data).string()); st::semiboldTextStyle,
named->namew = st::semiboldFont->width(nameString); CleanTagSymbols(Ui::Text::FormatSongNameFor(_data).string()));
} }
QSize Document::countOptimalSize() { QSize Document::countOptimalSize() {
@ -497,8 +497,8 @@ QSize Document::countOptimalSize() {
accumulate_max(maxWidth, tleft + MaxStatusWidth(_data) + unread + _parent->skipBlockWidth() + st::msgPadding.right()); accumulate_max(maxWidth, tleft + MaxStatusWidth(_data) + unread + _parent->skipBlockWidth() + st::msgPadding.right());
} }
if (auto named = Get<HistoryDocumentNamed>()) { if (const auto named = Get<HistoryDocumentNamed>()) {
accumulate_max(maxWidth, tleft + named->namew + tright); accumulate_max(maxWidth, tleft + named->name.maxWidth() + tright);
accumulate_min(maxWidth, st::msgMaxWidth); accumulate_min(maxWidth, st::msgMaxWidth);
} }
if (voice && voice->transcribe) { if (voice && voice->transcribe) {
@ -876,16 +876,15 @@ void Document::draw(
progress, progress,
inTTLViewer); inTTLViewer);
p.restore(); p.restore();
} else if (auto named = Get<HistoryDocumentNamed>()) { } else if (const auto named = Get<HistoryDocumentNamed>()) {
p.setFont(st::semiboldFont);
p.setPen(stm->historyFileNameFg); p.setPen(stm->historyFileNameFg);
const auto elided = (namewidth < named->namew); named->name.draw(p, {
if (elided) { .position = QPoint(nameleft, nametop),
p.drawTextLeft(nameleft, nametop, width, st::semiboldFont->elided(named->name, namewidth, Qt::ElideMiddle)); .outerWidth = width,
} else { .availableWidth = namewidth,
p.drawTextLeft(nameleft, nametop, width, named->name, named->namew); .elisionLines = 1,
} });
_tooltipFilename.setElided(elided); _tooltipFilename.setElided(namewidth < named->name.maxWidth());
} }
auto statusText = voiceStatusOverride.isEmpty() ? _statusText : voiceStatusOverride; auto statusText = voiceStatusOverride.isEmpty() ? _statusText : voiceStatusOverride;