QGIS API Documentation 3.41.0-Master (45a0abf3bec)
|
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. | |
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. | |
QgsUserProfile * | getProfile (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. | |
QgsUserProfile * | profileForName (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. | |
QgsUserProfile * | userProfile () |
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. | |
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 30 of file qgsuserprofilemanager.cpp.
QStringList QgsUserProfileManager::allProfiles | ( | ) | const |
Returns a list of all found profile names.
Definition at line 143 of file qgsuserprofilemanager.cpp.
QgsError QgsUserProfileManager::createUserProfile | ( | const QString & | name | ) |
Create a user profile given by the name.
name |
Definition at line 159 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 95 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 207 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 41 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 85 of file qgsuserprofilemanager.cpp.
QString QgsUserProfileManager::lastProfileName | ( | ) | const |
Returns the name of the most recently closed profile.
Empty if it is the first time QGIS is run.
Definition at line 121 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 240 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 148 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 153 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 36 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 90 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 259 of file qgsuserprofilemanager.cpp.
void QgsUserProfileManager::setDefaultFromActive | ( | ) |
Set the default profile name from the current active profile.
Definition at line 116 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 110 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 67 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 57 of file qgsuserprofilemanager.cpp.
QSettings * QgsUserProfileManager::settings | ( | ) |
Returns the settings for the profile manager.
Definition at line 230 of file qgsuserprofilemanager.cpp.
void QgsUserProfileManager::setUserProfileSelectionPolicy | ( | Qgis::UserProfileSelectionPolicy | policy | ) |
Sets the user profile selection policy.
policy | The policy to use when selecting a user profile. |
Definition at line 137 of file qgsuserprofilemanager.cpp.
void QgsUserProfileManager::updateLastProfileName | ( | ) |
Updates the last closed profile name.
Called when QGIS is closed.
Definition at line 126 of file qgsuserprofilemanager.cpp.
QgsUserProfile * QgsUserProfileManager::userProfile | ( | ) |
The currently active user profile.
Definition at line 235 of file qgsuserprofilemanager.cpp.
Qgis::UserProfileSelectionPolicy QgsUserProfileManager::userProfileSelectionPolicy | ( | ) | const |
Returns the user profile selection policy.
Definition at line 132 of file qgsuserprofilemanager.cpp.