QGIS API Documentation 3.32.0-Lima (311a8cb8a6)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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_sip.h"
24#include "qgis_core.h"
25#include "qgserror.h"
26#include "qgsuserprofile.h"
27
28#include <memory>
29
42class CORE_EXPORT QgsUserProfileManager : public QObject
43{
44 Q_OBJECT
45
46 public:
47
51 QgsUserProfileManager( const QString &rootLocation = QString(), QObject *parent = nullptr );
52
58 static QString resolveProfilesFolder( const QString &basePath = QString() );
59
71 QgsUserProfile *getProfile( const QString &defaultProfile = "default", bool createNew = true, bool initSettings = true ) SIP_FACTORY;
72
78 void setRootLocation( const QString &rootProfileLocation );
79
84 QString rootLocation() { return mRootProfilePath; }
85
96 void setNewProfileNotificationEnabled( bool enabled );
97
105 bool isNewProfileNotificationEnabled() const;
106
111 bool rootLocationIsSet() const;
112
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
150 QString lastProfileName() const;
151
156 void updateLastProfileName() SIP_SKIP;
157
162 Qgis::UserProfileSelectionPolicy userProfileSelectionPolicy() const;
163
169 void setUserProfileSelectionPolicy( Qgis::UserProfileSelectionPolicy policy );
170
176 QgsUserProfile *profileForName( const QString &name ) const SIP_FACTORY;
177
183 QgsError createUserProfile( const QString &name );
184
191 QgsError deleteProfile( const QString &name );
192
197 QgsUserProfile *userProfile();
198
206 void setActiveUserProfile( const QString &profile );
207
212 void loadUserProfile( const QString &name );
213
214 signals:
215
225 void profilesChanged();
226
227 private:
228
229 bool mWatchProfiles = false;
230 std::unique_ptr<QFileSystemWatcher> mWatcher;
231
232 QString mRootProfilePath;
233
234 std::unique_ptr<QgsUserProfile> mUserProfile;
235
236 QString settingsFile() const;
237
238 std::unique_ptr< QSettings > mSettings;
239};
240
241// clazy:excludeall=qstring-allocations
242
243#endif // QGSUSERPROFILEMANAGER_H
The Qgis class provides global constants for use throughout the application.
Definition: qgis.h:54
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.
User profile contains information about the user profile folders on the machine.
std::unique_ptr< GEOSGeometry, GeosDeleter > unique_ptr
Scoped GEOS pointer.
Definition: qgsgeos.h:74
#define SIP_SKIP
Definition: qgis_sip.h:126
#define SIP_FACTORY
Definition: qgis_sip.h:76