Class: QgsUserProfileManager¶
-
class
qgis.core.
QgsUserProfileManager
(rootLocation: str = '', parent: QObject = None)¶ Bases:
PyQt5.QtCore.QObject
User profile manager used to manage user profiles for the instance of QGIS.
User profile manager is used to manager list, and manage user profiles on the users machine.
In QGIS 3 all settings, plugins, etc were moved into a %APPDATA%/profiles folder for each platform. This allows for manage different user profiles per machine vs the single default one that was allowed in the past.
A user profile is all settings and anything that used to be found in .qgis3 in the users home folder.
New in version 3.0: Enums
Methods
Returns a list of all found profile names.
Create a user profile given by the name
Returns the name of the default profile that has been set in .default.
Deletes a profile from the root profiles folder.
Returns the profile from the given root profile location.
Returns whether the manager is watching for the creation of new user profiles and emitting the profilesChanged() signal when this occurs.
Starts a new instance of QGIS for the given profile.
Check if a profile exists.
Returns the profile found for a given name.
Resolves the profiles folder for the given path.
Returns the path to the root profiles location.
Check if the root location has been set for the manager.
Sets the active profile in the manager.
Set the default profile name from the current active profile.
Sets the default profile name.
Sets whether the manager should watch for the creation of new user profiles and emit the profilesChanged() signal when this occurs.
Set the root profile location for the profile manager.
The currently active user profile.
Signals
Emitted when the list of profiles is changed.
Attributes
-
allProfiles
(self) → List[str]¶ Returns a list of all found profile names.
-
childEvent
()¶
-
connectNotify
()¶
-
createUserProfile
(self, name: str) → QgsError¶ Create a user profile given by the name
- Parameters
name –
- Returns
A QgsError which report if there was any error creating the user profile.
-
customEvent
()¶
-
defaultProfileName
(self) → str¶ 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
- Returns
The name of the default profile.
Note
Setting overrideLocalProfile in global settings will always ignore profiles.ini
-
deleteProfile
(self, name: str) → QgsError¶ Deletes a profile from the root profiles folder.
- Parameters
name – The name of the profile to delete.
- Returns
A QgsError with a message if the profile failed to be deleted.
Note
There is no undo on this as it deletes the folder from the machine.
-
disconnectNotify
()¶
-
getProfile
(self, defaultProfile: str = '', createNew: bool = True, initSettings: bool = True) → QgsUserProfile¶ Returns the profile from the given root profile location. If no name is given it returns a profile called “default”. By default will create the profile folder if not found. By default will init the user settings.
- Parameters
defaultProfile – The profile name to find. Empty profile name will return “default” for the name.
createNew – Create the profile folder if it doesn’t exist.
initSettings – if the settings should be initialized
- Returns
The user profile
Note
Returns a new
QgsUserProfile
. Ownership transferred to caller.
-
isNewProfileNotificationEnabled
(self) → bool¶ Returns whether the manager is watching for the creation of new user profiles and emitting the profilesChanged() signal when this occurs. By default new profile notification is disabled.
See also
-
isSignalConnected
()¶
-
loadUserProfile
(self, name: str)¶ Starts a new instance of QGIS for the given profile.
- Parameters
name – The profile to start QGIS with.
-
profileExists
(self, name: str) → bool¶ Check if a profile exists.
- Returns
False if the profile can’t be found.
-
profileForName
(self, name: str) → QgsUserProfile¶ Returns the profile found for a given name.
- Parameters
name – The name of the profile to return.
- Returns
A QgsUserprofile pointing to the location of the user profile.
-
profilesChanged
¶ Emitted when the list of profiles is changed.
This signal will only be emitted when isNewProfileNotificationEnabled() is true. By default new profile notification is disabled.
See also
See also
setNewProfileNotificationEnabled()
[signal]
-
receivers
()¶
-
resolveProfilesFolder
(basePath: str = '') → str¶ Resolves the profiles folder for the given path. Path will have \profiles appended to the path
- Parameters
basePath – The base path to resolve the path from to append the \profiles folder to.
- Returns
The root path to store user profiles.
-
rootLocation
(self) → str¶ Returns the path to the root profiles location.
- Returns
The root path to the profiles folder.
-
rootLocationIsSet
(self) → bool¶ Check if the root location has been set for the manager.
- Returns
True if the root location has been set.
-
sender
()¶
-
senderSignalIndex
()¶
-
setActiveUserProfile
(self, profile: str)¶ Sets the active profile in the manager. This can only be set once. Setting this again does nothing.
- Parameters
profile – The name of the active profile
-
setDefaultFromActive
(self)¶ Set the default profile name from the current active profile.
-
setDefaultProfileName
(self, name: str)¶ Sets the default profile name. The default profile name is used when loading QGIS with no arguments.
- Parameters
name – The name of the profile to save.
-
setNewProfileNotificationEnabled
(self, enabled: bool)¶ Sets whether the manager should watch for the creation of new user profiles and emit the profilesChanged() signal when this occurs. By default new profile notification is disabled.
Before calling this, ensure that the correct root location has been set via calling setRootLocation().
See also
-
setRootLocation
(self, rootProfileLocation: str)¶ Set the root profile location for the profile manager. All profiles are loaded from this location. Will also contain a profiles.ini for holding profile settings.
- Parameters
rootProfileLocation – Path to the top level profile folder which contains folders for each profile.
-
timerEvent
()¶
-
userProfile
(self) → QgsUserProfile¶ The currently active user profile.
- Returns
The currently active user profile.
-