Browse Source

Open own broadcast controls and keep rejected voice recording idle

master
evgeny 5 days ago
parent
commit
80bd17a28e
  1. 1
      tools/chatgui/src/inputbar.cpp
  2. 7
      tools/chatgui/src/messagelist.cpp
  3. 2
      tools/chatgui/src/messagelist.h

1
tools/chatgui/src/inputbar.cpp

@ -466,6 +466,7 @@ void InputBar::onPttPressed() {
if (!m_recorder || !m_recorder->isInitialized()) return;
m_recorder->startRecording();
m_pttActive = m_recorder->isRecording();
if (!m_pttActive) { DEBUG_WARN(DEBUG_CATEGORY_MEDIA, "voice recording did not start; composer remains idle"); return; }
m_recordTarget = m_channelIdForRecord;
m_recordReply = m_replyTo; m_recordReplyGeneration = m_replyGeneration; m_replyFailed = false;
m_pttBtn->setStyleSheet(m_pttBtn->styleSheet() +

7
tools/chatgui/src/messagelist.cpp

@ -437,15 +437,18 @@ MessageList::MessageList(DbManager* db, AudioRecorder* recorder, QWidget *parent
m_streamBtn->setCursor(Qt::PointingHandCursor);
connect(m_streamBtn, &QPushButton::clicked, this, [this] {
auto watch = [this](const LiveSource& source) {
if (source.self) { emit streamPublishRequested(m_currentChannelId.toULongLong()); return; }
DEBUG_INFO(DEBUG_CATEGORY_STREAM, "desktop selected stream group=%s source=%llx epoch=%llx",
qPrintable(m_currentChannelId), (unsigned long long)source.id, (unsigned long long)source.epoch);
emit streamRequested(m_currentChannelId.toULongLong(), source.id, source.epoch, source.name);
};
QMenu menu(this);
auto* publish = menu.addAction(QCoreApplication::translate("ChatGui", "Broadcast stream"));
bool own = std::any_of(m_streamSources.begin(), m_streamSources.end(), [](const LiveSource& source) { return source.self; });
auto* publish = menu.addAction(QCoreApplication::translate("ChatGui", own ? "Manage stream" : "Start stream"));
connect(publish, &QAction::triggered, this, [this] { emit streamPublishRequested(m_currentChannelId.toULongLong()); });
if (!m_streamSources.isEmpty()) menu.addSeparator();
for (const auto& source : m_streamSources) {
if (source.self) continue;
auto* action = menu.addAction(QStringLiteral("%1 · %2").arg(source.name).arg(source.id));
connect(action, &QAction::triggered, this, [watch, source] { watch(source); });
}
@ -1512,7 +1515,7 @@ void MessageList::onStreamSources(const uint8_t* data, int len) {
clearStreams(); return;
}
QString name = member.value("name").toString(); if (name.isEmpty()) name = QString::number(id);
sources.push_back({id, epoch, name});
sources.push_back({id, epoch, name, member.value("self").toInt() != 0});
}
m_streamSources = std::move(sources); m_streamBtn->setVisible(true);
m_streamBtn->setText(m_streamSources.size() > 1 ? QString::number(m_streamSources.size()) : QString());

2
tools/chatgui/src/messagelist.h

@ -89,7 +89,7 @@ private:
quint64 m_callGroup = 0;
QPushButton* m_radioBtn = nullptr; /* шапка: переключатель рации */
QPushButton* m_streamBtn = nullptr;
struct LiveSource { quint64 id, epoch; QString name; };
struct LiveSource { quint64 id, epoch; QString name; bool self = false; };
QList<LiveSource> m_streamSources;
RadioPanel* m_radioPanel = nullptr; /* верхняя панель устройств, VAD и PTT */
bool m_radioOn = false;

Loading…
Cancel
Save