The status bar context menu was hard-coded to always appear at the
cursor position. However, context menus can also be triggered by
keyboard, for example with the Menu key, in which case it makes no
sense to show the context menu at whatever random position the
mouse cursor currently is.
Instead invoke the context menu in the middle of the status bar
when it is opened by keyboard.
showSpaceInfoAction->setCheckable(true);
showSpaceInfoAction->setChecked(GeneralSettings::showSpaceInfo());
- const QAction *action = menu.exec(QCursor::pos());
+ const QAction *action = menu.exec(event->reason() == QContextMenuEvent::Reason::Mouse ? QCursor::pos() : mapToGlobal(QPoint(width() / 2, height() / 2)));
if (action == showZoomSliderAction) {
const bool visible = showZoomSliderAction->isChecked();
GeneralSettings::setShowZoomSlider(visible);