Skip to content
Permalink
Browse files

[processing] extended 'menus' section in options, to allow adding but…

…tons
  • Loading branch information
volaya committed Apr 5, 2016
1 parent 5131e93 commit 673a86040de3ccca9a00f972f6256b37a51c7e63
Showing with 39 additions and 10 deletions.
  1. +21 −7 python/plugins/processing/gui/ConfigDialog.py
  2. +18 −3 python/plugins/processing/gui/menus.py
@@ -203,16 +203,30 @@ def fillTreeUsingProviders(self):
groupItem.setEditable(False)

for alg in provider.algs:
labelItem = QStandardItem(alg.name)
labelItem.setIcon(icon)
labelItem.setEditable(False)
algItem = QStandardItem(alg.name)
algItem.setIcon(icon)
algItem.setEditable(False)
try:
setting = ProcessingConfig.settings["MENU_" + alg.commandLineName()]
settingMenu = ProcessingConfig.settings["MENU_" + alg.commandLineName()]
settingButton = ProcessingConfig.settings["BUTTON_" + alg.commandLineName()]
settingIcon = ProcessingConfig.settings["ICON_" + alg.commandLineName()]
except:
continue
self.items[setting] = SettingItem(setting)

groupItem.insertRow(0, [labelItem, self.items[setting]])
self.items[settingMenu] = SettingItem(settingMenu)
self.items[settingButton] = SettingItem(settingButton)
self.items[settingIcon] = SettingItem(settingIcon)
menuLabelItem = QStandardItem("Menu path")
menuLabelItem.setEditable(False)
buttonLabelItem = QStandardItem("Add button in toolbar")
buttonLabelItem.setEditable(False)
iconLabelItem = QStandardItem("Icon")
iconLabelItem.setEditable(False)
emptyItem = QStandardItem()
emptyItem.setEditable(False)
algItem.insertRow(0, [menuLabelItem, self.items[settingMenu]])
algItem.insertRow(0, [buttonLabelItem, self.items[settingButton]])
algItem.insertRow(0, [iconLabelItem, self.items[settingIcon]])
groupItem.insertRow(0, [algItem, emptyItem])

emptyItem = QStandardItem()
emptyItem.setEditable(False)
@@ -4,6 +4,8 @@
from processing.gui.MessageDialog import MessageDialog
from processing.gui.AlgorithmDialog import AlgorithmDialog
from qgis.utils import iface
import os
from PyQt4.QtGui import QIcon

algorithmsToolbar = None
menusSettingsGroup = 'Menus'
@@ -106,7 +108,14 @@ def initializeMenus():
for provider in Processing.providers:
for alg in provider.algs:
d = defaultMenuEntries.get(alg.commandLineName(), "")
setting = Setting(menusSettingsGroup, "MENU_" + alg.commandLineName(), alg.name, d)
setting = Setting(menusSettingsGroup, "MENU_" + alg.commandLineName(),
"Menu path", d)
ProcessingConfig.addSetting(setting)
setting = Setting(menusSettingsGroup, "BUTTON_" + alg.commandLineName(),
"Add button", False)
ProcessingConfig.addSetting(setting)
setting = Setting(menusSettingsGroup, "ICON_" + alg.commandLineName(),
"Icon", "", valuetype = Setting.FILE)
ProcessingConfig.addSetting(setting)

ProcessingConfig.readSettings()
@@ -121,9 +130,15 @@ def createMenus():
for provider in list(Processing.algs.values()):
for alg in list(provider.values()):
menuPath = ProcessingConfig.getSetting("MENU_" + alg.commandLineName())
addButton = ProcessingConfig.getSetting("BUTTON_" + alg.commandLineName())
icon = ProcessingConfig.getSetting("ICON_" + alg.commandLineName())
if icon and os.path.exists(icon):
icon = QIcon(icon)
else:
icon = None
if menuPath:
paths = menuPath.split("/")
addAlgorithmEntry(alg, paths[0], paths[-1])
addAlgorithmEntry(alg, paths[0], paths[-1], addButton = addButton, icon = icon)


def removeMenus():
@@ -165,7 +180,7 @@ def removeAlgorithmEntry(alg, menuName, submenuName, actionText=None, delButton=
if delButton:
global algorithmsToolbar
if algorithmsToolbar is not None:
action = Processing.findAction(algorithmsToolbar.actions(), alg, actionText)
action = findAction(algorithmsToolbar.actions(), alg, actionText)
if action is not None:
algorithmsToolbar.removeAction(action)

0 comments on commit 673a860

Please sign in to comment.
You can’t perform that action at this time.