calls_cover_item.cpp 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 "calls/group/calls_cover_item.h"
  8. #include "boxes/peers/prepare_short_info_box.h"
  9. #include "styles/style_calls.h"
  10. #include "styles/style_info.h"
  11. namespace Calls {
  12. CoverItem::CoverItem(
  13. not_null<RpWidget*> parent,
  14. const style::Menu &stMenu,
  15. const style::ShortInfoCover &st,
  16. rpl::producer<QString> name,
  17. rpl::producer<QString> status,
  18. PreparedShortInfoUserpic userpic)
  19. : Ui::Menu::ItemBase(parent, stMenu)
  20. , _cover(
  21. this,
  22. st,
  23. std::move(name),
  24. std::move(status),
  25. std::move(userpic.value),
  26. [] { return false; })
  27. , _dummyAction(new QAction(parent))
  28. , _st(st) {
  29. setPointerCursor(false);
  30. initResizeHook(parent->sizeValue());
  31. enableMouseSelecting();
  32. enableMouseSelecting(_cover.widget());
  33. _cover.widget()->move(0, 0);
  34. _cover.moveRequests(
  35. ) | rpl::start_with_next(userpic.move, lifetime());
  36. }
  37. not_null<QAction*> CoverItem::action() const {
  38. return _dummyAction;
  39. }
  40. bool CoverItem::isEnabled() const {
  41. return false;
  42. }
  43. int CoverItem::contentHeight() const {
  44. return _st.size + st::groupCallMenu.separator.padding.bottom();
  45. }
  46. AboutItem::AboutItem(
  47. not_null<RpWidget*> parent,
  48. const style::Menu &st,
  49. TextWithEntities &&about)
  50. : Ui::Menu::ItemBase(parent, st)
  51. , _st(st)
  52. , _text(base::make_unique_q<Ui::FlatLabel>(
  53. this,
  54. rpl::single(std::move(about)),
  55. st::groupCallMenuAbout))
  56. , _dummyAction(new QAction(parent)) {
  57. setPointerCursor(false);
  58. initResizeHook(parent->sizeValue());
  59. enableMouseSelecting();
  60. enableMouseSelecting(_text.get());
  61. _text->setSelectable(true);
  62. _text->resizeToWidth(st::groupCallMenuAbout.minWidth);
  63. _text->moveToLeft(st.itemPadding.left(), st.itemPadding.top());
  64. }
  65. not_null<QAction*> AboutItem::action() const {
  66. return _dummyAction;
  67. }
  68. bool AboutItem::isEnabled() const {
  69. return false;
  70. }
  71. int AboutItem::contentHeight() const {
  72. return _st.itemPadding.top()
  73. + _text->height()
  74. + _st.itemPadding.bottom();
  75. }
  76. } // namespace Calls