From 74b8ed0633e9df63bece4d7ee70cdd4405b753ea Mon Sep 17 00:00:00 2001 From: csoler Date: Thu, 15 Aug 2019 18:11:57 +0200 Subject: [PATCH] bypass useless avatar dialog when choosing own avatar --- retroshare-gui/src/gui/FriendsDialog.ui | 17 ++++----- .../src/gui/common/AvatarWidget.cpp | 35 ++++++++++++++----- 2 files changed, 33 insertions(+), 19 deletions(-) diff --git a/retroshare-gui/src/gui/FriendsDialog.ui b/retroshare-gui/src/gui/FriendsDialog.ui index 094ffe042..beb9a68e5 100644 --- a/retroshare-gui/src/gui/FriendsDialog.ui +++ b/retroshare-gui/src/gui/FriendsDialog.ui @@ -145,17 +145,14 @@ - - - 61 - 61 - + + + 0 + 0 + - - - 61 - 61 - + + false diff --git a/retroshare-gui/src/gui/common/AvatarWidget.cpp b/retroshare-gui/src/gui/common/AvatarWidget.cpp index 3422015bc..5cd9f5d79 100644 --- a/retroshare-gui/src/gui/common/AvatarWidget.cpp +++ b/retroshare-gui/src/gui/common/AvatarWidget.cpp @@ -18,12 +18,15 @@ * * *******************************************************************************/ +#include + #include #include #include #include #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)