diff --git a/tools/chatgui/src/stream_publish_window.cpp b/tools/chatgui/src/stream_publish_window.cpp index e37da2a0..38cfeb89 100644 --- a/tools/chatgui/src/stream_publish_window.cpp +++ b/tools/chatgui/src/stream_publish_window.cpp @@ -17,6 +17,8 @@ #include #include #include +#include +#include #ifdef HAVE_STREAM_CAPTURE #include #include @@ -37,6 +39,8 @@ StreamPublishWindow::StreamPublishWindow(StreamPublishEngine* engine, uint64_t g else m_settings = document.object(); } setWindowTitle(text("Broadcast stream")); resize(720, 720); setMinimumSize(460, 480); + auto* escape = new QShortcut(QKeySequence(Qt::Key_Escape), this); escape->setContext(Qt::WidgetWithChildrenShortcut); + connect(escape, &QShortcut::activated, this, &QWidget::close); auto* layout = new QVBoxLayout(this); #ifdef HAVE_STREAM_CAPTURE auto* preview = new QVideoWidget(this); m_preview = preview; @@ -166,6 +170,15 @@ StreamPublishWindow::StreamPublishWindow(StreamPublishEngine* engine, uint64_t g refreshSources(); refreshCodecs(); restoreSettings(); synchronize(); } +void StreamPublishWindow::closeEvent(QCloseEvent* event) { + QWidget::closeEvent(event); + if (event->isAccepted()) { + DEBUG_INFO(DEBUG_CATEGORY_STREAM, "desktop publisher controls closed group=%llx active=%d", + (unsigned long long)m_group, m_engine->active()); + emit closed(); + } +} + /* В БД храним пользовательский выбор, а не runtime handles источника и рассчитанный auto-битрейт. */ void StreamPublishWindow::restoreSettings() { if (m_settings.isEmpty() || m_engine->active()) return; diff --git a/tools/chatgui/src/stream_publish_window.h b/tools/chatgui/src/stream_publish_window.h index e0f17846..b4862e2d 100644 --- a/tools/chatgui/src/stream_publish_window.h +++ b/tools/chatgui/src/stream_publish_window.h @@ -9,12 +9,16 @@ class QPushButton; class QCheckBox; class QButtonGroup; class QSpinBox; +class QCloseEvent; class StreamPublishWindow : public QWidget { Q_OBJECT public: StreamPublishWindow(StreamPublishEngine* engine, uint64_t group, QWidget* parent = nullptr, const QString& settings = {}); signals: void settingsChanged(const QString& settings); + void closed(); // Возвращает фокус окну, из которого открыто управление; публикация продолжает работать. +protected: + void closeEvent(QCloseEvent* event) override; private: StreamPublishEngine* m_engine; uint64_t m_group;