From b49dd02e3d5592047ace74525addcd4eb8d300b1 Mon Sep 17 00:00:00 2001 From: Klaas Freitag Date: Sun, 22 Jan 2017 13:52:19 +0100 Subject: [PATCH 1/8] New network job AvatarJob: GETs the account avatar from server. --- src/libsync/networkjobs.cpp | 37 +++++++++++++++++++++++++++++++++++++ src/libsync/networkjobs.h | 30 ++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) diff --git a/src/libsync/networkjobs.cpp b/src/libsync/networkjobs.cpp index 4cc5801ae..5568105d9 100644 --- a/src/libsync/networkjobs.cpp +++ b/src/libsync/networkjobs.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include "json.h" @@ -589,6 +590,42 @@ bool PropfindJob::finished() /*********************************************************************************************/ +AvatarJob::AvatarJob(AccountPtr account, QObject *parent) + : AbstractNetworkJob(account, QString(), parent) +{ + _avatarUrl = Utility::concatUrlPath(account->url(), QString("remote.php/dav/avatars/%1/128.png").arg(account->davUser())); +} + +void AvatarJob::start() +{ + QNetworkRequest req; + setReply(davRequest("GET", _avatarUrl, req)); + setupConnections(reply()); + AbstractNetworkJob::start(); +} + +bool AvatarJob::finished() +{ + int http_result_code = reply()->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); + + QPixmap avPixmap; + + if (http_result_code == 200) { + + QByteArray pngData = reply()->readAll(); + if( pngData.size() ) { + + if( avPixmap.loadFromData(pngData) ) { + qDebug() << "Retrieved Avatar pixmap!"; + } + } + } + emit(avatarPixmap(avPixmap)); + return true; +} + +/*********************************************************************************************/ + ProppatchJob::ProppatchJob(AccountPtr account, const QString &path, QObject *parent) : AbstractNetworkJob(account, path, parent) { diff --git a/src/libsync/networkjobs.h b/src/libsync/networkjobs.h index f7a37d950..2493be31d 100644 --- a/src/libsync/networkjobs.h +++ b/src/libsync/networkjobs.h @@ -129,6 +129,36 @@ private: QList _properties; }; + +/** + * @brief The AvatarJob class + * + * Retrieves the account users avatar from the server using a GET request. + * + * If the server does not have the avatar, the result Pixmap is empty. + * + * @ingroup libsync + */ +class OWNCLOUDSYNC_EXPORT AvatarJob : public AbstractNetworkJob { + Q_OBJECT +public: + explicit AvatarJob(AccountPtr account, QObject *parent = 0); + void start() Q_DECL_OVERRIDE; + +signals: + /** + * @brief avatarPixmap - returns either a valid pixmap or not. + */ + + void avatarPixmap(QPixmap); + +private slots: + virtual bool finished() Q_DECL_OVERRIDE; + +private: + QUrl _avatarUrl; +}; + /** * @brief Send a Proppatch request * From e05d6bfcdc39b551d0a29c763afcabcadb5d05a6 Mon Sep 17 00:00:00 2001 From: Klaas Freitag Date: Sun, 22 Jan 2017 13:55:08 +0100 Subject: [PATCH 2/8] 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. --- src/libsync/account.cpp | 10 ++++++++++ src/libsync/account.h | 8 ++++++++ src/libsync/connectionvalidator.cpp | 11 +++++++++++ src/libsync/connectionvalidator.h | 1 + 4 files changed, 30 insertions(+) diff --git a/src/libsync/account.cpp b/src/libsync/account.cpp index 77f953659..ad4ca60f4 100644 --- a/src/libsync/account.cpp +++ b/src/libsync/account.cpp @@ -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()); diff --git a/src/libsync/account.h b/src/libsync/account.h index 2c21fa548..a4894a6e9 100644 --- a/src/libsync/account.h +++ b/src/libsync/account.h @@ -26,6 +26,8 @@ #include #include #include +#include + #include "utility.h" #include #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); void slotCredentialsFetched(); @@ -209,6 +216,7 @@ private: QWeakPointer _sharedThis; QString _id; QString _davUser; + QPixmap _avatarPixmap; QMap _settingsMap; QUrl _url; QList _approvedCerts; diff --git a/src/libsync/connectionvalidator.cpp b/src/libsync/connectionvalidator.cpp index ec63685aa..d1c40d768 100644 --- a/src/libsync/connectionvalidator.cpp +++ b/src/libsync/connectionvalidator.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #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); } diff --git a/src/libsync/connectionvalidator.h b/src/libsync/connectionvalidator.h index 13e1435a5..e4f0fac7f 100644 --- a/src/libsync/connectionvalidator.h +++ b/src/libsync/connectionvalidator.h @@ -119,6 +119,7 @@ protected slots: void slotCapabilitiesRecieved(const QVariantMap&); void slotUserFetched(const QVariantMap &); + void slotAvatarPixmap(const QPixmap&); private: void reportResult(Status status); From d466a059151fec1ed883ea124e6bc7dcf9a2457d Mon Sep 17 00:00:00 2001 From: Klaas Freitag Date: Sun, 22 Jan 2017 13:58:36 +0100 Subject: [PATCH 3/8] SettingsDialog: Display the user avatar as action icon if available. The avatar image is fetched from the server async, thus connect a signal from the account if the avatar changes. Server feature https://github.com/owncloud/core/pull/26872 is needed. --- src/gui/settingsdialog.cpp | 48 +++++++++++++++++++++++++++++++++----- src/gui/settingsdialog.h | 7 ++++++ 2 files changed, 49 insertions(+), 6 deletions(-) diff --git a/src/gui/settingsdialog.cpp b/src/gui/settingsdialog.cpp index 499fb3e0a..665738cd4 100644 --- a/src/gui/settingsdialog.cpp +++ b/src/gui/settingsdialog.cpp @@ -196,8 +196,17 @@ void SettingsDialog::accountAdded(AccountState *s) bool brandingSingleAccount = !Theme::instance()->multiAccount(); - auto accountAction = createColorAwareAction(QLatin1String(":/client/resources/account.png"), - brandingSingleAccount ? tr("Account") : s->account()->displayName()); + QAction *accountAction; + QPixmap avatar = s->account()->avatar(); + const QString actionText = brandingSingleAccount ? tr("Account") : s->account()->displayName(); + if(avatar.isNull()) { + accountAction = createColorAwareAction(QLatin1String(":/client/resources/account.png"), + actionText); + } else { + QIcon icon(avatar); + accountAction = createActionWithIcon(icon, actionText); + } + if (!brandingSingleAccount) { accountAction->setToolTip(s->account()->displayName()); accountAction->setIconText(s->shortDisplayNameForSettings(height * buttonSizeRatio)); @@ -207,14 +216,30 @@ void SettingsDialog::accountAdded(AccountState *s) _ui->stack->insertWidget(0 , accountSettings); _actionGroup->addAction(accountAction); _actionGroupWidgets.insert(accountAction, accountSettings); + _actionForAccount.insert(s->account().data(), accountAction); connect( accountSettings, SIGNAL(folderChanged()), _gui, SLOT(slotFoldersChanged())); connect( accountSettings, SIGNAL(openFolderAlias(const QString&)), _gui, SLOT(slotFolderOpenAction(QString))); + connect(s->account().data(), SIGNAL(accountChangedAvatar()), SLOT(slotAccountAvatarChanged())); slotRefreshActivity(s); } +void SettingsDialog::slotAccountAvatarChanged() +{ + Account *account = static_cast(sender()); + if( account && _actionForAccount.contains(account)) { + QAction *action = _actionForAccount[account]; + if( action ) { + QPixmap pix = account->avatar(); + if( !pix.isNull() ) { + action->setIcon( QIcon(pix) ); + } + } + } +} + void SettingsDialog::accountRemoved(AccountState *s) { for (auto it = _actionGroupWidgets.begin(); it != _actionGroupWidgets.end(); ++it) { @@ -236,6 +261,9 @@ void SettingsDialog::accountRemoved(AccountState *s) } } + if( _actionForAccount.contains(s->account().data()) ) { + _actionForAccount.remove(s->account().data()); + } _activitySettings->slotRemoveAccount(s); // Hide when the last account is deleted. We want to enter the same @@ -306,14 +334,22 @@ public: } }; +QAction *SettingsDialog::createActionWithIcon(const QIcon& icon, const QString& text, const QString& iconPath) +{ + QAction *action = new ToolButtonAction(icon, text, this); + action->setCheckable(true); + if(!iconPath.isEmpty()) { + action->setProperty("iconPath", iconPath); + } + return action; + +} + QAction *SettingsDialog::createColorAwareAction(const QString &iconPath, const QString &text) { // all buttons must have the same size in order to keep a good layout QIcon coloredIcon = createColorAwareIcon(iconPath); - QAction *action = new ToolButtonAction(coloredIcon, text, this); - action->setCheckable(true); - action->setProperty("iconPath", iconPath); - return action; + return createActionWithIcon(coloredIcon, text, iconPath); } void SettingsDialog::slotRefreshActivity( AccountState* accountState ) diff --git a/src/gui/settingsdialog.h b/src/gui/settingsdialog.h index dd4ffd448..39f2595a1 100644 --- a/src/gui/settingsdialog.h +++ b/src/gui/settingsdialog.h @@ -58,6 +58,7 @@ public slots: void showActivityPage(); void slotSwitchPage(QAction *action); void slotRefreshActivity(AccountState *accountState ); + void slotAccountAvatarChanged(); protected: void reject() Q_DECL_OVERRIDE; @@ -73,12 +74,18 @@ private: QIcon createColorAwareIcon(const QString &name); QAction *createColorAwareAction(const QString &iconName, const QString &fileName); + QAction *createActionWithIcon(const QIcon& icon, const QString& text, const QString& iconPath = QString()); + Ui::SettingsDialog * const _ui; QActionGroup* _actionGroup; // Maps the actions from the action group to the corresponding widgets QHash _actionGroupWidgets; + // Maps the action in the dialog to their according account. Needed in + // case the account avatar changes + QHash _actionForAccount; + QToolBar* _toolBar; ActivitySettings *_activitySettings; From 2a12610a460c6206dec21626cd98c171690e578b Mon Sep 17 00:00:00 2001 From: Klaas Freitag Date: Mon, 23 Jan 2017 21:34:34 +0100 Subject: [PATCH 4/8] Update ASCII-Art describing the connection check flow. Added Avatar fetching --- src/libsync/connectionvalidator.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libsync/connectionvalidator.h b/src/libsync/connectionvalidator.h index e4f0fac7f..f9ad88160 100644 --- a/src/libsync/connectionvalidator.h +++ b/src/libsync/connectionvalidator.h @@ -68,7 +68,10 @@ namespace OCC { +-> fetchUser PropfindJob | - +-> slotUserFetched --> X + +-> slotUserFetched + AvatarJob + | + +-> slotAvatarPixmap --> reportResult() \endcode */ From c00e3e8c0aaacebe11aff8f5aa3878556842adb0 Mon Sep 17 00:00:00 2001 From: Klaas Freitag Date: Mon, 23 Jan 2017 21:35:12 +0100 Subject: [PATCH 5/8] ConnectionValidator: Set a 20 second timeout for Avatar request. --- src/libsync/connectionvalidator.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libsync/connectionvalidator.cpp b/src/libsync/connectionvalidator.cpp index d1c40d768..2a0efab2e 100644 --- a/src/libsync/connectionvalidator.cpp +++ b/src/libsync/connectionvalidator.cpp @@ -255,6 +255,7 @@ void ConnectionValidator::slotUserFetched(const QVariantMap &json) _account->setDavUser(user); AvatarJob *job = new AvatarJob(_account, this); + job->setTimeout(20*1000); QObject::connect(job, SIGNAL(avatarPixmap(QPixmap)), this, SLOT(slotAvatarPixmap(QPixmap))); job->start(); From e95b73dfac91375e6bdb88d109246f9d3d77afd2 Mon Sep 17 00:00:00 2001 From: Klaas Freitag Date: Mon, 23 Jan 2017 21:36:18 +0100 Subject: [PATCH 6/8] Avatar: Set a circle mask around the avatar image. The server displays the avatar cut into a circle, and so we do. --- src/gui/settingsdialog.cpp | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/gui/settingsdialog.cpp b/src/gui/settingsdialog.cpp index 665738cd4..173466a52 100644 --- a/src/gui/settingsdialog.cpp +++ b/src/gui/settingsdialog.cpp @@ -40,6 +40,8 @@ #include #include #include +#include +#include namespace { const char TOOLBAR_CSS[] = @@ -54,6 +56,23 @@ namespace { namespace OCC { +static QIcon circleMask( const QPixmap& avatar ) +{ + int dim = avatar.width(); + + QPixmap fixedImage(dim, dim); + fixedImage.fill(Qt::transparent); + + QPainter imgPainter(&fixedImage); + QPainterPath clip; + clip.addEllipse(0, 0, dim, dim); + imgPainter.setClipPath(clip); + imgPainter.drawPixmap(0, 0, dim, dim, avatar); + imgPainter.end(); + + return QIcon(fixedImage); +} + // // Whenever you change something here check both settingsdialog.cpp and settingsdialogmac.cpp ! // @@ -203,7 +222,7 @@ void SettingsDialog::accountAdded(AccountState *s) accountAction = createColorAwareAction(QLatin1String(":/client/resources/account.png"), actionText); } else { - QIcon icon(avatar); + QIcon icon = circleMask(avatar); accountAction = createActionWithIcon(icon, actionText); } @@ -234,7 +253,7 @@ void SettingsDialog::slotAccountAvatarChanged() if( action ) { QPixmap pix = account->avatar(); if( !pix.isNull() ) { - action->setIcon( QIcon(pix) ); + action->setIcon( circleMask(pix) ); } } } From 5e33898a08b9b1b415562569793c9eef123a7d27 Mon Sep 17 00:00:00 2001 From: Klaas Freitag Date: Thu, 9 Mar 2017 22:34:36 +0100 Subject: [PATCH 7/8] Avatar: Use QImage instead of QPixmap to avoid dep on QApplication. That fixes the test suite. --- src/gui/settingsdialog.cpp | 8 ++++---- src/libsync/account.cpp | 8 ++++---- src/libsync/account.h | 6 +++--- src/libsync/connectionvalidator.cpp | 6 +++--- src/libsync/connectionvalidator.h | 4 ++-- src/libsync/networkjobs.cpp | 6 +++--- src/libsync/networkjobs.h | 2 +- 7 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/gui/settingsdialog.cpp b/src/gui/settingsdialog.cpp index 173466a52..0deab3687 100644 --- a/src/gui/settingsdialog.cpp +++ b/src/gui/settingsdialog.cpp @@ -56,7 +56,7 @@ namespace { namespace OCC { -static QIcon circleMask( const QPixmap& avatar ) +static QIcon circleMask( const QImage& avatar ) { int dim = avatar.width(); @@ -67,7 +67,7 @@ static QIcon circleMask( const QPixmap& avatar ) QPainterPath clip; clip.addEllipse(0, 0, dim, dim); imgPainter.setClipPath(clip); - imgPainter.drawPixmap(0, 0, dim, dim, avatar); + imgPainter.drawImage(0, 0, avatar); imgPainter.end(); return QIcon(fixedImage); @@ -216,7 +216,7 @@ void SettingsDialog::accountAdded(AccountState *s) bool brandingSingleAccount = !Theme::instance()->multiAccount(); QAction *accountAction; - QPixmap avatar = s->account()->avatar(); + QImage avatar = s->account()->avatar(); const QString actionText = brandingSingleAccount ? tr("Account") : s->account()->displayName(); if(avatar.isNull()) { accountAction = createColorAwareAction(QLatin1String(":/client/resources/account.png"), @@ -251,7 +251,7 @@ void SettingsDialog::slotAccountAvatarChanged() if( account && _actionForAccount.contains(account)) { QAction *action = _actionForAccount[account]; if( action ) { - QPixmap pix = account->avatar(); + QImage pix = account->avatar(); if( !pix.isNull() ) { action->setIcon( circleMask(pix) ); } diff --git a/src/libsync/account.cpp b/src/libsync/account.cpp index ad4ca60f4..06634056d 100644 --- a/src/libsync/account.cpp +++ b/src/libsync/account.cpp @@ -90,13 +90,13 @@ void Account::setDavUser(const QString &newDavUser) _davUser = newDavUser; } -QPixmap Account::avatar() const +QImage Account::avatar() const { - return _avatarPixmap; + return _avatarImg; } -void Account::setAvatar(const QPixmap& pixmap) +void Account::setAvatar(const QImage &img) { - _avatarPixmap = pixmap; + _avatarImg = img; emit accountChangedAvatar(); } diff --git a/src/libsync/account.h b/src/libsync/account.h index a4894a6e9..4b61efb2e 100644 --- a/src/libsync/account.h +++ b/src/libsync/account.h @@ -80,8 +80,8 @@ public: QString davUser() const; void setDavUser(const QString &newDavUser); - QPixmap avatar() const; - void setAvatar(const QPixmap& pixmap); + QImage avatar() const; + void setAvatar(const QImage& img); /// The name of the account as shown in the toolbar QString displayName() const; @@ -216,7 +216,7 @@ private: QWeakPointer _sharedThis; QString _id; QString _davUser; - QPixmap _avatarPixmap; + QImage _avatarImg; QMap _settingsMap; QUrl _url; QList _approvedCerts; diff --git a/src/libsync/connectionvalidator.cpp b/src/libsync/connectionvalidator.cpp index 2a0efab2e..7e63bb538 100644 --- a/src/libsync/connectionvalidator.cpp +++ b/src/libsync/connectionvalidator.cpp @@ -256,15 +256,15 @@ void ConnectionValidator::slotUserFetched(const QVariantMap &json) AvatarJob *job = new AvatarJob(_account, this); job->setTimeout(20*1000); - QObject::connect(job, SIGNAL(avatarPixmap(QPixmap)), this, SLOT(slotAvatarPixmap(QPixmap))); + QObject::connect(job, SIGNAL(avatarPixmap(QImage)), this, SLOT(slotAvatarImage(QImage))); job->start(); } } -void ConnectionValidator::slotAvatarPixmap(const QPixmap& pixmap) +void ConnectionValidator::slotAvatarImage(const QImage& img) { - _account->setAvatar(pixmap); + _account->setAvatar(img); reportResult(Connected); } diff --git a/src/libsync/connectionvalidator.h b/src/libsync/connectionvalidator.h index f9ad88160..a612b6182 100644 --- a/src/libsync/connectionvalidator.h +++ b/src/libsync/connectionvalidator.h @@ -71,7 +71,7 @@ namespace OCC { +-> slotUserFetched AvatarJob | - +-> slotAvatarPixmap --> reportResult() + +-> slotAvatarImage --> reportResult() \endcode */ @@ -122,7 +122,7 @@ protected slots: void slotCapabilitiesRecieved(const QVariantMap&); void slotUserFetched(const QVariantMap &); - void slotAvatarPixmap(const QPixmap&); + void slotAvatarImage(const QImage &img); private: void reportResult(Status status); diff --git a/src/libsync/networkjobs.cpp b/src/libsync/networkjobs.cpp index 5568105d9..f89da5e6a 100644 --- a/src/libsync/networkjobs.cpp +++ b/src/libsync/networkjobs.cpp @@ -608,19 +608,19 @@ bool AvatarJob::finished() { int http_result_code = reply()->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); - QPixmap avPixmap; + QImage avImage; if (http_result_code == 200) { QByteArray pngData = reply()->readAll(); if( pngData.size() ) { - if( avPixmap.loadFromData(pngData) ) { + if( avImage.loadFromData(pngData) ) { qDebug() << "Retrieved Avatar pixmap!"; } } } - emit(avatarPixmap(avPixmap)); + emit(avatarPixmap(avImage)); return true; } diff --git a/src/libsync/networkjobs.h b/src/libsync/networkjobs.h index 2493be31d..6802c5d2b 100644 --- a/src/libsync/networkjobs.h +++ b/src/libsync/networkjobs.h @@ -150,7 +150,7 @@ signals: * @brief avatarPixmap - returns either a valid pixmap or not. */ - void avatarPixmap(QPixmap); + void avatarPixmap(QImage); private slots: virtual bool finished() Q_DECL_OVERRIDE; From 554d1b88fc46d07ebe6be6315d0830b013e84296 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Wed, 12 Apr 2017 17:55:28 +0200 Subject: [PATCH 8/8] Avatar: macOS support --- src/3rdparty/qtmacgoodies | 2 +- src/gui/settingsdialogmac.cpp | 38 +++++++++++++++++++++++++++++++++++ src/gui/settingsdialogmac.h | 1 + 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/src/3rdparty/qtmacgoodies b/src/3rdparty/qtmacgoodies index 044580c32..4ffbff5d5 160000 --- a/src/3rdparty/qtmacgoodies +++ b/src/3rdparty/qtmacgoodies @@ -1 +1 @@ -Subproject commit 044580c32837edba05a055aabca27245939454eb +Subproject commit 4ffbff5d5fca7332f6390ddc2fe74cd29e8675f8 diff --git a/src/gui/settingsdialogmac.cpp b/src/gui/settingsdialogmac.cpp index 9e4d6a950..ac65dae7a 100644 --- a/src/gui/settingsdialogmac.cpp +++ b/src/gui/settingsdialogmac.cpp @@ -34,9 +34,30 @@ #include #include #include +#include +#include namespace OCC { +// Duplicate in settingsdialog.cpp +static QIcon circleMask( const QImage& avatar ) +{ + int dim = avatar.width(); + + QPixmap fixedImage(dim, dim); + fixedImage.fill(Qt::transparent); + + QPainter imgPainter(&fixedImage); + QPainterPath clip; + clip.addEllipse(0, 0, dim, dim); + imgPainter.setClipPath(clip); + imgPainter.drawImage(0, 0, avatar); + imgPainter.end(); + + return QIcon(fixedImage); +} + + // // Whenever you change something here check both settingsdialog.cpp and settingsdialogmac.cpp ! // @@ -125,6 +146,8 @@ void SettingsDialogMac::accountAdded(AccountState *s) connect( accountSettings, &AccountSettings::folderChanged, _gui, &ownCloudGui::slotFoldersChanged); connect( accountSettings, &AccountSettings::openFolderAlias, _gui, &ownCloudGui::slotFolderOpenAction); + connect(s->account().data(), SIGNAL(accountChangedAvatar()), this, SLOT(slotAccountAvatarChanged())); + slotRefreshActivity(s); } @@ -147,4 +170,19 @@ void SettingsDialogMac::slotRefreshActivity( AccountState* accountState ) } } +void SettingsDialogMac::slotAccountAvatarChanged() +{ + Account *account = static_cast(sender()); + auto list = findChildren(QString()); + foreach(auto p, list) { + if (p->accountsState()->account() == account) { + int idx = indexForPanel(p); + QImage pix = account->avatar(); + if (!pix.isNull()) { + setPreferencesPanelIcon(idx, circleMask(pix)); + } + } + } +} + } diff --git a/src/gui/settingsdialogmac.h b/src/gui/settingsdialogmac.h index 608c4f8e1..a00046153 100644 --- a/src/gui/settingsdialogmac.h +++ b/src/gui/settingsdialogmac.h @@ -52,6 +52,7 @@ public slots: private slots: void accountAdded(AccountState *); void accountRemoved(AccountState *); + void slotAccountAvatarChanged(); private: void closeEvent(QCloseEvent *event);