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/dolphinmainwindow.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src/dolphinmainwindow.cpp') diff --git a/src/dolphinmainwindow.cpp b/src/dolphinmainwindow.cpp index 6ca6e59f7..1150b7488 100644 --- a/src/dolphinmainwindow.cpp +++ b/src/dolphinmainwindow.cpp @@ -1374,13 +1374,14 @@ void DolphinMainWindow::slotSearchModeChanged(bool enabled) #endif } -void DolphinMainWindow::openContextMenu(const KFileItem& item, +void DolphinMainWindow::openContextMenu(const QPoint& pos, + const KFileItem& item, const KUrl& url, const QList& customActions) { - QPointer contextMenu = new DolphinContextMenu(this, item, url); - contextMenu->setCustomActions(customActions); - const DolphinContextMenu::Command command = contextMenu->open(); + QWeakPointer contextMenu = new DolphinContextMenu(this, pos, item, url); + contextMenu.data()->setCustomActions(customActions); + const DolphinContextMenu::Command command = contextMenu.data()->open(); switch (command) { case DolphinContextMenu::OpenParentFolderInNewWindow: { @@ -1397,7 +1398,7 @@ void DolphinMainWindow::openContextMenu(const KFileItem& item, break; } - delete contextMenu; + delete contextMenu.data(); } void DolphinMainWindow::updateToolBarMenu() @@ -2111,8 +2112,8 @@ void DolphinMainWindow::connectViewSignals(DolphinViewContainer* container) this, SLOT(toggleActiveView())); connect(view, SIGNAL(tabRequested(KUrl)), this, SLOT(openNewTab(KUrl))); - connect(view, SIGNAL(requestContextMenu(KFileItem,KUrl,QList)), - this, SLOT(openContextMenu(KFileItem,KUrl,QList))); + connect(view, SIGNAL(requestContextMenu(QPoint,KFileItem,KUrl,QList)), + this, SLOT(openContextMenu(QPoint,KFileItem,KUrl,QList))); connect(view, SIGNAL(startedPathLoading(KUrl)), this, SLOT(enableStopAction())); connect(view, SIGNAL(finishedPathLoading(KUrl)), -- cgit v1.3