info_profile_members_controllers.cpp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. This file is part of Telegram Desktop,
  3. the official desktop application for the Telegram messaging service.
  4. For license and copyright information please follow this link:
  5. https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
  6. */
  7. #include "info/profile/info_profile_members_controllers.h"
  8. #include "boxes/peers/edit_participants_box.h"
  9. #include "info/profile/info_profile_values.h"
  10. #include "data/data_chat.h"
  11. #include "data/data_user.h"
  12. #include "ui/unread_badge.h"
  13. #include "lang/lang_keys.h"
  14. #include "styles/style_info.h"
  15. #include "styles/style_boxes.h"
  16. #include "styles/style_dialogs.h"
  17. namespace Info {
  18. namespace Profile {
  19. MemberListRow::MemberListRow(
  20. not_null<UserData*> user,
  21. Type type)
  22. : PeerListRowWithLink(user)
  23. , _type(type) {
  24. setType(type);
  25. }
  26. void MemberListRow::setType(Type type) {
  27. _type = type;
  28. PeerListRowWithLink::setActionLink(!_type.adminRank.isEmpty()
  29. ? _type.adminRank
  30. : (_type.rights == Rights::Creator)
  31. ? tr::lng_owner_badge(tr::now)
  32. : (_type.rights == Rights::Admin)
  33. ? tr::lng_admin_badge(tr::now)
  34. : QString());
  35. }
  36. bool MemberListRow::rightActionDisabled() const {
  37. return true;
  38. }
  39. QMargins MemberListRow::rightActionMargins() const {
  40. const auto skip = st::contactsCheckPosition.x();
  41. return QMargins(
  42. skip,
  43. st::defaultPeerListItem.namePosition.y(),
  44. st::defaultPeerListItem.photoPosition.x() + skip,
  45. 0);
  46. }
  47. not_null<UserData*> MemberListRow::user() const {
  48. return peer()->asUser();
  49. }
  50. void MemberListRow::refreshStatus() {
  51. if (user()->isBot()) {
  52. const auto seesAllMessages = (user()->botInfo->readsAllHistory
  53. || _type.rights != Rights::Normal);
  54. setCustomStatus(seesAllMessages
  55. ? tr::lng_status_bot_reads_all(tr::now)
  56. : tr::lng_status_bot_not_reads_all(tr::now));
  57. } else {
  58. PeerListRow::refreshStatus();
  59. }
  60. }
  61. std::unique_ptr<ParticipantsBoxController> CreateMembersController(
  62. not_null<Window::SessionNavigation*> navigation,
  63. not_null<PeerData*> peer) {
  64. return std::make_unique<ParticipantsBoxController>(
  65. navigation,
  66. peer,
  67. ParticipantsBoxController::Role::Profile);
  68. }
  69. } // namespace Profile
  70. } // namespace Info