From fd05ec47ab0ce21f81634ab669a58bc0084a30fa Mon Sep 17 00:00:00 2001 From: evgeny Date: Tue, 20 Oct 2026 16:39:50 +0200 Subject: [PATCH] Connect the all-streams window to chat actions and service lifetime --- tools/chatgui/src/mainwindow.cpp | 17 ++++++++++++++++- tools/chatgui/src/mainwindow.h | 2 ++ tools/chatgui/src/messagelist.cpp | 2 +- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/tools/chatgui/src/mainwindow.cpp b/tools/chatgui/src/mainwindow.cpp index 2cbfd81c..5165ea41 100644 --- a/tools/chatgui/src/mainwindow.cpp +++ b/tools/chatgui/src/mainwindow.cpp @@ -2,6 +2,7 @@ #include "mainwindow.h" #include "single_instance.h" #include "streamplayer_window.h" +#include "streamgrid_window.h" #include "stream_publish_engine.h" #include "stream_publish_window.h" #include "channellist.h" @@ -211,6 +212,7 @@ MainWindow::~MainWindow() { if (m_streamPublishWindow) delete m_streamPublishWindow.data(); delete m_streamPublisher; m_streamPublisher = nullptr; if (m_streamPlayer) delete m_streamPlayer.data(); + if (m_streamGrid) delete m_streamGrid.data(); gui_bridge_set_stream_sources_cb(nullptr); s_mainWindow = nullptr; m_cpuLoadTimer->stop(); @@ -634,6 +636,7 @@ void MainWindow::setupBridgeCallbacks() { s_mainWindow->m_messageList->clearDmCallRoute(); s_mainWindow->m_messageList->clearStreams(); if (s_mainWindow->m_streamPlayer) s_mainWindow->m_streamPlayer->close(); + if (s_mainWindow->m_streamGrid) s_mainWindow->m_streamGrid->close(); s_mainWindow->m_channelList->clearDmPresence(); } else { if (type == 12) s_mainWindow->m_messageList->watchStreams(); @@ -650,7 +653,9 @@ void MainWindow::setupBridgeCallbacks() { s_mainWindow->m_messageList->onDmMessages(data, len); }); gui_bridge_set_stream_sources_cb([](const uint8_t* data, int len) { - if (s_mainWindow) s_mainWindow->m_messageList->onStreamSources(data, len); + if (!s_mainWindow) return; + s_mainWindow->m_messageList->onStreamSources(data, len); + if (s_mainWindow->m_streamGrid) s_mainWindow->m_streamGrid->onSources(data, len); }); gui_bridge_set_attachment_preparation_cb([](const uint8_t* data, int len) { if (s_mainWindow) s_mainWindow->m_messageList->onAttachmentPreparation(data, len); @@ -678,10 +683,20 @@ void MainWindow::setupConnects() { }); connect(m_messageList, &MessageList::streamRequested, this, [this](quint64 group, quint64 source, quint64 epoch, const QString& name) { + if (m_streamGrid) delete m_streamGrid.data(); if (m_streamPlayer) delete m_streamPlayer.data(); m_streamPlayer = new StreamPlayerWindow(group, source, epoch, name); m_streamPlayer->setAttribute(Qt::WA_DeleteOnClose); m_streamPlayer->show(); }); + connect(m_messageList, &MessageList::allStreamsRequested, this, [this](quint64 group) { + if (m_streamPlayer) delete m_streamPlayer.data(); + if (m_streamGrid && m_streamGrid->group() != group) delete m_streamGrid.data(); + if (!m_streamGrid) { + m_streamGrid = new StreamGridWindow(group); + m_streamGrid->setAttribute(Qt::WA_DeleteOnClose); + } + m_streamGrid->show(); m_streamGrid->raise(); m_streamGrid->activateWindow(); + }); connect(RadioAudioEngine::instance(), &RadioAudioEngine::stateChanged, this, [this] { auto* engine = RadioAudioEngine::instance(); m_accountList->model()->setRadioState(engine->groupId(), engine->isActive(), engine->isTransmitting()); diff --git a/tools/chatgui/src/mainwindow.h b/tools/chatgui/src/mainwindow.h index a93a020c..ee06eca9 100644 --- a/tools/chatgui/src/mainwindow.h +++ b/tools/chatgui/src/mainwindow.h @@ -22,6 +22,7 @@ class AudioRecorder; class ConnMonitorWindow; class VideoPlayerWindow; class StreamPlayerWindow; +class StreamGridWindow; class StreamPublishEngine; class StreamPublishWindow; class ImageViewerWindow; @@ -131,6 +132,7 @@ private: ConnMonitorWindow *m_connMonitor = nullptr; VideoPlayerWindow *m_videoPlayer = nullptr; QPointer m_streamPlayer; + QPointer m_streamGrid; StreamPublishEngine* m_streamPublisher = nullptr; QPointer m_streamPublishWindow; ImageViewerWindow *m_imageViewer = nullptr; diff --git a/tools/chatgui/src/messagelist.cpp b/tools/chatgui/src/messagelist.cpp index 30303876..0893d3a5 100644 --- a/tools/chatgui/src/messagelist.cpp +++ b/tools/chatgui/src/messagelist.cpp @@ -539,7 +539,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 LiveSource& source) { return source.self; }); + const bool own = std::any_of(m_streamSources.begin(), m_streamSources.end(), [](const LiveStreamSource& source) { return source.self; }); auto* publish = menu.addAction(text(own ? "Manage stream" : "Start stream")); menu.addSeparator(); auto* files = menu.addAction(text("Group files"));