mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-15 21:57:10 +02:00
Fix crash in recent actions with spoilers.
This commit is contained in:
parent
0e6c899cee
commit
6cb01998cc
4 changed files with 48 additions and 17 deletions
|
@ -247,7 +247,17 @@ void Game::draw(Painter &p, const PaintContext &context) const {
|
|||
endskip = _parent->skipBlockWidth();
|
||||
}
|
||||
_parent->prepareCustomEmojiPaint(p, context, _description);
|
||||
_description.drawLeftElided(p, padding.left(), tshift, paintw, width(), _descriptionLines, style::al_left, 0, -1, endskip, false, toDescriptionSelection(context.selection));
|
||||
_description.draw(p, {
|
||||
.position = { padding.left(), tshift },
|
||||
.outerWidth = width(),
|
||||
.availableWidth = paintw,
|
||||
.spoiler = Ui::Text::DefaultSpoilerCache(),
|
||||
.now = context.now,
|
||||
.paused = context.paused,
|
||||
.selection = toDescriptionSelection(context.selection),
|
||||
.elisionLines = _descriptionLines,
|
||||
.elisionRemoveFromEnd = endskip,
|
||||
});
|
||||
tshift += _descriptionLines * lineHeight;
|
||||
}
|
||||
if (_attach) {
|
||||
|
|
|
@ -228,7 +228,16 @@ void Invoice::draw(Painter &p, const PaintContext &context) const {
|
|||
}
|
||||
if (_descriptionHeight) {
|
||||
p.setPen(stm->historyTextFg);
|
||||
_description.drawLeft(p, padding.left(), tshift, paintw, width(), style::al_left, 0, -1, toDescriptionSelection(context.selection));
|
||||
_parent->prepareCustomEmojiPaint(p, context, _description);
|
||||
_description.draw(p, {
|
||||
.position = { padding.left(), tshift },
|
||||
.outerWidth = width(),
|
||||
.availableWidth = paintw,
|
||||
.spoiler = Ui::Text::DefaultSpoilerCache(),
|
||||
.now = context.now,
|
||||
.paused = context.paused,
|
||||
.selection = toDescriptionSelection(context.selection),
|
||||
});
|
||||
tshift += _descriptionHeight;
|
||||
}
|
||||
if (_attach) {
|
||||
|
@ -353,6 +362,17 @@ void Invoice::clickHandlerPressedChanged(const ClickHandlerPtr &p, bool pressed)
|
|||
}
|
||||
}
|
||||
|
||||
bool Invoice::hasHeavyPart() const {
|
||||
return _attach ? _attach->hasHeavyPart() : false;
|
||||
}
|
||||
|
||||
void Invoice::unloadHeavyPart() {
|
||||
if (_attach) {
|
||||
_attach->unloadHeavyPart();
|
||||
}
|
||||
_description.unloadPersistentAnimation();
|
||||
}
|
||||
|
||||
TextForMimeData Invoice::selectedText(TextSelection selection) const {
|
||||
auto titleResult = _title.toTextForMimeData(selection);
|
||||
auto descriptionResult = _description.toTextForMimeData(
|
||||
|
|
|
@ -70,14 +70,8 @@ public:
|
|||
return _attach.get();
|
||||
}
|
||||
|
||||
bool hasHeavyPart() const override {
|
||||
return _attach ? _attach->hasHeavyPart() : false;
|
||||
}
|
||||
void unloadHeavyPart() override {
|
||||
if (_attach) {
|
||||
_attach->unloadHeavyPart();
|
||||
}
|
||||
}
|
||||
bool hasHeavyPart() const override;
|
||||
void unloadHeavyPart() override;
|
||||
|
||||
private:
|
||||
QSize countOptimalSize() override;
|
||||
|
|
|
@ -568,13 +568,20 @@ void WebPage::draw(Painter &p, const PaintContext &context) const {
|
|||
endskip = _parent->skipBlockWidth();
|
||||
}
|
||||
_parent->prepareCustomEmojiPaint(p, context, _description);
|
||||
if (_descriptionLines > 0) {
|
||||
_description.drawLeftElided(p, padding.left(), tshift, paintw, width(), _descriptionLines, style::al_left, 0, -1, endskip, false, toDescriptionSelection(context.selection));
|
||||
tshift += _descriptionLines * lineHeight;
|
||||
} else {
|
||||
_description.drawLeft(p, padding.left(), tshift, paintw, width(), style::al_left, 0, -1, toDescriptionSelection(context.selection));
|
||||
tshift += _description.countHeight(paintw);
|
||||
}
|
||||
_description.draw(p, {
|
||||
.position = { padding.left(), tshift },
|
||||
.outerWidth = width(),
|
||||
.availableWidth = paintw,
|
||||
.spoiler = Ui::Text::DefaultSpoilerCache(),
|
||||
.now = context.now,
|
||||
.paused = context.paused,
|
||||
.selection = toDescriptionSelection(context.selection),
|
||||
.elisionLines = std::max(_descriptionLines, 0),
|
||||
.elisionRemoveFromEnd = (_descriptionLines > 0) ? endskip : 0,
|
||||
});
|
||||
tshift += (_descriptionLines > 0)
|
||||
? (_descriptionLines * lineHeight)
|
||||
: _description.countHeight(paintw);
|
||||
}
|
||||
if (_attach) {
|
||||
auto attachAtTop = !_siteNameLines && !_titleLines && !_descriptionLines;
|
||||
|
|
Loading…
Add table
Reference in a new issue