tabbed_section.cpp 2.0 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 "chat_helpers/tabbed_section.h"
  8. #include "chat_helpers/tabbed_selector.h"
  9. #include "ui/ui_utility.h"
  10. #include "window/window_session_controller.h"
  11. #include "styles/style_chat_helpers.h"
  12. namespace ChatHelpers {
  13. object_ptr<Window::SectionWidget> TabbedMemento::createWidget(
  14. QWidget *parent,
  15. not_null<Window::SessionController*> controller,
  16. Window::Column column,
  17. const QRect &geometry) {
  18. auto result = object_ptr<TabbedSection>(parent, controller);
  19. result->setGeometry(geometry);
  20. return result;
  21. }
  22. TabbedSection::TabbedSection(
  23. QWidget *parent,
  24. not_null<Window::SessionController*> controller)
  25. : Window::SectionWidget(parent, controller)
  26. , _selector(controller->tabbedSelector()) {
  27. if (Ui::InFocusChain(_selector)) {
  28. parent->window()->setFocus();
  29. }
  30. _selector->setParent(this);
  31. _selector->setRoundRadius(0);
  32. _selector->setGeometry(rect());
  33. _selector->showStarted();
  34. _selector->show();
  35. _selector->setAfterShownCallback(nullptr);
  36. _selector->setBeforeHidingCallback(nullptr);
  37. setAttribute(Qt::WA_OpaquePaintEvent, true);
  38. }
  39. void TabbedSection::beforeHiding() {
  40. _selector->beforeHiding();
  41. }
  42. void TabbedSection::afterShown() {
  43. _selector->afterShown();
  44. }
  45. void TabbedSection::resizeEvent(QResizeEvent *e) {
  46. _selector->setGeometry(rect());
  47. }
  48. void TabbedSection::showFinishedHook() {
  49. afterShown();
  50. }
  51. bool TabbedSection::showInternal(
  52. not_null<Window::SectionMemento*> memento,
  53. const Window::SectionShow &params) {
  54. return false;
  55. }
  56. bool TabbedSection::floatPlayerHandleWheelEvent(QEvent *e) {
  57. return _selector->floatPlayerHandleWheelEvent(e);
  58. }
  59. QRect TabbedSection::floatPlayerAvailableRect() {
  60. return _selector->floatPlayerAvailableRect();
  61. }
  62. TabbedSection::~TabbedSection() {
  63. beforeHiding();
  64. controller()->takeTabbedSelectorOwnershipFrom(this);
  65. }
  66. } // namespace ChatHelpers