auto-connect + GUI per-channel indicators
- chat_core_connect_auto: direct ETCP connect from SQLite (no BGP) - auto_connect: parallel connect to peers with 3s timeout, retry 10s - RTT saved to node_addresses on disconnect - vertical status bar + circle badge with online count per channel - ChannelListView prevents deselection
This commit is contained in:
1 parent
1a0229fd4f
commit
dccf54b30b
22 files changed
+909
-10
No files matched your search
@@ -9,15 +9,30 @@ void ChannelDelegate::paint(QPainter *painter, const QStyleOptionViewItem &optio
|
||||
const QModelIndex &index) const {
|
||||
painter->save();
|
||||
|
||||
const int barWidth = 4;
|
||||
const int margin = 8;
|
||||
const int iconSize = 32;
|
||||
|
||||
int peersOnline = index.data(ChannelPeersOnlineRole).toInt();
|
||||
int autoActive = index.data(ChannelAutoConnectActiveRole).toInt();
|
||||
|
||||
/* ── background ── */
|
||||
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());
|
||||
}
|
||||
|
||||
const int margin = 8;
|
||||
const int iconSize = 32;
|
||||
QRect iconRect(option.rect.left() + margin,
|
||||
/* ── vertical status bar (left edge, over background) ── */
|
||||
QColor barColor = Qt::transparent;
|
||||
if (peersOnline > 0) barColor = QColor("#4CAF50");
|
||||
else if (autoActive && peersOnline == 0) barColor = QColor("#FFC107");
|
||||
if (barColor.alpha() > 0) {
|
||||
QRect barRect(option.rect.left(), option.rect.top(), barWidth, option.rect.height());
|
||||
painter->fillRect(barRect, barColor);
|
||||
}
|
||||
|
||||
QRect iconRect(option.rect.left() + margin + barWidth,
|
||||
option.rect.top() + (option.rect.height() - iconSize) / 2,
|
||||
iconSize, iconSize);
|
||||
|
||||
@@ -26,6 +41,24 @@ void ChannelDelegate::paint(QPainter *painter, const QStyleOptionViewItem &optio
|
||||
icon.paint(painter, iconRect);
|
||||
}
|
||||
|
||||
/* ── online count badge (top-left of avatar, above it) ── */
|
||||
if (peersOnline > 0) {
|
||||
int badgeSize = 16;
|
||||
QRect badgeRect(iconRect.left() - 4, iconRect.top() - 6, badgeSize, badgeSize);
|
||||
painter->setRenderHint(QPainter::Antialiasing);
|
||||
painter->setBrush(QColor("#4CAF50"));
|
||||
painter->setPen(QPen(Qt::white, 1.5));
|
||||
painter->drawEllipse(badgeRect);
|
||||
QFont badgeFont = option.font;
|
||||
badgeFont.setBold(true);
|
||||
badgeFont.setPixelSize(10);
|
||||
painter->setFont(badgeFont);
|
||||
painter->setPen(Qt::white);
|
||||
QString num = QString::number(peersOnline);
|
||||
if (peersOnline > 9) num = "9+";
|
||||
painter->drawText(badgeRect, Qt::AlignCenter, num);
|
||||
}
|
||||
|
||||
QRect textRect(iconRect.right() + margin, option.rect.top() + margin,
|
||||
option.rect.right() - iconRect.right() - 2 * margin,
|
||||
option.rect.height() - 2 * margin);
|
||||
|
||||
Reference in new issue
Block a user