diff --git a/ui/widgets/checkbox.cpp b/ui/widgets/checkbox.cpp index e75482b..97afa5b 100644 --- a/ui/widgets/checkbox.cpp +++ b/ui/widgets/checkbox.cpp @@ -380,7 +380,22 @@ Checkbox::Checkbox( const style::Check &checkSt) : Checkbox( parent, - text, + rpl::single(text) | rpl::map(TextWithEntities::Simple), + st, + std::make_unique( + checkSt, + checked)) { +} + +Checkbox::Checkbox( + QWidget *parent, + const TextWithEntities &text, + bool checked, + const style::Checkbox &st, + const style::Check &checkSt) +: Checkbox( + parent, + rpl::single(text), st, std::make_unique( checkSt, @@ -395,7 +410,7 @@ Checkbox::Checkbox( const style::Toggle &toggleSt) : Checkbox( parent, - rpl::single(text), + rpl::single(text) | rpl::map(TextWithEntities::Simple), st, std::make_unique( toggleSt, @@ -410,7 +425,7 @@ Checkbox::Checkbox( const style::Check &checkSt) : Checkbox( parent, - std::move(text), + std::move(text) | rpl::map(TextWithEntities::Simple), st, std::make_unique( checkSt, @@ -425,7 +440,7 @@ Checkbox::Checkbox( const style::Toggle &toggleSt) : Checkbox( parent, - std::move(text), + std::move(text) | rpl::map(TextWithEntities::Simple), st, std::make_unique( toggleSt, @@ -439,14 +454,14 @@ Checkbox::Checkbox( std::unique_ptr check) : Checkbox( parent, - rpl::single(text), + rpl::single(text) | rpl::map(TextWithEntities::Simple), st, std::move(check)) { } Checkbox::Checkbox( QWidget *parent, - rpl::producer &&text, + rpl::producer &&text, const style::Checkbox &st, std::unique_ptr check) : RippleButton(parent, st.ripple) @@ -462,8 +477,17 @@ Checkbox::Checkbox( setCursor(style::cur_pointer); std::move( text - ) | rpl::start_with_next([=](QString &&value) { - setText(std::move(value)); + ) | rpl::start_with_next([=](TextWithEntities &&value) { + if (value.entities.empty()) { + setText(base::take(value.text)); + } else { + _text.setMarkedText( + _st.style, + std::move(value), + _checkboxRichOptions); + resizeToText(); + update(); + } }, lifetime()); } diff --git a/ui/widgets/checkbox.h b/ui/widgets/checkbox.h index 7c0d7de..eeb5bf5 100644 --- a/ui/widgets/checkbox.h +++ b/ui/widgets/checkbox.h @@ -140,6 +140,12 @@ public: bool checked = false, const style::Checkbox &st = st::defaultCheckbox, const style::Check &checkSt = st::defaultCheck); + Checkbox( + QWidget *parent, + const TextWithEntities &text, + bool checked = false, + const style::Checkbox &st = st::defaultCheckbox, + const style::Check &checkSt = st::defaultCheck); Checkbox( QWidget *parent, const QString &text, @@ -165,7 +171,7 @@ public: std::unique_ptr check); Checkbox( QWidget *parent, - rpl::producer &&text, + rpl::producer &&text, const style::Checkbox &st, std::unique_ptr check);