QGIS API Documentation 3.41.0-Master (3440c17df1d)
Loading...
Searching...
No Matches
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
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
149 QString lastProfileName() const;
150
155 void updateLastProfileName() SIP_SKIP;
156
161 Qgis::UserProfileSelectionPolicy userProfileSelectionPolicy() const;
162
168 void setUserProfileSelectionPolicy( Qgis::UserProfileSelectionPolicy policy );
169
175 QgsUserProfile *profileForName( const QString &name ) const SIP_FACTORY;
176
182 QgsError createUserProfile( const QString &name );
183
190 QgsError deleteProfile( const QString &name );
191
196 QgsUserProfile *userProfile();
197
205 void setActiveUserProfile( const QString &profile );
206
211 void loadUserProfile( const QString &name );
212
217 QSettings *settings();
218
219 signals:
220
230 void profilesChanged();
231
232 private:
233
234 bool mWatchProfiles = false;
235 std::unique_ptr<QFileSystemWatcher> mWatcher;
236
237 QString mRootProfilePath;
238
239 std::unique_ptr<QgsUserProfile> mUserProfile;
240
241 QString settingsFile() const;
242
243 std::unique_ptr< QSettings > mSettings;
244};
245
246// clazy:excludeall=qstring-allocations
247
248#endif // QGSUSERPROFILEMANAGER_H
The Qgis class provides global constants for use throughout the application.
Definition qgis.h:54
A container for error messages.
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.
#define SIP_SKIP
Definition qgis_sip.h:126
#define SIP_FACTORY
Definition qgis_sip.h:76