Allow disabling spoilers / emoji in FlatLabel.
This commit is contained in:
parent
67dc933d72
commit
c3aab1bd14
2 changed files with 17 additions and 1 deletions
|
|
@ -962,6 +962,9 @@ void FlatLabel::paintEvent(QPaintEvent *e) {
|
||||||
: _st.maxHeight
|
: _st.maxHeight
|
||||||
? qMax(_st.maxHeight / lineHeight, 1)
|
? qMax(_st.maxHeight / lineHeight, 1)
|
||||||
: ((height() / lineHeight) + 2);
|
: ((height() / lineHeight) + 2);
|
||||||
|
const auto paused = _animationsPausedCallback
|
||||||
|
? _animationsPausedCallback()
|
||||||
|
: WhichAnimationsPaused::None;
|
||||||
_text.draw(p, {
|
_text.draw(p, {
|
||||||
.position = { textLeft, _st.margin.top() },
|
.position = { textLeft, _st.margin.top() },
|
||||||
.availableWidth = textWidth,
|
.availableWidth = textWidth,
|
||||||
|
|
@ -970,6 +973,10 @@ void FlatLabel::paintEvent(QPaintEvent *e) {
|
||||||
.palette = &_st.palette,
|
.palette = &_st.palette,
|
||||||
.spoiler = Text::DefaultSpoilerCache(),
|
.spoiler = Text::DefaultSpoilerCache(),
|
||||||
.now = crl::now(),
|
.now = crl::now(),
|
||||||
|
.pausedEmoji = (paused == WhichAnimationsPaused::CustomEmoji
|
||||||
|
|| paused == WhichAnimationsPaused::All),
|
||||||
|
.pausedSpoiler = (paused == WhichAnimationsPaused::Spoiler
|
||||||
|
|| paused == WhichAnimationsPaused::All),
|
||||||
.selection = selection,
|
.selection = selection,
|
||||||
.elisionLines = lines,
|
.elisionLines = lines,
|
||||||
.elisionBreakEverywhere = renderElided && _breakEverywhere,
|
.elisionBreakEverywhere = renderElided && _breakEverywhere,
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,6 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
class FlatLabel : public RpWidget, public ClickHandlerHost {
|
class FlatLabel : public RpWidget, public ClickHandlerHost {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FlatLabel(
|
FlatLabel(
|
||||||
QWidget *parent,
|
QWidget *parent,
|
||||||
|
|
@ -130,6 +129,15 @@ public:
|
||||||
void setContextCopyText(const QString ©Text);
|
void setContextCopyText(const QString ©Text);
|
||||||
void setBreakEverywhere(bool breakEverywhere);
|
void setBreakEverywhere(bool breakEverywhere);
|
||||||
void setTryMakeSimilarLines(bool tryMakeSimilarLines);
|
void setTryMakeSimilarLines(bool tryMakeSimilarLines);
|
||||||
|
enum class WhichAnimationsPaused {
|
||||||
|
None,
|
||||||
|
CustomEmoji,
|
||||||
|
Spoiler,
|
||||||
|
All,
|
||||||
|
};
|
||||||
|
void setAnimationsPausedCallback(Fn<WhichAnimationsPaused()> callback) {
|
||||||
|
_animationsPausedCallback = std::move(callback);
|
||||||
|
}
|
||||||
|
|
||||||
int naturalWidth() const override;
|
int naturalWidth() const override;
|
||||||
QMargins getMargins() const override;
|
QMargins getMargins() const override;
|
||||||
|
|
@ -251,6 +259,7 @@ private:
|
||||||
QString _contextCopyText;
|
QString _contextCopyText;
|
||||||
|
|
||||||
ClickHandlerFilter _clickHandlerFilter;
|
ClickHandlerFilter _clickHandlerFilter;
|
||||||
|
Fn<WhichAnimationsPaused()> _animationsPausedCallback;
|
||||||
|
|
||||||
// text selection and context menu by touch support (at least Windows Surface tablets)
|
// text selection and context menu by touch support (at least Windows Surface tablets)
|
||||||
bool _touchSelect = false;
|
bool _touchSelect = false;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue