From 291468a9abbbe4fa28c83b1f5748cfee7a67bfe9 Mon Sep 17 00:00:00 2001 From: nowrep Date: Fri, 9 Mar 2012 16:02:27 +0100 Subject: [PATCH] Showing context menus on event's position. - some keyboards (usually in laptops) have special key for showing context menu - context menu events from keyboard will now be shown on correct position (not on mouse position) --- src/lib/bookmarks/bookmarkstoolbar.cpp | 4 ++-- src/lib/navigation/locationbar.cpp | 2 +- src/lib/navigation/websearchbar.cpp | 2 +- src/lib/popupwindow/popupwebview.cpp | 2 +- src/lib/webview/tabbar.cpp | 2 +- src/lib/webview/tabbedwebview.cpp | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/lib/bookmarks/bookmarkstoolbar.cpp b/src/lib/bookmarks/bookmarkstoolbar.cpp index 22e063c58..984266652 100644 --- a/src/lib/bookmarks/bookmarkstoolbar.cpp +++ b/src/lib/bookmarks/bookmarkstoolbar.cpp @@ -89,7 +89,7 @@ void BookmarksToolbar::customContextMenuRequested(const QPoint &pos) menu.addAction(tr("&Hide Toolbar"), this, SLOT(hidePanel())); //Prevent choosing first option with double rightclick - QPoint position = QCursor::pos(); + QPoint position = mapToGlobal(pos); QPoint p(position.x(), position.y() + 1); menu.exec(p); } @@ -113,7 +113,7 @@ void BookmarksToolbar::showBookmarkContextMenu(const QPoint &pos) menu.addAction(IconProvider::fromTheme("list-remove"), tr("Remove bookmark"), this, SLOT(removeButton()))->setData(buttonPointer); //Prevent choosing first option with double rightclick - QPoint position = QCursor::pos(); + QPoint position = button->mapToGlobal(pos); QPoint p(position.x(), position.y() + 1); menu.exec(p); } diff --git a/src/lib/navigation/locationbar.cpp b/src/lib/navigation/locationbar.cpp index ae1924a3c..0f5b03b29 100644 --- a/src/lib/navigation/locationbar.cpp +++ b/src/lib/navigation/locationbar.cpp @@ -312,7 +312,7 @@ void LocationBar::contextMenuEvent(QContextMenuEvent* event) m_pasteAndGoAction->setEnabled(!QApplication::clipboard()->text().isEmpty()); //Prevent choosing first option with double rightclick - QPoint pos = QCursor::pos(); + QPoint pos = mapToGlobal(event->pos()); QPoint p(pos.x(), pos.y() + 1); m_menu->popup(p); } diff --git a/src/lib/navigation/websearchbar.cpp b/src/lib/navigation/websearchbar.cpp index a4e6bcd01..eca99038c 100644 --- a/src/lib/navigation/websearchbar.cpp +++ b/src/lib/navigation/websearchbar.cpp @@ -276,7 +276,7 @@ void WebSearchBar::contextMenuEvent(QContextMenuEvent* event) m_pasteAndGoAction->setEnabled(!QApplication::clipboard()->text().isEmpty()); //Prevent choosing first option with double rightclick - QPoint pos = QCursor::pos(); + QPoint pos = mapToGlobal(event->pos()); QPoint p(pos.x(), pos.y() + 1); m_menu->popup(p); } diff --git a/src/lib/popupwindow/popupwebview.cpp b/src/lib/popupwindow/popupwebview.cpp index 8c555937b..5a33d2e07 100644 --- a/src/lib/popupwindow/popupwebview.cpp +++ b/src/lib/popupwindow/popupwebview.cpp @@ -85,7 +85,7 @@ void PopupWebView::contextMenuEvent(QContextMenuEvent* event) if (!m_menu->isEmpty()) { //Prevent choosing first option with double rightclick - const QPoint &pos = QCursor::pos(); + const QPoint &pos = mapToGlobal(event->pos()); QPoint p(pos.x(), pos.y() + 1); m_menu->popup(p); return; diff --git a/src/lib/webview/tabbar.cpp b/src/lib/webview/tabbar.cpp index 50a518b75..704062e3e 100644 --- a/src/lib/webview/tabbar.cpp +++ b/src/lib/webview/tabbar.cpp @@ -154,7 +154,7 @@ void TabBar::contextMenuRequested(const QPoint &position) } //Prevent choosing first option with double rightclick - const QPoint &pos = QCursor::pos(); + const QPoint &pos = mapToGlobal(position); QPoint p(pos.x(), pos.y() + 1); menu.exec(p); diff --git a/src/lib/webview/tabbedwebview.cpp b/src/lib/webview/tabbedwebview.cpp index 7fc75311d..b1a4943d7 100644 --- a/src/lib/webview/tabbedwebview.cpp +++ b/src/lib/webview/tabbedwebview.cpp @@ -329,7 +329,7 @@ void TabbedWebView::contextMenuEvent(QContextMenuEvent* event) if (!m_menu->isEmpty()) { //Prevent choosing first option with double rightclick - const QPoint &pos = QCursor::pos(); + const QPoint &pos = mapToGlobal(event->pos()); QPoint p(pos.x(), pos.y() + 1); m_menu->popup(p);