-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added possibility to add custom actions for the group-nodes in the layer tree #59585
base: master
Are you sure you want to change the base?
Conversation
🪟 Windows buildsDownload Windows builds of this PR for testing. 🪟 Windows Qt6 buildsDownload Windows Qt6 builds of this PR for testing. |
It would be great to be able to add a custom action in the default menu (right click in blank area of layer tree). |
cce776c
to
9ae57b3
Compare
I agree, though i think it would be better to create a separate issue. |
The QGIS project highly values your contribution and would love to see this work merged! Unfortunately this PR has not had any activity in the last 14 days and is being automatically marked as "stale". If you think this pull request should be merged, please check
|
9ae57b3
to
7d49dd4
Compare
7d49dd4
to
1b99119
Compare
The QGIS project highly values your contribution and would love to see this work merged! Unfortunately this PR has not had any activity in the last 14 days and is being automatically marked as "stale". If you think this pull request should be merged, please check
|
Would love to see this implemented. If there was a way to upvote or something, that would be great. I'm hoping that by commenting, it attracts attention. |
1b99119
to
bfba646
Compare
@rouault Could you please check if i need to add anything here or is it good to go? |
It's fine by me, but I'd welcome the ACK from another core committer more familiar than me with that part of the application |
Ah, i see! Should i tag someone specific or we just wait for someone to come and review it when they have time? |
I'm personally -1 to this approach. I think that what you're trying to achieve can already be done by connecting to the contextMenuAboutToShow signal in iface.layerTreeView(). |
The QGIS project highly values your contribution and would love to see this work merged! Unfortunately this PR has not had any activity in the last 14 days and is being automatically marked as "stale". If you think this pull request should be merged, please check
|
@nyalldawson In other words, adding it to the interface of menu provider (extending it) allows it to be encapsulated in object-oriented sense, keeping general functionality in one place and particular customization - in the other (through the means of the handling signal). There is also a moment of where custom menus/actions are being added in context menu. If we catch menu via signal - by default addition appends them to the end, which is often reserved to the export options in terms of user experience. But in manager it is potentially customizable (api can be extended to use some kind of priority) |
Actually the signal gives MORE flexibility, because you have access to the full (already populated) menu in the argument. So your code can decide exactly where to insert actions/submenus, as you can find an inbuilt action and then insert your action/menu before it. You also get a lot more flexibility in handling submenus then the API proposed in this pull request, as you could nest submenus, add to other submenus, etc. In short, the proposed API is adding a lot of complexity for quite a rigid API, when there's already a much more flexible API available in current versions which allows you to achieve the same result. |
The QGIS project highly values your contribution and would love to see this work merged! Unfortunately this PR has not had any activity in the last 14 days and is being automatically marked as "stale". If you think this pull request should be merged, please check
|
…ternal components during its population process
bfba646
to
3f172e6
Compare
Understood! |
@@ -38,7 +38,7 @@ QMenu *QgsLayoutAppMenuProvider::createContextMenu( QWidget *parent, QgsLayout * | |||
//undo/redo | |||
menu->addAction( layout->undoStack()->stack()->createUndoAction( menu ) ); | |||
menu->addAction( layout->undoStack()->stack()->createRedoAction( menu ) ); | |||
menu->addSeparator(); | |||
menu->addSeparator()->setText( QLatin1String( "UndoRedoSeparator" ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be:
menu->addSeparator()->setText( QLatin1String( "UndoRedoSeparator" ) ); | |
menu->addSeparator()->setObjectName( QLatin1String( "UndoRedoSeparator" ) ); |
Description
Currently, you can create a custom action in the context menu of layer-tree only for different types of layers. This PR provides public API to add an action for groups of layers.
Two functions are added to public API of QGisInterface:
virtual void addCustomActionForGroups( QAction *action, const QString &menu ) = 0;
virtual bool removeCustomActionForGroups( QAction *action ) = 0;
Fixes #53692