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)
|
const style::Toggle &toggleSt)
|
||||||
: Checkbox(
|
: Checkbox(
|
||||||
parent,
|
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,
|
st,
|
||||||
std::make_unique<ToggleView>(
|
std::make_unique<ToggleView>(
|
||||||
toggleSt,
|
toggleSt,
|
||||||
|
|
@ -406,17 +436,34 @@ Checkbox::Checkbox(
|
||||||
const QString &text,
|
const QString &text,
|
||||||
const style::Checkbox &st,
|
const style::Checkbox &st,
|
||||||
std::unique_ptr<AbstractCheckView> check)
|
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)
|
: RippleButton(parent, st.ripple)
|
||||||
, _st(st)
|
, _st(st)
|
||||||
, _check(std::move(check))
|
, _check(std::move(check))
|
||||||
, _text(
|
, _text(
|
||||||
_st.style,
|
_st.style,
|
||||||
text,
|
QString(),
|
||||||
_checkboxOptions,
|
_checkboxOptions,
|
||||||
countTextMinWidth()) {
|
countTextMinWidth()) {
|
||||||
_check->setUpdateCallback([=] { update(); });
|
_check->setUpdateCallback([=] { update(); });
|
||||||
resizeToText();
|
resizeToText();
|
||||||
setCursor(style::cur_pointer);
|
setCursor(style::cur_pointer);
|
||||||
|
std::move(
|
||||||
|
text
|
||||||
|
) | rpl::start_with_next([=](QString &&value) {
|
||||||
|
setText(std::move(value));
|
||||||
|
}, lifetime());
|
||||||
}
|
}
|
||||||
|
|
||||||
int Checkbox::countTextMinWidth() const {
|
int Checkbox::countTextMinWidth() const {
|
||||||
|
|
|
||||||
|
|
@ -146,11 +146,28 @@ public:
|
||||||
bool checked,
|
bool checked,
|
||||||
const style::Checkbox &st,
|
const style::Checkbox &st,
|
||||||
const style::Toggle &toggleSt);
|
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(
|
Checkbox(
|
||||||
QWidget *parent,
|
QWidget *parent,
|
||||||
const QString &text,
|
const QString &text,
|
||||||
const style::Checkbox &st,
|
const style::Checkbox &st,
|
||||||
std::unique_ptr<AbstractCheckView> check);
|
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 setText(const QString &text, bool rich = false);
|
||||||
void setCheckAlignment(style::align alignment);
|
void setCheckAlignment(style::align alignment);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue