Skip to content
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

Settings registry (QEP 124) part two settings introspection #42860

Merged
merged 13 commits into from
Apr 26, 2021

Conversation

domi4484
Copy link
Contributor

@domi4484 domi4484 commented Apr 19, 2021

As of Enhancement proposal #124 and as followup to merged pr #42597 this pull request introduces a new class QgsSettingsRegistry.

QgsSettingsRegistry is used for settings introspection and collects a list of QgsSettingsEntries and a list of child sub QgsSettingsRegistries

Sub modules and plugins can have their own settings registry and register it to the main one (QgsSettingsRegistryCore).

Usage example from plugin:

settingsEntryMyPlugin = QgsSettingsEntryInteger("myPlugin/integerValue", self.pluginName, 123)

settingsRegistryMyPlugin = QgsSettingsRegistry()
settingsRegistryMyPlugin.addSettingsEntry(settingsEntryMyPlugin)

# add registry to core registry
QgsApplication.settingsRegistryCore().addChildSettingsRegistry(settingsRegistryMyPlugin)

QgsSettingsRegistryCore can be used as single entry point for example from the advanced settings editor. If settings are registered the description is shown like in the following screenshot. In the future more information could be used to improve the editor like default values, value range and so on.

image

@github-actions github-actions bot added this to the 3.20.0 milestone Apr 19, 2021
@elpaso
Copy link
Contributor

elpaso commented Apr 20, 2021

@domi4484 nice work!

Just a question how is the section handled? Is it set in the QgsSettingsEntry ?

@domi4484
Copy link
Contributor Author

@elpaso Thank you for the suggestions!

Yes the section is passed to the QgsSettingsEntry constructor. It means settings in the core registry could have other sections than core.
From plugins (python) the section parameter is not available in the constructor and it is forced to "Plugins".

When getting/setting values internally QgsSettings is used and the section is passed one to one.

}

if ( !hasDynamicKey() )
return completeKeyToCheck == prefixedSettingsKey;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably use QString::compare method for a string comparison.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pblottiere Thank you for the review! Why is QString::compare preferable over the == operator in this case? Compare return an integer with more information (greater/smaller/equal) and all i want is to know if the string are equal.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in this case, it doesn't seem to be significant
https://forum.qt.io/topic/52155/compare-2-qstring-use-or-qstring-compare

Co-authored-by: Paul Blottiere <blottiere.paul@gmail.com>
/**
* Add a child \a settingsRegistry to the register.
*/
void addChildSettingsRegistry( const QgsSettingsRegistry *settingsRegistry );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addChildSettingsRegistry => integrateRegistry or addRegistry or appendRegistry ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants