mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Improved subtitle space in permissions and restrictions edit boxes.
This commit is contained in:
parent
fb8b88557e
commit
841f1afe1e
6 changed files with 32 additions and 33 deletions
|
@ -597,8 +597,6 @@ rightsHeaderLabel: FlatLabel(boxLabel) {
|
||||||
}
|
}
|
||||||
textFg: windowActiveTextFg;
|
textFg: windowActiveTextFg;
|
||||||
}
|
}
|
||||||
rightsUntilMargin: margins(0px, 8px, 0px, 20px);
|
|
||||||
rightsRankMargin: margins(0px, 7px, 0px, 20px);
|
|
||||||
|
|
||||||
groupStickersRemove: defaultMultiSelectSearchCancel;
|
groupStickersRemove: defaultMultiSelectSearchCancel;
|
||||||
groupStickersRemovePosition: point(6px, 6px);
|
groupStickersRemovePosition: point(6px, 6px);
|
||||||
|
|
|
@ -436,14 +436,16 @@ void CreateModerateMessagesBox(
|
||||||
return result;
|
return result;
|
||||||
}();
|
}();
|
||||||
|
|
||||||
auto [checkboxes, getRestrictions, changes] = CreateEditRestrictions(
|
Ui::AddSubsectionTitle(
|
||||||
box,
|
inner,
|
||||||
rpl::conditional(
|
rpl::conditional(
|
||||||
rpl::single(isSingle),
|
rpl::single(isSingle),
|
||||||
tr::lng_restrict_users_part_single_header(),
|
tr::lng_restrict_users_part_single_header(),
|
||||||
tr::lng_restrict_users_part_header(
|
tr::lng_restrict_users_part_header(
|
||||||
lt_count,
|
lt_count,
|
||||||
rpl::single(participants.size()) | tr::to_count())),
|
rpl::single(participants.size()) | tr::to_count())));
|
||||||
|
auto [checkboxes, getRestrictions, changes] = CreateEditRestrictions(
|
||||||
|
box,
|
||||||
prepareFlags,
|
prepareFlags,
|
||||||
disabledMessages,
|
disabledMessages,
|
||||||
{ .isForum = peer->isForum() });
|
{ .isForum = peer->isForum() });
|
||||||
|
|
|
@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
|
|
||||||
#include "lang/lang_keys.h"
|
#include "lang/lang_keys.h"
|
||||||
#include "ui/controls/userpic_button.h"
|
#include "ui/controls/userpic_button.h"
|
||||||
|
#include "ui/vertical_list.h"
|
||||||
#include "ui/wrap/vertical_layout.h"
|
#include "ui/wrap/vertical_layout.h"
|
||||||
#include "ui/wrap/padding_wrap.h"
|
#include "ui/wrap/padding_wrap.h"
|
||||||
#include "ui/wrap/slide_wrap.h"
|
#include "ui/wrap/slide_wrap.h"
|
||||||
|
@ -63,6 +64,10 @@ public:
|
||||||
template <typename Widget>
|
template <typename Widget>
|
||||||
Widget *addControl(object_ptr<Widget> widget, QMargins margin);
|
Widget *addControl(object_ptr<Widget> widget, QMargins margin);
|
||||||
|
|
||||||
|
[[nodiscard]] not_null<Ui::VerticalLayout*> verticalLayout() const {
|
||||||
|
return _rows;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int resizeGetHeight(int newWidth) override;
|
int resizeGetHeight(int newWidth) override;
|
||||||
void paintEvent(QPaintEvent *e) override;
|
void paintEvent(QPaintEvent *e) override;
|
||||||
|
@ -164,6 +169,10 @@ EditParticipantBox::EditParticipantBox(
|
||||||
, _hasAdminRights(hasAdminRights) {
|
, _hasAdminRights(hasAdminRights) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
not_null<Ui::VerticalLayout*> EditParticipantBox::verticalLayout() const {
|
||||||
|
return _inner->verticalLayout();
|
||||||
|
}
|
||||||
|
|
||||||
void EditParticipantBox::prepare() {
|
void EditParticipantBox::prepare() {
|
||||||
_inner = setInnerWidget(object_ptr<Inner>(
|
_inner = setInnerWidget(object_ptr<Inner>(
|
||||||
this,
|
this,
|
||||||
|
@ -279,9 +288,8 @@ void EditAdminBox::prepare() {
|
||||||
object_ptr<Ui::VerticalLayout>(this)));
|
object_ptr<Ui::VerticalLayout>(this)));
|
||||||
const auto inner = _adminControlsWrap->entity();
|
const auto inner = _adminControlsWrap->entity();
|
||||||
|
|
||||||
inner->add(
|
Ui::AddDivider(inner);
|
||||||
object_ptr<Ui::BoxContentDivider>(inner),
|
Ui::AddSkip(inner);
|
||||||
st::rightsDividerMargin);
|
|
||||||
|
|
||||||
const auto chat = peer()->asChat();
|
const auto chat = peer()->asChat();
|
||||||
const auto channel = peer()->asChannel();
|
const auto channel = peer()->asChannel();
|
||||||
|
@ -335,9 +343,9 @@ void EditAdminBox::prepare() {
|
||||||
.isForum = peer()->isForum(),
|
.isForum = peer()->isForum(),
|
||||||
.anyoneCanAddMembers = anyoneCanAddMembers,
|
.anyoneCanAddMembers = anyoneCanAddMembers,
|
||||||
};
|
};
|
||||||
|
Ui::AddSubsectionTitle(inner, tr::lng_rights_edit_admin_header());
|
||||||
auto [checkboxes, getChecked, changes] = CreateEditAdminRights(
|
auto [checkboxes, getChecked, changes] = CreateEditAdminRights(
|
||||||
inner,
|
inner,
|
||||||
tr::lng_rights_edit_admin_header(),
|
|
||||||
prepareFlags,
|
prepareFlags,
|
||||||
disabledMessages,
|
disabledMessages,
|
||||||
options);
|
options);
|
||||||
|
@ -441,9 +449,7 @@ void EditAdminBox::refreshButtons() {
|
||||||
|
|
||||||
not_null<Ui::InputField*> EditAdminBox::addRankInput(
|
not_null<Ui::InputField*> EditAdminBox::addRankInput(
|
||||||
not_null<Ui::VerticalLayout*> container) {
|
not_null<Ui::VerticalLayout*> container) {
|
||||||
container->add(
|
Ui::AddDivider(container);
|
||||||
object_ptr<Ui::BoxContentDivider>(container),
|
|
||||||
st::rightsRankMargin);
|
|
||||||
|
|
||||||
container->add(
|
container->add(
|
||||||
object_ptr<Ui::FlatLabel>(
|
object_ptr<Ui::FlatLabel>(
|
||||||
|
@ -712,9 +718,8 @@ void EditRestrictedBox::prepare() {
|
||||||
|
|
||||||
setTitle(tr::lng_rights_user_restrictions());
|
setTitle(tr::lng_rights_user_restrictions());
|
||||||
|
|
||||||
addControl(
|
Ui::AddDivider(verticalLayout());
|
||||||
object_ptr<Ui::BoxContentDivider>(this),
|
Ui::AddSkip(verticalLayout());
|
||||||
st::rightsDividerMargin);
|
|
||||||
|
|
||||||
const auto chat = peer()->asChat();
|
const auto chat = peer()->asChat();
|
||||||
const auto channel = peer()->asChannel();
|
const auto channel = peer()->asChannel();
|
||||||
|
@ -749,16 +754,20 @@ void EditRestrictedBox::prepare() {
|
||||||
return result;
|
return result;
|
||||||
}();
|
}();
|
||||||
|
|
||||||
|
Ui::AddSubsectionTitle(
|
||||||
|
verticalLayout(),
|
||||||
|
tr::lng_rights_user_restrictions_header());
|
||||||
auto [checkboxes, getRestrictions, changes] = CreateEditRestrictions(
|
auto [checkboxes, getRestrictions, changes] = CreateEditRestrictions(
|
||||||
this,
|
this,
|
||||||
tr::lng_rights_user_restrictions_header(),
|
|
||||||
prepareFlags,
|
prepareFlags,
|
||||||
disabledMessages,
|
disabledMessages,
|
||||||
{ .isForum = peer()->isForum() });
|
{ .isForum = peer()->isForum() });
|
||||||
addControl(std::move(checkboxes), QMargins());
|
addControl(std::move(checkboxes), QMargins());
|
||||||
|
|
||||||
_until = prepareRights.until;
|
_until = prepareRights.until;
|
||||||
addControl(object_ptr<Ui::BoxContentDivider>(this), st::rightsUntilMargin);
|
addControl(
|
||||||
|
object_ptr<Ui::FixedHeightWidget>(this, st::defaultVerticalListSkip));
|
||||||
|
Ui::AddDivider(verticalLayout());
|
||||||
addControl(
|
addControl(
|
||||||
object_ptr<Ui::FlatLabel>(
|
object_ptr<Ui::FlatLabel>(
|
||||||
this,
|
this,
|
||||||
|
|
|
@ -36,6 +36,8 @@ public:
|
||||||
not_null<UserData*> user,
|
not_null<UserData*> user,
|
||||||
bool hasAdminRights);
|
bool hasAdminRights);
|
||||||
|
|
||||||
|
[[nodiscard]] not_null<Ui::VerticalLayout*> verticalLayout() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void prepare() override;
|
void prepare() override;
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "ui/wrap/vertical_layout.h"
|
#include "ui/wrap/vertical_layout.h"
|
||||||
#include "ui/layers/generic_box.h"
|
#include "ui/layers/generic_box.h"
|
||||||
#include "ui/painter.h"
|
#include "ui/painter.h"
|
||||||
|
#include "ui/vertical_list.h"
|
||||||
#include "ui/widgets/labels.h"
|
#include "ui/widgets/labels.h"
|
||||||
#include "ui/widgets/checkbox.h"
|
#include "ui/widgets/checkbox.h"
|
||||||
#include "ui/widgets/buttons.h"
|
#include "ui/widgets/buttons.h"
|
||||||
|
@ -583,14 +584,6 @@ template <typename Flags>
|
||||||
ApplyDependencies(state->checkViews, dependencies, view);
|
ApplyDependencies(state->checkViews, dependencies, view);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (descriptor.header) {
|
|
||||||
container->add(
|
|
||||||
object_ptr<Ui::FlatLabel>(
|
|
||||||
container,
|
|
||||||
std::move(descriptor.header),
|
|
||||||
st::rightsHeaderLabel),
|
|
||||||
st::rightsHeaderMargin);
|
|
||||||
}
|
|
||||||
const auto addCheckbox = [&](
|
const auto addCheckbox = [&](
|
||||||
not_null<Ui::VerticalLayout*> verticalLayout,
|
not_null<Ui::VerticalLayout*> verticalLayout,
|
||||||
bool isInner,
|
bool isInner,
|
||||||
|
@ -1146,9 +1139,11 @@ void ShowEditPeerPermissionsBox(
|
||||||
return result;
|
return result;
|
||||||
}();
|
}();
|
||||||
|
|
||||||
|
Ui::AddSubsectionTitle(
|
||||||
|
inner,
|
||||||
|
tr::lng_rights_default_restrictions_header());
|
||||||
auto [checkboxes, getRestrictions, changes] = CreateEditRestrictions(
|
auto [checkboxes, getRestrictions, changes] = CreateEditRestrictions(
|
||||||
inner,
|
inner,
|
||||||
tr::lng_rights_default_restrictions_header(),
|
|
||||||
restrictions,
|
restrictions,
|
||||||
disabledMessages,
|
disabledMessages,
|
||||||
{ .isForum = peer->isForum() });
|
{ .isForum = peer->isForum() });
|
||||||
|
@ -1312,7 +1307,6 @@ std::vector<AdminRightLabel> AdminRightLabels(
|
||||||
|
|
||||||
EditFlagsControl<ChatRestrictions> CreateEditRestrictions(
|
EditFlagsControl<ChatRestrictions> CreateEditRestrictions(
|
||||||
QWidget *parent,
|
QWidget *parent,
|
||||||
rpl::producer<QString> header,
|
|
||||||
ChatRestrictions restrictions,
|
ChatRestrictions restrictions,
|
||||||
base::flat_map<ChatRestrictions, QString> disabledMessages,
|
base::flat_map<ChatRestrictions, QString> disabledMessages,
|
||||||
Data::RestrictionsSetOptions options) {
|
Data::RestrictionsSetOptions options) {
|
||||||
|
@ -1321,7 +1315,6 @@ EditFlagsControl<ChatRestrictions> CreateEditRestrictions(
|
||||||
widget.data(),
|
widget.data(),
|
||||||
NegateRestrictions(restrictions),
|
NegateRestrictions(restrictions),
|
||||||
{
|
{
|
||||||
.header = std::move(header),
|
|
||||||
.labels = NestedRestrictionLabelsList(options),
|
.labels = NestedRestrictionLabelsList(options),
|
||||||
.disabledMessages = std::move(disabledMessages),
|
.disabledMessages = std::move(disabledMessages),
|
||||||
});
|
});
|
||||||
|
@ -1338,7 +1331,6 @@ EditFlagsControl<ChatRestrictions> CreateEditRestrictions(
|
||||||
|
|
||||||
EditFlagsControl<ChatAdminRights> CreateEditAdminRights(
|
EditFlagsControl<ChatAdminRights> CreateEditAdminRights(
|
||||||
QWidget *parent,
|
QWidget *parent,
|
||||||
rpl::producer<QString> header,
|
|
||||||
ChatAdminRights rights,
|
ChatAdminRights rights,
|
||||||
base::flat_map<ChatAdminRights, QString> disabledMessages,
|
base::flat_map<ChatAdminRights, QString> disabledMessages,
|
||||||
Data::AdminRightsSetOptions options) {
|
Data::AdminRightsSetOptions options) {
|
||||||
|
@ -1347,7 +1339,6 @@ EditFlagsControl<ChatAdminRights> CreateEditAdminRights(
|
||||||
widget.data(),
|
widget.data(),
|
||||||
rights,
|
rights,
|
||||||
{
|
{
|
||||||
.header = std::move(header),
|
|
||||||
.labels = NestedAdminRightLabels(options),
|
.labels = NestedAdminRightLabels(options),
|
||||||
.disabledMessages = std::move(disabledMessages),
|
.disabledMessages = std::move(disabledMessages),
|
||||||
});
|
});
|
||||||
|
|
|
@ -73,7 +73,6 @@ struct NestedEditFlagsLabels {
|
||||||
|
|
||||||
template <typename Flags>
|
template <typename Flags>
|
||||||
struct EditFlagsDescriptor {
|
struct EditFlagsDescriptor {
|
||||||
rpl::producer<QString> header;
|
|
||||||
std::vector<NestedEditFlagsLabels<Flags>> labels;
|
std::vector<NestedEditFlagsLabels<Flags>> labels;
|
||||||
base::flat_map<Flags, QString> disabledMessages;
|
base::flat_map<Flags, QString> disabledMessages;
|
||||||
const style::SettingsButton *st = nullptr;
|
const style::SettingsButton *st = nullptr;
|
||||||
|
@ -90,7 +89,6 @@ using AdminRightLabel = EditFlagsLabel<ChatAdminRights>;
|
||||||
|
|
||||||
[[nodiscard]] auto CreateEditRestrictions(
|
[[nodiscard]] auto CreateEditRestrictions(
|
||||||
QWidget *parent,
|
QWidget *parent,
|
||||||
rpl::producer<QString> header,
|
|
||||||
ChatRestrictions restrictions,
|
ChatRestrictions restrictions,
|
||||||
base::flat_map<ChatRestrictions, QString> disabledMessages,
|
base::flat_map<ChatRestrictions, QString> disabledMessages,
|
||||||
Data::RestrictionsSetOptions options)
|
Data::RestrictionsSetOptions options)
|
||||||
|
@ -98,7 +96,6 @@ using AdminRightLabel = EditFlagsLabel<ChatAdminRights>;
|
||||||
|
|
||||||
[[nodiscard]] auto CreateEditAdminRights(
|
[[nodiscard]] auto CreateEditAdminRights(
|
||||||
QWidget *parent,
|
QWidget *parent,
|
||||||
rpl::producer<QString> header,
|
|
||||||
ChatAdminRights rights,
|
ChatAdminRights rights,
|
||||||
base::flat_map<ChatAdminRights, QString> disabledMessages,
|
base::flat_map<ChatAdminRights, QString> disabledMessages,
|
||||||
Data::AdminRightsSetOptions options)
|
Data::AdminRightsSetOptions options)
|
||||||
|
|
Loading…
Add table
Reference in a new issue