Increased clickable area for each item in EditPeerHistoryVisibilityBox.

This commit is contained in:
23rd 2024-04-11 22:55:23 +03:00 committed by John Preston
parent abe83ccb8f
commit 39ed7d7f4c

View file

@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "lang/lang_keys.h" #include "lang/lang_keys.h"
#include "ui/layers/generic_box.h" #include "ui/layers/generic_box.h"
#include "ui/widgets/buttons.h"
#include "ui/widgets/checkbox.h" #include "ui/widgets/checkbox.h"
#include "ui/widgets/labels.h" #include "ui/widgets/labels.h"
#include "styles/style_layers.h" #include "styles/style_layers.h"
@ -23,6 +24,17 @@ void EditPeerHistoryVisibilityBox(
Ui::RadioenumGroup<HistoryVisibility> Ui::RadioenumGroup<HistoryVisibility>
>(historyVisibilitySavedValue); >(historyVisibilitySavedValue);
const auto addButton = [=](
not_null<Ui::RpWidget*> inner,
HistoryVisibility v) {
const auto button = Ui::CreateChild<Ui::AbstractButton>(inner.get());
inner->sizeValue(
) | rpl::start_with_next([=](const QSize &s) {
button->resize(s);
}, button->lifetime());
button->setClickedCallback([=] { historyVisibility->setValue(v); });
};
box->setTitle(tr::lng_manage_history_visibility_title()); box->setTitle(tr::lng_manage_history_visibility_title());
box->addButton(tr::lng_settings_save(), [=] { box->addButton(tr::lng_settings_save(), [=] {
savedCallback(historyVisibility->current()); savedCallback(historyVisibility->current());
@ -31,32 +43,36 @@ void EditPeerHistoryVisibilityBox(
box->addButton(tr::lng_cancel(), [=] { box->closeBox(); }); box->addButton(tr::lng_cancel(), [=] { box->closeBox(); });
box->addSkip(st::editPeerHistoryVisibilityTopSkip); box->addSkip(st::editPeerHistoryVisibilityTopSkip);
box->addRow(object_ptr<Ui::Radioenum<HistoryVisibility>>( const auto visible = box->addRow(object_ptr<Ui::VerticalLayout>(box));
visible->add(object_ptr<Ui::Radioenum<HistoryVisibility>>(
box, box,
historyVisibility, historyVisibility,
HistoryVisibility::Visible, HistoryVisibility::Visible,
tr::lng_manage_history_visibility_shown(tr::now), tr::lng_manage_history_visibility_shown(tr::now),
st::defaultBoxCheckbox)); st::defaultBoxCheckbox));
box->addRow( visible->add(
object_ptr<Ui::FlatLabel>( object_ptr<Ui::FlatLabel>(
box, box,
tr::lng_manage_history_visibility_shown_about(), tr::lng_manage_history_visibility_shown_about(),
st::editPeerPrivacyLabel), st::editPeerPrivacyLabel),
st::editPeerPreHistoryLabelMargins + st::boxRowPadding); st::editPeerPreHistoryLabelMargins);
addButton(visible, HistoryVisibility::Visible);
box->addSkip(st::editPeerHistoryVisibilityTopSkip); box->addSkip(st::editPeerHistoryVisibilityTopSkip);
box->addRow(object_ptr<Ui::Radioenum<HistoryVisibility>>( const auto hidden = box->addRow(object_ptr<Ui::VerticalLayout>(box));
hidden->add(object_ptr<Ui::Radioenum<HistoryVisibility>>(
box, box,
historyVisibility, historyVisibility,
HistoryVisibility::Hidden, HistoryVisibility::Hidden,
tr::lng_manage_history_visibility_hidden(tr::now), tr::lng_manage_history_visibility_hidden(tr::now),
st::defaultBoxCheckbox)); st::defaultBoxCheckbox));
box->addRow( hidden->add(
object_ptr<Ui::FlatLabel>( object_ptr<Ui::FlatLabel>(
box, box,
(isLegacy (isLegacy
? tr::lng_manage_history_visibility_hidden_legacy ? tr::lng_manage_history_visibility_hidden_legacy
: tr::lng_manage_history_visibility_hidden_about)(), : tr::lng_manage_history_visibility_hidden_about)(),
st::editPeerPrivacyLabel), st::editPeerPrivacyLabel),
st::editPeerPreHistoryLabelMargins + st::boxRowPadding); st::editPeerPreHistoryLabelMargins);
addButton(hidden, HistoryVisibility::Hidden);
} }