From 0f9210e4912a5f197dc2c477410417a78c471330 Mon Sep 17 00:00:00 2001 From: evgeny Date: Sun, 4 Oct 2026 15:59:45 +0200 Subject: [PATCH] Share the desktop portable radio icon painter --- tools/chatgui/src/flagpainter.cpp | 16 ++++++++++++++++ tools/chatgui/src/flagpainter.h | 4 +++- tools/chatgui/src/messagelist.cpp | 11 ++--------- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/tools/chatgui/src/flagpainter.cpp b/tools/chatgui/src/flagpainter.cpp index 48d44c7a..cba8d0b6 100644 --- a/tools/chatgui/src/flagpainter.cpp +++ b/tools/chatgui/src/flagpainter.cpp @@ -2,6 +2,22 @@ #include #include +// Портативная рация: общий рисунок для кнопки и списка участников. +void FlagPainter::drawRadio(QPainter* p, int x, int y, int sz, const QColor& color) { + p->save(); + p->setRenderHint(QPainter::Antialiasing); + p->translate(x, y); + p->scale(sz / 24.0, sz / 24.0); + p->setPen(QPen(color, 1.7, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); + p->setBrush(Qt::NoBrush); + p->drawLine(QPointF(8.5, 1), QPointF(8.5, 9)); + p->drawLine(QPointF(14.5, 7), QPointF(14.5, 9)); + p->drawRoundedRect(QRectF(7, 9, 10, 13), 2, 2); + p->drawRoundedRect(QRectF(9.5, 11.5, 5, 3), 0.5, 0.5); + for (int yLine : {16, 18, 20}) p->drawLine(QPointF(9.5, yLine), QPointF(14.5, yLine)); + p->restore(); +} + void FlagPainter::draw(QPainter* p, uint8_t flags, int x, int y, int sz) { if (!flags) return; int cx = x; diff --git a/tools/chatgui/src/flagpainter.h b/tools/chatgui/src/flagpainter.h index d2c28c34..550cf395 100644 --- a/tools/chatgui/src/flagpainter.h +++ b/tools/chatgui/src/flagpainter.h @@ -1,4 +1,4 @@ -/* Отрисовка флагов участника (supernode/admin/moder/deleted) и отдельного значка storage. */ +/* Отрисовка флагов участника и общих значков storage/рации. */ #ifndef FLAGPAINTER_H #define FLAGPAINTER_H @@ -10,11 +10,13 @@ #define MEMBER_FLAG_ADMIN 0x02 #define MEMBER_FLAG_MODER 0x04 #define MEMBER_FLAG_DELETED 0x08 +#define MEMBER_FLAG_RADIO 0x10 class FlagPainter { public: static void draw(QPainter* p, uint8_t flags, int x, int y, int sz); static void drawStorage(QPainter* p, int x, int y, int sz); + static void drawRadio(QPainter* p, int x, int y, int sz, const QColor& color); private: static void drawLightning(QPainter* p, int x, int y, int sz); diff --git a/tools/chatgui/src/messagelist.cpp b/tools/chatgui/src/messagelist.cpp index ebb9c1d5..8cdd23df 100644 --- a/tools/chatgui/src/messagelist.cpp +++ b/tools/chatgui/src/messagelist.cpp @@ -52,6 +52,7 @@ void chat_core_save_ui_state_trampoline(void* arg); #include "radio_audio_engine.h" #include "radiopanel.h" +#include "flagpainter.h" #include #include #include @@ -61,15 +62,7 @@ static QIcon makeRadioIcon(const QColor& color) { QPixmap pix(48, 48); pix.fill(Qt::transparent); QPainter p(&pix); - p.setRenderHint(QPainter::Antialiasing); - p.scale(2, 2); - p.setPen(QPen(color, 1.7, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); - p.setBrush(Qt::NoBrush); - p.drawLine(QPointF(8.5, 1), QPointF(8.5, 9)); - p.drawLine(QPointF(14.5, 7), QPointF(14.5, 9)); - p.drawRoundedRect(QRectF(7, 9, 10, 13), 2, 2); - p.drawRoundedRect(QRectF(9.5, 11.5, 5, 3), 0.5, 0.5); - for (int y : {16, 18, 20}) p.drawLine(QPointF(9.5, y), QPointF(14.5, y)); + FlagPainter::drawRadio(&p, 0, 0, 48, color); p.end(); QIcon icon; // Явно задаём все режимы: Qt не перекрашивает значок при checked/disabled.