profile_block_widget.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. #pragma once
  8. #include "ui/rp_widget.h"
  9. namespace Profile {
  10. class SectionMemento;
  11. class BlockWidget : public Ui::RpWidget {
  12. public:
  13. BlockWidget(QWidget *parent, PeerData *peer, const QString &title);
  14. virtual void showFinished() {
  15. }
  16. virtual void saveState(not_null<SectionMemento*> memento) {
  17. }
  18. virtual void restoreState(not_null<SectionMemento*> memento) {
  19. }
  20. protected:
  21. void paintEvent(QPaintEvent *e) override;
  22. virtual void paintContents(Painter &p) {
  23. }
  24. // Where does the block content start (after the title).
  25. int contentTop() const;
  26. // Resizes content and counts natural widget height for the desired width.
  27. int resizeGetHeight(int newWidth) override = 0;
  28. void contentSizeUpdated() {
  29. resizeToWidth(width());
  30. }
  31. PeerData *peer() const {
  32. return _peer;
  33. }
  34. bool emptyTitle() const {
  35. return _title.isEmpty();
  36. }
  37. private:
  38. void paintTitle(Painter &p);
  39. PeerData *_peer;
  40. QString _title;
  41. };
  42. } // namespace Profile