1
0
mirror of https://invent.kde.org/system/dolphin synced 2024-07-07 10:51:45 +00:00

Never show status bar context menu away from status bar

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.
This commit is contained in:
Felix Ernst 2023-10-16 16:50:07 +02:00 committed by Felix Ernst
parent dfbd432d3f
commit f38d788a97

View File

@ -269,7 +269,7 @@ void DolphinStatusBar::contextMenuEvent(QContextMenuEvent *event)
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);