Add rpl interface to RadiobuttonGroup.
This commit is contained in:
parent
e05eb63476
commit
f85c3c88f7
22 changed files with 50 additions and 46 deletions
|
@ -1018,7 +1018,7 @@ void SetupChannelBox::prepare() {
|
|||
cancel);
|
||||
|
||||
connect(_link, &Ui::MaskedInputField::changed, [=] { handleChange(); });
|
||||
_link->setVisible(_privacyGroup->value() == Privacy::Public);
|
||||
_link->setVisible(_privacyGroup->current() == Privacy::Public);
|
||||
|
||||
_privacyGroup->setChangedCallback([=](Privacy value) {
|
||||
privacyChanged(value);
|
||||
|
@ -1063,7 +1063,7 @@ void SetupChannelBox::updateMaxHeight() {
|
|||
: 0)
|
||||
+ st::newGroupPadding.bottom();
|
||||
if (!_channel->isMegagroup()
|
||||
|| _privacyGroup->value() == Privacy::Public) {
|
||||
|| _privacyGroup->current() == Privacy::Public) {
|
||||
newHeight += st::newGroupLinkPadding.top()
|
||||
+ _link->height()
|
||||
+ st::newGroupLinkPadding.bottom();
|
||||
|
@ -1264,7 +1264,7 @@ void SetupChannelBox::save() {
|
|||
};
|
||||
if (_saveRequestId) {
|
||||
return;
|
||||
} else if (_privacyGroup->value() == Privacy::Private) {
|
||||
} else if (_privacyGroup->current() == Privacy::Private) {
|
||||
closeBox();
|
||||
} else {
|
||||
const auto link = _link->text().trimmed();
|
||||
|
|
|
@ -81,9 +81,9 @@ void AutoLockBox::prepare() {
|
|||
|
||||
const auto timeInput = Ui::CreateChild<Ui::TimeInput>(
|
||||
this,
|
||||
(group->value() == kCustom)
|
||||
(group->current() == kCustom
|
||||
? TimeString(currentTime)
|
||||
: kDefaultCustom.utf8(),
|
||||
: kDefaultCustom.utf8()),
|
||||
st::autolockTimeField,
|
||||
st::autolockDateField,
|
||||
st::scheduleTimeSeparator,
|
||||
|
@ -115,7 +115,9 @@ void AutoLockBox::prepare() {
|
|||
});
|
||||
|
||||
rpl::merge(
|
||||
boxClosing() | rpl::filter([=] { return group->value() == kCustom; }),
|
||||
boxClosing() | rpl::filter(
|
||||
[=] { return group->current() == kCustom; }
|
||||
),
|
||||
timeInput->submitRequests()
|
||||
) | rpl::start_with_next([=] {
|
||||
if (const auto result = collect()) {
|
||||
|
|
|
@ -717,7 +717,7 @@ void ProxiesBox::refreshProxyForCalls() {
|
|||
return;
|
||||
}
|
||||
_proxyForCalls->toggle(
|
||||
(_proxySettings->value() == ProxyData::Settings::Enabled
|
||||
(_proxySettings->current() == ProxyData::Settings::Enabled
|
||||
&& _currentProxySupportsCallsId != 0),
|
||||
anim::type::normal);
|
||||
}
|
||||
|
@ -864,7 +864,7 @@ void ProxyBox::refreshButtons() {
|
|||
addButton(tr::lng_settings_save(), [=] { save(); });
|
||||
addButton(tr::lng_cancel(), [=] { closeBox(); });
|
||||
|
||||
const auto type = _type->value();
|
||||
const auto type = _type->current();
|
||||
if (type == Type::Socks5 || type == Type::Mtproto) {
|
||||
addLeftButton(tr::lng_proxy_share(), [=] { share(); });
|
||||
}
|
||||
|
@ -885,7 +885,7 @@ void ProxyBox::share() {
|
|||
|
||||
ProxyData ProxyBox::collectData() {
|
||||
auto result = ProxyData();
|
||||
result.type = _type->value();
|
||||
result.type = _type->current();
|
||||
result.host = _host->getLastText().trimmed();
|
||||
result.port = _port->getLastText().trimmed().toInt();
|
||||
result.user = (result.type == Type::Mtproto)
|
||||
|
@ -1053,7 +1053,7 @@ void ProxyBox::setupControls(const ProxyData &data) {
|
|||
handleType(type);
|
||||
refreshButtons();
|
||||
});
|
||||
handleType(_type->value());
|
||||
handleType(_type->current());
|
||||
}
|
||||
|
||||
void ProxyBox::addLabel(
|
||||
|
|
|
@ -44,7 +44,9 @@ void DownloadPathBox::prepare() {
|
|||
|
||||
setTitle(tr::lng_download_path_header());
|
||||
|
||||
_group->setChangedCallback([this](Directory value) { radioChanged(value); });
|
||||
_group->setChangedCallback([this](Directory value) {
|
||||
radioChanged(value);
|
||||
});
|
||||
|
||||
_pathLink->addClickHandler([=] { editPath(); });
|
||||
if (!_path.isEmpty() && _path != FileDialog::Tmp()) {
|
||||
|
@ -54,7 +56,7 @@ void DownloadPathBox::prepare() {
|
|||
}
|
||||
|
||||
void DownloadPathBox::updateControlsVisibility() {
|
||||
auto custom = (_group->value() == Directory::Custom);
|
||||
auto custom = (_group->current() == Directory::Custom);
|
||||
_pathLink->setVisible(custom);
|
||||
|
||||
auto newHeight = st::boxOptionListPadding.top() + (_default ? _default->getMargins().top() + _default->heightNoMargins() : 0) + st::boxOptionListSkip + _temp->heightNoMargins() + st::boxOptionListSkip + _dir->heightNoMargins();
|
||||
|
@ -122,7 +124,7 @@ void DownloadPathBox::editPath() {
|
|||
|
||||
void DownloadPathBox::save() {
|
||||
#ifndef OS_WIN_STORE
|
||||
auto value = _group->value();
|
||||
auto value = _group->current();
|
||||
auto computePath = [this, value] {
|
||||
if (value == Directory::Custom) {
|
||||
return _path;
|
||||
|
|
|
@ -582,7 +582,7 @@ void EditMessagesPrivacyBox(
|
|||
box->addButton(tr::lng_settings_save(), [=] {
|
||||
if (controller->session().premium()) {
|
||||
privacy->updateNewRequirePremium(
|
||||
group->value() == kOptionPremium);
|
||||
group->current() == kOptionPremium);
|
||||
box->closeBox();
|
||||
} else {
|
||||
showToast();
|
||||
|
|
|
@ -386,7 +386,7 @@ void GiftBox(
|
|||
state->buttonText.events(),
|
||||
Ui::Premium::GiftGradientStops(),
|
||||
[=] {
|
||||
const auto value = group->value();
|
||||
const auto value = group->current();
|
||||
return (value < options.size() && value >= 0)
|
||||
? options[value].botUrl
|
||||
: QString();
|
||||
|
@ -665,7 +665,7 @@ void GiftsBox(
|
|||
}
|
||||
auto invoice = api->invoice(
|
||||
users.size(),
|
||||
api->monthsFromPreset(group->value()));
|
||||
api->monthsFromPreset(group->current()));
|
||||
invoice.purpose = Payments::InvoicePremiumGiftCodeUsers{ users };
|
||||
|
||||
state->confirmButtonBusy = true;
|
||||
|
|
|
@ -840,7 +840,7 @@ void EditRestrictedBox::createUntilGroup() {
|
|||
|
||||
void EditRestrictedBox::createUntilVariants() {
|
||||
auto addVariant = [&](int value, const QString &text) {
|
||||
if (!canSave() && _untilGroup->value() != value) {
|
||||
if (!canSave() && _untilGroup->current() != value) {
|
||||
return;
|
||||
}
|
||||
_untilVariants.emplace_back(
|
||||
|
|
|
@ -25,7 +25,7 @@ void EditPeerHistoryVisibilityBox(
|
|||
|
||||
box->setTitle(tr::lng_manage_history_visibility_title());
|
||||
box->addButton(tr::lng_settings_save(), [=] {
|
||||
savedCallback(historyVisibility->value());
|
||||
savedCallback(historyVisibility->current());
|
||||
box->closeBox();
|
||||
});
|
||||
box->addButton(tr::lng_cancel(), [=] { box->closeBox(); });
|
||||
|
|
|
@ -76,7 +76,7 @@ public:
|
|||
}
|
||||
|
||||
[[nodiscard]] Privacy getPrivacy() const {
|
||||
return _controls.privacy->value();
|
||||
return _controls.privacy->current();
|
||||
}
|
||||
|
||||
[[nodiscard]] bool noForwards() const {
|
||||
|
@ -238,7 +238,7 @@ void Controller::createContent() {
|
|||
}, wrap->lifetime());
|
||||
} else {
|
||||
_controls.whoSendWrap->toggle(
|
||||
(_controls.privacy->value() == Privacy::HasUsername),
|
||||
(_controls.privacy->current() == Privacy::HasUsername),
|
||||
anim::type::instant);
|
||||
}
|
||||
auto joinToWrite = _controls.joinToWrite
|
||||
|
@ -299,7 +299,7 @@ void Controller::createContent() {
|
|||
if (_linkOnly) {
|
||||
_controls.inviteLinkWrap->show(anim::type::instant);
|
||||
} else {
|
||||
if (_controls.privacy->value() == Privacy::NoUsername) {
|
||||
if (_controls.privacy->current() == Privacy::NoUsername) {
|
||||
checkUsernameAvailability();
|
||||
}
|
||||
const auto forShowing = _dataSavedValue
|
||||
|
@ -474,7 +474,7 @@ object_ptr<Ui::RpWidget> Controller::createUsernameEdit() {
|
|||
&Ui::UsernameInput::changed,
|
||||
[this] { usernameChanged(); });
|
||||
|
||||
const auto shown = (_controls.privacy->value() == Privacy::HasUsername);
|
||||
const auto shown = (_controls.privacy->current() == Privacy::HasUsername);
|
||||
result->toggle(shown, anim::type::instant);
|
||||
|
||||
return result;
|
||||
|
@ -539,7 +539,7 @@ void Controller::checkUsernameAvailability() {
|
|||
if (!_controls.usernameInput) {
|
||||
return;
|
||||
}
|
||||
const auto initial = (_controls.privacy->value() != Privacy::HasUsername);
|
||||
const auto initial = (_controls.privacy->current() != Privacy::HasUsername);
|
||||
const auto checking = initial
|
||||
? u".bad."_q
|
||||
: getUsernameInput();
|
||||
|
@ -573,11 +573,11 @@ void Controller::checkUsernameAvailability() {
|
|||
_controls.privacy->setValue(Privacy::NoUsername);
|
||||
} else if (type == u"CHANNELS_ADMIN_PUBLIC_TOO_MUCH"_q) {
|
||||
_usernameState = UsernameState::TooMany;
|
||||
if (_controls.privacy->value() == Privacy::HasUsername) {
|
||||
if (_controls.privacy->current() == Privacy::HasUsername) {
|
||||
askUsernameRevoke();
|
||||
}
|
||||
} else if (initial) {
|
||||
if (_controls.privacy->value() == Privacy::HasUsername) {
|
||||
if (_controls.privacy->current() == Privacy::HasUsername) {
|
||||
showUsernameEmpty();
|
||||
setFocusUsername();
|
||||
}
|
||||
|
|
|
@ -1142,7 +1142,7 @@ void AccountsLimitBox(
|
|||
const auto ref = QString();
|
||||
|
||||
const auto wasAccount = &session->account();
|
||||
const auto nowAccount = accounts[group->value()];
|
||||
const auto nowAccount = accounts[group->current()];
|
||||
if (wasAccount == nowAccount) {
|
||||
Settings::ShowPremium(session, ref);
|
||||
return;
|
||||
|
|
|
@ -327,7 +327,7 @@ void RingtonesBox(
|
|||
|
||||
box->setWidth(st::boxWideWidth);
|
||||
box->addButton(tr::lng_settings_save(), [=] {
|
||||
const auto value = state->group->value();
|
||||
const auto value = state->group->current();
|
||||
auto sound = (value == kDefaultValue)
|
||||
? Data::NotifySound()
|
||||
: (value == kNoSoundValue)
|
||||
|
|
|
@ -95,7 +95,7 @@ void SelfDestructionBox::showContent() {
|
|||
|
||||
clearButtons();
|
||||
addButton(tr::lng_settings_save(), [=] {
|
||||
const auto value = _ttlGroup->value();
|
||||
const auto value = _ttlGroup->current();
|
||||
switch (_type) {
|
||||
case Type::Account:
|
||||
_session->api().selfDestruct().updateAccountTTL(value);
|
||||
|
|
|
@ -78,7 +78,7 @@ void ChooseFormatBox(
|
|||
addFormatOption(
|
||||
tr::lng_export_option_html_and_json(tr::now),
|
||||
Format::HtmlAndJson);
|
||||
box->addButton(tr::lng_settings_save(), [=] { done(group->value()); });
|
||||
box->addButton(tr::lng_settings_save(), [=] { done(group->current()); });
|
||||
box->addButton(tr::lng_cancel(), [=] { box->closeBox(); });
|
||||
}
|
||||
|
||||
|
|
|
@ -630,9 +630,9 @@ void CreateGiveawayBox(
|
|||
|
||||
const auto createCallback = [=](GiveawayType type) {
|
||||
return [=] {
|
||||
const auto was = membersGroup->value();
|
||||
const auto was = membersGroup->current();
|
||||
membersGroup->setValue(type);
|
||||
const auto now = membersGroup->value();
|
||||
const auto now = membersGroup->current();
|
||||
if (was == now) {
|
||||
base::call_delayed(
|
||||
st::defaultRippleAnimation.hideDuration,
|
||||
|
@ -990,7 +990,7 @@ void CreateGiveawayBox(
|
|||
if (state->confirmButtonBusy.current()) {
|
||||
return;
|
||||
}
|
||||
const auto type = typeGroup->value();
|
||||
const auto type = typeGroup->current();
|
||||
const auto isSpecific = (type == GiveawayType::SpecificUsers);
|
||||
const auto isRandom = (type == GiveawayType::Random);
|
||||
if (!isSpecific && !isRandom) {
|
||||
|
@ -1003,7 +1003,7 @@ void CreateGiveawayBox(
|
|||
prepaid
|
||||
? prepaid->months
|
||||
: state->apiOptions.monthsFromPreset(
|
||||
durationGroup->value()));
|
||||
durationGroup->current()));
|
||||
if (isSpecific) {
|
||||
if (state->selectedToAward.empty()) {
|
||||
return;
|
||||
|
@ -1029,7 +1029,7 @@ void CreateGiveawayBox(
|
|||
.countries = state->countriesValue.current(),
|
||||
.additionalPrize = state->additionalPrize.current(),
|
||||
.untilDate = state->dateValue.current(),
|
||||
.onlyNewSubscribers = (membersGroup->value()
|
||||
.onlyNewSubscribers = (membersGroup->current()
|
||||
== GiveawayType::OnlyNewMembers),
|
||||
.showWinners = state->showWinners.current(),
|
||||
};
|
||||
|
|
|
@ -140,7 +140,7 @@ void RequestTypeBox::setupControls(
|
|||
_height = y;
|
||||
|
||||
_submit = [=] {
|
||||
const auto value = group->hasValue() ? group->value() : -1;
|
||||
const auto value = group->hasValue() ? group->current() : -1;
|
||||
if (value >= 0) {
|
||||
submit(value);
|
||||
}
|
||||
|
|
|
@ -503,7 +503,7 @@ QPointer<Ui::RpWidget> Business::createPinnedToBottom(
|
|||
std::move(buttonText),
|
||||
std::nullopt,
|
||||
[=, options = session->api().premium().subscriptionOptions()] {
|
||||
const auto value = _radioGroup->value();
|
||||
const auto value = _radioGroup->current();
|
||||
return (value < options.size() && value >= 0)
|
||||
? options[value].botUrl
|
||||
: QString();
|
||||
|
|
|
@ -607,7 +607,7 @@ void ChooseMediaDeviceBox(
|
|||
button->finishAnimating();
|
||||
button->clicks(
|
||||
) | rpl::filter([=] {
|
||||
return (group->value() == index);
|
||||
return (group->current() == index);
|
||||
}) | rpl::start_with_next([=] {
|
||||
choose(id);
|
||||
}, button->lifetime());
|
||||
|
|
|
@ -294,7 +294,7 @@ void GlobalTTL::rebuildButtons(TimeId currentTTL) const {
|
|||
rpl::single(ttlText)),
|
||||
st::settingsButtonNoIcon));
|
||||
button->setClickedCallback([=] {
|
||||
if (_group->value() == ttl) {
|
||||
if (_group->current() == ttl) {
|
||||
return;
|
||||
}
|
||||
if (!ttl) {
|
||||
|
@ -357,7 +357,7 @@ void GlobalTTL::setupContent() {
|
|||
|
||||
show->showBox(Box(TTLMenu::TTLBox, TTLMenu::Args{
|
||||
.show = show,
|
||||
.startTtl = _group->value(),
|
||||
.startTtl = _group->current(),
|
||||
.callback = [=](TimeId ttl, Fn<void()>) { showSure(ttl, true); },
|
||||
.hideDisable = true,
|
||||
}));
|
||||
|
|
|
@ -1190,7 +1190,7 @@ QPointer<Ui::RpWidget> Premium::createPinnedToBottom(
|
|||
std::move(buttonText),
|
||||
std::nullopt,
|
||||
[=, options = session->api().premium().subscriptionOptions()] {
|
||||
const auto value = _radioGroup->value();
|
||||
const auto value = _radioGroup->current();
|
||||
return (value < options.size() && value >= 0)
|
||||
? options[value].botUrl
|
||||
: QString();
|
||||
|
|
|
@ -598,7 +598,7 @@ object_ptr<Ui::RpWidget> PhoneNumberPrivacyController::setupMiddleWidget(
|
|||
_saveAdditional = [=] {
|
||||
controller->session().api().userPrivacy().save(
|
||||
Api::UserPrivacy::Key::AddedByPhone,
|
||||
Api::UserPrivacy::Rule{ .option = group->value() });
|
||||
Api::UserPrivacy::Rule{ .option = group->current() });
|
||||
};
|
||||
|
||||
return widget;
|
||||
|
|
|
@ -1063,7 +1063,7 @@ void AddAccountsRow(
|
|||
});
|
||||
const auto index = int(state->accounts.size()) - 1;
|
||||
state->accounts[index].checkbox.setChecked(
|
||||
index == group->value(),
|
||||
index == group->current(),
|
||||
anim::type::instant);
|
||||
|
||||
widget->paintRequest(
|
||||
|
@ -1303,7 +1303,7 @@ void AddGiftOptions(
|
|||
int nowIndex = 0;
|
||||
Ui::Animations::Simple animation;
|
||||
};
|
||||
const auto wasGroupValue = group->value();
|
||||
const auto wasGroupValue = group->current();
|
||||
const auto animation = parent->lifetime().make_state<Animation>();
|
||||
animation->nowIndex = wasGroupValue;
|
||||
|
||||
|
@ -1324,7 +1324,7 @@ void AddGiftOptions(
|
|||
const auto &stCheckbox = st::defaultBoxCheckbox;
|
||||
auto radioView = std::make_unique<GradientRadioView>(
|
||||
st::defaultRadio,
|
||||
(group->hasValue() && group->value() == index));
|
||||
(group->hasValue() && group->current() == index));
|
||||
const auto radioViewRaw = radioView.get();
|
||||
const auto radio = Ui::CreateChild<Ui::Radiobutton>(
|
||||
row,
|
||||
|
@ -1468,7 +1468,7 @@ void AddGiftOptions(
|
|||
|
||||
row->setClickedCallback([=, duration = st::defaultCheck.duration] {
|
||||
group->setValue(index);
|
||||
animation->nowIndex = group->value();
|
||||
animation->nowIndex = group->current();
|
||||
animation->animation.stop();
|
||||
animation->animation.start(
|
||||
[=] { parent->update(); },
|
||||
|
|
|
@ -498,7 +498,7 @@ bool CloudList::insertTillLimit(
|
|||
void CloudList::insert(int index, const Data::CloudTheme &theme) {
|
||||
const auto id = theme.id;
|
||||
const auto value = groupValueForId(id);
|
||||
const auto checked = _group->hasValue() && (_group->value() == value);
|
||||
const auto checked = _group->hasValue() && (_group->current() == value);
|
||||
auto check = std::make_unique<CloudListCheck>(checked);
|
||||
const auto raw = check.get();
|
||||
auto button = std::make_unique<Ui::Radiobutton>(
|
||||
|
|
Loading…
Reference in a new issue