mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-15 00:04:00 -04:00
Load default profile name from global
Also adds overrideLocalProfile to ignore local profiles.ini file
This commit is contained in:
parent
e37f682cca
commit
12c634cef3
@ -8,7 +8,6 @@
|
||||
|
||||
|
||||
|
||||
|
||||
class QgsUserProfile
|
||||
{
|
||||
%Docstring
|
||||
|
@ -95,6 +95,12 @@ class QgsUserProfileManager : QObject
|
||||
QString defaultProfileName() const;
|
||||
%Docstring
|
||||
Returns the name of the default profile that has been set in .default.
|
||||
First checks profile.ini in \\profiles folder
|
||||
Then checks defaultProfile in global settings
|
||||
Finally returns "default" if all else fails
|
||||
.. note::
|
||||
|
||||
Setting overrideLocalProfile in global settings will always ignore profiles.ini
|
||||
:return: The name of the default profile.
|
||||
:rtype: str
|
||||
%End
|
||||
|
@ -821,9 +821,9 @@ int main( int argc, char *argv[] )
|
||||
{
|
||||
configLocalStorageLocation = getenv( "QGIS_CUSTOM_CONFIG_PATH" );
|
||||
}
|
||||
else if ( settings.contains( "profiles-path", QgsSettings::Core ) )
|
||||
else if ( settings.contains( "profilesPath", QgsSettings::Core ) )
|
||||
{
|
||||
configLocalStorageLocation = settings.value( "profiles-path", "", QgsSettings::Core ).toString();
|
||||
configLocalStorageLocation = settings.value( "profilesPath", "", QgsSettings::Core ).toString();
|
||||
QgsDebugMsg( QString( "Loading profiles path from global config at %1" ).arg( configLocalStorageLocation ) );
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
/***************************************************************************
|
||||
qgsuserprofile.h
|
||||
--------------------------------------
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "qgsuserprofile.h"
|
||||
#include "qgsapplication.h"
|
||||
#include "qgslogger.h"
|
||||
#include "qgssettings.h"
|
||||
|
||||
#include <QFile>
|
||||
#include <QDir>
|
||||
@ -80,14 +81,22 @@ bool QgsUserProfileManager::rootLocationIsSet() const
|
||||
|
||||
QString QgsUserProfileManager::defaultProfileName() const
|
||||
{
|
||||
QString profileName = "default";
|
||||
mSettings->value( "/defaultProfile", "default" );
|
||||
return profileName;
|
||||
QString defaultName = "default";
|
||||
// If the profiles.ini doesn't have the default profile we grab it from
|
||||
// global settings as it might be set by the admin.
|
||||
// If the overrideProfile flag is set then no matter what the profiles.ini says we always take the
|
||||
// global profile.
|
||||
QgsSettings globalSettings;
|
||||
if ( !mSettings->contains( "/core/defaultProfile" ) || globalSettings.value( "overrideLocalProfile", false, QgsSettings::Core ).toBool() )
|
||||
{
|
||||
return globalSettings.value( "defaultProfile", defaultName, QgsSettings::Core ).toString();
|
||||
}
|
||||
return mSettings->value( "/core/defaultProfile", defaultName ).toString();
|
||||
}
|
||||
|
||||
void QgsUserProfileManager::setDefaultProfileName( const QString &name )
|
||||
{
|
||||
mSettings->setValue( "/defaultProfile", name );
|
||||
mSettings->setValue( "/core/defaultProfile", name );
|
||||
mSettings->sync();
|
||||
}
|
||||
|
||||
|
@ -100,6 +100,10 @@ class CORE_EXPORT QgsUserProfileManager : public QObject
|
||||
|
||||
/**
|
||||
* Returns the name of the default profile that has been set in .default.
|
||||
* First checks profile.ini in \\profiles folder
|
||||
* Then checks defaultProfile in global settings
|
||||
* Finally returns "default" if all else fails
|
||||
* \note Setting overrideLocalProfile in global settings will always ignore profiles.ini
|
||||
* \return The name of the default profile.
|
||||
*/
|
||||
QString defaultProfileName() const;
|
||||
|
Loading…
x
Reference in New Issue
Block a user