From 2ed55522792f387dfff774019ac5f6df1e772f1b Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 23 Jul 2019 11:06:31 +0200 Subject: [PATCH] Improve custom badge input phrases. --- Telegram/Resources/langs/lang.strings | 5 +++-- Telegram/SourceFiles/boxes/boxes.style | 15 ++++++++++++++- .../boxes/peers/edit_participant_box.cpp | 17 +++++++++++++---- .../SourceFiles/history/history_message.cpp | 19 +++++++++++-------- 4 files changed, 41 insertions(+), 15 deletions(-) diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 2bc56a1b9..b487a01ae 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -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."; diff --git a/Telegram/SourceFiles/boxes/boxes.style b/Telegram/SourceFiles/boxes/boxes.style index c91ea0fed..713551373 100644 --- a/Telegram/SourceFiles/boxes/boxes.style +++ b/Telegram/SourceFiles/boxes/boxes.style @@ -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; +} diff --git a/Telegram/SourceFiles/boxes/peers/edit_participant_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_participant_box.cpp index 65bb708f9..8194ee4fe 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_participant_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_participant_box.cpp @@ -365,7 +365,7 @@ void EditAdminBox::prepare() { ))->setDuration(0); } _aboutAddAdmins = addControl( - object_ptr(this, st::boxLabel), + object_ptr(this, st::boxDividerLabel), st::rightsAboutMargin); std::move( selectedFlags @@ -405,11 +405,18 @@ not_null EditAdminBox::addRankInput() { object_ptr(this), st::rightsRankMargin); + addControl( + object_ptr( + this, + tr::lng_rights_edit_admin_rank_name(), + st::rightsHeaderLabel), + st::rightsHeaderMargin); + const auto result = addControl( object_ptr( 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 EditAdminBox::addRankInput() { addControl( object_ptr( 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); diff --git a/Telegram/SourceFiles/history/history_message.cpp b/Telegram/SourceFiles/history/history_message.cpp index b6b8d80a4..80e083733 100644 --- a/Telegram/SourceFiles/history/history_message.cpp +++ b/Telegram/SourceFiles/history/history_message.cpp @@ -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();