mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-05 01:25:39 -05:00
commit
e183ac75bd
@ -22,6 +22,10 @@
|
|||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
#include <QBuffer>
|
#include <QBuffer>
|
||||||
|
#include <QPixmap>
|
||||||
|
#include <QImage>
|
||||||
|
#include <QSize>
|
||||||
|
#include <QPainter>
|
||||||
|
|
||||||
#include "WireGroupItem.h"
|
#include "WireGroupItem.h"
|
||||||
#include "WireGroupDialog.h"
|
#include "WireGroupDialog.h"
|
||||||
@ -31,6 +35,27 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
static QImage getCirclePhoto(const QImage original, int sizePhoto)
|
||||||
|
{
|
||||||
|
QImage target(sizePhoto, sizePhoto, QImage::Format_ARGB32_Premultiplied);
|
||||||
|
target.fill(Qt::transparent);
|
||||||
|
|
||||||
|
QPainter painter(&target);
|
||||||
|
painter.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
|
||||||
|
painter.setBrush(QBrush(Qt::white));
|
||||||
|
auto scaledPhoto = original
|
||||||
|
.scaled(sizePhoto, sizePhoto, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation)
|
||||||
|
.convertToFormat(QImage::Format_ARGB32_Premultiplied);
|
||||||
|
int margin = 0;
|
||||||
|
if (scaledPhoto.width() > sizePhoto) {
|
||||||
|
margin = (scaledPhoto.width() - sizePhoto) / 2;
|
||||||
|
}
|
||||||
|
painter.drawEllipse(0, 0, sizePhoto, sizePhoto);
|
||||||
|
painter.setCompositionMode(QPainter::CompositionMode_SourceIn);
|
||||||
|
painter.drawImage(0, 0, scaledPhoto, margin, 0);
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
|
||||||
/** Constructor */
|
/** Constructor */
|
||||||
|
|
||||||
WireGroupItem::WireGroupItem(WireGroupHolder *holder, const RsWireGroup &grp)
|
WireGroupItem::WireGroupItem(WireGroupHolder *holder, const RsWireGroup &grp)
|
||||||
@ -63,7 +88,12 @@ void WireGroupItem::setup()
|
|||||||
mGroup.mHeadshot.mSize,
|
mGroup.mHeadshot.mSize,
|
||||||
pixmap,GxsIdDetails::ORIGINAL))
|
pixmap,GxsIdDetails::ORIGINAL))
|
||||||
{
|
{
|
||||||
pixmap = pixmap.scaled(32,32);
|
//make avatar as circle avatar
|
||||||
|
QImage orginalImage = pixmap.toImage();
|
||||||
|
QImage circleImage = getCirclePhoto(orginalImage,orginalImage.size().width());
|
||||||
|
pixmap.convertFromImage(circleImage);
|
||||||
|
|
||||||
|
pixmap = pixmap.scaled(40,40);
|
||||||
label_headshot->setPixmap(pixmap);
|
label_headshot->setPixmap(pixmap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,14 +35,32 @@
|
|||||||
<enum>QFrame::Raised</enum>
|
<enum>QFrame::Raised</enum>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
|
<property name="bottomMargin">
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>6</number>
|
||||||
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_headshot">
|
<widget class="QLabel" name="label_headshot">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
<property name="maximumSize">
|
<property name="maximumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>32</width>
|
<width>40</width>
|
||||||
<height>32</height>
|
<height>40</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
@ -1128,6 +1128,10 @@ PulseReply #line_replyLine , PulseMessage #line{
|
|||||||
color: #7ecbfb;
|
color: #7ecbfb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PulseReply QLabel#label_groupName{
|
||||||
|
color: #5b7083;
|
||||||
|
}
|
||||||
|
|
||||||
WireDialog QLabel#label_viewMode {
|
WireDialog QLabel#label_viewMode {
|
||||||
font-size: 12pt;
|
font-size: 12pt;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user