mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-25 14:36:01 +03:00
Make the Account store the avatar pixmap.
The avatar pixmap is fetched from the server by the Connectionvalidator, once it has validated the user name, it queries the avatar pixmap. If the server does not have the avatar route, an empty pixmap is stored.
This commit is contained in:
parent
b49dd02e3d
commit
e05d6bfcdc
4 changed files with 30 additions and 0 deletions
|
@ -90,6 +90,16 @@ void Account::setDavUser(const QString &newDavUser)
|
|||
_davUser = newDavUser;
|
||||
}
|
||||
|
||||
QPixmap Account::avatar() const
|
||||
{
|
||||
return _avatarPixmap;
|
||||
}
|
||||
void Account::setAvatar(const QPixmap& pixmap)
|
||||
{
|
||||
_avatarPixmap = pixmap;
|
||||
emit accountChangedAvatar();
|
||||
}
|
||||
|
||||
QString Account::displayName() const
|
||||
{
|
||||
QString dn = QString("%1@%2").arg(_credentials->user(), _url.host());
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
#include <QSslCipher>
|
||||
#include <QSslError>
|
||||
#include <QSharedPointer>
|
||||
#include <QPixmap>
|
||||
|
||||
#include "utility.h"
|
||||
#include <memory>
|
||||
#include "capabilities.h"
|
||||
|
@ -78,6 +80,9 @@ public:
|
|||
QString davUser() const;
|
||||
void setDavUser(const QString &newDavUser);
|
||||
|
||||
QPixmap avatar() const;
|
||||
void setAvatar(const QPixmap& pixmap);
|
||||
|
||||
/// The name of the account as shown in the toolbar
|
||||
QString displayName() const;
|
||||
|
||||
|
@ -197,6 +202,8 @@ signals:
|
|||
|
||||
void serverVersionChanged(Account* account, const QString& newVersion, const QString& oldVersion);
|
||||
|
||||
void accountChangedAvatar();
|
||||
|
||||
protected Q_SLOTS:
|
||||
void slotHandleSslErrors(QNetworkReply*,QList<QSslError>);
|
||||
void slotCredentialsFetched();
|
||||
|
@ -209,6 +216,7 @@ private:
|
|||
QWeakPointer<Account> _sharedThis;
|
||||
QString _id;
|
||||
QString _davUser;
|
||||
QPixmap _avatarPixmap;
|
||||
QMap<QString, QVariant> _settingsMap;
|
||||
QUrl _url;
|
||||
QList<QSslCertificate> _approvedCerts;
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include <QtCore>
|
||||
#include <QNetworkReply>
|
||||
#include <QNetworkProxyFactory>
|
||||
#include <QPixmap>
|
||||
|
||||
#include "connectionvalidator.h"
|
||||
#include "account.h"
|
||||
|
@ -252,7 +253,17 @@ void ConnectionValidator::slotUserFetched(const QVariantMap &json)
|
|||
QString user = json.value("ocs").toMap().value("data").toMap().value("id").toString();
|
||||
if (!user.isEmpty()) {
|
||||
_account->setDavUser(user);
|
||||
|
||||
AvatarJob *job = new AvatarJob(_account, this);
|
||||
QObject::connect(job, SIGNAL(avatarPixmap(QPixmap)), this, SLOT(slotAvatarPixmap(QPixmap)));
|
||||
|
||||
job->start();
|
||||
}
|
||||
}
|
||||
|
||||
void ConnectionValidator::slotAvatarPixmap(const QPixmap& pixmap)
|
||||
{
|
||||
_account->setAvatar(pixmap);
|
||||
reportResult(Connected);
|
||||
}
|
||||
|
||||
|
|
|
@ -119,6 +119,7 @@ protected slots:
|
|||
|
||||
void slotCapabilitiesRecieved(const QVariantMap&);
|
||||
void slotUserFetched(const QVariantMap &);
|
||||
void slotAvatarPixmap(const QPixmap&);
|
||||
|
||||
private:
|
||||
void reportResult(Status status);
|
||||
|
|
Loading…
Reference in a new issue