QGIS API Documentation 4.1.0-Master (60fea48833c)
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 <memory>
19
20#include "qgis.h"
21#include "qgis_core.h"
22#include "qgis_sip.h"
23#include "qgserror.h"
24#include "qgsuserprofile.h"
25
26#include <QFileSystemWatcher>
27#include <QSettings>
28
40class CORE_EXPORT QgsUserProfileManager : public QObject
41{
42 Q_OBJECT
43
44 public:
48 QgsUserProfileManager( const QString &rootLocation = QString(), QObject *parent = nullptr );
49
55 static QString resolveProfilesFolder( const QString &basePath = QString() );
56
68 std::unique_ptr< QgsUserProfile > getProfile( const QString &defaultProfile = "default", bool createNew = true, bool initSettings = true );
69
75 void setRootLocation( const QString &rootProfileLocation );
76
81 QString rootLocation() const { return mRootProfilePath; }
82
93 void setNewProfileNotificationEnabled( bool enabled );
94
102 bool isNewProfileNotificationEnabled() const;
103
108 bool rootLocationIsSet() const;
109
113 QStringList allProfiles() const;
114
119 bool profileExists( const QString &name ) const;
120
129 QString defaultProfileName() const;
130
136 void setDefaultProfileName( const QString &name );
137
141 void setDefaultFromActive();
142
147 QString lastProfileName() const;
148
153 void updateLastProfileName() SIP_SKIP;
154
159 Qgis::UserProfileSelectionPolicy userProfileSelectionPolicy() const;
160
166 void setUserProfileSelectionPolicy( Qgis::UserProfileSelectionPolicy policy );
167
173 std::unique_ptr< QgsUserProfile > profileForName( const QString &name ) const;
174
180 QgsError createUserProfile( const QString &name );
181
188 QgsError deleteProfile( const QString &name );
189
194 QgsUserProfile *userProfile();
195
203 void setActiveUserProfile( const QString &profile );
204
209 void loadUserProfile( const QString &name );
210
215 QSettings *settings();
216
217 signals:
218
229
230 private:
231 bool mWatchProfiles = false;
232 std::unique_ptr<QFileSystemWatcher> mWatcher;
233
234 QString mRootProfilePath;
235
236 std::unique_ptr<QgsUserProfile> mUserProfile;
237
238 QString settingsFile() const;
239
240 std::unique_ptr< QSettings > mSettings;
241};
242
243// clazy:excludeall=qstring-allocations
244
245#endif // QGSUSERPROFILEMANAGER_H
Provides global constants and enumerations for use throughout the application.
Definition qgis.h:62
A container for error messages.
Definition qgserror.h:83
std::unique_ptr< QgsUserProfile > getProfile(const QString &defaultProfile="default", bool createNew=true, bool initSettings=true)
Returns the profile from the given root profile location.
void setRootLocation(const QString &rootProfileLocation)
Set the root profile location for the profile manager.
static QString resolveProfilesFolder(const QString &basePath=QString())
Resolves the profiles folder for the given path.
QgsUserProfileManager(const QString &rootLocation=QString(), QObject *parent=nullptr)
User profile manager used to manage user profiles for the instance of QGIS.
void profilesChanged()
Emitted when the list of profiles is changed.
QString rootLocation() const
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:133