Merge pull request #2310 from defnax/avatardialog-fix-v2

Fixed Avatar storing on Avatar Dialog
This commit is contained in:
defnax 2021-02-11 19:03:50 +01:00 committed by GitHub
commit 8e0e4eb138
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 6 deletions

View File

@ -151,8 +151,14 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>96</width>
<height>96</height>
</size>
</property>
<property name="scaledContents">
<bool>false</bool>
<bool>true</bool>
</property>
</widget>
</item>
@ -171,7 +177,7 @@
<string/>
</property>
<property name="icon">
<iconset resource="images.qrc">
<iconset>
<normaloff>:/images/edit_16.png</normaloff>:/images/edit_16.png</iconset>
</property>
<property name="toolButtonStyle">
@ -264,7 +270,7 @@
</action>
<action name="actionSet_your_Avatar">
<property name="icon">
<iconset resource="images.qrc">
<iconset>
<normaloff>:/images/add_image24.png</normaloff>:/images/add_image24.png</iconset>
</property>
<property name="text">

View File

@ -132,7 +132,7 @@ void AvatarDialog::getAvatar(QPixmap &avatar)
void AvatarDialog::getAvatar(QByteArray &avatar)
{
const QPixmap *pixmap = ui->avatarLabel->pixmap();
pixmap = ui->avatarLabel->extractCroppedScaledPicture();
if (!pixmap) {
avatar.clear();
return;
@ -141,7 +141,7 @@ void AvatarDialog::getAvatar(QByteArray &avatar)
QBuffer buffer(&avatar);
buffer.open(QIODevice::WriteOnly);
pixmap->save(&buffer, "PNG"); // writes image into ba in PNG format
pixmap.save(&buffer, "PNG"); // writes image into ba in PNG format
}
void AvatarDialog::load()
@ -331,6 +331,6 @@ void AvatarDialog::addAvatar()
QString sticker = qobject_cast<QPushButton*>(sender())->statusTip();
QPixmap pixmap(sticker);
ui->avatarLabel->setPixmap(pixmap);
ui->avatarLabel->setPicture(pixmap);
updateInterface();
}

View File

@ -62,6 +62,7 @@ private slots:
private:
void updateInterface();
QPixmap pixmap;
private:
Ui::AvatarDialog *ui;