Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
May 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

## 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)
- Minor: Added the ability to reply to a message by `Shift + Right Click`ing the username. (#4424)
Expand Down
33 changes: 15 additions & 18 deletions src/widgets/helper/Button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,27 +348,24 @@ void Button::showMenu()
if (!this->menu_)
return;

auto point = [this] {
auto point = this->mapToGlobal(
QPoint(this->width() - this->menu_->width(), this->height()));
auto menuSizeHint = this->menu_->sizeHint();
auto point = this->mapToGlobal(
QPoint(this->width() - menuSizeHint.width(), this->height()));

auto *screen = QApplication::screenAt(point);
if (screen == nullptr)
{
screen = QApplication::primaryScreen();
}
auto bounds = screen->availableGeometry();

if (point.y() + this->menu_->height() > bounds.bottom())
{
point.setY(point.y() - this->menu_->height() - this->height());
}
auto *screen = QApplication::screenAt(point);
if (screen == nullptr)
{
screen = QApplication::primaryScreen();
}
auto bounds = screen->availableGeometry();

return point;
};
if (point.y() + menuSizeHint.height() > bounds.bottom())
{
// Menu doesn't fit going down, flip it to go up instead
point.setY(point.y() - menuSizeHint.height() - this->height());
}

this->menu_->popup(point());
this->menu_->move(point());
this->menu_->popup(point);
this->menuVisible_ = true;
}

Expand Down