Commit c3b238bb authored by Alexander Lohnau's avatar Alexander Lohnau 💬 Committed by Elvis Angelaccio
Browse files

Move repetitive contextmenu related logic in one place

This makes a bit easier to handle the stuff.
Also we don't need the `addVersionControlPluginActions` utility method
and we can put it in the new utility method instead.
parent b6209595
......@@ -271,12 +271,7 @@ void DolphinContextMenu::openItemContextMenu()
insertDefaultItemActions(selectedItemsProps);
addSeparator();
fileItemActions.addServiceActionsTo(this);
fileItemActions.addPluginActionsTo(this);
addVersionControlPluginActions();
addAdditionalActions(fileItemActions, selectedItemsProps);
// insert 'Copy To' and 'Move To' sub menus
if (GeneralSettings::showCopyMoveMenu()) {
......@@ -338,18 +333,7 @@ void DolphinContextMenu::openViewportContextMenu()
addAction(m_mainWindow->actionCollection()->action(QStringLiteral("sort")));
addAction(m_mainWindow->actionCollection()->action(QStringLiteral("view_mode")));
addSeparator();
// Insert service actions
QList<QAction *> additionalActions;
if (baseUrlProperties.isDirectory() && baseUrlProperties.isLocal()) {
additionalActions << m_mainWindow->actionCollection()->action(QStringLiteral("open_terminal"));
}
fileItemActions.addServiceActionsTo(this, additionalActions);
fileItemActions.addPluginActionsTo(this);
addVersionControlPluginActions();
addAdditionalActions(fileItemActions, baseUrlProperties);
addCustomActions();
addSeparator();
......@@ -489,8 +473,22 @@ void DolphinContextMenu::addOpenWithActions(KFileItemActions& fileItemActions)
fileItemActions.addOpenWithActionsTo(this, QStringLiteral("DesktopEntryName != '%1'").arg(qApp->desktopFileName()));
}
void DolphinContextMenu::addVersionControlPluginActions()
void DolphinContextMenu::addCustomActions()
{
addActions(m_customActions);
}
void DolphinContextMenu::addAdditionalActions(KFileItemActions &fileItemActions, const KFileItemListProperties &props)
{
addSeparator();
QList<QAction *> additionalActions;
if (props.isDirectory() && props.isLocal()) {
additionalActions << m_mainWindow->actionCollection()->action(QStringLiteral("open_terminal"));
}
fileItemActions.addServiceActionsTo(this, additionalActions);
fileItemActions.addPluginActionsTo(this);
const DolphinView* view = m_mainWindow->activeViewContainer()->view();
const QList<QAction*> versionControlActions = view->versionControlActions(m_selectedItems);
if (!versionControlActions.isEmpty()) {
......@@ -499,8 +497,3 @@ void DolphinContextMenu::addVersionControlPluginActions()
}
}
void DolphinContextMenu::addCustomActions()
{
addActions(m_customActions);
}
......@@ -107,11 +107,6 @@ private:
*/
void addOpenWithActions(KFileItemActions& fileItemActions);
/**
* Adds actions that are provided by a KVersionControlPlugin.
*/
void addVersionControlPluginActions();
/**
* Adds custom actions e.g. like the "[x] Expandable Folders"-action
* provided in the details view.
......@@ -119,6 +114,11 @@ private:
void addCustomActions();
private:
/**
* Add services, custom actions, plugins and version control items to the menu
*/
void addAdditionalActions(KFileItemActions &fileItemActions, const KFileItemListProperties &props);
struct Entry
{
int type;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment