]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Never show status bar context menu away from status bar
authorFelix Ernst <felixernst@zohomail.eu>
Mon, 16 Oct 2023 14:50:07 +0000 (16:50 +0200)
committerFelix Ernst <felixernst@kde.org>
Wed, 18 Oct 2023 08:27:27 +0000 (08:27 +0000)
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.

src/statusbar/dolphinstatusbar.cpp

index 9c101b3fa8e15ca676015187dba66d0dacaefa06..9830960dc97d5aa9f15a3695452f7c75651c27bd 100644 (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);