Skip to content
Permalink
Browse files

[FEATURE] Add user profiles.

All user settings/plugins, etc are now loaded from APPDATA for each
platform and no longer .qgis3 and are isolated from each other.
 This allows for different profiles depending on what the user of QGIS
needs, e.g test, prod, demo, etc

Profile menu allows for switching between profiles, or creating new
ones.
  • Loading branch information
NathanW2 committed Apr 9, 2017
1 parent 1961795 commit 7b92f1f1e445e069db0a6fb454318ad789c98778
@@ -7,6 +7,7 @@ qgis_composerutils
ProcessingGrass7AlgorithmsImageryTest
ProcessingGrass7AlgorithmsRasterTest
PyQgsDBManagerGpkg
PyQgsAppStartup

# temporary during processing refactoring
ProcessingParametersTest
@@ -395,5 +395,7 @@
%Include layertree/qgslayertreemodellegendnode.sip
%Include layertree/qgslayertreenode.sip
%Include layertree/qgslayertreeregistrybridge.sip
%Include qgsuserprofilemanager.sip
%Include symbology-ng/qgsarrowsymbollayer.sip
%Include composer/qgscomposerutils.sip
%Include qgsuserprofile.sip
@@ -80,7 +80,7 @@ to change due to centralization.
static const char *QGIS_ORGANIZATION_NAME;
static const char *QGIS_ORGANIZATION_DOMAIN;
static const char *QGIS_APPLICATION_NAME;
QgsApplication( SIP_PYLIST argv, bool GUIenabled, QString customConfigPath = QString() ) / PostHook = __pyQtQAppHook__ / [( int &argc, char **argv, bool GUIenabled, const QString &customConfigPath = QString() )];
QgsApplication( SIP_PYLIST argv, bool GUIenabled, QString profileFolder = QString(), QString platformName = "desktop" ) / PostHook = __pyQtQAppHook__ / [( int &argc, char **argv, bool GUIenabled, const QString &profileFolder = QString(), const QString &platformName = "desktop" )];
%MethodCode
// The Python interface is a list of argument strings that is modified.

@@ -95,7 +95,7 @@ to change due to centralization.
// Create it now the arguments are right.
static int nargc = argc;

sipCpp = new sipQgsApplication( nargc, argv, a1, *a2 );
sipCpp = new sipQgsApplication( nargc, argv, a1, *a2, *a3 );

// Now modify the original list.
qtgui_UpdatePyArgv( a0, argc, argv );
@@ -0,0 +1,88 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/qgsuserprofile.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/


class QgsUserProfile
{
%Docstring
User profile contains information about the user profile folders on the 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.

.. versionadded:: 3.0
%End

%TypeHeaderCode
#include "qgsuserprofile.h"
%End
public:

QgsUserProfile( const QString &folder );
%Docstring
Reference to a existing user profile folder.
Profile folder should be created using QgsProfileManager.
\param folder An existing profile folder as the base of the user profile.
%End

const QString folder() const;
%Docstring
The base folder for the user profile.
:rtype: str
%End

QgsError validate() const;
%Docstring
Check of the profile is in a valid state.
:rtype: QgsError
%End

const QString name() const;
%Docstring
The name for the user profile.
:rtype: str
%End

void initSettings() const;
%Docstring
Init the settings from the user folder.
%End

const QString alias() const;
%Docstring
Return the alias for the user profile.
:return: If no alias is set name() is returned.
:rtype: str
%End

QgsError setAlias( const QString &alias );
%Docstring
Set the alias of the profile. The alias is a user friendly name.
\param alias A user friendly name for the profile.
:return: True of setting the alias was successful.
:rtype: QgsError
%End

const QIcon icon() const;
%Docstring
The icon for the user profile.
:return: A QIcon for the users
:rtype: QIcon
%End

};

/************************************************************************
* This file has been generated automatically from *
* *
* src/core/qgsuserprofile.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
@@ -0,0 +1,178 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/qgsuserprofilemanager.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/





class QgsUserProfileManager : QObject
{
%Docstring
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.

.. versionadded:: 3.0
%End

%TypeHeaderCode
#include "qgsuserprofilemanager.h"
%End
public:

QgsUserProfileManager( const QString &rootLocation = QString(), QObject *parent = 0 );
%Docstring
User profile manager used to manage user profiles for the instance of QGIS.
%End

static QString resolveProfilesFolder( const QString &basePath = QString() );
%Docstring
Resolves the profiles folder for the given path. Path will have \\profiles appended to the path
\param basePath The base path to resolve the path from to append the \\profiles folder to.
:return: The root path to store user profiles.
:rtype: str
%End

QgsUserProfile *getProfile( const QString &defaultProfile = "default", bool createNew = true, bool initSettings = true ) /Factory/;
%Docstring
Return 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.
.. note::

Returns a new QgsUserProfile. Ownership transferred to caller.
\param defaultProfile The profile name to find. Empty profile name will return "default" for the name.
\param createNew Create the profile folder if it doesn't exist.
:return: The user profile
:rtype: QgsUserProfile
%End

void setRootLocation( QString rootProfileLocation );
%Docstring
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.
\param rootProfileLocation Path to the top level profile folder which contains folders for each profile.
%End

QString rootLocation();
%Docstring
Returns the path to the root profiles location.
:return: The root path to the profiles folder.
:rtype: str
%End

bool rootLocationIsSet() const;
%Docstring
Check if the root location has been set for the manager.
:return: True if the root location has been set.
:rtype: bool
%End

QStringList allProfiles() const;
%Docstring
A list of all found profile names.
:return:
:rtype: list of str
%End

bool profileExists( const QString &name ) const;
%Docstring
Check if a profile exists.
:return: False if the profile can't be found.
:rtype: bool
%End

QString defaultProfileName() const;
%Docstring
Returns the name of the default profile that has been set in .default.
:return: The name of the default profile.
:rtype: str
%End

void setDefaultProfileName( const QString &name );
%Docstring
Sets the default profile name. The default profile name is used when loading QGIS
with no arguments.
\param name The name of the profile to save.
%End

void setDefaultFromActive();
%Docstring
Set the default profile name from the current active profile.
%End

QgsUserProfile *profileForName( const QString name ) const;
%Docstring
Return the profile found for a given name.
\param name The name of the profile to return.
:return: A QgsUserprofile pointing to the location of the user profile.
:rtype: QgsUserProfile
%End

QgsError createUserProfile( const QString &name );
%Docstring
Create a user profile given by the name
\param name
:return: A QgsError which report if there was any error creating the user profile.
:rtype: QgsError
%End

QgsError deleteProfile( const QString name );
%Docstring
Deletes a profile from the root profiles folder.
.. note::

There is no undo on this as it deletes the folder from the machine.
\param name The name of the profile to delete.
:return: A QgsError with a message if the profile failed to be deleted.
:rtype: QgsError
%End

QgsUserProfile *userProfile();
%Docstring
The currently active user profile.
:return: The currently active user profile.
:rtype: QgsUserProfile
%End

void setActiveUserProfile( const QString &profile );
%Docstring
Sets the active profile in the manager.
This can only be set once.
Setting this again does nothing.

\param profile The name of the active profile
%End

void loadUserProfile( const QString &name );
%Docstring
Starts a new instance of QGIS for the given profile.
\param name The profile to start QGIS with.
%End

signals:

void profilesChanged( );
%Docstring
Emitted when the list of profiles is changed.
%End

};

/************************************************************************
* This file has been generated automatically from *
* *
* src/core/qgsuserprofilemanager.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/

9 comments on commit 7b92f1f

@nirvn

This comment has been minimized.

Copy link
Contributor

@nirvn nirvn replied Jul 24, 2017

Wouhou!

@Gustry

This comment has been minimized.

Copy link
Contributor

@Gustry Gustry replied Jul 24, 2017

Hi, nice feature ! But I lost all my QGIS toolbar on MacOS, I can't access the toolbar anymore.
screen shot 2017-07-24 at 09 22 13

@NathanW2

This comment has been minimized.

Copy link
Member Author

@NathanW2 NathanW2 replied Jul 24, 2017

@Gustry

This comment has been minimized.

Copy link
Contributor

@Gustry Gustry replied Jul 24, 2017

Sorry, it's still the same

@NathanW2

This comment has been minimized.

Copy link
Member Author

@NathanW2 NathanW2 replied Jul 24, 2017

@Gustry

This comment has been minimized.

Copy link
Contributor

@Gustry Gustry replied Jul 24, 2017

As a quick workaround, I commented out the all block and now it's working :

//  mConfigMenuBar = new QMenuBar( menuBar() );
//  mConfigMenuBar->addMenu( mConfigMenu );
//  menuBar()->setCornerWidget( mConfigMenuBar );
//  mConfigMenuBar->show();

I know I lost your feature, but it's a just workaround for now.

screen shot 2017-07-24 at 12 22 29

@NathanW2

This comment has been minimized.

Copy link
Member Author

@NathanW2 NathanW2 replied Jul 24, 2017

@ghtmtt

This comment has been minimized.

Copy link
Contributor

@ghtmtt ghtmtt replied Jul 24, 2017

@NathanW2 so the folder .qgis3 won't be used anymore?

BTW: this feature is reeealy incredible! Thanks a lot!

@NathanW2

This comment has been minimized.

Copy link
Member Author

@NathanW2 NathanW2 replied Jul 24, 2017

Please sign in to comment.
You can’t perform that action at this time.