[Customization] Add processing in user defined menu or toolbar#64913
[Customization] Add processing in user defined menu or toolbar#64913troopa81 wants to merge 5 commits intoqgis:masterfrom
Conversation
Use macro for property used to identify user mtoolbars/menus and check that the item is really visible
efc18c1 to
285a066
Compare
🪟 Windows Qt6 buildsDownload Windows Qt6 builds of this PR for testing. 🍎 MacOS Qt6 buildsDownload MacOS Qt6 builds of this PR for testing. |
Implement the possibility to add processing algorithm action in user defined menu or toolbar. When triggered, those actions would open a dialog to parametrize and execute the associated processing. AlgorithmDialog is a Python implementation from the processing module, so we use QgsPythonRunner to trigger the opening of the dialog.
And use auto scroll
|
Should we remove existing Processing functionality to add algorithms to menus/toolbars to avoid duplication? |
In the long term, I'd like too! But the logic is a bit different a would require more work to assure compatibilty |
| const QString command( "import processing; from qgis.utils import iface;" | ||
| "dialog = processing.createAlgorithmDialog('%1');\n" | ||
| "if dialog: dialog.show()\n" | ||
| "else: iface.messageBar().pushMessage( 'Invalid algorithm id : %1', Qgis.MessageLevel.Warning )" ); | ||
| QgsPythonRunner::run( command.arg( mProcessingAlgorithmId ) ); |
There was a problem hiding this comment.
There's similar (rather fragile) logic in QgsProcessingHistoryProvider. I think we could improve this by adding a setExecAlgorithmDialogFunction method to QgsProcessingGuiRegistry, which allows us to set (from python) the function to exec the algorithm dialog. We could then call that from c++ code without having to duplicate this logic.
(Incidentally, this should be processing.execAlgorithmDialog, not createAlgorithmDialog/show)
There was a problem hiding this comment.
OK, I'll do it when bug fix is over
| const QIcon lIcon = icon(); | ||
| if ( !lIcon.isNull() ) | ||
| { | ||
| // We have no idea what would be the best size to store, it depends on the widget that would |
There was a problem hiding this comment.
Why aren't we just getting the icon from the algorithm itself in readXmlItem ?
There was a problem hiding this comment.
I'd leave that off till there's a concrete need for it. Right now it's just bloating the file size, and will result in a poorer quality (non-vector) icon.
|
theoretical question: do you think this customisation support could allow us to add optional actions which aren't exposed by default? I am wondering if it would give us a way of integrating the functionality of the "plugin reloader" plugin, which is a must-have for plugin developers but shouldn't be exposed by default for "normal" users. 🤔 |

Implement the possibility to add processing algorithm action in user
defined menu or toolbar. When triggered, those actions would open a
dialog to parametrize and execute the associated processing.
AlgorithmDialog is a Python implementation from the processing module,
so we use QgsPythonRunner to trigger the opening of the dialog.
include #64912 and #64900
Funded by Stadt Frankfurt am Main and Oslandia