]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphincontextmenu.cpp
Apply an item effect to all cut items. As discussed with Fredrik this should be done...
[dolphin.git] / src / dolphincontextmenu.cpp
index 8cc79e9554363e64ef1683a48a192d21f233555d..14760658128d3477ab2361eb7b95e6086a28e502 100644 (file)
 #include <QDir>
 
 DolphinContextMenu::DolphinContextMenu(DolphinView* parent,
-                                       KFileItem* fileInfo,
-                                       const QPoint& pos) :
+                                       KFileItem* fileInfo) :
    m_dolphinView(parent),
-   m_fileInfo(fileInfo),
-   m_pos(pos)
+   m_fileInfo(fileInfo)
 {
 }
 
@@ -99,12 +97,12 @@ void DolphinContextMenu::openViewportContextMenu()
     popup->addMenu(viewModeMenu);
     popup->addSeparator();
 
-    QAction* bookmarkAction = popup->addAction(i18n("Bookmark this folder"));
+    QAction* bookmarkAction = popup->addAction(KIcon("bookmark-folder"), i18n("Bookmark this folder"));
     popup->addSeparator();
 
     QAction* propertiesAction = popup->addAction(i18n("Properties..."));
 
-    QAction* activatedAction = popup->exec(m_pos);
+    QAction* activatedAction = popup->exec(QCursor::pos());
     if (activatedAction == propertiesAction) {
         new KPropertiesDialog(dolphin->activeView()->url());
     }
@@ -153,13 +151,20 @@ void DolphinContextMenu::openItemContextMenu()
     QAction* renameAction = dolphin->actionCollection()->action("rename");
     popup->addAction(renameAction);
 
-    // insert 'Move to Trash' for local Urls, otherwise insert 'Delete'
+    // insert 'Move to Trash' and (optionally) 'Delete'
+    const KSharedConfig::Ptr globalConfig = KSharedConfig::openConfig("kdeglobals", KConfig::NoGlobals);
+    const KConfigGroup kdeConfig(globalConfig, "KDE");
+    bool showDeleteCommand = kdeConfig.readEntry("ShowDeleteCommand", false);
     const KUrl& url = dolphin->activeView()->url();
     if (url.isLocalFile()) {
         QAction* moveToTrashAction = dolphin->actionCollection()->action("move_to_trash");
         popup->addAction(moveToTrashAction);
     }
     else {
+        showDeleteCommand = true;
+    }
+
+    if (showDeleteCommand) {
         QAction* deleteAction = dolphin->actionCollection()->action("delete");
         popup->addAction(deleteAction);
     }
@@ -169,7 +174,7 @@ void DolphinContextMenu::openItemContextMenu()
     // urls contains only one item, i.e. no multiple selection made
     QAction* bookmarkAction = 0;
     if (m_fileInfo->isDir() && (urls.count() == 1)) {
-        bookmarkAction = popup->addAction(i18n("Bookmark this folder"));
+        bookmarkAction = popup->addAction(KIcon("bookmark-folder"), i18n("Bookmark this folder"));
     }
 
     // Insert 'Open With...' sub menu
@@ -185,7 +190,7 @@ void DolphinContextMenu::openItemContextMenu()
     QAction* propertiesAction = dolphin->actionCollection()->action("properties");
     popup->addAction(propertiesAction);
 
-    QAction* activatedAction = popup->exec(m_pos);
+    QAction* activatedAction = popup->exec(QCursor::pos());
 
     if ((bookmarkAction!= 0) && (activatedAction == bookmarkAction)) {
         const KUrl selectedUrl(m_fileInfo->url());
@@ -319,8 +324,7 @@ QList<QAction*> DolphinContextMenu::insertActionItems(KMenu* popup,
         QStringList entries = dir.entryList(QDir::Files);
 
         for (QStringList::ConstIterator entryIt = entries.begin(); entryIt != entries.end(); ++entryIt) {
-            KSimpleConfig cfg(*dirIt + *entryIt, true);
-            cfg.setDesktopGroup();
+            KConfigGroup cfg(KSharedConfig::openConfig( *dirIt + *entryIt, KConfig::OnlyLocal), "Desktop Entry" );
             if ((cfg.hasKey("Actions") || cfg.hasKey("X-KDE-GetActionMenu")) && cfg.hasKey("ServiceTypes")) {
                 //const QStringList types = cfg.readListEntry("ServiceTypes");
                 QStringList types;