fixed update of identity list when avatar is changed and changed avatar to use ZoomableLabel

This commit is contained in:
csoler 2021-01-18 21:49:03 +01:00
parent 5d805e3798
commit ddc0a8c1ec
3 changed files with 31 additions and 5 deletions

View File

@ -644,6 +644,7 @@ void p3IdService::notifyChanges(std::vector<RsGxsNotify *> &changes)
case RsGxsNotify::TYPE_PROCESSED: break ; // Happens when the group is subscribed. This is triggered by RsGenExchange::subscribeToGroup, so better not 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!! // call it again from here!!
case RsGxsNotify::TYPE_UPDATED:
case RsGxsNotify::TYPE_PUBLISHED: case RsGxsNotify::TYPE_PUBLISHED:
{ {
auto ev = std::make_shared<RsGxsIdentityEvent>(); auto ev = std::make_shared<RsGxsIdentityEvent>();

View File

@ -20,6 +20,7 @@
#include <QBuffer> #include <QBuffer>
#include <QMessageBox> #include <QMessageBox>
#include <QToolTip>
#include "IdEditDialog.h" #include "IdEditDialog.h"
#include "ui_IdEditDialog.h" #include "ui_IdEditDialog.h"
@ -100,6 +101,7 @@ IdEditDialog::~IdEditDialog() {}
void IdEditDialog::changeAvatar() void IdEditDialog::changeAvatar()
{ {
#ifdef TODO
AvatarDialog dialog(this); AvatarDialog dialog(this);
dialog.setAvatar(mAvatar); dialog.setAvatar(mAvatar);
@ -109,6 +111,23 @@ void IdEditDialog::changeAvatar()
setAvatar(newAvatar); 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) void IdEditDialog::setupNewId(bool pseudo,bool enable_anon)
@ -598,6 +617,8 @@ void IdEditDialog::updateId()
mEditGroup.mMeta.mGroupName = groupname.toUtf8().constData(); mEditGroup.mMeta.mGroupName = groupname.toUtf8().constData();
mAvatar = ui->avatarLabel->extractCroppedScaledPicture();
if (!mAvatar.isNull()) if (!mAvatar.isNull())
{ {
QByteArray ba; QByteArray ba;

View File

@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>542</width> <width>593</width>
<height>536</height> <height>604</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy"> <property name="sizePolicy">
@ -291,7 +291,7 @@
<item> <item>
<layout class="QVBoxLayout" name="avatarVLayout"> <layout class="QVBoxLayout" name="avatarVLayout">
<item> <item>
<widget class="QLabel" name="avatarLabel"> <widget class="ZoomableLabel" name="avatarLabel">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed"> <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch> <horstretch>0</horstretch>
@ -330,7 +330,7 @@
<item> <item>
<widget class="QPushButton" name="avatarButton"> <widget class="QPushButton" name="avatarButton">
<property name="text"> <property name="text">
<string>Set Avatar</string> <string>Choose image...</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -529,9 +529,13 @@
<header>gui/common/HeaderFrame.h</header> <header>gui/common/HeaderFrame.h</header>
<container>1</container> <container>1</container>
</customwidget> </customwidget>
<customwidget>
<class>ZoomableLabel</class>
<extends>QLabel</extends>
<header>gui/gxschannels/GxsChannelPostThumbnail.h</header>
</customwidget>
</customwidgets> </customwidgets>
<resources> <resources>
<include location="../images.qrc"/>
<include location="../icons.qrc"/> <include location="../icons.qrc"/>
</resources> </resources>
<connections/> <connections/>