tools/chatgui: Qt5 GUI chat app stub with tray, channel list, message bubbles

This commit is contained in:
Evgeny committed 2026-06-22 22:48:27 +03:00
1 parent 6717c863e7
commit b667d6f352
20 files changed
+1089

No files matched your search

+69
View File
@@ -0,0 +1,69 @@
#include "accountlist.h"
#include <QVBoxLayout>
#include <QLabel>
#include <QPainter>
#include <QPixmap>
static QPixmap makeAvatar(const QColor &color, const QString &letter) {
QPixmap pix(24, 24);
pix.fill(Qt::transparent);
QPainter p(&pix);
p.setRenderHint(QPainter::Antialiasing);
p.setBrush(color);
p.setPen(Qt::NoPen);
p.drawEllipse(0, 0, 24, 24);
p.setPen(Qt::white);
QFont f = p.font();
f.setBold(true);
f.setPointSize(10);
p.setFont(f);
p.drawText(QRect(0, 0, 24, 24), Qt::AlignCenter, letter);
p.end();
return pix;
}
AccountList::AccountList(QWidget *parent)
: QWidget(parent)
, m_listView(new QListView(this))
, m_model(new QStandardItemModel(this))
{
auto *layout = new QVBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(0);
auto *header = new QLabel("Accounts", this);
header->setAlignment(Qt::AlignCenter);
header->setStyleSheet("font-weight: bold; padding: 8px; background: palette(window);");
layout->addWidget(header);
m_listView->setModel(m_model);
m_listView->setEditTriggers(QAbstractItemView::NoEditTriggers);
m_listView->setSelectionMode(QAbstractItemView::SingleSelection);
m_listView->setIconSize(QSize(24, 24));
m_listView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
m_listView->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
layout->addWidget(m_listView);
populateStubData();
}
void AccountList::populateStubData() {
struct {
const char *name;
QColor color;
const char *letter;
} accounts[] = {
{"Alice", QColor(74, 144, 226), "A"},
{"Bob", QColor(126, 211, 33), "B"},
{"Carol", QColor(245, 166, 35), "C"},
{"Dave", QColor(144, 19, 254), "D"},
{"Eve", QColor(0, 184, 148), "E"},
};
for (const auto &a : accounts) {
auto *item = new QStandardItem();
item->setText(a.name);
item->setIcon(QIcon(makeAvatar(a.color, a.letter)));
m_model->appendRow(item);
}
}