fixed use of no avatar instead of default avatar image when creating a new ID

This commit is contained in:
csoler 2021-03-28 13:26:49 +02:00
parent fae6314374
commit 5274a060e5
2 changed files with 10 additions and 9 deletions

View File

@ -46,6 +46,7 @@ IdEditDialog::IdEditDialog(QWidget *parent) :
ui(new(Ui::IdEditDialog)) ui(new(Ui::IdEditDialog))
{ {
mIsNew = true; mIsNew = true;
mAvatarIsSet = false;
ui->setupUi(this); ui->setupUi(this);
@ -126,6 +127,7 @@ void IdEditDialog::changeAvatar()
ui->avatarLabel->setPicture(QPixmap::fromImage(img)); ui->avatarLabel->setPicture(QPixmap::fromImage(img));
ui->avatarLabel->setEnableZoom(true); ui->avatarLabel->setEnableZoom(true);
ui->avatarLabel->setToolTip(tr("Use the mouse to zoom and adjust the image for your avatar.")); ui->avatarLabel->setToolTip(tr("Use the mouse to zoom and adjust the image for your avatar."));
mAvatarIsSet = true;
// shows the tooltip for a while // shows the tooltip for a while
QToolTip::showText( ui->avatarLabel->mapToGlobal( QPoint( 0, 0 ) ), ui->avatarLabel->toolTip() ); QToolTip::showText( ui->avatarLabel->mapToGlobal( QPoint( 0, 0 ) ), ui->avatarLabel->toolTip() );
@ -211,9 +213,11 @@ void IdEditDialog::setAvatar(const QPixmap &avatar)
if (!mAvatar.isNull()) { if (!mAvatar.isNull()) {
ui->avatarLabel->setPicture(avatar); ui->avatarLabel->setPicture(avatar);
mAvatarIsSet = true;
} else { } else {
// we need to use the default pixmap here, generated from the ID // we need to use the default pixmap here, generated from the ID
ui->avatarLabel->setPicture(GxsIdDetails::makeDefaultIcon(RsGxsId(mEditGroup.mMeta.mGroupId))); ui->avatarLabel->setText(tr("No avatar chosen\ndefault will\nbe used"));
mAvatarIsSet = false;
} }
} }
@ -517,14 +521,10 @@ void IdEditDialog::loadRecognTags()
void IdEditDialog::submit() void IdEditDialog::submit()
{ {
if (mIsNew) if (mIsNew)
{
createId(); createId();
}
else else
{
updateId(); updateId();
} }
}
void IdEditDialog::createId() void IdEditDialog::createId()
{ {
@ -551,10 +551,10 @@ void IdEditDialog::createId()
params.nickname = groupname.toUtf8().constData(); params.nickname = groupname.toUtf8().constData();
params.isPgpLinked = (ui->radioButton_GpgId->isChecked()); params.isPgpLinked = (ui->radioButton_GpgId->isChecked());
if(mAvatarIsSet)
{
mAvatar = ui->avatarLabel->extractCroppedScaledPicture(); mAvatar = ui->avatarLabel->extractCroppedScaledPicture();
if (!mAvatar.isNull())
{
QByteArray ba; QByteArray ba;
QBuffer buffer(&ba); QBuffer buffer(&ba);

View File

@ -84,6 +84,7 @@ protected:
RsGxsGroupId mGroupId; RsGxsGroupId mGroupId;
QPixmap mAvatar; // Avatar from identity (not calculated) QPixmap mAvatar; // Avatar from identity (not calculated)
bool mAvatarIsSet;
}; };
#endif #endif