Skip to content

Latest commit

 

History

History
112 lines (93 loc) · 3.5 KB

userinfo.h

File metadata and controls

112 lines (93 loc) · 3.5 KB
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*
* Copyright (C) 2020 Open Mobile Platform LLC.
*
* You may use this file under the terms of the BSD license as follows:
*
* "Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Nemo Mobile nor the names of its contributors
* may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
*/
#ifndef USERINFO_H
#define USERINFO_H
#include <QObject>
#include <QList>
#include <QSharedPointer>
#include "systemsettingsglobal.h"
class UserInfoPrivate;
Mar 23, 2020
Mar 23, 2020
42
class UserModel;
43
44
45
46
47
48
class SYSTEMSETTINGS_EXPORT UserInfo: public QObject
{
Q_OBJECT
Q_DECLARE_PRIVATE(UserInfo)
Apr 1, 2020
Apr 1, 2020
49
Q_PROPERTY(QString displayName READ displayName NOTIFY displayNameChanged)
50
51
52
Q_PROPERTY(QString username READ username NOTIFY usernameChanged)
Q_PROPERTY(QString name READ name NOTIFY nameChanged)
Q_PROPERTY(UserType type READ type CONSTANT)
Apr 23, 2020
Apr 23, 2020
53
Q_PROPERTY(int uid READ uid WRITE setUid NOTIFY uidChanged)
Mar 31, 2020
Mar 31, 2020
54
Q_PROPERTY(bool current READ current NOTIFY currentChanged)
Apr 27, 2020
Apr 27, 2020
55
Q_PROPERTY(bool alone READ alone NOTIFY aloneChanged)
Mar 23, 2020
Mar 23, 2020
57
58
friend class UserModel;
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
public:
enum UserType {
User = 0,
DeviceOwner = 1,
};
Q_ENUM(UserType)
UserInfo();
UserInfo(const UserInfo &other);
~UserInfo();
static UserInfo placeholder();
bool isValid() const;
Apr 1, 2020
Apr 1, 2020
74
QString displayName() const;
75
76
77
78
QString username() const;
QString name() const;
UserType type() const;
int uid() const;
Apr 23, 2020
Apr 23, 2020
79
void setUid(int uid);
80
bool current() const;
Apr 27, 2020
Apr 27, 2020
81
bool alone();
82
83
84
85
86
87
88
89
Q_INVOKABLE void reset();
UserInfo &operator=(const UserInfo &other);
bool operator==(const UserInfo &other) const;
bool operator!=(const UserInfo &other) const;
signals:
Apr 1, 2020
Apr 1, 2020
90
void displayNameChanged();
91
92
93
void usernameChanged();
void nameChanged();
void uidChanged();
Mar 31, 2020
Mar 31, 2020
94
void currentChanged();
Apr 27, 2020
Apr 27, 2020
95
void aloneChanged();
96
97
98
99
100
101
102
private:
explicit UserInfo(int uid);
explicit UserInfo(QString username);
void setUsername(QString username);
void setName(QString name);
Mar 31, 2020
Mar 31, 2020
103
bool updateCurrent();
Apr 15, 2020
Apr 15, 2020
104
void replace(QSharedPointer<UserInfoPrivate> other);
105
106
void connectSignals();
Apr 23, 2020
Apr 23, 2020
107
void watchForChanges();
Apr 15, 2020
Apr 15, 2020
108
void waitForActivation();
109
110
111
112
QSharedPointer<UserInfoPrivate> d_ptr;
};
#endif /* USERINFO_H */