|
26 | 26 | #include "thumbnailjob.h"
|
27 | 27 | #include "sharee.h"
|
28 | 28 | #include "sharemanager.h"
|
29 |
| -#include "avatarjob.h" |
30 | 29 |
|
31 | 30 | #include "QProgressIndicator.h"
|
32 | 31 | #include <QBuffer>
|
@@ -470,53 +469,23 @@ void ShareUserLine::loadAvatar()
|
470 | 469 |
|
471 | 470 | // We can only fetch avatars for local users currently
|
472 | 471 | if (_share->getShareWith()->type() == Sharee::User) {
|
473 |
| - AvatarJob2 *job = new AvatarJob2(_share->getShareWith()->shareWith(), 48, _share->account(), this); |
474 |
| - connect(job, SIGNAL(avatarReady(QByteArray, QString)), SLOT(slotAvatarLoaded(QByteArray, QString))); |
| 472 | + AvatarJob *job = new AvatarJob(_share->account(), _share->getShareWith()->shareWith(), 48, this); |
| 473 | + connect(job, &AvatarJob::avatarPixmap, this, &ShareUserLine::slotAvatarLoaded); |
475 | 474 | job->start();
|
476 | 475 | }
|
477 | 476 | }
|
478 | 477 |
|
479 |
| -void ShareUserLine::slotAvatarLoaded(const QByteArray &data, const QString &mimeType) |
| 478 | +void ShareUserLine::slotAvatarLoaded(QImage avatar) |
480 | 479 | {
|
481 |
| - QPixmap p; |
482 |
| - bool valid = false; |
483 |
| - if (mimeType == "image/png") { |
484 |
| - valid = p.loadFromData(data, "PNG"); |
485 |
| - } else if (mimeType == "image/jpeg") { |
486 |
| - valid = p.loadFromData(data, "JPG"); |
487 |
| - } else { |
488 |
| - // Guess the filetype |
489 |
| - valid = p.loadFromData(data); |
490 |
| - } |
| 480 | + if (avatar.isNull()) |
| 481 | + return; |
491 | 482 |
|
492 |
| - // If the image was loaded succesfully set it! |
493 |
| - if (valid) { |
| 483 | + avatar = AvatarJob::makeCircularAvatar(avatar); |
494 | 484 |
|
495 |
| - /* |
496 |
| - * We want round avatars so create a new pixmap to draw |
497 |
| - * the round avatar on and set a transparent background |
498 |
| - */ |
499 |
| - QPixmap avatar(p.width(), p.height()); |
500 |
| - avatar.fill(QColor(0,0,0,0)); |
501 |
| - |
502 |
| - // Initialise our painer |
503 |
| - QPainter painter(&avatar); |
504 |
| - painter.setRenderHint(QPainter::Antialiasing); |
505 |
| - |
506 |
| - // Set to draw only a cricle |
507 |
| - QPainterPath path; |
508 |
| - path.addEllipse(0,0,p.width(),p.height()); |
509 |
| - painter.setClipPath(path); |
510 |
| - |
511 |
| - // Draw the round avatar |
512 |
| - painter.drawPixmap(0,0,p.width(),p.width(),p); |
513 |
| - |
514 |
| - // Set the avatar |
515 |
| - _ui->avatar->setPixmap(avatar); |
516 |
| - |
517 |
| - // Remove the stylesheet |
518 |
| - _ui->avatar->setStyleSheet(""); |
519 |
| - } |
| 485 | + _ui->avatar->setPixmap(QPixmap::fromImage(avatar)); |
| 486 | + |
| 487 | + // Remove the stylesheet for the fallback avatar |
| 488 | + _ui->avatar->setStyleSheet(""); |
520 | 489 | }
|
521 | 490 |
|
522 | 491 | void ShareUserLine::on_deleteShareButton_clicked()
|
|
0 commit comments