Improve custom badge input phrases.

This commit is contained in:
John Preston 2019-07-23 11:06:31 +02:00
parent 4d92d74de0
commit 2ed5552279
4 changed files with 41 additions and 15 deletions

View File

@ -1092,6 +1092,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_edited" = "edited";
"lng_edited_date" = "Edited: {date}";
"lng_admin_badge" = "admin";
"lng_owner_badge" = "owner";
"lng_channel_badge" = "channel";
"lng_fast_reply" = "Reply";
"lng_cancel_edit_post_sure" = "Cancel editing?";
@ -1628,8 +1629,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_rights_edit_admin" = "Manage permissions";
"lng_rights_edit_admin_header" = "What can this admin do?";
"lng_rights_edit_admin_rank_name" = "Custom admin badge (optional)";
"lng_rights_edit_admin_rank_about" = "You can specify a custom badge that will be shown in all messages from this admin.";
"lng_rights_edit_admin_rank_name" = "Custom title";
"lng_rights_edit_admin_rank_about" = "A custom title that will be shown to all members instead of '{title}'.";
"lng_rights_about_add_admins_yes" = "This admin will be able to add new admins with the same (or more limited) permissions.";
"lng_rights_about_add_admins_no" = "This admin will not be able to add new admins.";

View File

@ -761,7 +761,7 @@ rightsHeaderLabel: FlatLabel(boxLabel) {
textFg: windowActiveTextFg;
}
rightsUntilMargin: margins(0px, 8px, 0px, 20px);
rightsRankMargin: margins(0px, 8px, 0px, 2px);
rightsRankMargin: margins(0px, 16px, 0px, 20px);
mutePhotoButton: UserpicButton(defaultUserpicButton) {
size: size(40px, 40px);
@ -994,3 +994,16 @@ slowmodeLabelsMargin: margins(0px, 5px, 0px, 0px);
slowmodeLabel: LabelSimple(defaultLabelSimple) {
textFg: windowSubTextFg;
}
customBadgeField: InputField(defaultInputField) {
textMargins: margins(2px, 7px, 2px, 0px);
placeholderFg: placeholderFg;
placeholderFgActive: placeholderFgActive;
placeholderFgError: placeholderFgActive;
placeholderMargins: margins(0px, 0px, 0px, 0px);
placeholderScale: 0.;
placeholderFont: normalFont;
heightMin: 32px;
}

View File

@ -365,7 +365,7 @@ void EditAdminBox::prepare() {
))->setDuration(0);
}
_aboutAddAdmins = addControl(
object_ptr<Ui::FlatLabel>(this, st::boxLabel),
object_ptr<Ui::FlatLabel>(this, st::boxDividerLabel),
st::rightsAboutMargin);
std::move(
selectedFlags
@ -405,11 +405,18 @@ not_null<Ui::InputField*> EditAdminBox::addRankInput() {
object_ptr<BoxContentDivider>(this),
st::rightsRankMargin);
addControl(
object_ptr<Ui::FlatLabel>(
this,
tr::lng_rights_edit_admin_rank_name(),
st::rightsHeaderLabel),
st::rightsHeaderMargin);
const auto result = addControl(
object_ptr<Ui::InputField>(
this,
st::defaultInputField,
tr::lng_rights_edit_admin_rank_name(),
st::customBadgeField,
(amCreator() ? tr::lng_owner_badge : tr::lng_admin_badge)(),
_oldRank),
st::rightsAboutMargin);
result->setMaxLength(kAdminRoleLimit);
@ -422,7 +429,9 @@ not_null<Ui::InputField*> EditAdminBox::addRankInput() {
addControl(
object_ptr<Ui::FlatLabel>(
this,
tr::lng_rights_edit_admin_rank_about(),
tr::lng_rights_edit_admin_rank_about(
lt_title,
(amCreator() ? tr::lng_owner_badge : tr::lng_admin_badge)()),
st::boxDividerLabel),
st::rightsAboutMargin);

View File

@ -650,15 +650,18 @@ void HistoryMessage::refreshMessageBadge() {
}
const auto info = channel->mgInfo.get();
const auto i = channel->mgInfo->admins.find(peerToUser(user->id));
return (i == channel->mgInfo->admins.end())
? (info->creator != user
? QString()
: info->creatorRank.isEmpty()
? tr::lng_admin_badge(tr::now)
: info->creatorRank)
: i->second.isEmpty()
const auto custom = (i != channel->mgInfo->admins.end())
? i->second
: (info->creator == user)
? info->creatorRank
: QString();
return !custom.isEmpty()
? custom
: (info->creator == user)
? tr::lng_owner_badge(tr::now)
: (i != channel->mgInfo->admins.end())
? tr::lng_admin_badge(tr::now)
: i->second;
: QString();
}();
if (text.isEmpty()) {
_messageBadge.clear();