profile_block_widget.cpp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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 "profile/profile_block_widget.h"
  8. #include "ui/painter.h"
  9. #include "styles/style_profile.h"
  10. #include "styles/style_widgets.h"
  11. namespace Profile {
  12. BlockWidget::BlockWidget(
  13. QWidget *parent,
  14. PeerData *peer,
  15. const QString &title) : RpWidget(parent)
  16. , _peer(peer)
  17. , _title(title) {
  18. }
  19. int BlockWidget::contentTop() const {
  20. return emptyTitle() ? 0 : (st::profileBlockMarginTop + st::profileBlockTitleHeight);
  21. }
  22. void BlockWidget::paintEvent(QPaintEvent *e) {
  23. Painter p(this);
  24. paintTitle(p);
  25. paintContents(p);
  26. }
  27. void BlockWidget::paintTitle(Painter &p) {
  28. if (emptyTitle()) return;
  29. p.setFont(st::profileBlockTitleFont);
  30. p.setPen(st::profileBlockTitleFg);
  31. int titleLeft = st::profileBlockTitlePosition.x();
  32. int titleTop = st::profileBlockMarginTop + st::profileBlockTitlePosition.y();
  33. p.drawTextLeft(titleLeft, titleTop, width(), _title);
  34. }
  35. } // namespace Profile