QGIS API Documentation
3.16.0-Hannover (43b64b13f3)
|
User profile manager is used to manager list, and manage user profiles on the users machine. More...
#include <qgsuserprofilemanager.h>
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... | |
QgsUserProfile * | getProfile (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... | |
QgsUserProfile * | profileForName (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... | |
QgsUserProfile * | userProfile () |
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... | |
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.
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.
QStringList QgsUserProfileManager::allProfiles | ( | ) | const |
Returns a list of all found profile names.
Definition at line 120 of file qgsuserprofilemanager.cpp.
QgsError QgsUserProfileManager::createUserProfile | ( | const QString & | name | ) |
Create a user profile given by the name.
name |
Definition at line 136 of file qgsuserprofilemanager.cpp.
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
Definition at line 94 of file qgsuserprofilemanager.cpp.
QgsError QgsUserProfileManager::deleteProfile | ( | const QString & | name | ) |
Deletes a profile from the root profiles folder.
name | The name of the profile to delete. |
Definition at line 180 of file qgsuserprofilemanager.cpp.
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.
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 |
Definition at line 40 of file qgsuserprofilemanager.cpp.
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.
Definition at line 84 of file qgsuserprofilemanager.cpp.
void QgsUserProfileManager::loadUserProfile | ( | const QString & | name | ) |
Starts a new instance of QGIS for the given profile.
name | The profile to start QGIS with. |
Definition at line 208 of file qgsuserprofilemanager.cpp.
bool QgsUserProfileManager::profileExists | ( | const QString & | name | ) | const |
Check if a profile exists.
false
if the profile can't be found. Definition at line 125 of file qgsuserprofilemanager.cpp.
QgsUserProfile * QgsUserProfileManager::profileForName | ( | const QString & | name | ) | const |
Returns the profile found for a given name.
name | The name of the profile to return. |
Definition at line 130 of file qgsuserprofilemanager.cpp.
|
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.
|
static |
Resolves the profiles folder for the given path.
Path will have \profiles appended to the path
basePath | The base path to resolve the path from to append the \profiles folder to. |
Definition at line 35 of file qgsuserprofilemanager.cpp.
|
inline |
Returns the path to the root profiles location.
Definition at line 83 of file qgsuserprofilemanager.h.
bool QgsUserProfileManager::rootLocationIsSet | ( | ) | const |
Check if the root location has been set for the manager.
true
if the root location has been set. Definition at line 89 of file qgsuserprofilemanager.cpp.
void QgsUserProfileManager::setActiveUserProfile | ( | const QString & | profile | ) |
Sets the active profile in the manager.
This can only be set once. Setting this again does nothing.
profile | The name of the active profile |
Definition at line 227 of file qgsuserprofilemanager.cpp.
void QgsUserProfileManager::setDefaultFromActive | ( | ) |
Set the default profile name from the current active profile.
Definition at line 115 of file qgsuserprofilemanager.cpp.
void QgsUserProfileManager::setDefaultProfileName | ( | const QString & | name | ) |
Sets the default profile name.
The default profile name is used when loading QGIS with no arguments.
name | The name of the profile to save. |
Definition at line 109 of file qgsuserprofilemanager.cpp.
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().
Definition at line 66 of file qgsuserprofilemanager.cpp.
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.
rootProfileLocation | Path to the top level profile folder which contains folders for each profile. |
Definition at line 56 of file qgsuserprofilemanager.cpp.
QgsUserProfile * QgsUserProfileManager::userProfile | ( | ) |
The currently active user profile.
Definition at line 203 of file qgsuserprofilemanager.cpp.