rp_window.cpp 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. // This file is part of Desktop App Toolkit,
  2. // a set of libraries for developing nice desktop applications.
  3. //
  4. // For license and copyright information please follow this link:
  5. // https://github.com/desktop-app/legal/blob/master/LEGAL
  6. //
  7. #include "ui/widgets/rp_window.h"
  8. #include "ui/platform/ui_platform_window.h"
  9. namespace Ui {
  10. RpWindow::RpWindow(QWidget *parent)
  11. : RpWidget(parent)
  12. , _helper(Platform::CreateWindowHelper(this)) {
  13. Expects(_helper != nullptr);
  14. _helper->initInWindow(this);
  15. hide();
  16. }
  17. RpWindow::~RpWindow() = default;
  18. not_null<RpWidget*> RpWindow::body() {
  19. return _helper->body();
  20. }
  21. not_null<const RpWidget*> RpWindow::body() const {
  22. return _helper->body().get();
  23. }
  24. QMargins RpWindow::frameMargins() const {
  25. return _helper->frameMargins();
  26. }
  27. int RpWindow::additionalContentPadding() const {
  28. return _helper->additionalContentPadding();
  29. }
  30. rpl::producer<int> RpWindow::additionalContentPaddingValue() const {
  31. return _helper->additionalContentPaddingValue();
  32. }
  33. auto RpWindow::hitTestRequests() const
  34. -> rpl::producer<not_null<Platform::HitTestRequest*>> {
  35. return _helper->hitTestRequests();
  36. }
  37. rpl::producer<Platform::HitTestResult> RpWindow::systemButtonOver() const {
  38. return _helper->systemButtonOver();
  39. }
  40. rpl::producer<Platform::HitTestResult> RpWindow::systemButtonDown() const {
  41. return _helper->systemButtonDown();
  42. }
  43. void RpWindow::overrideSystemButtonOver(Platform::HitTestResult button) {
  44. _helper->overrideSystemButtonOver(button);
  45. }
  46. void RpWindow::overrideSystemButtonDown(Platform::HitTestResult button) {
  47. _helper->overrideSystemButtonDown(button);
  48. }
  49. void RpWindow::setTitle(const QString &title) {
  50. _helper->setTitle(title);
  51. }
  52. void RpWindow::setTitleStyle(const style::WindowTitle &st) {
  53. _helper->setTitleStyle(st);
  54. }
  55. void RpWindow::setNativeFrame(bool enabled) {
  56. _helper->setNativeFrame(enabled);
  57. }
  58. void RpWindow::setMinimumSize(QSize size) {
  59. _helper->setMinimumSize(size);
  60. }
  61. void RpWindow::setFixedSize(QSize size) {
  62. _helper->setFixedSize(size);
  63. }
  64. void RpWindow::setStaysOnTop(bool enabled) {
  65. _helper->setStaysOnTop(enabled);
  66. }
  67. void RpWindow::setGeometry(QRect rect) {
  68. _helper->setGeometry(rect);
  69. }
  70. void RpWindow::showFullScreen() {
  71. _helper->showFullScreen();
  72. }
  73. void RpWindow::showNormal() {
  74. _helper->showNormal();
  75. }
  76. void RpWindow::close() {
  77. _helper->close();
  78. }
  79. void RpWindow::setBodyTitleArea(
  80. Fn<WindowTitleHitTestFlags(QPoint)> testMethod) {
  81. _helper->setBodyTitleArea(std::move(testMethod));
  82. }
  83. bool RpWindow::mousePressCancelled() const {
  84. return _helper->mousePressCancelled();
  85. }
  86. int RpWindow::manualRoundingRadius() const {
  87. return _helper->manualRoundingRadius();
  88. }
  89. const style::TextStyle &RpWindow::titleTextStyle() const {
  90. return _helper->titleTextStyle();
  91. }
  92. } // namespace Ui