bypass useless avatar dialog when choosing own avatar

This commit is contained in:
csoler 2019-08-15 18:11:57 +02:00
parent 6e7a86058d
commit 74b8ed0633
No known key found for this signature in database
GPG Key ID: 7BCA522266C0804C
2 changed files with 33 additions and 19 deletions

View File

@ -145,17 +145,14 @@
</property>
<item row="0" column="0" rowspan="2">
<widget class="AvatarWidget" name="avatar">
<property name="minimumSize">
<size>
<width>61</width>
<height>61</height>
</size>
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>61</width>
<height>61</height>
</size>
<property name="scaledContents">
<bool>false</bool>
</property>
</widget>
</item>

View File

@ -18,12 +18,15 @@
* *
*******************************************************************************/
#include <QBuffer>
#include <rshare.h>
#include <retroshare/rsstatus.h>
#include <retroshare/rspeers.h>
#include <retroshare/rsmsgs.h>
#include "gui/notifyqt.h"
#include "util/misc.h"
#include "gui/common/AvatarDefs.h"
#include "gui/common/AvatarDialog.h"
@ -85,19 +88,33 @@ void AvatarWidget::mouseReleaseEvent(QMouseEvent */*event*/)
if (!mFlag.isOwnId) {
return;
}
QPixmap img = misc::getOpenThumbnailedPicture(this, tr("Choose avatar"), AvatarDialog::RS_AVATAR_DEFAULT_IMAGE_W,AvatarDialog::RS_AVATAR_DEFAULT_IMAGE_H);
AvatarDialog dialog(this);
if (img.isNull())
return;
QPixmap avatar;
AvatarDefs::getOwnAvatar(avatar, "");
setPixmap(img);
dialog.setAvatar(avatar);
if (dialog.exec() == QDialog::Accepted) {
QByteArray newAvatar;
dialog.getAvatar(newAvatar);
QByteArray data;
QBuffer buffer(&data);
rsMsgs->setOwnAvatarData((unsigned char *)(newAvatar.data()), newAvatar.size()) ; // last char 0 included.
}
buffer.open(QIODevice::WriteOnly);
img.save(&buffer, "PNG"); // writes image into a in PNG format
rsMsgs->setOwnAvatarData((unsigned char *)(data.data()), data.size()) ; // last char 0 included.
// AvatarDialog dialog(this);
//
// QPixmap avatar;
// AvatarDefs::getOwnAvatar(avatar, "");
//
// dialog.setAvatar(avatar);
// if (dialog.exec() == QDialog::Accepted) {
// QByteArray newAvatar;
// dialog.getAvatar(newAvatar);
//
// rsMsgs->setOwnAvatarData((unsigned char *)(newAvatar.data()), newAvatar.size()) ; // last char 0 included.
// }
}
void AvatarWidget::setFrameType(FrameType type)