Support hidden custom title on macOS.

This commit is contained in:
John Preston 2020-08-12 21:00:03 +04:00
parent 3d5108a878
commit c45b62084c
3 changed files with 14 additions and 0 deletions

View file

@ -197,6 +197,9 @@ WindowHelper::WindowHelper(not_null<RpWidget*> window)
_private->customTitleHeight()) _private->customTitleHeight())
: nullptr) : nullptr)
, _body(Ui::CreateChild<RpWidget>(window.get())) { , _body(Ui::CreateChild<RpWidget>(window.get())) {
if (_title->shouldBeHidden()) {
toggleCustomTitle(false);
}
init(); init();
} }
@ -218,10 +221,16 @@ void WindowHelper::setTitle(const QString &title) {
void WindowHelper::setTitleStyle(const style::WindowTitle &st) { void WindowHelper::setTitleStyle(const style::WindowTitle &st) {
if (_title) { if (_title) {
_title->setStyle(st); _title->setStyle(st);
if (_title->shouldBeHidden()) {
toggleCustomTitle(false);
}
} }
} }
void WindowHelper::toggleCustomTitle(bool visible) { void WindowHelper::toggleCustomTitle(bool visible) {
if (_title->shouldBeHidden()) {
visible = false;
}
if (!_title || _title->isHidden() != visible) { if (!_title || _title->isHidden() != visible) {
return; return;
} }

View file

@ -29,6 +29,7 @@ public:
void setText(const QString &text); void setText(const QString &text);
void setStyle(const style::WindowTitle &st); void setStyle(const style::WindowTitle &st);
[[nodiscard]] QString text() const; [[nodiscard]] QString text() const;
[[nodiscard]] bool shouldBeHidden() const;
protected: protected:
void paintEvent(QPaintEvent *e) override; void paintEvent(QPaintEvent *e) override;

View file

@ -38,6 +38,10 @@ void TitleWidget::setStyle(const style::WindowTitle &st) {
update(); update();
} }
bool TitleWidget::shouldBeHidden() const {
return !_st->height;
}
QString TitleWidget::text() const { QString TitleWidget::text() const {
return _text; return _text;
} }