mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Added ability to fill chat participant statuses with custom widgets.
This commit is contained in:
parent
8688a68115
commit
642554828c
1 changed files with 31 additions and 15 deletions
|
@ -207,16 +207,36 @@ ChatRestrictions DisabledByAdminRights(not_null<PeerData*> peer) {
|
||||||
: Flag::ChangeInfo);
|
: Flag::ChangeInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
not_null<Ui::Checkbox*> AddDefaultCheckbox(
|
||||||
|
not_null<Ui::VerticalLayout*> container,
|
||||||
|
const QString &text,
|
||||||
|
bool toggled,
|
||||||
|
bool locked) {
|
||||||
|
auto toggle = std::make_unique<Ui::ToggleView>(
|
||||||
|
st::rightsToggle,
|
||||||
|
toggled);
|
||||||
|
toggle->setLocked(locked);
|
||||||
|
return container->add(
|
||||||
|
object_ptr<Ui::Checkbox>(
|
||||||
|
container,
|
||||||
|
text,
|
||||||
|
st::rightsCheckbox,
|
||||||
|
std::move(toggle)),
|
||||||
|
st::rightsToggleMargin);
|
||||||
|
};
|
||||||
|
|
||||||
template <
|
template <
|
||||||
typename Flags,
|
typename Flags,
|
||||||
typename DisabledMessagePairs,
|
typename DisabledMessagePairs,
|
||||||
typename FlagLabelPairs>
|
typename FlagLabelPairs,
|
||||||
|
typename CheckboxFactory>
|
||||||
[[nodiscard]] EditFlagsControl<Flags, Ui::RpWidget> CreateEditFlags(
|
[[nodiscard]] EditFlagsControl<Flags, Ui::RpWidget> CreateEditFlags(
|
||||||
not_null<Ui::VerticalLayout*> container,
|
not_null<Ui::VerticalLayout*> container,
|
||||||
rpl::producer<QString> header,
|
rpl::producer<QString> header,
|
||||||
Flags checked,
|
Flags checked,
|
||||||
const DisabledMessagePairs &disabledMessagePairs,
|
const DisabledMessagePairs &disabledMessagePairs,
|
||||||
const FlagLabelPairs &flagLabelPairs) {
|
const FlagLabelPairs &flagLabelPairs,
|
||||||
|
CheckboxFactory checkboxFactory) {
|
||||||
const auto checkboxes = container->lifetime(
|
const auto checkboxes = container->lifetime(
|
||||||
).make_state<std::map<Flags, QPointer<Ui::Checkbox>>>();
|
).make_state<std::map<Flags, QPointer<Ui::Checkbox>>>();
|
||||||
|
|
||||||
|
@ -255,17 +275,11 @@ template <
|
||||||
? std::make_optional(lockedIt->second)
|
? std::make_optional(lockedIt->second)
|
||||||
: std::nullopt;
|
: std::nullopt;
|
||||||
const auto toggled = ((checked & flags) != 0);
|
const auto toggled = ((checked & flags) != 0);
|
||||||
auto toggle = std::make_unique<Ui::ToggleView>(
|
const auto control = checkboxFactory(
|
||||||
st::rightsToggle,
|
container,
|
||||||
toggled);
|
text,
|
||||||
toggle->setLocked(locked.has_value());
|
toggled,
|
||||||
const auto control = container->add(
|
locked.has_value());
|
||||||
object_ptr<Ui::Checkbox>(
|
|
||||||
container,
|
|
||||||
text,
|
|
||||||
st::rightsCheckbox,
|
|
||||||
std::move(toggle)),
|
|
||||||
st::rightsToggleMargin);
|
|
||||||
control->checkedChanges(
|
control->checkedChanges(
|
||||||
) | rpl::start_with_next([=](bool checked) {
|
) | rpl::start_with_next([=](bool checked) {
|
||||||
if (locked.has_value()) {
|
if (locked.has_value()) {
|
||||||
|
@ -740,7 +754,8 @@ EditFlagsControl<ChatRestrictions, Ui::RpWidget> CreateEditRestrictions(
|
||||||
header,
|
header,
|
||||||
NegateRestrictions(restrictions),
|
NegateRestrictions(restrictions),
|
||||||
disabledMessages,
|
disabledMessages,
|
||||||
RestrictionLabels(options));
|
RestrictionLabels(options),
|
||||||
|
AddDefaultCheckbox);
|
||||||
result.widget = std::move(widget);
|
result.widget = std::move(widget);
|
||||||
result.value = [original = std::move(result.value)]{
|
result.value = [original = std::move(result.value)]{
|
||||||
return NegateRestrictions(original());
|
return NegateRestrictions(original());
|
||||||
|
@ -764,7 +779,8 @@ EditFlagsControl<ChatAdminRights, Ui::RpWidget> CreateEditAdminRights(
|
||||||
header,
|
header,
|
||||||
rights,
|
rights,
|
||||||
disabledMessages,
|
disabledMessages,
|
||||||
AdminRightLabels(options));
|
AdminRightLabels(options),
|
||||||
|
AddDefaultCheckbox);
|
||||||
result.widget = std::move(widget);
|
result.widget = std::move(widget);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue