KCoreAddons

kuserproxy.h
1/*
2 SPDX-FileCopyrightText: 2013 Marco Martin <mart@kde.org>
3 SPDX-FileCopyrightText: 2014 Sebastian K├╝gler <sebas@kde.org>
4
5 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
6*/
7
8#ifndef KUSERPROXY_H
9#define KUSERPROXY_H
10
11#include <QObject>
12#include <QUrl>
13
14#include <KDirWatch>
15#include <KUser>
16
17/**
18 * KUserProxy (exposed as KUser to the QML runtime) is an object allowing
19 * read-only access to the user's name, os and version and the configured
20 * user image. This object can be used to personalize user interfaces.
21 *
22 * Example usage:
23 * @code
24 import org.kde.coreaddons as KCoreAddons
25 [...]
26
27 Item {
28 [...]
29 KCoreAddons.KUser {
30 id: kuser
31 }
32
33 Image {
34 id: faceIcon
35 source: kuser.faceIconUrl
36 [...]
37 }
38
39 Text {
40 text: kuser.fullName
41 [...]
42 }
43 }
44 @endcode
45
46 * @short KUser provides read-only access to the user's personal information
47 * @see KUser
48 */
49class KUserProxy : public QObject
50{
52
53 Q_PROPERTY(QString fullName READ fullName NOTIFY nameChanged)
54 Q_PROPERTY(QString loginName READ loginName NOTIFY nameChanged)
55 Q_PROPERTY(QUrl faceIconUrl READ faceIconUrl NOTIFY faceIconUrlChanged)
56 Q_PROPERTY(QString os READ os CONSTANT)
57 Q_PROPERTY(QString host READ host CONSTANT)
58
59public:
60 KUserProxy(QObject *parent = nullptr);
61 ~KUserProxy() override;
62
63 /**
64 * @return the full name of the user
65 * @see nameChanged
66 */
67 QString fullName() const;
68
69 /**
70 * @return the user's login name
71 * @see nameChanged
72 *
73 */
74 QString loginName() const;
75
76 /**
77 * @return the url of the user's configured image (including file:/)
78 * @see faceIconUrlChanged
79 */
80 QUrl faceIconUrl() const;
81
82 /**
83 * @return pretty name indicating operating system and version
84 * @see nameChanged
85 */
87
88 /**
89 * @return the system's hostname
90 * @see nameChanged
91 */
92 QString host() const;
93
95 /**
96 * signal that the user's name or login name changed
97 * @see fullName
98 * @see loginName
99 */
101 /**
102 * signal that the user image changed
103 * @see faceIconUrl
104 */
106
107private:
108 void update(const QString &path);
109 KDirWatch m_dirWatch;
110 KUser m_user;
111 QString m_os;
112 bool m_temporaryEmptyFaceIconPath;
113};
114
115#endif // KUSERPROXY_H
Class for watching directory and file changes.
Definition kdirwatch.h:56
KUserProxy (exposed as KUser to the QML runtime) is an object allowing read-only access to the user's...
Definition kuserproxy.h:50
void faceIconUrlChanged()
signal that the user image changed
void nameChanged()
signal that the user's name or login name changed
QString os()
Represents a user on your system.
Definition kuser.h:226
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
Q_SIGNALSQ_SIGNALS
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jun 7 2024 12:01:00 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.