QGIS API Documentation 3.41.0-Master (3440c17df1d)
Loading...
Searching...
No Matches
Signals | Public Member Functions | Static Public Member Functions | List of all members
QgsUserProfileManager Class Reference

User profile manager is used to manager list, and manage user profiles on the users machine. More...

#include <qgsuserprofilemanager.h>

Inheritance diagram for QgsUserProfileManager:
Inheritance graph
[legend]

Signals

void profilesChanged ()
 Emitted when the list of profiles is changed.
 

Public Member Functions

 QgsUserProfileManager (const QString &rootLocation=QString(), QObject *parent=nullptr)
 User profile manager used to manage user profiles for the instance of QGIS.
 
QStringList allProfiles () const
 Returns a list of all found profile names.
 
QgsError createUserProfile (const QString &name)
 Create a user profile given by the name.
 
QString defaultProfileName () const
 Returns the name of the default profile that has been set in .default.
 
QgsError deleteProfile (const QString &name)
 Deletes a profile from the root profiles folder.
 
QgsUserProfilegetProfile (const QString &defaultProfile="default", bool createNew=true, bool initSettings=true)
 Returns the profile from the given root profile location.
 
bool isNewProfileNotificationEnabled () const
 Returns whether the manager is watching for the creation of new user profiles and emitting the profilesChanged() signal when this occurs.
 
QString lastProfileName () const
 Returns the name of the most recently closed profile.
 
void loadUserProfile (const QString &name)
 Starts a new instance of QGIS for the given profile.
 
bool profileExists (const QString &name) const
 Check if a profile exists.
 
QgsUserProfileprofileForName (const QString &name) const
 Returns the profile found for a given name.
 
QString rootLocation ()
 Returns the path to the root profiles location.
 
bool rootLocationIsSet () const
 Check if the root location has been set for the manager.
 
void setActiveUserProfile (const QString &profile)
 Sets the active profile in the manager.
 
void setDefaultFromActive ()
 Set the default profile name from the current active profile.
 
void setDefaultProfileName (const QString &name)
 Sets the default profile name.
 
void setNewProfileNotificationEnabled (bool enabled)
 Sets whether the manager should watch for the creation of new user profiles and emit the profilesChanged() signal when this occurs.
 
void setRootLocation (const QString &rootProfileLocation)
 Set the root profile location for the profile manager.
 
QSettings * settings ()
 Returns the settings for the profile manager.
 
void setUserProfileSelectionPolicy (Qgis::UserProfileSelectionPolicy policy)
 Sets the user profile selection policy.
 
void updateLastProfileName ()
 Updates the last closed profile name.
 
QgsUserProfileuserProfile ()
 The currently active user profile.
 
Qgis::UserProfileSelectionPolicy userProfileSelectionPolicy () const
 Returns the user profile selection policy.
 

Static Public Member Functions

static QString resolveProfilesFolder (const QString &basePath=QString())
 Resolves the profiles folder for the given path.
 

Detailed Description

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.

Definition at line 41 of file qgsuserprofilemanager.h.

Constructor & Destructor Documentation

◆ QgsUserProfileManager()

QgsUserProfileManager::QgsUserProfileManager ( const QString &  rootLocation = QString(),
QObject *  parent = nullptr 
)

User profile manager used to manage user profiles for the instance of QGIS.

Definition at line 30 of file qgsuserprofilemanager.cpp.

Member Function Documentation

◆ allProfiles()

QStringList QgsUserProfileManager::allProfiles ( ) const

Returns a list of all found profile names.

Definition at line 143 of file qgsuserprofilemanager.cpp.

◆ createUserProfile()

QgsError QgsUserProfileManager::createUserProfile ( const QString &  name)

Create a user profile given by the name.

Parameters
name
Returns
A QgsError which report if there was any error creating the user profile.

Definition at line 159 of file qgsuserprofilemanager.cpp.

◆ defaultProfileName()

QString QgsUserProfileManager::defaultProfileName ( ) const

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

Definition at line 95 of file qgsuserprofilemanager.cpp.

◆ deleteProfile()

QgsError QgsUserProfileManager::deleteProfile ( const QString &  name)

Deletes a profile from the root profiles folder.

Parameters
nameThe 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.

Definition at line 207 of file qgsuserprofilemanager.cpp.

◆ getProfile()

QgsUserProfile * QgsUserProfileManager::getProfile ( const QString &  defaultProfile = "default",
bool  createNew = true,
bool  initSettings = true 
)

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
defaultProfileThe profile name to find. Empty profile name will return "default" for the name.
createNewCreate the profile folder if it doesn't exist.
initSettingsif the settings should be initialized
Returns
The user profile
Note
Returns a new QgsUserProfile. Ownership transferred to caller.

Definition at line 41 of file qgsuserprofilemanager.cpp.

◆ isNewProfileNotificationEnabled()

bool QgsUserProfileManager::isNewProfileNotificationEnabled ( ) const

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
setNewProfileNotificationEnabled()

Definition at line 85 of file qgsuserprofilemanager.cpp.

◆ lastProfileName()

QString QgsUserProfileManager::lastProfileName ( ) const

Returns the name of the most recently closed profile.

Empty if it is the first time QGIS is run.

Since
QGIS 3.32

Definition at line 121 of file qgsuserprofilemanager.cpp.

◆ loadUserProfile()

void QgsUserProfileManager::loadUserProfile ( const QString &  name)

Starts a new instance of QGIS for the given profile.

Parameters
nameThe profile to start QGIS with.

Definition at line 240 of file qgsuserprofilemanager.cpp.

◆ profileExists()

bool QgsUserProfileManager::profileExists ( const QString &  name) const

Check if a profile exists.

Returns
false if the profile can't be found.

Definition at line 148 of file qgsuserprofilemanager.cpp.

◆ profileForName()

QgsUserProfile * QgsUserProfileManager::profileForName ( const QString &  name) const

Returns the profile found for a given name.

Parameters
nameThe name of the profile to return.
Returns
A QgsUserprofile pointing to the location of the user profile.

Definition at line 153 of file qgsuserprofilemanager.cpp.

◆ profilesChanged

void QgsUserProfileManager::profilesChanged ( )
signal

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
isNewProfileNotificationEnabled()
setNewProfileNotificationEnabled()

◆ resolveProfilesFolder()

QString QgsUserProfileManager::resolveProfilesFolder ( const QString &  basePath = QString())
static

Resolves the profiles folder for the given path.

Path will have \profiles appended to the path

Parameters
basePathThe base path to resolve the path from to append the \profiles folder to.
Returns
The root path to store user profiles.

Definition at line 36 of file qgsuserprofilemanager.cpp.

◆ rootLocation()

QString QgsUserProfileManager::rootLocation ( )
inline

Returns the path to the root profiles location.

Returns
The root path to the profiles folder.

Definition at line 83 of file qgsuserprofilemanager.h.

◆ rootLocationIsSet()

bool QgsUserProfileManager::rootLocationIsSet ( ) const

Check if the root location has been set for the manager.

Returns
true if the root location has been set.

Definition at line 90 of file qgsuserprofilemanager.cpp.

◆ setActiveUserProfile()

void QgsUserProfileManager::setActiveUserProfile ( const QString &  profile)

Sets the active profile in the manager.

This can only be set once. Setting this again does nothing.

Parameters
profileThe name of the active profile

Definition at line 259 of file qgsuserprofilemanager.cpp.

◆ setDefaultFromActive()

void QgsUserProfileManager::setDefaultFromActive ( )

Set the default profile name from the current active profile.

Definition at line 116 of file qgsuserprofilemanager.cpp.

◆ setDefaultProfileName()

void QgsUserProfileManager::setDefaultProfileName ( const QString &  name)

Sets the default profile name.

The default profile name is used when loading QGIS with no arguments.

Parameters
nameThe name of the profile to save.

Definition at line 110 of file qgsuserprofilemanager.cpp.

◆ setNewProfileNotificationEnabled()

void QgsUserProfileManager::setNewProfileNotificationEnabled ( bool  enabled)

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
isNewProfileNotificationEnabled()

Definition at line 67 of file qgsuserprofilemanager.cpp.

◆ setRootLocation()

void QgsUserProfileManager::setRootLocation ( const QString &  rootProfileLocation)

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
rootProfileLocationPath to the top level profile folder which contains folders for each profile.

Definition at line 57 of file qgsuserprofilemanager.cpp.

◆ settings()

QSettings * QgsUserProfileManager::settings ( )

Returns the settings for the profile manager.

Since
QGIS 3.32

Definition at line 230 of file qgsuserprofilemanager.cpp.

◆ setUserProfileSelectionPolicy()

void QgsUserProfileManager::setUserProfileSelectionPolicy ( Qgis::UserProfileSelectionPolicy  policy)

Sets the user profile selection policy.

Parameters
policyThe policy to use when selecting a user profile.
Since
QGIS 3.32

Definition at line 137 of file qgsuserprofilemanager.cpp.

◆ updateLastProfileName()

void QgsUserProfileManager::updateLastProfileName ( )

Updates the last closed profile name.

Called when QGIS is closed.

Since
QGIS 3.32

Definition at line 126 of file qgsuserprofilemanager.cpp.

◆ userProfile()

QgsUserProfile * QgsUserProfileManager::userProfile ( )

The currently active user profile.

Returns
The currently active user profile.

Definition at line 235 of file qgsuserprofilemanager.cpp.

◆ userProfileSelectionPolicy()

Qgis::UserProfileSelectionPolicy QgsUserProfileManager::userProfileSelectionPolicy ( ) const

Returns the user profile selection policy.

Since
QGIS 3.32

Definition at line 132 of file qgsuserprofilemanager.cpp.


The documentation for this class was generated from the following files: