QGIS API Documentation  3.6.0-Noosa (5873452)
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. More...
 

Public Member Functions

 QgsUserProfileManager (const QString &rootLocation=QString(), QObject *parent=nullptr)
 User profile manager used to manage user profiles for the instance of QGIS. More...
 
QStringList allProfiles () const
 Returns a list of all found profile names. More...
 
QgsError createUserProfile (const QString &name)
 Create a user profile given by the name. More...
 
QString defaultProfileName () const
 Returns the name of the default profile that has been set in .default. More...
 
QgsError deleteProfile (const QString &name)
 Deletes a profile from the root profiles folder. More...
 
QgsUserProfilegetProfile (const QString &defaultProfile="default", bool createNew=true, bool initSettings=true)
 Returns the profile from the given root profile location. More...
 
bool isNewProfileNotificationEnabled () const
 Returns whether the manager is watching for the creation of new user profiles and emitting the profilesChanged() signal when this occurs. More...
 
void loadUserProfile (const QString &name)
 Starts a new instance of QGIS for the given profile. More...
 
bool profileExists (const QString &name) const
 Check if a profile exists. More...
 
QgsUserProfileprofileForName (const QString &name) const
 Returns the profile found for a given name. More...
 
QString rootLocation ()
 Returns the path to the root profiles location. More...
 
bool rootLocationIsSet () const
 Check if the root location has been set for the manager. More...
 
void setActiveUserProfile (const QString &profile)
 Sets the active profile in the manager. More...
 
void setDefaultFromActive ()
 Set the default profile name from the current active profile. More...
 
void setDefaultProfileName (const QString &name)
 Sets the default profile name. More...
 
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. More...
 
void setRootLocation (const QString &rootProfileLocation)
 Set the root profile location for the profile manager. More...
 
QgsUserProfileuserProfile ()
 The currently active user profile. More...
 

Static Public Member Functions

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

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.

Since
QGIS 3.0

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 29 of file qgsuserprofilemanager.cpp.

Member Function Documentation

◆ allProfiles()

QStringList QgsUserProfileManager::allProfiles ( ) const

Returns a list of all found profile names.

Definition at line 120 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 136 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 94 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 169 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 40 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 84 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 197 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 125 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 130 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 35 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 89 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 216 of file qgsuserprofilemanager.cpp.

◆ setDefaultFromActive()

void QgsUserProfileManager::setDefaultFromActive ( )

Set the default profile name from the current active profile.

Definition at line 115 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 109 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 66 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 56 of file qgsuserprofilemanager.cpp.

◆ userProfile()

QgsUserProfile * QgsUserProfileManager::userProfile ( )

The currently active user profile.

Returns
The currently active user profile.

Definition at line 192 of file qgsuserprofilemanager.cpp.


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