3232from processing .gui .MessageDialog import MessageDialog
3333from processing .gui .AlgorithmDialog import AlgorithmDialog
3434from qgis .utils import iface
35- from qgis .core import QgsApplication , QgsMessageLog
35+ from qgis .core import QgsApplication , QgsMessageLog , QgsStringUtils
3636from processing .gui .MessageBarProgress import MessageBarProgress
3737from processing .gui .AlgorithmExecutor import execute
3838from processing .gui .Postprocessing import handleAlgorithmResults
@@ -182,7 +182,10 @@ def removeMenus():
182182
183183
184184def addAlgorithmEntry (alg , menuName , submenuName , actionText = None , icon = None , addButton = False ):
185- action = QAction (icon or alg .icon (), actionText or alg .displayName (), iface .mainWindow ())
185+ if actionText is None :
186+ actionText = QgsStringUtils .capitalize (alg .displayName (), QgsStringUtils .TitleCase ) + QCoreApplication .translate ('Processing' , '…' )
187+ action = QAction (icon or alg .icon (), actionText , iface .mainWindow ())
188+ action .setData (alg .id ())
186189 action .triggered .connect (lambda : _executeAlgorithm (alg ))
187190 action .setObjectName ("mProcessingUserMenu_%s" % alg .id ())
188191
@@ -199,11 +202,11 @@ def addAlgorithmEntry(alg, menuName, submenuName, actionText=None, icon=None, ad
199202 algorithmsToolbar .addAction (action )
200203
201204
202- def removeAlgorithmEntry (alg , menuName , submenuName , actionText = None , delButton = True ):
205+ def removeAlgorithmEntry (alg , menuName , submenuName , delButton = True ):
203206 if menuName :
204207 menu = getMenu (menuName , iface .mainWindow ().menuBar ())
205208 subMenu = getMenu (submenuName , menu )
206- action = findAction (subMenu .actions (), alg , actionText )
209+ action = findAction (subMenu .actions (), alg )
207210 if action is not None :
208211 subMenu .removeAction (action )
209212
@@ -213,7 +216,7 @@ def removeAlgorithmEntry(alg, menuName, submenuName, actionText=None, delButton=
213216 if delButton :
214217 global algorithmsToolbar
215218 if algorithmsToolbar is not None :
216- action = findAction (algorithmsToolbar .actions (), alg , actionText )
219+ action = findAction (algorithmsToolbar .actions (), alg )
217220 if action is not None :
218221 algorithmsToolbar .removeAction (action )
219222
@@ -260,8 +263,8 @@ def getMenu(name, parent):
260263 return parent .addMenu (name )
261264
262265
263- def findAction (actions , alg , actionText = None ):
266+ def findAction (actions , alg ):
264267 for action in actions :
265- if action .text () in [ actionText , alg .displayName (), alg . name ()] :
268+ if action .data () == alg .id () :
266269 return action
267270 return None
0 commit comments