stcp: ed25519 pubkey exchange in handshake, fix instance destroy segfault, fix chat_tcp_test
- u_async.c: process immediate_queue BEFORE epoll_wait in uasync_poll - stcp_link.c: defensive NULL etcp_conn/etcp_link in stcp_link_close - utun_instance.c: move stcp_server_list_destroy_all to Phase J (before ETCP), add deferred drain in both Phase J and L - stcp.h/c: STCP_HS_ENC_CLIENT 6→38, STCP_HS_ENC_SERVER 7→39, exchange ed25519_pubkey in both handshake directions - etcp_connections.c: copy peer_ed25519 from STCP to ETCP_CONN in etcp_link_enter_ready_tcp; guard link->etcp in tcp_link_close_cb - chat_sync.c: fix lk->conn NULL dereference for TCP links - test_stcp.c: update stcp_server_create/stcp_client_connect callsites - tools/chat_tcp_test: change transport udp→tcp
This commit is contained in:
1 parent
a3783b5f55
commit
38c9f229bc
1272 files changed
+968388
-1
No files matched your search
@@ -0,0 +1,63 @@
|
||||
#include "accountdelegate.h"
|
||||
#include "memberlistmodel.h"
|
||||
#include <QPainter>
|
||||
#include <QFont>
|
||||
|
||||
AccountDelegate::AccountDelegate(QObject *parent)
|
||||
: QStyledItemDelegate(parent) {}
|
||||
|
||||
void AccountDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
|
||||
const QModelIndex &index) const {
|
||||
painter->save();
|
||||
|
||||
if (option.state & QStyle::State_Selected)
|
||||
painter->fillRect(option.rect, option.palette.highlight());
|
||||
else if (option.state & QStyle::State_MouseOver)
|
||||
painter->fillRect(option.rect, option.palette.light());
|
||||
else
|
||||
painter->fillRect(option.rect, option.palette.alternateBase());
|
||||
|
||||
const int margin = 4;
|
||||
const int iconSz = 24;
|
||||
|
||||
QIcon icon = qvariant_cast<QIcon>(index.data(Qt::DecorationRole));
|
||||
if (!icon.isNull())
|
||||
icon.paint(painter, option.rect.left() + margin, option.rect.top() + (option.rect.height() - iconSz) / 2, iconSz, iconSz);
|
||||
|
||||
const int x = option.rect.left() + iconSz + margin * 3;
|
||||
const int w = option.rect.right() - x - margin;
|
||||
const int yMid = option.rect.top() + option.rect.height() / 2;
|
||||
|
||||
QFont nameFont = painter->font();
|
||||
nameFont.setBold(true);
|
||||
nameFont.setPixelSize(13);
|
||||
painter->setFont(nameFont);
|
||||
|
||||
QColor textColor = option.palette.color(QPalette::Text);
|
||||
if (option.state & QStyle::State_Selected) textColor = option.palette.color(QPalette::HighlightedText);
|
||||
if (index.data(Qt::UserRole + 2).toBool()) textColor = QColor("#4CAF50");
|
||||
painter->setPen(textColor);
|
||||
|
||||
QString name = index.data(Qt::DisplayRole).toString();
|
||||
painter->drawText(QRect(x, option.rect.top() + 2, w, yMid - option.rect.top() - 2),
|
||||
Qt::AlignLeft | Qt::AlignBottom, name);
|
||||
|
||||
QFont subFont = painter->font();
|
||||
subFont.setBold(false);
|
||||
subFont.setPixelSize(10);
|
||||
painter->setFont(subFont);
|
||||
painter->setPen(QColor(130, 130, 130));
|
||||
|
||||
QString sub = index.data(Qt::UserRole + 1).toString();
|
||||
if (!sub.isEmpty())
|
||||
painter->drawText(QRect(x, yMid + 2, w, option.rect.bottom() - yMid - 2),
|
||||
Qt::AlignLeft | Qt::AlignTop, sub);
|
||||
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
QSize AccountDelegate::sizeHint(const QStyleOptionViewItem &option,
|
||||
const QModelIndex &index) const {
|
||||
(void)option; (void)index;
|
||||
return QSize(160, 36);
|
||||
}
|
||||
Reference in new issue
Block a user