From 6551c000fc68134932cdc21f2cc7086b34bff30b Mon Sep 17 00:00:00 2001 From: Peter Penz Date: Sat, 8 Oct 2011 21:40:34 +0200 Subject: Context menu cleanups - Open the context menu on the mouse-press event, not on the mouse-release event. - Provide an explicit position-information and don't use QCursor::pos(). This fixes the issue that opening a context-menu by the keyboard opens below the cursor. - Provide different signals in the KItemListController for the different context-menu types (item vs. view vs. header). - Implement turning on/off roles by the header-context-menu. --- src/dolphincontextmenu.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/dolphincontextmenu.cpp') diff --git a/src/dolphincontextmenu.cpp b/src/dolphincontextmenu.cpp index 617189715..848ba7de0 100644 --- a/src/dolphincontextmenu.cpp +++ b/src/dolphincontextmenu.cpp @@ -61,8 +61,11 @@ K_GLOBAL_STATIC(KModifierKeyInfo, m_keyInfo) DolphinContextMenu::DolphinContextMenu(DolphinMainWindow* parent, + const QPoint& pos, const KFileItem& fileInfo, const KUrl& baseUrl) : + QObject(parent), + m_pos(pos), m_mainWindow(parent), m_fileInfo(fileInfo), m_baseUrl(baseUrl), @@ -187,7 +190,7 @@ void DolphinContextMenu::openTrashContextMenu() addShowMenuBarAction(); - QAction *action = m_popup->exec(QCursor::pos()); + QAction *action = m_popup->exec(m_pos); if (action == emptyTrashAction) { KonqOperations::emptyTrash(m_mainWindow); } else if (action == addToPlacesAction) { @@ -212,7 +215,7 @@ void DolphinContextMenu::openTrashItemContextMenu() QAction* propertiesAction = m_mainWindow->actionCollection()->action("properties"); m_popup->addAction(propertiesAction); - if (m_popup->exec(QCursor::pos()) == restoreAction) { + if (m_popup->exec(m_pos) == restoreAction) { KUrl::List selectedUrls; foreach (const KFileItem &item, m_selectedItems) { selectedUrls.append(item.url()); @@ -299,7 +302,7 @@ void DolphinContextMenu::openItemContextMenu() QAction* propertiesAction = m_mainWindow->actionCollection()->action("properties"); m_popup->addAction(propertiesAction); - QAction* activatedAction = m_popup->exec(QCursor::pos()); + QAction* activatedAction = m_popup->exec(m_pos); if (activatedAction) { if (activatedAction == addToPlacesAction) { const KUrl selectedUrl(m_fileInfo.url()); @@ -361,7 +364,7 @@ void DolphinContextMenu::openViewportContextMenu() addShowMenuBarAction(); - QAction* action = m_popup->exec(QCursor::pos()); + QAction* action = m_popup->exec(m_pos); if (addToPlacesAction && (action == addToPlacesAction)) { const KUrl url = m_mainWindow->activeViewContainer()->url(); if (url.isValid()) { -- cgit v1.3