Added ability to pass rpl::producer to Checkbox constructors.
This commit is contained in:
parent
34eb5a8eb8
commit
697f2851b0
2 changed files with 66 additions and 2 deletions
|
|
@ -394,7 +394,37 @@ Checkbox::Checkbox(
|
|||
const style::Toggle &toggleSt)
|
||||
: Checkbox(
|
||||
parent,
|
||||
text,
|
||||
rpl::single(text),
|
||||
st,
|
||||
std::make_unique<ToggleView>(
|
||||
toggleSt,
|
||||
checked)) {
|
||||
}
|
||||
|
||||
Checkbox::Checkbox(
|
||||
QWidget *parent,
|
||||
rpl::producer<QString> &&text,
|
||||
bool checked,
|
||||
const style::Checkbox &st,
|
||||
const style::Check &checkSt)
|
||||
: Checkbox(
|
||||
parent,
|
||||
std::move(text),
|
||||
st,
|
||||
std::make_unique<CheckView>(
|
||||
checkSt,
|
||||
checked)) {
|
||||
}
|
||||
|
||||
Checkbox::Checkbox(
|
||||
QWidget *parent,
|
||||
rpl::producer<QString> &&text,
|
||||
bool checked,
|
||||
const style::Checkbox &st,
|
||||
const style::Toggle &toggleSt)
|
||||
: Checkbox(
|
||||
parent,
|
||||
std::move(text),
|
||||
st,
|
||||
std::make_unique<ToggleView>(
|
||||
toggleSt,
|
||||
|
|
@ -406,17 +436,34 @@ Checkbox::Checkbox(
|
|||
const QString &text,
|
||||
const style::Checkbox &st,
|
||||
std::unique_ptr<AbstractCheckView> check)
|
||||
: Checkbox(
|
||||
parent,
|
||||
rpl::single(text),
|
||||
st,
|
||||
std::move(check)) {
|
||||
}
|
||||
|
||||
Checkbox::Checkbox(
|
||||
QWidget *parent,
|
||||
rpl::producer<QString> &&text,
|
||||
const style::Checkbox &st,
|
||||
std::unique_ptr<AbstractCheckView> check)
|
||||
: RippleButton(parent, st.ripple)
|
||||
, _st(st)
|
||||
, _check(std::move(check))
|
||||
, _text(
|
||||
_st.style,
|
||||
text,
|
||||
QString(),
|
||||
_checkboxOptions,
|
||||
countTextMinWidth()) {
|
||||
_check->setUpdateCallback([=] { update(); });
|
||||
resizeToText();
|
||||
setCursor(style::cur_pointer);
|
||||
std::move(
|
||||
text
|
||||
) | rpl::start_with_next([=](QString &&value) {
|
||||
setText(std::move(value));
|
||||
}, lifetime());
|
||||
}
|
||||
|
||||
int Checkbox::countTextMinWidth() const {
|
||||
|
|
|
|||
|
|
@ -146,11 +146,28 @@ public:
|
|||
bool checked,
|
||||
const style::Checkbox &st,
|
||||
const style::Toggle &toggleSt);
|
||||
Checkbox(
|
||||
QWidget *parent,
|
||||
rpl::producer<QString> &&text,
|
||||
bool checked = false,
|
||||
const style::Checkbox &st = st::defaultCheckbox,
|
||||
const style::Check &checkSt = st::defaultCheck);
|
||||
Checkbox(
|
||||
QWidget *parent,
|
||||
rpl::producer<QString> &&text,
|
||||
bool checked,
|
||||
const style::Checkbox &st,
|
||||
const style::Toggle &toggleSt);
|
||||
Checkbox(
|
||||
QWidget *parent,
|
||||
const QString &text,
|
||||
const style::Checkbox &st,
|
||||
std::unique_ptr<AbstractCheckView> check);
|
||||
Checkbox(
|
||||
QWidget *parent,
|
||||
rpl::producer<QString> &&text,
|
||||
const style::Checkbox &st,
|
||||
std::unique_ptr<AbstractCheckView> check);
|
||||
|
||||
void setText(const QString &text, bool rich = false);
|
||||
void setCheckAlignment(style::align alignment);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue