QGIS API Documentation  3.0.2-Girona (307d082)
qgsuserprofilemanager.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsuserprofilemanager.h
3  --------------------------------------
4  Date : Jul-2017
5  Copyright : (C) 2017 by Nathan Woodrow
6  Email : woodrow.nathan at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 #ifndef QGSUSERPROFILEMANAGER_H
16 #define QGSUSERPROFILEMANAGER_H
17 
18 #include <QSettings>
19 #include <QFileSystemWatcher>
20 
21 
22 #include "qgis.h"
23 #include "qgis_core.h"
24 #include "qgserror.h"
25 #include "qgsuserprofile.h"
26 
27 #include <memory>
28 
41 class CORE_EXPORT QgsUserProfileManager : public QObject
42 {
43  Q_OBJECT
44 
45  public:
46 
50  QgsUserProfileManager( const QString &rootLocation = QString(), QObject *parent = nullptr );
51 
57  static QString resolveProfilesFolder( const QString &basePath = QString() );
58 
70  QgsUserProfile *getProfile( const QString &defaultProfile = "default", bool createNew = true, bool initSettings = true ) SIP_FACTORY;
71 
77  void setRootLocation( const QString &rootProfileLocation );
78 
83  QString rootLocation() { return mRootProfilePath; }
84 
95  void setNewProfileNotificationEnabled( bool enabled );
96 
104  bool isNewProfileNotificationEnabled() const;
105 
110  bool rootLocationIsSet() const;
111 
116  QStringList allProfiles() const;
117 
122  bool profileExists( const QString &name ) const;
123 
132  QString defaultProfileName() const;
133 
139  void setDefaultProfileName( const QString &name );
140 
144  void setDefaultFromActive();
145 
151  QgsUserProfile *profileForName( const QString &name ) const SIP_FACTORY;
152 
158  QgsError createUserProfile( const QString &name );
159 
166  QgsError deleteProfile( const QString &name );
167 
172  QgsUserProfile *userProfile();
173 
181  void setActiveUserProfile( const QString &profile );
182 
187  void loadUserProfile( const QString &name );
188 
189  signals:
190 
200  void profilesChanged();
201 
202  private:
203 
204  bool mWatchProfiles = false;
205  std::unique_ptr<QFileSystemWatcher> mWatcher;
206 
207  QString mRootProfilePath;
208 
209  std::unique_ptr<QgsUserProfile> mUserProfile;
210 
211  QString settingsFile() const;
212 
213  std::unique_ptr< QSettings > mSettings;
214 };
215 
216 // clazy:excludeall=qstring-allocations
217 
218 #endif // QGSUSERPROFILEMANAGER_H
User profile contains information about the user profile folders on the machine.
#define SIP_FACTORY
Definition: qgis_sip.h:69
QString rootLocation()
Returns the path to the root profiles location.
QgsError is container for error messages (report).
Definition: qgserror.h:80
User profile manager is used to manager list, and manage user profiles on the users machine...