matrixion/src/ui/UserProfile.h

54 lines
1.4 KiB
C
Raw Normal View History

2020-05-17 16:34:47 +03:00
#pragma once
#include <QObject>
#include <QString>
2020-05-27 11:49:26 +03:00
#include <QVector>
2020-05-17 16:34:47 +03:00
2020-05-22 08:47:02 +03:00
#include "MatrixClient.h"
class DeviceInfo
2020-05-17 16:34:47 +03:00
{
2020-05-22 08:47:02 +03:00
public:
2020-05-27 11:49:26 +03:00
DeviceInfo(const QString deviceID, const QString displayName)
: device_id(deviceID)
, display_name(displayName)
{}
DeviceInfo() {}
2020-05-22 08:47:02 +03:00
2020-05-17 16:34:47 +03:00
QString device_id;
QString display_name;
};
class UserProfile : public QObject
{
Q_OBJECT
2020-05-27 11:49:26 +03:00
Q_PROPERTY(QString userId READ getUserId WRITE setUserId NOTIFY userIdChanged)
2020-05-22 08:47:02 +03:00
Q_PROPERTY(QVector<DeviceInfo> deviceList READ getDeviceList NOTIFY deviceListUpdated)
2020-05-17 16:34:47 +03:00
public:
2020-05-22 08:47:02 +03:00
// constructor
2020-05-17 16:34:47 +03:00
explicit UserProfile(QObject *parent = 0);
2020-05-22 08:47:02 +03:00
// getters
QVector<DeviceInfo> getDeviceList();
QString getUserId();
// setters
void setUserId(const QString &userId);
2020-05-17 16:34:47 +03:00
Q_INVOKABLE void fetchDeviceList(const QString &userID);
2020-05-27 11:49:26 +03:00
Q_INVOKABLE void updateDeviceList();
2020-06-26 01:54:42 +03:00
Q_INVOKABLE void banUser();
// Q_INVOKABLE void ignoreUser();
Q_INVOKABLE void kickUser();
Q_INVOKABLE void startChat();
2020-05-17 16:34:47 +03:00
signals:
2020-05-27 11:49:26 +03:00
void userIdChanged();
2020-05-22 08:47:02 +03:00
void deviceListUpdated();
2020-05-17 16:34:47 +03:00
private:
2020-05-22 08:47:02 +03:00
QVector<DeviceInfo> deviceList;
QString userId;
2020-06-28 18:31:34 +03:00
void callback_fn(const mtx::responses::QueryKeys &res,
mtx::http::RequestErr err,
std::string user_id);
2020-05-17 16:34:47 +03:00
};