mirror of
https://invent.kde.org/system/dolphin
synced 2024-09-12 12:54:29 +00:00
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.
This commit is contained in:
parent
b62095950a
commit
c3b238bbe9
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue