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 <QQmlEngine>
13#include <QUrl>
14
15#include <KDirWatch>
16#include <KUser>
17
18/**
19 * KUserProxy (exposed as KUser to the QML runtime) is an object allowing
20 * read-only access to the user's name, os and version and the configured
21 * user image. This object can be used to personalize user interfaces.
22 *
23 * Example usage:
24 * @code
25 import org.kde.coreaddons as KCoreAddons
26 [...]
27
28 Item {
29 [...]
30 KCoreAddons.KUser {
31 id: kuser
32 }
33
34 Image {
35 id: faceIcon
36 source: kuser.faceIconUrl
37 [...]
38 }
39
40 Text {
41 text: kuser.fullName
42 [...]
43 }
44 }
45 @endcode
46
47 * @short KUser provides read-only access to the user's personal information
48 * @see KUser
49 */
50class KUserProxy : public QObject
51{
53 QML_NAMED_ELEMENT(KUser)
54
55 Q_PROPERTY(QString fullName READ fullName NOTIFY nameChanged)
56 Q_PROPERTY(QString loginName READ loginName NOTIFY nameChanged)
57 Q_PROPERTY(QUrl faceIconUrl READ faceIconUrl NOTIFY faceIconUrlChanged)
58 Q_PROPERTY(QString os READ os CONSTANT)
59 Q_PROPERTY(QString host READ host CONSTANT)
60
61public:
62 KUserProxy(QObject *parent = nullptr);
63 ~KUserProxy() override;
64
65 /**
66 * @return the full name of the user
67 * @see nameChanged
68 */
69 QString fullName() const;
70
71 /**
72 * @return the user's login name
73 * @see nameChanged
74 *
75 */
76 QString loginName() const;
77
78 /**
79 * @return the url of the user's configured image (including file:/)
80 * @see faceIconUrlChanged
81 */
82 QUrl faceIconUrl() const;
83
84 /**
85 * @return pretty name indicating operating system and version
86 * @see nameChanged
87 */
89
90 /**
91 * @return the system's hostname
92 * @see nameChanged
93 */
94 QString host() const;
95
97 /**
98 * signal that the user's name or login name changed
99 * @see fullName
100 * @see loginName
101 */
103 /**
104 * signal that the user image changed
105 * @see faceIconUrl
106 */
108
109private:
110 void update(const QString &path);
111 KDirWatch m_dirWatch;
112 KUser m_user;
113 QString m_os;
114 bool m_temporaryEmptyFaceIconPath;
115};
116
117#endif // KUSERPROXY_H
Class for watching directory and file changes.
Definition kdirwatch.h:56
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
QObject(QObject *parent)
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
Q_SIGNALSQ_SIGNALS
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri Jan 24 2025 11:55:52 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.