Skip to content

Conversation

@nyalldawson
Copy link
Collaborator

This adds api in the provider gui to allow a provider to create a custom widget which exposes options to customise and change the layer's source.

E.g. a file based layer provider could expose a widget for selecting a new file path, and an online one could expose widgets for changing the host, authentication, etc.

And adds two implementations of this.

  1. A file picker widget for GDAL file based layers:

image

  1. A widget for customising XYZ layer properties (it's VERY handy to allow customising the zmin/zmax on a layer by layer basis!!)

image

@nyalldawson nyalldawson added API API improvement only, no visible user interface changes Changelog Items that are queued to appear in the visual changelog - remove after harvesting labels Dec 23, 2020
@github-actions github-actions bot added this to the 3.18.0 milestone Dec 23, 2020
This adds api in the provider gui to allow a provider to create a custom
widget which exposes options to customise and change the layer's source.

E.g. a file based layer provider could expose a widget for selecting
a new file path, and an online one could expose widgets for changing
the host, authentication, etc.
changing layer file source from raster layer properties
like the min/max zoom levels and authentication settings for any
XYZ layer in a project on a layer-by-layer basis
@elpaso
Copy link
Contributor

elpaso commented Dec 23, 2020

@nyalldawson I'm probably missing something, isn't this in part a duplication of the source select dialogs?

And we already have the "Change data source" functionality (that relies on the browser, that in turn opens the source select dialogs).

The only difference I see in this use case is that you are not allowed to change provider, that could be implemented re-using the change data provider.

I feel that re-using (possibly enhancing) the existing source select widgets is the way to go to avoid code duplication and for a better UX.

@nyalldawson
Copy link
Collaborator Author

@elpaso there's quite a difference here between use cases. Eg take a look at the screen shot for the XYZ settings widget, and you'll see its very different to the XYZ source select widget.

Another use case I really want this for is to allow change of auth config for an existing layer. That's really tricky to do via the "change data source" > browser> data source manager approach. You're forced to edit an existing connection (or clone it), globally change its auth config, and then reselect the layer source. That's far from user friendly.

I did you with the idea of reusing the source select widget API here, but in the end rejected that idea as the source select API has zero overlap with what we need here (a set existing source, get new source string methods) and we'd just end up with a Frankensteined interface trying to handle two different use cases...

@elpaso
Copy link
Contributor

elpaso commented Dec 23, 2020

@elpaso there's quite a difference here between use cases. Eg take a look at the screen shot for the XYZ settings widget, and you'll see its very different to the XYZ source select widget.

Yeah, the one I had in mind is actually the connections dialog QgsXyzConnectionDialog which is not exposed to API, I see no difference between that dialog and the one you embedded in the layer properties dialog

immagine

Are you sure you cannot abstract out the connections widgets (at least the dialog UI) to be re-usable in this context instead of creating a whole new API with duplication of functionality?

I mean, in this case GUI-wise all you have to do is to hide the connection name field.

I'm scared about maintaining another API and keep features in sync between the two GUIs.

@nyalldawson
Copy link
Collaborator Author

I guess the XYZ connection dialog could embed the subset widget from this pr, which would remove the extra UI file and some of the duplication...

But I still can't see any way to avoid the new API, the existing one just doesn't work for this functionality

@elpaso
Copy link
Contributor

elpaso commented Dec 23, 2020

I guess the XYZ connection dialog could embed the subset widget from this pr, which would remove the extra UI file and some of the duplication...

This sounds like the way to go!

The important thing is to avoid to maintain two nearly identical UIs.

But I still can't see any way to avoid the new API, the existing one just doesn't work for this functionality

👍

@nyalldawson
Copy link
Collaborator Author

@elpaso done in b262350

@nyalldawson nyalldawson merged commit a92c882 into qgis:master Dec 25, 2020
@nyalldawson nyalldawson deleted the source_widget branch December 25, 2020 23:51
@zacharlie zacharlie added ChangelogHarvested This PR description has been harvested in the Changelog already. and removed Changelog Items that are queued to appear in the visual changelog - remove after harvesting labels Jan 1, 2021
@DelazJ DelazJ added the Needs Documentation When merging a labeled PR, an issue will be created in the Doc repo. label Dec 4, 2025
@qgis-bot
Copy link
Collaborator

qgis-bot commented Dec 4, 2025

@nyalldawson
A documentation ticket has been opened at qgis/QGIS-Documentation#10522
It is your responsibility to visit this ticket and add as much detail as possible for the documentation team to correctly document this change.
Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

API API improvement only, no visible user interface changes ChangelogHarvested This PR description has been harvested in the Changelog already. Needs Documentation When merging a labeled PR, an issue will be created in the Doc repo.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants