Allow disabling spoilers / emoji in FlatLabel.

This commit is contained in:
John Preston 2023-06-30 21:12:21 +04:00
parent 67dc933d72
commit c3aab1bd14
2 changed files with 17 additions and 1 deletions

View file

@ -962,6 +962,9 @@ void FlatLabel::paintEvent(QPaintEvent *e) {
: _st.maxHeight
? qMax(_st.maxHeight / lineHeight, 1)
: ((height() / lineHeight) + 2);
const auto paused = _animationsPausedCallback
? _animationsPausedCallback()
: WhichAnimationsPaused::None;
_text.draw(p, {
.position = { textLeft, _st.margin.top() },
.availableWidth = textWidth,
@ -970,6 +973,10 @@ void FlatLabel::paintEvent(QPaintEvent *e) {
.palette = &_st.palette,
.spoiler = Text::DefaultSpoilerCache(),
.now = crl::now(),
.pausedEmoji = (paused == WhichAnimationsPaused::CustomEmoji
|| paused == WhichAnimationsPaused::All),
.pausedSpoiler = (paused == WhichAnimationsPaused::Spoiler
|| paused == WhichAnimationsPaused::All),
.selection = selection,
.elisionLines = lines,
.elisionBreakEverywhere = renderElided && _breakEverywhere,

View file

@ -94,7 +94,6 @@ private:
};
class FlatLabel : public RpWidget, public ClickHandlerHost {
public:
FlatLabel(
QWidget *parent,
@ -130,6 +129,15 @@ public:
void setContextCopyText(const QString &copyText);
void setBreakEverywhere(bool breakEverywhere);
void setTryMakeSimilarLines(bool tryMakeSimilarLines);
enum class WhichAnimationsPaused {
None,
CustomEmoji,
Spoiler,
All,
};
void setAnimationsPausedCallback(Fn<WhichAnimationsPaused()> callback) {
_animationsPausedCallback = std::move(callback);
}
int naturalWidth() const override;
QMargins getMargins() const override;
@ -251,6 +259,7 @@ private:
QString _contextCopyText;
ClickHandlerFilter _clickHandlerFilter;
Fn<WhichAnimationsPaused()> _animationsPausedCallback;
// text selection and context menu by touch support (at least Windows Surface tablets)
bool _touchSelect = false;