diff --git a/Telegram/SourceFiles/boxes/edit_privacy_box.cpp b/Telegram/SourceFiles/boxes/edit_privacy_box.cpp index 4459d7e12..8a25c347d 100644 --- a/Telegram/SourceFiles/boxes/edit_privacy_box.cpp +++ b/Telegram/SourceFiles/boxes/edit_privacy_box.cpp @@ -90,14 +90,7 @@ std::unique_ptr PrivacyExceptionsBoxControl class EditPrivacyBox::OptionWidget : public TWidget { public: - OptionWidget(QWidget *parent, int value, bool selected, const QString &text, const QString &description); - - void setChangedCallback(base::lambda callback) { - connect(_option, SIGNAL(changed()), base::lambda_slot(this, std::move(callback)), SLOT(action())); - } - bool checked() const { - return _option->checked(); - } + OptionWidget(QWidget *parent, const std::shared_ptr &group, int value, const QString &text, const QString &description); QMargins getMargins() const override { return _option->getMargins(); @@ -112,8 +105,8 @@ private: }; -EditPrivacyBox::OptionWidget::OptionWidget(QWidget *parent, int value, bool selected, const QString &text, const QString &description) : TWidget(parent) -, _option(this, qsl("privacy_option"), value, text, selected, st::defaultBoxCheckbox) +EditPrivacyBox::OptionWidget::OptionWidget(QWidget *parent, const std::shared_ptr &group, int value, const QString &text, const QString &description) : TWidget(parent) +, _option(this, group, value, text, st::defaultBoxCheckbox) , _description(this, description, Ui::FlatLabel::InitType::Simple, st::editPrivacyLabel) { } @@ -185,15 +178,15 @@ int EditPrivacyBox::resizeGetHeight(int newWidth) { int EditPrivacyBox::countDefaultHeight(int newWidth) { auto height = 0; - auto optionHeight = [this, newWidth](Option option, const QString &label) { + auto fakeGroup = std::make_shared(0); + auto optionHeight = [this, newWidth, &fakeGroup](Option option, const QString &label) { auto description = _controller->optionDescription(option); if (description.isEmpty()) { return 0; } auto value = static_cast(Option::Everyone); - auto selected = false; - auto fake = object_ptr(nullptr, value, selected, label, description); + auto fake = object_ptr(nullptr, fakeGroup, value, label, description); fake->resizeToNaturalWidth(newWidth - st::editPrivacyOptionMargin.left() - st::editPrivacyOptionMargin.right()); return st::editPrivacyOptionMargin.top() + fake->heightNoMargins() + st::editPrivacyOptionMargin.bottom(); }; @@ -304,23 +297,23 @@ void EditPrivacyBox::createOption(Option option, object_ptr &widge auto selected = (_option == option); if (!description.isEmpty() || selected) { auto value = static_cast(option); - widget.create(this, value, selected, label, description); - widget->setChangedCallback([this, option, widget = widget.data()] { - if (widget->checked()) { - _option = option; - _alwaysLink->toggleAnimated(showExceptionLink(Exception::Always)); - _neverLink->toggleAnimated(showExceptionLink(Exception::Never)); - } - }); + widget.create(this, _optionGroup, value, label, description); } } void EditPrivacyBox::createWidgets() { _loading.destroy(); + _optionGroup = std::make_shared(static_cast(_option)); createOption(Option::Everyone, _everyone, lang(lng_edit_privacy_everyone)); createOption(Option::Contacts, _contacts, lang(lng_edit_privacy_contacts)); createOption(Option::Nobody, _nobody, lang(lng_edit_privacy_nobody)); + _optionGroup->setChangedCallback([this](int value) { + _option = static_cast