Display shown spoilers as plain text.

This commit is contained in:
John Preston 2021-12-30 15:20:43 +03:00
parent 5f94fa24a0
commit 541c8d258b

View file

@ -1788,16 +1788,8 @@ private:
} }
const auto hasSpoiler = fillSpoiler.width != QFixed(); const auto hasSpoiler = fillSpoiler.width != QFixed();
const auto hasSelect = fillSelect.to != QFixed(); const auto hasSelect = fillSelect.to != QFixed();
if (hasSpoiler && !_background.inFront) {
fillSpoilerRange(fillSpoiler.from, fillSpoiler.width, blockIndex);
}
if (hasSelect) { if (hasSelect) {
const auto opacity = _p->opacity();
if (hasSpoiler && !_background.inFront) {
_p->setOpacity(kSelectedSpoilerOpacity);
}
fillSelectRange(fillSelect.from, fillSelect.to); fillSelectRange(fillSelect.from, fillSelect.to);
_p->setOpacity(opacity);
} }
if (!_background.inFront) { if (!_background.inFront) {
Emoji::Draw( Emoji::Draw(
@ -1905,21 +1897,10 @@ private:
gf.justified = false; gf.justified = false;
gf.initWithScriptItem(si); gf.initWithScriptItem(si);
const auto hasBackground = !_background.inFront
&& _background.color;
if (hasBackground) {
fillSpoilerRange(x, si.width, blockIndex);
}
auto hasSelected = false; auto hasSelected = false;
auto hasNotSelected = true; auto hasNotSelected = true;
auto selectedRect = QRect(); auto selectedRect = QRect();
if (_localFrom + itemStart < _selection.to && _localFrom + itemEnd > _selection.from) { if (_localFrom + itemStart < _selection.to && _localFrom + itemEnd > _selection.from) {
const auto opacity = _p->opacity();
if (hasBackground) {
_p->setOpacity(kSelectedSpoilerOpacity);
}
hasSelected = true; hasSelected = true;
auto selX = x; auto selX = x;
auto selWidth = itemWidth; auto selWidth = itemWidth;
@ -1962,31 +1943,32 @@ private:
if (rtl) selX = x + itemWidth - (selX - x) - selWidth; if (rtl) selX = x + itemWidth - (selX - x) - selWidth;
selectedRect = QRect(selX.toInt(), _y + _yDelta, (selX + selWidth).toInt() - selX.toInt(), _fontHeight); selectedRect = QRect(selX.toInt(), _y + _yDelta, (selX + selWidth).toInt() - selX.toInt(), _fontHeight);
fillSelectRange(selX, selX + selWidth); fillSelectRange(selX, selX + selWidth);
_p->setOpacity(opacity);
} }
if (Q_UNLIKELY(hasSelected)) { if (!_background.inFront || _background.startMs) {
if (Q_UNLIKELY(hasNotSelected)) { if (Q_UNLIKELY(hasSelected)) {
auto clippingEnabled = _p->hasClipping(); if (Q_UNLIKELY(hasNotSelected)) {
auto clippingRegion = _p->clipRegion(); auto clippingEnabled = _p->hasClipping();
_p->setClipRect(selectedRect, Qt::IntersectClip); auto clippingRegion = _p->clipRegion();
_p->setPen(*_currentPenSelected); _p->setClipRect(selectedRect, Qt::IntersectClip);
_p->drawTextItem(QPointF(x.toReal(), textY), gf); _p->setPen(*_currentPenSelected);
auto externalClipping = clippingEnabled ? clippingRegion : QRegion(QRect((_x - _w).toInt(), _y - _lineHeight, (_x + 2 * _w).toInt(), _y + 2 * _lineHeight)); _p->drawTextItem(QPointF(x.toReal(), textY), gf);
_p->setClipRegion(externalClipping - selectedRect); auto externalClipping = clippingEnabled ? clippingRegion : QRegion(QRect((_x - _w).toInt(), _y - _lineHeight, (_x + 2 * _w).toInt(), _y + 2 * _lineHeight));
_p->setPen(*_currentPen); _p->setClipRegion(externalClipping - selectedRect);
_p->drawTextItem(QPointF(x.toReal(), textY), gf); _p->setPen(*_currentPen);
if (clippingEnabled) { _p->drawTextItem(QPointF(x.toReal(), textY), gf);
_p->setClipRegion(clippingRegion); if (clippingEnabled) {
_p->setClipRegion(clippingRegion);
} else {
_p->setClipping(false);
}
} else { } else {
_p->setClipping(false); _p->setPen(*_currentPenSelected);
_p->drawTextItem(QPointF(x.toReal(), textY), gf);
} }
} else { } else {
_p->setPen(*_currentPenSelected); _p->setPen(*_currentPen);
_p->drawTextItem(QPointF(x.toReal(), textY), gf); _p->drawTextItem(QPointF(x.toReal(), textY), gf);
} }
} else {
_p->setPen(*_currentPen);
_p->drawTextItem(QPointF(x.toReal(), textY), gf);
} }
if (_background.inFront || _background.startMs) { if (_background.inFront || _background.startMs) {
@ -2881,11 +2863,6 @@ private:
*_background.color); *_background.color);
mutableCache.color = (*_background.color)->c; mutableCache.color = (*_background.color)->c;
} }
if (inBack) {
_currentPen = &_textPalette->spoilerActiveFg->p;
_currentPenSelected = &_textPalette->spoilerActiveFg->p;
return;
}
} else { } else {
_background = {}; _background = {};
} }