X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/056b6855d3d1575bcaf095a69fec5b767aefa16b..684ab89c7d92fc1807f09cf15924b8149049eb4b:/src/dolphincontextmenu.cpp diff --git a/src/dolphincontextmenu.cpp b/src/dolphincontextmenu.cpp index 1d99f9637..f633fb945 100644 --- a/src/dolphincontextmenu.cpp +++ b/src/dolphincontextmenu.cpp @@ -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& 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); @@ -210,15 +218,15 @@ void DolphinContextMenu::openItemContextMenu() KonqMenuActions menuActions; menuActions.setPopupMenuInfo(popupInfo); - // 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,7 +285,8 @@ void DolphinContextMenu::openViewportContextMenu() QAction* addToPlacesAction = popup->addAction(KIcon("bookmark-new"), i18nc("@action:inmenu Add current folder to places", "Add to Places")); - popup->addSeparator(); + + addCustomActions(popup); QAction* propertiesAction = popup->addAction(i18nc("@action:inmenu", "Properties")); @@ -379,4 +388,11 @@ KonqFileItemCapabilities& DolphinContextMenu::capabilities() return *m_capabilities; } +void DolphinContextMenu::addCustomActions(KMenu* menu) +{ + foreach (QAction* action, m_customActions) { + menu->addAction(action); + } +} + #include "dolphincontextmenu.moc"