|
|
|
|
@ -23,18 +23,22 @@ static QRect radioMuteButtonRect(const QRect& row) {
|
|
|
|
|
return QRect(row.right() - 63, row.center().y() - 14, 28, 28); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void drawRadioMuteButton(QPainter* painter, const QRect& button, bool muted) { |
|
|
|
|
// Волны показывают передачу, красное перечёркивание имеет приоритет при локальном mute.
|
|
|
|
|
static void drawRadioMuteButton(QPainter* painter, const QRect& button, bool muted, bool speaking) { |
|
|
|
|
painter->save(); |
|
|
|
|
painter->setRenderHint(QPainter::Antialiasing); |
|
|
|
|
painter->translate(button.center()); |
|
|
|
|
QColor color(muted ? "#EF5350" : "#4CAF50"); |
|
|
|
|
QColor color(muted ? "#EF5350" : speaking ? "#4CAF50" : "#9E9E9E"); |
|
|
|
|
QPainterPath speaker; |
|
|
|
|
speaker.moveTo(-8, -3); speaker.lineTo(-4, -3); speaker.lineTo(1, -7); |
|
|
|
|
speaker.lineTo(1, 7); speaker.lineTo(-4, 3); speaker.lineTo(-8, 3); speaker.closeSubpath(); |
|
|
|
|
painter->fillPath(speaker, color); |
|
|
|
|
painter->setPen(QPen(color, 1.8, Qt::SolidLine, Qt::RoundCap)); painter->setBrush(Qt::NoBrush); |
|
|
|
|
painter->drawArc(QRectF(-3, -5, 10, 10), -60 * 16, 120 * 16); |
|
|
|
|
painter->drawArc(QRectF(-6, -8, 16, 16), -60 * 16, 120 * 16); |
|
|
|
|
if (muted) painter->drawLine(QPointF(-10, 10), QPointF(10, -10)); |
|
|
|
|
else if (speaking) { |
|
|
|
|
painter->drawArc(QRectF(-3, -5, 10, 10), -60 * 16, 120 * 16); |
|
|
|
|
painter->drawArc(QRectF(-6, -8, 16, 16), -60 * 16, 120 * 16); |
|
|
|
|
} |
|
|
|
|
painter->restore(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -69,7 +73,7 @@ void AccountDelegate::paint(QPainter *painter, const QStyleOptionViewItem &optio
|
|
|
|
|
|
|
|
|
|
const int x = option.rect.left() + iconSz + margin * 3; |
|
|
|
|
const bool canInvite = !index.data(Qt::UserRole + 2).toBool(); |
|
|
|
|
const int w = option.rect.right() - x - margin - (canInvite ? 64 : 0); |
|
|
|
|
const int w = option.rect.right() - x - margin - 64; |
|
|
|
|
const int yMid = option.rect.top() + option.rect.height() / 2; |
|
|
|
|
|
|
|
|
|
uint8_t flags = (uint8_t)(index.data(Qt::UserRole + 3).toInt() & 0xFF); |
|
|
|
|
@ -117,8 +121,9 @@ void AccountDelegate::paint(QPainter *painter, const QStyleOptionViewItem &optio
|
|
|
|
|
painter->drawText(QRect(flagX, yMid + 2, w - (flagX - x), option.rect.bottom() - yMid - 2), |
|
|
|
|
Qt::AlignLeft | Qt::AlignTop, sub); |
|
|
|
|
|
|
|
|
|
drawRadioMuteButton(painter, radioMuteButtonRect(option.rect), flags & CHAT_MEMBER_FLAG_RADIO_MUTED, |
|
|
|
|
index.data(MemberListModel::RadioSpeakingRole).toBool()); |
|
|
|
|
if (canInvite) { |
|
|
|
|
drawRadioMuteButton(painter, radioMuteButtonRect(option.rect), flags & CHAT_MEMBER_FLAG_RADIO_MUTED); |
|
|
|
|
QFont plusFont = nameFont; plusFont.setPixelSize(22); plusFont.setStrikeOut(false); |
|
|
|
|
painter->setFont(plusFont); |
|
|
|
|
painter->setPen(option.palette.color(QPalette::Link)); |
|
|
|
|
@ -168,10 +173,13 @@ bool AccountDelegate::editorEvent(QEvent* event, QAbstractItemModel* model, cons
|
|
|
|
|
|
|
|
|
|
bool AccountDelegate::helpEvent(QHelpEvent* event, QAbstractItemView* view, const QStyleOptionViewItem& option, |
|
|
|
|
const QModelIndex& index) { |
|
|
|
|
if (event && !index.data(Qt::UserRole + 2).toBool() && radioMuteButtonRect(option.rect).contains(event->pos())) { |
|
|
|
|
if (event && radioMuteButtonRect(option.rect).contains(event->pos())) { |
|
|
|
|
const bool muted = index.data(Qt::UserRole + 3).toInt() & CHAT_MEMBER_FLAG_RADIO_MUTED; |
|
|
|
|
QToolTip::showText(event->globalPos(), QCoreApplication::translate("ChatGui", |
|
|
|
|
muted ? "Listen to this member in radio" : "Mute this member in radio"), view); |
|
|
|
|
const bool speaking = index.data(MemberListModel::RadioSpeakingRole).toBool(); |
|
|
|
|
QString text = QCoreApplication::translate("ChatGui", muted ? "Radio: muted" : speaking ? "Radio: speaking" : "Radio: silent"); |
|
|
|
|
if (!index.data(Qt::UserRole + 2).toBool()) text += '\n' + QCoreApplication::translate("ChatGui", |
|
|
|
|
muted ? "Listen to this member in radio" : "Mute this member in radio"); |
|
|
|
|
QToolTip::showText(event->globalPos(), text, view); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
return QStyledItemDelegate::helpEvent(event, view, option, index); |
|
|
|
|
|