Added ability to pass TextWithEntities to Checkbox.
This commit is contained in:
parent
3461c18cda
commit
0a0e5e1258
2 changed files with 39 additions and 9 deletions
|
|
@ -380,7 +380,22 @@ Checkbox::Checkbox(
|
||||||
const style::Check &checkSt)
|
const style::Check &checkSt)
|
||||||
: Checkbox(
|
: Checkbox(
|
||||||
parent,
|
parent,
|
||||||
text,
|
rpl::single(text) | rpl::map(TextWithEntities::Simple),
|
||||||
|
st,
|
||||||
|
std::make_unique<CheckView>(
|
||||||
|
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,
|
st,
|
||||||
std::make_unique<CheckView>(
|
std::make_unique<CheckView>(
|
||||||
checkSt,
|
checkSt,
|
||||||
|
|
@ -395,7 +410,7 @@ Checkbox::Checkbox(
|
||||||
const style::Toggle &toggleSt)
|
const style::Toggle &toggleSt)
|
||||||
: Checkbox(
|
: Checkbox(
|
||||||
parent,
|
parent,
|
||||||
rpl::single(text),
|
rpl::single(text) | rpl::map(TextWithEntities::Simple),
|
||||||
st,
|
st,
|
||||||
std::make_unique<ToggleView>(
|
std::make_unique<ToggleView>(
|
||||||
toggleSt,
|
toggleSt,
|
||||||
|
|
@ -410,7 +425,7 @@ Checkbox::Checkbox(
|
||||||
const style::Check &checkSt)
|
const style::Check &checkSt)
|
||||||
: Checkbox(
|
: Checkbox(
|
||||||
parent,
|
parent,
|
||||||
std::move(text),
|
std::move(text) | rpl::map(TextWithEntities::Simple),
|
||||||
st,
|
st,
|
||||||
std::make_unique<CheckView>(
|
std::make_unique<CheckView>(
|
||||||
checkSt,
|
checkSt,
|
||||||
|
|
@ -425,7 +440,7 @@ Checkbox::Checkbox(
|
||||||
const style::Toggle &toggleSt)
|
const style::Toggle &toggleSt)
|
||||||
: Checkbox(
|
: Checkbox(
|
||||||
parent,
|
parent,
|
||||||
std::move(text),
|
std::move(text) | rpl::map(TextWithEntities::Simple),
|
||||||
st,
|
st,
|
||||||
std::make_unique<ToggleView>(
|
std::make_unique<ToggleView>(
|
||||||
toggleSt,
|
toggleSt,
|
||||||
|
|
@ -439,14 +454,14 @@ Checkbox::Checkbox(
|
||||||
std::unique_ptr<AbstractCheckView> check)
|
std::unique_ptr<AbstractCheckView> check)
|
||||||
: Checkbox(
|
: Checkbox(
|
||||||
parent,
|
parent,
|
||||||
rpl::single(text),
|
rpl::single(text) | rpl::map(TextWithEntities::Simple),
|
||||||
st,
|
st,
|
||||||
std::move(check)) {
|
std::move(check)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Checkbox::Checkbox(
|
Checkbox::Checkbox(
|
||||||
QWidget *parent,
|
QWidget *parent,
|
||||||
rpl::producer<QString> &&text,
|
rpl::producer<TextWithEntities> &&text,
|
||||||
const style::Checkbox &st,
|
const style::Checkbox &st,
|
||||||
std::unique_ptr<AbstractCheckView> check)
|
std::unique_ptr<AbstractCheckView> check)
|
||||||
: RippleButton(parent, st.ripple)
|
: RippleButton(parent, st.ripple)
|
||||||
|
|
@ -462,8 +477,17 @@ Checkbox::Checkbox(
|
||||||
setCursor(style::cur_pointer);
|
setCursor(style::cur_pointer);
|
||||||
std::move(
|
std::move(
|
||||||
text
|
text
|
||||||
) | rpl::start_with_next([=](QString &&value) {
|
) | rpl::start_with_next([=](TextWithEntities &&value) {
|
||||||
setText(std::move(value));
|
if (value.entities.empty()) {
|
||||||
|
setText(base::take(value.text));
|
||||||
|
} else {
|
||||||
|
_text.setMarkedText(
|
||||||
|
_st.style,
|
||||||
|
std::move(value),
|
||||||
|
_checkboxRichOptions);
|
||||||
|
resizeToText();
|
||||||
|
update();
|
||||||
|
}
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -140,6 +140,12 @@ public:
|
||||||
bool checked = false,
|
bool checked = false,
|
||||||
const style::Checkbox &st = st::defaultCheckbox,
|
const style::Checkbox &st = st::defaultCheckbox,
|
||||||
const style::Check &checkSt = st::defaultCheck);
|
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(
|
Checkbox(
|
||||||
QWidget *parent,
|
QWidget *parent,
|
||||||
const QString &text,
|
const QString &text,
|
||||||
|
|
@ -165,7 +171,7 @@ public:
|
||||||
std::unique_ptr<AbstractCheckView> check);
|
std::unique_ptr<AbstractCheckView> check);
|
||||||
Checkbox(
|
Checkbox(
|
||||||
QWidget *parent,
|
QWidget *parent,
|
||||||
rpl::producer<QString> &&text,
|
rpl::producer<TextWithEntities> &&text,
|
||||||
const style::Checkbox &st,
|
const style::Checkbox &st,
|
||||||
std::unique_ptr<AbstractCheckView> check);
|
std::unique_ptr<AbstractCheckView> check);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue