Improve call buffering, CM handle lifecycle and radio PTT controls

This commit is contained in:
evgeny committed 2026-09-30 17:31:53 +03:00
1 parent 752c1f140c
commit 2d21c53b4b
55 files changed
+2060 -496

No files matched your search

+40 -2
View File
@@ -13,6 +13,7 @@
#include <QVBoxLayout>
#include <QPainter>
#include <QPixmap>
#include <QStyle>
#include <QDateTime>
#include <QJsonDocument>
#include <QJsonObject>
@@ -49,6 +50,30 @@ void chat_core_save_ui_state_trampoline(void* arg);
#include <QPushButton>
#include <QHBoxLayout>
// Портативная рация: один и тот же значок во всех состояниях кнопки.
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));
p.end();
QIcon icon;
// Явно задаём все режимы: Qt не перекрашивает значок при checked/disabled.
for (auto mode : {QIcon::Normal, QIcon::Disabled, QIcon::Active, QIcon::Selected}) {
icon.addPixmap(pix, mode, QIcon::Off);
icon.addPixmap(pix, mode, QIcon::On);
}
return icon;
}
static QPixmap makeAvatar(const QColor &color, const QString &letter, int size = 36) {
QPixmap pix(size, size);
pix.fill(Qt::transparent);
@@ -331,7 +356,10 @@ MessageList::MessageList(DbManager* db, AudioRecorder* recorder, QWidget *parent
m_talkingLabel->hide();
hl->addWidget(m_talkingLabel);
m_radioBtn = new QPushButton(QString::fromUtf8("\xF0\x9F\x93\xBB"), header);
m_radioBtn = new QPushButton(header);
m_radioBtn->setIcon(makeRadioIcon(header->palette().color(QPalette::ButtonText)));
m_radioBtn->setIconSize(QSize(24, 24));
m_radioBtn->setAccessibleName(QStringLiteral("Рация"));
m_radioBtn->setCheckable(true);
m_radioBtn->setFixedSize(34, 30);
m_radioBtn->setCursor(Qt::PointingHandCursor);
@@ -373,8 +401,10 @@ MessageList::MessageList(DbManager* db, AudioRecorder* recorder, QWidget *parent
m_pttBtn->setToolTip(QStringLiteral("Держите и говорите"));
m_pttBtn->setStyleSheet(
"QPushButton { border: 3px solid white; border-radius: 48px; background: #e74c3c; color: white; font-size: 36px; }"
"QPushButton:pressed { background: #c0392b; }");
"QPushButton[transmitting=\"true\"] { background: #27ae60; }");
m_pttBtn->setProperty("transmitting", false);
m_pttBtn->hide();
connect(RadioAudioEngine::instance(), &RadioAudioEngine::talkingChanged, this, [this](bool) { updateRadioUi(); });
connect(m_pttBtn, &QPushButton::pressed, this, []() {
RadioAudioEngine::instance()->talkBegin();
});
@@ -1130,6 +1160,14 @@ void MessageList::onRadioToggled(bool on) {
void MessageList::updateRadioUi() {
if (!m_pttBtn) return;
auto* audio = RadioAudioEngine::instance();
bool transmitting = audio->isTalking() && audio->groupId() == m_currentChannelId.toULongLong();
if (m_pttBtn->property("transmitting").toBool() != transmitting) {
m_pttBtn->setProperty("transmitting", transmitting);
m_pttBtn->style()->unpolish(m_pttBtn);
m_pttBtn->style()->polish(m_pttBtn);
m_pttBtn->update();
}
bool show = m_radioOn && !isDmChannel(m_currentChannelId);
m_pttBtn->setVisible(show);
if (show) {