QGIS API Documentation 3.99.0-Master (26c88405ac0)
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:
45
49 QgsUserProfileManager( const QString &rootLocation = QString(), QObject *parent = nullptr );
50
56 static QString resolveProfilesFolder( const QString &basePath = QString() );
57
69 std::unique_ptr< QgsUserProfile > getProfile( const QString &defaultProfile = "default", bool createNew = true, bool initSettings = true );
70
76 void setRootLocation( const QString &rootProfileLocation );
77
82 QString rootLocation() const { return mRootProfilePath; }
83
94 void setNewProfileNotificationEnabled( bool enabled );
95
103 bool isNewProfileNotificationEnabled() const;
104
109 bool rootLocationIsSet() const;
110
114 QStringList allProfiles() const;
115
120 bool profileExists( const QString &name ) const;
121
130 QString defaultProfileName() const;
131
137 void setDefaultProfileName( const QString &name );
138
142 void setDefaultFromActive();
143
148 QString lastProfileName() const;
149
154 void updateLastProfileName() SIP_SKIP;
155
160 Qgis::UserProfileSelectionPolicy userProfileSelectionPolicy() const;
161
167 void setUserProfileSelectionPolicy( Qgis::UserProfileSelectionPolicy policy );
168
174 std::unique_ptr< QgsUserProfile > profileForName( const QString &name ) const;
175
181 QgsError createUserProfile( const QString &name );
182
189 QgsError deleteProfile( const QString &name );
190
195 QgsUserProfile *userProfile();
196
204 void setActiveUserProfile( const QString &profile );
205
210 void loadUserProfile( const QString &name );
211
216 QSettings *settings();
217
218 signals:
219
230
231 private:
232
233 bool mWatchProfiles = false;
234 std::unique_ptr<QFileSystemWatcher> mWatcher;
235
236 QString mRootProfilePath;
237
238 std::unique_ptr<QgsUserProfile> mUserProfile;
239
240 QString settingsFile() const;
241
242 std::unique_ptr< QSettings > mSettings;
243};
244
245// clazy:excludeall=qstring-allocations
246
247#endif // QGSUSERPROFILEMANAGER_H
Provides global constants and enumerations for use throughout the application.
Definition qgis.h:56
A container for error messages.
Definition qgserror.h:81
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:134