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" = "edited";
"lng_edited_date" = "Edited: {date}"; "lng_edited_date" = "Edited: {date}";
"lng_admin_badge" = "admin"; "lng_admin_badge" = "admin";
"lng_owner_badge" = "owner";
"lng_channel_badge" = "channel"; "lng_channel_badge" = "channel";
"lng_fast_reply" = "Reply"; "lng_fast_reply" = "Reply";
"lng_cancel_edit_post_sure" = "Cancel editing?"; "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" = "Manage permissions";
"lng_rights_edit_admin_header" = "What can this admin do?"; "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_name" = "Custom title";
"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_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_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."; "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; textFg: windowActiveTextFg;
} }
rightsUntilMargin: margins(0px, 8px, 0px, 20px); rightsUntilMargin: margins(0px, 8px, 0px, 20px);
rightsRankMargin: margins(0px, 8px, 0px, 2px); rightsRankMargin: margins(0px, 16px, 0px, 20px);
mutePhotoButton: UserpicButton(defaultUserpicButton) { mutePhotoButton: UserpicButton(defaultUserpicButton) {
size: size(40px, 40px); size: size(40px, 40px);
@ -994,3 +994,16 @@ slowmodeLabelsMargin: margins(0px, 5px, 0px, 0px);
slowmodeLabel: LabelSimple(defaultLabelSimple) { slowmodeLabel: LabelSimple(defaultLabelSimple) {
textFg: windowSubTextFg; 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); ))->setDuration(0);
} }
_aboutAddAdmins = addControl( _aboutAddAdmins = addControl(
object_ptr<Ui::FlatLabel>(this, st::boxLabel), object_ptr<Ui::FlatLabel>(this, st::boxDividerLabel),
st::rightsAboutMargin); st::rightsAboutMargin);
std::move( std::move(
selectedFlags selectedFlags
@ -405,11 +405,18 @@ not_null<Ui::InputField*> EditAdminBox::addRankInput() {
object_ptr<BoxContentDivider>(this), object_ptr<BoxContentDivider>(this),
st::rightsRankMargin); st::rightsRankMargin);
addControl(
object_ptr<Ui::FlatLabel>(
this,
tr::lng_rights_edit_admin_rank_name(),
st::rightsHeaderLabel),
st::rightsHeaderMargin);
const auto result = addControl( const auto result = addControl(
object_ptr<Ui::InputField>( object_ptr<Ui::InputField>(
this, this,
st::defaultInputField, st::customBadgeField,
tr::lng_rights_edit_admin_rank_name(), (amCreator() ? tr::lng_owner_badge : tr::lng_admin_badge)(),
_oldRank), _oldRank),
st::rightsAboutMargin); st::rightsAboutMargin);
result->setMaxLength(kAdminRoleLimit); result->setMaxLength(kAdminRoleLimit);
@ -422,7 +429,9 @@ not_null<Ui::InputField*> EditAdminBox::addRankInput() {
addControl( addControl(
object_ptr<Ui::FlatLabel>( object_ptr<Ui::FlatLabel>(
this, 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::boxDividerLabel),
st::rightsAboutMargin); st::rightsAboutMargin);

View File

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