Fix the menu position on macOS when using Qt 6.5 (#4595)

This commit is contained in:
pajlada 2023-05-02 20:50:13 +02:00 committed by GitHub
parent 379cc5761c
commit 6672adf287
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 19 deletions

View file

@ -2,7 +2,11 @@
## Unversioned ## Unversioned
## 2.4.3 ## Slated for 2.4.3
- Bugfix: Fixed the menu warping on macOS on Qt6. (#4595)
## 2.4.3 Beta
- Major: Added support for FrankerFaceZ animated emotes. (#4434) - Major: Added support for FrankerFaceZ animated emotes. (#4434)
- Minor: Added the ability to reply to a message by `Shift + Right Click`ing the username. (#4424) - Minor: Added the ability to reply to a message by `Shift + Right Click`ing the username. (#4424)

View file

@ -348,9 +348,9 @@ void Button::showMenu()
if (!this->menu_) if (!this->menu_)
return; return;
auto point = [this] { auto menuSizeHint = this->menu_->sizeHint();
auto point = this->mapToGlobal( auto point = this->mapToGlobal(
QPoint(this->width() - this->menu_->width(), this->height())); QPoint(this->width() - menuSizeHint.width(), this->height()));
auto *screen = QApplication::screenAt(point); auto *screen = QApplication::screenAt(point);
if (screen == nullptr) if (screen == nullptr)
@ -359,16 +359,13 @@ void Button::showMenu()
} }
auto bounds = screen->availableGeometry(); auto bounds = screen->availableGeometry();
if (point.y() + this->menu_->height() > bounds.bottom()) if (point.y() + menuSizeHint.height() > bounds.bottom())
{ {
point.setY(point.y() - this->menu_->height() - this->height()); // Menu doesn't fit going down, flip it to go up instead
point.setY(point.y() - menuSizeHint.height() - this->height());
} }
return point; this->menu_->popup(point);
};
this->menu_->popup(point());
this->menu_->move(point());
this->menuVisible_ = true; this->menuVisible_ = true;
} }