]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphincontextmenu.cpp
Context menu cleanups
[dolphin.git] / src / dolphincontextmenu.cpp
index 79ffdaa2eca6451230224aa6be54af5b3624c5fc..848ba7de086fd9293e52d3bfc22bc8d9c57515d6 100644 (file)
 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),
@@ -86,8 +89,8 @@ DolphinContextMenu::DolphinContextMenu(DolphinMainWindow* parent,
         if (m_keyInfo->isKeyPressed(Qt::Key_Shift) || m_keyInfo->isKeyLatched(Qt::Key_Shift)) {
             m_shiftPressed = true;
         }
-        connect(m_keyInfo, SIGNAL(keyPressed(Qt::Key, bool)),
-                this, SLOT(slotKeyModifierPressed(Qt::Key, bool)));
+        connect(m_keyInfo, SIGNAL(keyPressed(Qt::Key,bool)),
+                this, SLOT(slotKeyModifierPressed(Qt::Key,bool)));
     }
 
     m_removeAction = new QAction(this);
@@ -187,18 +190,9 @@ void DolphinContextMenu::openTrashContextMenu()
 
     addShowMenuBarAction();
 
-    QAction *action = m_popup->exec(QCursor::pos());
+    QAction *action = m_popup->exec(m_pos);
     if (action == emptyTrashAction) {
-        const QString text(i18nc("@info", "Do you really want to empty the Trash? All items will be deleted."));
-        const bool del = KMessageBox::warningContinueCancel(m_mainWindow,
-                                                            text,
-                                                            QString(),
-                                                            KGuiItem(i18nc("@action:button", "Empty Trash"),
-                                                                     KIcon("user-trash"))
-                                                           ) == KMessageBox::Continue;
-        if (del) {
-            KonqOperations::emptyTrash(m_mainWindow);
-        }
+        KonqOperations::emptyTrash(m_mainWindow);
     } else if (action == addToPlacesAction) {
         const KUrl& url = m_mainWindow->activeViewContainer()->url();
         if (url.isValid()) {
@@ -221,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());
@@ -243,7 +237,7 @@ void DolphinContextMenu::openItemContextMenu()
             // setup 'Create New' menu
             DolphinNewFileMenu* newFileMenu = new DolphinNewFileMenu(m_mainWindow);
             const DolphinView* view = m_mainWindow->activeViewContainer()->view();
-            newFileMenu->setViewShowsHiddenFiles(view->showHiddenFiles());
+            newFileMenu->setViewShowsHiddenFiles(view->hiddenFilesShown());
             newFileMenu->checkUpToDate();
             newFileMenu->setPopupFiles(m_fileInfo.url());
             newFileMenu->setEnabled(selectedItemsProperties().supportsWriting());
@@ -308,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());
@@ -329,7 +323,7 @@ void DolphinContextMenu::openViewportContextMenu()
     // setup 'Create New' menu
     KNewFileMenu* newFileMenu = m_mainWindow->newFileMenu();
     const DolphinView* view = m_mainWindow->activeViewContainer()->view();
-    newFileMenu->setViewShowsHiddenFiles(view->showHiddenFiles());
+    newFileMenu->setViewShowsHiddenFiles(view->hiddenFilesShown());
     newFileMenu->checkUpToDate();
     newFileMenu->setPopupFiles(m_baseUrl);
     m_popup->addMenu(newFileMenu->menu());
@@ -370,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()) {