-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathonlineusersdialog.cpp
More file actions
55 lines (40 loc) · 1.41 KB
/
Copy pathonlineusersdialog.cpp
File metadata and controls
55 lines (40 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include "onlineusersdialog.h"
#include "remoteuser.h"
#include "ui_onlineusersdialog.h"
#include "notepad.h"
#include <QGridLayout>
#include <QPainterPath>
#include <QPainter>
#include <QHBoxLayout>
#include <QLayout>
#include <QListWidget>
#include <QListWidgetItem>
OnlineUsersDialog::OnlineUsersDialog(QList<RemoteUser> onlineUsers, QWidget *parent):
QDialog(parent),
ui(new Ui::OnlineUsersDialog),
onlineUsers(onlineUsers)
{
ui->setupUi(this);
this->setWindowTitle("Online Users");
QListWidget* listWidget = new QListWidget(this);
listWidget->setStyleSheet("background-color: transparent;");
for (int i=0; i<onlineUsers.count(); i++) {
QImage image;
image.loadFromData(onlineUsers[i].getUserInfo().getImage());
QPixmap qImage = QPixmap::fromImage(image);
QPixmap pixmap(50,50);
pixmap.fill(Qt::transparent);
QPainter painter(&pixmap);
painter.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
QPainterPath path;
path.addEllipse(0, 0, 50, 50);
painter.setClipPath(path);
painter.drawPixmap(0, 0, 50, 50, qImage);
QString userString = onlineUsers[i].getUserInfo().getName() + " " + onlineUsers[i].getUserInfo().getSurname();
listWidget->addItem(new QListWidgetItem(QIcon(pixmap), userString));
}
}
OnlineUsersDialog::~OnlineUsersDialog()
{
delete ui;
}