]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/dolphincontextmenu.cpp
The feature freeze is near: Add video support to the Information Panel. Phonon is...
[dolphin.git] / src / dolphincontextmenu.cpp
index 1d99f96373e7dcce4817954c7946dfc9b1eea1cc..8d014fc2c0a81ca429671e4bef3beae96857ac22 100644 (file)
@@ -28,6 +28,7 @@
 #include "dolphin_generalsettings.h"
 
 #include <kactioncollection.h>
+#include <kfileitemlistproperties.h>
 #include <kfileplacesmodel.h>
 #include <kdesktopfile.h>
 #include <kglobal.h>
 #include <kmimetypetrader.h>
 #include <knewmenu.h>
 #include <konqmimedata.h>
-#include <konq_fileitemcapabilities.h>
+#include <kfileitemlistproperties.h>
 #include <konq_operations.h>
 #include <konq_menuactions.h>
-#include <konq_popupmenuinformation.h>
 #include <klocale.h>
 #include <kpropertiesdialog.h>
 #include <krun.h>
@@ -61,7 +61,8 @@ DolphinContextMenu::DolphinContextMenu(DolphinMainWindow* parent,
     m_fileInfo(fileInfo),
     m_baseUrl(baseUrl),
     m_context(NoContext),
-    m_copyToMenu(parent)
+    m_copyToMenu(parent),
+    m_customActions()
 {
     // The context menu either accesses the URLs of the selected items
     // or the items itself. To increase the performance both lists are cached.
@@ -76,6 +77,11 @@ DolphinContextMenu::~DolphinContextMenu()
     m_capabilities = 0;
 }
 
+void DolphinContextMenu::setCustomActions(const QList<QAction*>& actions)
+{
+    m_customActions = actions;
+}
+
 void DolphinContextMenu::open()
 {
     // get the context information
@@ -119,6 +125,8 @@ void DolphinContextMenu::openTrashContextMenu()
     QAction* addToPlacesAction = popup->addAction(KIcon("bookmark-new"),
                                                   i18nc("@action:inmenu Add current folder to places", "Add to Places"));
 
+    addCustomActions(popup);
+
     QAction* propertiesAction = m_mainWindow->actionCollection()->action("properties");
     popup->addAction(propertiesAction);
 
@@ -204,21 +212,19 @@ void DolphinContextMenu::openItemContextMenu()
                                              i18nc("@action:inmenu Add selected folder to places", "Add to Places"));
     }
 
-    KonqPopupMenuInformation popupInfo;
-    popupInfo.setItems(m_selectedItems);
-    popupInfo.setParentWidget(m_mainWindow);
     KonqMenuActions menuActions;
-    menuActions.setPopupMenuInfo(popupInfo);
+    menuActions.setParentWidget(m_mainWindow);
+    menuActions.setItemListProperties(m_selectedItems);
 
-    // Insert 'Open With...' action or sub menu
+    // insert 'Open With...' action or sub menu
     menuActions.addOpenWithActionsTo(popup, "DesktopEntryName != 'dolphin'");
 
-    // Insert 'Actions' sub menu
+    // insert 'Actions' sub menu
     if (menuActions.addActionsTo(popup)) {
         popup->addSeparator();
     }
 
-    // Insert 'Copy To' and 'Move To' sub menus
+    // insert 'Copy To' and 'Move To' sub menus
     if (DolphinSettings::instance().generalSettings()->showCopyMoveMenu()) {
         m_copyToMenu.setItems(m_selectedItems);
         m_copyToMenu.setReadOnly(!capabilities().supportsWriting());
@@ -277,10 +283,11 @@ void DolphinContextMenu::openViewportContextMenu()
 
     QAction* addToPlacesAction = popup->addAction(KIcon("bookmark-new"),
                                                   i18nc("@action:inmenu Add current folder to places", "Add to Places"));
-    popup->addSeparator();
 
-    QAction* propertiesAction = popup->addAction(i18nc("@action:inmenu", "Properties"));
+    addCustomActions(popup);
 
+    QAction* propertiesAction = popup->addAction(i18nc("@action:inmenu", "Properties"));
+    propertiesAction->setIcon(KIcon("document-properties"));
     QAction* action = popup->exec(QCursor::pos());
     if (action == propertiesAction) {
         const KUrl& url = m_mainWindow->activeViewContainer()->url();
@@ -371,12 +378,19 @@ QAction* DolphinContextMenu::createPasteAction()
     return action;
 }
 
-KonqFileItemCapabilities& DolphinContextMenu::capabilities()
+KFileItemListProperties& DolphinContextMenu::capabilities()
 {
     if (m_capabilities == 0) {
-        m_capabilities = new KonqFileItemCapabilities(m_selectedItems);
+        m_capabilities = new KFileItemListProperties(m_selectedItems);
     }
     return *m_capabilities;
 }
 
+void DolphinContextMenu::addCustomActions(KMenu* menu)
+{
+    foreach (QAction* action, m_customActions) {
+        menu->addAction(action);
+    }
+}
+
 #include "dolphincontextmenu.moc"