From ddc0a8c1ec6477cae0979f832b02bb439e77c947 Mon Sep 17 00:00:00 2001 From: csoler Date: Mon, 18 Jan 2021 21:49:03 +0100 Subject: [PATCH] fixed update of identity list when avatar is changed and changed avatar to use ZoomableLabel --- libretroshare/src/services/p3idservice.cc | 1 + .../src/gui/Identity/IdEditDialog.cpp | 21 +++++++++++++++++++ .../src/gui/Identity/IdEditDialog.ui | 14 ++++++++----- 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/libretroshare/src/services/p3idservice.cc b/libretroshare/src/services/p3idservice.cc index 543a29f43..84398e053 100644 --- a/libretroshare/src/services/p3idservice.cc +++ b/libretroshare/src/services/p3idservice.cc @@ -644,6 +644,7 @@ void p3IdService::notifyChanges(std::vector &changes) case RsGxsNotify::TYPE_PROCESSED: break ; // Happens when the group is subscribed. This is triggered by RsGenExchange::subscribeToGroup, so better not // call it again from here!! + case RsGxsNotify::TYPE_UPDATED: case RsGxsNotify::TYPE_PUBLISHED: { auto ev = std::make_shared(); diff --git a/retroshare-gui/src/gui/Identity/IdEditDialog.cpp b/retroshare-gui/src/gui/Identity/IdEditDialog.cpp index 94d092faf..33eb903b0 100644 --- a/retroshare-gui/src/gui/Identity/IdEditDialog.cpp +++ b/retroshare-gui/src/gui/Identity/IdEditDialog.cpp @@ -20,6 +20,7 @@ #include #include +#include #include "IdEditDialog.h" #include "ui_IdEditDialog.h" @@ -100,6 +101,7 @@ IdEditDialog::~IdEditDialog() {} void IdEditDialog::changeAvatar() { +#ifdef TODO AvatarDialog dialog(this); dialog.setAvatar(mAvatar); @@ -109,6 +111,23 @@ void IdEditDialog::changeAvatar() setAvatar(newAvatar); } +#endif + // For now we use a simpler method since AvatarDialog is not finished yet; we use the thumbnail viewer to allow the user to + // select a proper scale/crop of a given image to make his/her avatar. + + QString image_filename ; + + if(!misc::getOpenFileName(this,RshareSettings::LASTDIR_IMAGES,tr("Import image"), tr("Image files (*.jpg *.png);;All files (*)"),image_filename)) + return; + + QImage img(image_filename); + + ui->avatarLabel->setPicture(QPixmap::fromImage(img)); + ui->avatarLabel->setEnableZoom(true); + ui->avatarLabel->setToolTip(tr("Use the mouse to zoom and adjust the image for your avatar.")); + + // shows the tooltip for a while + QToolTip::showText( ui->avatarLabel->mapToGlobal( QPoint( 0, 0 ) ), ui->avatarLabel->toolTip() ); } void IdEditDialog::setupNewId(bool pseudo,bool enable_anon) @@ -598,6 +617,8 @@ void IdEditDialog::updateId() mEditGroup.mMeta.mGroupName = groupname.toUtf8().constData(); + mAvatar = ui->avatarLabel->extractCroppedScaledPicture(); + if (!mAvatar.isNull()) { QByteArray ba; diff --git a/retroshare-gui/src/gui/Identity/IdEditDialog.ui b/retroshare-gui/src/gui/Identity/IdEditDialog.ui index 9ed2d258a..fee114a9d 100644 --- a/retroshare-gui/src/gui/Identity/IdEditDialog.ui +++ b/retroshare-gui/src/gui/Identity/IdEditDialog.ui @@ -6,8 +6,8 @@ 0 0 - 542 - 536 + 593 + 604 @@ -291,7 +291,7 @@ - + 0 @@ -330,7 +330,7 @@ - Set Avatar + Choose image... @@ -529,9 +529,13 @@
gui/common/HeaderFrame.h
1 + + ZoomableLabel + QLabel +
gui/gxschannels/GxsChannelPostThumbnail.h
+
-