QGIS API Documentation 4.1.0-Master (376402f9aeb)
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
31
43class CORE_EXPORT QgsUserProfileManager : public QObject
44{
45 Q_OBJECT
46
47 public:
49
51
55 QgsUserProfileManager( const QString &rootLocation = QString(), QObject *parent = nullptr );
56
62 static QString resolveProfilesFolder( const QString &basePath = QString() );
63
75 std::unique_ptr< QgsUserProfile > getProfile( const QString &defaultProfile = "default", bool createNew = true, bool initSettings = true );
76
82 void setRootLocation( const QString &rootProfileLocation );
83
88 QString rootLocation() const { return mRootProfilePath; }
89
100 void setNewProfileNotificationEnabled( bool enabled );
101
109 bool isNewProfileNotificationEnabled() const;
110
115 bool rootLocationIsSet() const;
116
120 QStringList allProfiles() const;
121
126 bool profileExists( const QString &name ) const;
127
136 QString defaultProfileName() const;
137
143 void setDefaultProfileName( const QString &name );
144
148 void setDefaultFromActive();
149
154 QString lastProfileName() const;
155
160 void updateLastProfileName() SIP_SKIP;
161
166 Qgis::UserProfileSelectionPolicy userProfileSelectionPolicy() const;
167
173 void setUserProfileSelectionPolicy( Qgis::UserProfileSelectionPolicy policy );
174
180 std::unique_ptr< QgsUserProfile > profileForName( const QString &name ) const;
181
187 QgsError createUserProfile( const QString &name );
188
195 QgsError deleteProfile( const QString &name );
196
201 QgsUserProfile *userProfile();
202
210 void setActiveUserProfile( const QString &profile );
211
216 void loadUserProfile( const QString &name );
217
222 QSettings *settings();
223
224 signals:
225
236
237 private:
238 bool mWatchProfiles = false;
239 std::unique_ptr<QFileSystemWatcher> mWatcher;
240
241 QString mRootProfilePath;
242
243 std::unique_ptr<QgsUserProfile> mUserProfile;
244
245 QString settingsFile() const;
246
247 std::unique_ptr< QSettings > mSettings;
248};
249
250// clazy:excludeall=qstring-allocations
251
252#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
A boolean settings entry.
A string settings entry.
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 const QgsSettingsEntryString * settingsDefaultProfile
static QString resolveProfilesFolder(const QString &basePath=QString())
Resolves the profiles folder for the given path.
static const QgsSettingsEntryBool * settingsOverrideLocalProfile
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