From 4adff4d92039aa64ff33418bfe705c0a85a076e1 Mon Sep 17 00:00:00 2001 From: evgeny Date: Tue, 20 Oct 2026 19:46:32 +0200 Subject: [PATCH] Show active publisher shortcut in desktop channel header --- tools/chatgui/src/mainwindow.cpp | 1 + tools/chatgui/src/messagelist.cpp | 34 ++++++++++++++++++++++++++++++- tools/chatgui/src/messagelist.h | 4 ++++ 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/tools/chatgui/src/mainwindow.cpp b/tools/chatgui/src/mainwindow.cpp index 5165ea414..3fa12bf14 100644 --- a/tools/chatgui/src/mainwindow.cpp +++ b/tools/chatgui/src/mainwindow.cpp @@ -671,6 +671,7 @@ void MainWindow::setupConnects() { if (!m_streamPublisher) { m_streamPublisher = new StreamPublishEngine(this); connect(m_streamPublisher, &StreamPublishEngine::stateChanged, this, [this](const QString& state) { + m_messageList->setStreamPublisherGroup(m_streamPublisher->active() ? m_streamPublisher->group() : 0); if (m_trayIcon) m_trayIcon->setToolTip(m_streamPublisher->active() ? QStringLiteral("vibechat · ") + state : QStringLiteral("vibechat")); }); } diff --git a/tools/chatgui/src/messagelist.cpp b/tools/chatgui/src/messagelist.cpp index 0893d3a50..f22b20e75 100644 --- a/tools/chatgui/src/messagelist.cpp +++ b/tools/chatgui/src/messagelist.cpp @@ -526,6 +526,27 @@ MessageList::MessageList(DbManager* db, AudioRecorder* recorder, QWidget *parent }); hl->addWidget(m_streamBtn); + m_streamPublishBtn = new QPushButton(header); m_streamPublishBtn->setObjectName("streamPublishButton"); + QPixmap publishIcon(24, 24); publishIcon.fill(Qt::transparent); + { QPainter painter(&publishIcon); painter.setRenderHint(QPainter::Antialiasing); + painter.setPen(Qt::NoPen); painter.setBrush(QColor("#e53935")); + painter.drawRoundedRect(QRectF(2, 6, 14, 12), 2, 2); + const QPointF lens[] = {{16, 10}, {22, 6}, {22, 18}, {16, 14}}; painter.drawPolygon(lens, 4); } + m_streamPublishBtn->setIcon(QIcon(publishIcon)); m_streamPublishBtn->setIconSize(QSize(24, 24)); + m_streamPublishBtn->setFixedSize(34, 30); m_streamPublishBtn->hide(); + m_streamPublishBtn->setCursor(Qt::PointingHandCursor); + m_streamPublishBtn->setToolTip(QCoreApplication::translate("ChatGui", "Manage stream")); + m_streamPublishBtn->setAccessibleName(m_streamPublishBtn->toolTip()); + connect(m_streamPublishBtn, &QPushButton::clicked, this, [this] { + if (!m_streamPublisherGroup || m_currentChannelId.toULongLong() != m_streamPublisherGroup) { + DEBUG_WARN(DEBUG_CATEGORY_STREAM, "desktop own stream action stale channel=%s publisher_group=%llx", + qPrintable(m_currentChannelId), (unsigned long long)m_streamPublisherGroup); return; + } + DEBUG_INFO(DEBUG_CATEGORY_STREAM, "desktop own stream header clicked group=%llx", (unsigned long long)m_streamPublisherGroup); + emit streamPublishRequested(m_streamPublisherGroup); + }); + hl->addWidget(m_streamPublishBtn); + m_groupMenuButton = new QPushButton(QStringLiteral("…"), header); m_groupMenuButton->setObjectName("groupMenuButton"); m_groupMenuButton->setFixedSize(34, 30); @@ -539,7 +560,7 @@ MessageList::MessageList(DbManager* db, AudioRecorder* recorder, QWidget *parent if (!channel.toULongLong()) return; auto text = [](const char* s) { return QCoreApplication::translate("ChatGui", s); }; QMenu menu(this); - const bool own = std::any_of(m_streamSources.begin(), m_streamSources.end(), [](const LiveStreamSource& source) { return source.self; }); + const bool own = m_streamPublisherGroup && m_streamPublisherGroup == channel.toULongLong(); auto* publish = menu.addAction(text(own ? "Manage stream" : "Start stream")); menu.addSeparator(); auto* files = menu.addAction(text("Group files")); @@ -856,6 +877,7 @@ void MessageList::loadChannel(const QString& channelId) { if (!sameChannel && m_keyRequestsDialog) m_keyRequestsDialog->close(); refreshKeyRequests(); clearStreams(); watchStreams(); + setStreamPublisherGroup(m_streamPublisherGroup); m_groupMenuButton->setVisible(channelId.toULongLong() != 0); clearDmCallRoute(); m_callBtn->setVisible(isDmChannel(channelId)); @@ -1569,6 +1591,16 @@ void MessageList::clearStreams() { m_streamBtn->setToolTip(QCoreApplication::translate("ChatGui", "Live streams")); } +/* Кнопка следует за локальным publisher, а не за запаздывающим/недоступным сетевым каталогом. */ +void MessageList::setStreamPublisherGroup(quint64 group) { + m_streamPublisherGroup = group; + const bool visible = group && group == m_currentChannelId.toULongLong(); + if (visible == !m_streamPublishBtn->isHidden()) return; + m_streamPublishBtn->setVisible(visible); + DEBUG_INFO(DEBUG_CATEGORY_STREAM, "desktop own stream header channel=%s publisher_group=%llx visible=%d", + qPrintable(m_currentChannelId), (unsigned long long)group, visible); +} + /* Полный снимок применяется атомарно; ответы предыдущего канала не меняют текущую шапку. */ void MessageList::onStreamSources(const uint8_t* data, int len) { StreamSourceSnapshot snapshot; diff --git a/tools/chatgui/src/messagelist.h b/tools/chatgui/src/messagelist.h index 3f8513d52..71b321413 100644 --- a/tools/chatgui/src/messagelist.h +++ b/tools/chatgui/src/messagelist.h @@ -53,6 +53,8 @@ public: void onStreamSources(const uint8_t* data, int len); void clearStreams(); void watchStreams(); + /* Обновляет кнопку своей публикации в её канале; group=0 скрывает после завершения. GUI-поток. */ + void setStreamPublisherGroup(quint64 group); signals: void readPositionChanged(const QString& channelId, qint64 lastReadMsgId); @@ -99,6 +101,8 @@ private: quint64 m_callGroup = 0; QPushButton* m_radioBtn = nullptr; /* шапка: переключатель рации */ QPushButton* m_streamBtn = nullptr; + QPushButton* m_streamPublishBtn = nullptr; // Прямой переход к действующей собственной публикации. + quint64 m_streamPublisherGroup = 0; // Канал локального publisher, независимо от снимков каталога. QList m_streamSources; RadioPanel* m_radioPanel = nullptr; /* верхняя панель устройств, VAD и PTT */ bool m_radioOn = false;