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
[FEATURE][needs-docs] Add XYZ connection to provide default OpenStreetMap tiles #5000
Conversation
def tearDown(self): | ||
"""Run after each test.""" | ||
qDebug('tearDown') | ||
pass |
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.
Watch out for the indentation here
qDebug('settings.allKeys(): {0}'.format(settings.allKeys())) | ||
defaulturl = settings.value('qgis/connections-xyz/OpenStreetMap/url') | ||
|
||
def testKey(): |
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.
is this function necessary?
I think you should just assert in the main body, same for testLayer
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.
Thanks @elpaso
Done!
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.
It was a WIP. Now I think it is fully implemented.
Now we support the removal of default connections by users.
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.
LGTM thanks!
Can you please address the two minor issues that I've commented in the review?
QStringList global = settings.globalChildGroups(); | ||
settings.endGroup(); | ||
|
||
for ( auto &s : global ) |
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.
To avoid a detach you might want to try the new qgsAsConst
029f741 recently added by @nyalldawson or use Q_FOREACH
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.
It also should be const auto &
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.
To avoid a detach you might want to try the new qgsAsConst 029f741 recently added by @nyalldawson or use Q_FOREACH
... or simply use const QStringList global
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 prefer to avoid the Q_FOREACH
.
I've used the suggested pattern:
const QStringList global = settings.globalChildGroups();
for ( const auto &s : global )
@@ -156,6 +156,11 @@ Returns a list of all top-level keys that can be read using the QSettings object | |||
Returns a list of all key top-level groups that contain keys that can be read using the QSettings object. | |||
:rtype: list of str | |||
%End | |||
QStringList globalChildGroups() const; |
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.
Would you mind adding a test case for globalChildGroups()
to https://github.com/qgis/QGIS/blob/master/tests/src/python/test_qgssettings.py ?
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.
Thanks @elpaso. I discovered another minor issue writing the test. The test now covers the settings.globalChildGroups()
.
Fix container iteration
qDebug('QgsApplication.pkgDataPath(): {0}'.format(QgsApplication.pkgDataPath())) | ||
# Path after deployment | ||
# QgsSettings.setGlobalSettingsPath(QgsApplication.pkgDataPath() + '/qgis_global_settings.ini') | ||
# Path before deployment | ||
QgsSettings.setGlobalSettingsPath(QgsApplication.pkgDataPath() + '/resources/qgis_global_settings.ini') | ||
assert QgsSettings.setGlobalSettingsPath(QgsApplication.pkgDataPath() + '/resources/qgis_global_settings.ini') |
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.
Better use self.assertTrue
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.
@m-kuhn thanks! Fixed!
@jgrocha sorry if I didn't mentioned it before, but maybe would be better if you move the tests from globaltest_qgis_global_settings.py into test_qgssettings.py. |
@elpaso I was separating all logic regarding to the presence/absence of the new |
@elpaso The new method |
Description
This PR adds a default XYZ connection, so users can add easily OpenStreetMap tiles.
Currently, no layer is added to the map. Later we can add an option to add it by default when starting a new project, but only if the user enables it.
With this connection available, users can add the OpenStreetMap as a new layer with just one double click on it, using the old brower panel or the new brower.
This feature was discusssed on the mailing list. The thread was started by @pcav.
There is a previous PR #4352 that can be closed if this one is merged. The previous PR contains the discussion that supports the approach taken. The approach used is based on the new
qgis_global_settings.ini
. This file is read only and support initial settings. The contents write now are:Removal of global settings
To delete a global settings connection, it is necessary to write something on the local settings.
So, if the user decide to remove the OpenStreetMap default connection, a new entry will be added to the local settings:
connections-xyz\OpenStreetMap\hidden=true
This way, the connection will not be visible. If the user resets his local settings, the global one will be visible again.
Test
To test this PR on a developing environment (QGIS not installed) it is necessary to manually copy or link
qgis_global_settings.ini
to the current developmentQgsApplication::pkgDataPath()
folder, is is problably the root of the repository. Just in case, it can be checked on the Python console with:QgsApplication.pkgDataPath()
. In my case, I just need to;Checklist
fixes #11111
in the commit message next to the description[FEATURE]
in the commit message[needs-docs]
in the commit message and containt sufficient information in the commit message to be documentedscripts/prepare-commit.sh
script before each commit