QGIS API Documentation 3.30.0-'s-Hertogenbosch (f186b8efe0)
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_sip.h"
23#include "qgis_core.h"
24#include "qgserror.h"
25#include "qgsuserprofile.h"
26
27#include <memory>
28
41class 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
115 QStringList allProfiles() const;
116
121 bool profileExists( const QString &name ) const;
122
131 QString defaultProfileName() const;
132
138 void setDefaultProfileName( const QString &name );
139
143 void setDefaultFromActive();
144
150 QgsUserProfile *profileForName( const QString &name ) const SIP_FACTORY;
151
157 QgsError createUserProfile( const QString &name );
158
165 QgsError deleteProfile( const QString &name );
166
171 QgsUserProfile *userProfile();
172
180 void setActiveUserProfile( const QString &profile );
181
186 void loadUserProfile( const QString &name );
187
188 signals:
189
200
201 private:
202
203 bool mWatchProfiles = false;
204 std::unique_ptr<QFileSystemWatcher> mWatcher;
205
206 QString mRootProfilePath;
207
208 std::unique_ptr<QgsUserProfile> mUserProfile;
209
210 QString settingsFile() const;
211
212 std::unique_ptr< QSettings > mSettings;
213};
214
215// clazy:excludeall=qstring-allocations
216
217#endif // QGSUSERPROFILEMANAGER_H
QgsError is container for error messages (report).
Definition: qgserror.h:81
User profile manager is used to manager list, and manage user profiles on the users machine.
QString rootLocation()
Returns the path to the root profiles location.
void profilesChanged()
Emitted when the list of profiles is changed.
User profile contains information about the user profile folders on the machine.
#define SIP_FACTORY
Definition: qgis_sip.h:76