211 lines
4.2 KiB
C++
Executable File
211 lines
4.2 KiB
C++
Executable File
|
|
|
|
|
|
#include "avs_app.h"
|
|
#include <AudioVideoManagement/ava_control.h>
|
|
#include <LtsMultiMonitor/lts_dummy_widget.h>
|
|
#include <LtsMultiMonitor/lts_multi_monitor.h>
|
|
#include <QGuiApplication>
|
|
#include <QScreen>
|
|
#include <QPoint>
|
|
#include <QtGlobal>
|
|
|
|
|
|
|
|
|
|
|
|
#include <QDebug>
|
|
|
|
|
|
|
|
|
|
namespace
|
|
{
|
|
|
|
QScreen* screenAt(const QPoint &pos)
|
|
{
|
|
const auto screens = QGuiApplication::screens();
|
|
for (auto screen : screens)
|
|
if (screen->geometry().contains(pos))
|
|
return screen;
|
|
return QGuiApplication::primaryScreen();
|
|
}
|
|
|
|
QRect screenGeometryOf(const QPoint &pos)
|
|
{
|
|
|
|
QScreen *screen = screenAt(pos);
|
|
return screen->geometry();
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace AudioVideoManagement
|
|
{
|
|
|
|
const QString AvsApp::ALL_STREAMS = QStringLiteral("*");
|
|
|
|
AvsApp::AvsApp(const QString &dialogId, AvaControl *avaControl)
|
|
: m_dialogId(dialogId)
|
|
, m_avaControl(avaControl)
|
|
, m_visible(false)
|
|
{
|
|
Q_ASSERT(avaControl);
|
|
}
|
|
|
|
AvsApp::~AvsApp()
|
|
{
|
|
if (m_screenPlacementHelper)
|
|
m_screenPlacementHelper->deleteLater();
|
|
}
|
|
|
|
void AvsApp::show(const QVector<QWidget *> irreplacableWidgets)
|
|
{
|
|
qWarning() << "AvsApp::show";
|
|
Q_ASSERT(!m_presetGeometry);
|
|
|
|
if (m_screenPlacementHelper)
|
|
return;
|
|
|
|
m_screenPlacementHelper = new LtsMultiMonitor::FullscreenVideoDummyWidget;
|
|
|
|
connect(m_screenPlacementHelper, &LtsMultiMonitor::FullscreenVideoDummyWidget::signalWidgetPlaced, this, &AvsApp::onWidgetPlaced);
|
|
connect(m_screenPlacementHelper, &LtsMultiMonitor::FullscreenVideoDummyWidget::signalHideVideo, this, &AvsApp::onHideVideo);
|
|
connect(m_screenPlacementHelper, &LtsMultiMonitor::FullscreenVideoDummyWidget::signalShowVideo, this, &AvsApp::onShowVideo);
|
|
connect(m_screenPlacementHelper, &LtsMultiMonitor::FullscreenVideoDummyWidget::destroyed, this, &AvsApp::onPlacementHelperDestroyed);
|
|
|
|
LtsMultiMonitor::LtsMultiMonitor::getInstance()->selectScreen(m_screenPlacementHelper, nullptr, false, true , irreplacableWidgets);
|
|
}
|
|
|
|
void AvsApp::show(const QRect &geometry)
|
|
{
|
|
qWarning() << "AvsApp::show (direct)";
|
|
showAvsDialog(geometry);
|
|
m_presetGeometry = geometry;
|
|
}
|
|
|
|
void AvsApp::hide(bool andClose)
|
|
{
|
|
qWarning() << "AvsApp::hide";
|
|
|
|
hideAvsDialog();
|
|
|
|
if (m_presetGeometry)
|
|
{
|
|
m_presetGeometry.reset();
|
|
qWarning() << "AvsApp::hide (with preset geo)";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (andClose && m_screenPlacementHelper != nullptr)
|
|
m_screenPlacementHelper->deleteLater();
|
|
}
|
|
|
|
bool AvsApp::isVisible() const
|
|
{
|
|
return m_visible;
|
|
}
|
|
|
|
bool AvsApp::isActive() const
|
|
{
|
|
return isVisible() || (m_screenPlacementHelper != nullptr);
|
|
}
|
|
|
|
void AvsApp::releaseStreams()
|
|
{
|
|
|
|
m_avaControl->releaseStream(m_dialogId, ALL_STREAMS);
|
|
}
|
|
|
|
|
|
|
|
void AvsApp::onWidgetPlaced(const QRect &geometry)
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
qWarning() << "AvsApp::onWidgetPlaced";
|
|
|
|
if (strcmp(PROJECTBUILD,"ahtc") == 0 || strcmp(PROJECTBUILD,"qatarmout") == 0 )
|
|
{
|
|
showAvsDialog(geometry);
|
|
}
|
|
else
|
|
{
|
|
QRect screenGeometry = geometry;
|
|
if (!geometry.isNull())
|
|
screenGeometry = screenGeometryOf(geometry.topLeft());
|
|
|
|
showAvsDialog(screenGeometry);
|
|
}
|
|
|
|
}
|
|
|
|
void AvsApp::onHideVideo()
|
|
{
|
|
hideAndPauseAvsDialog();
|
|
}
|
|
|
|
void AvsApp::onShowVideo()
|
|
{
|
|
showAndResumeAvsDialog();
|
|
}
|
|
|
|
void AvsApp::onPlacementHelperDestroyed()
|
|
{
|
|
qWarning() << "AvsApp::onPlacementHelperDestroyed()";
|
|
|
|
if (static_cast<LtsMultiMonitor::FullscreenVideoDummyWidget *>(sender()) != m_screenPlacementHelper)
|
|
return;
|
|
|
|
Q_ASSERT(m_screenPlacementHelper);
|
|
Q_ASSERT(!m_presetGeometry);
|
|
m_screenPlacementHelper = nullptr;
|
|
hideAvsDialog();
|
|
}
|
|
|
|
void AvsApp::showAvsDialog(const QRect &geometry)
|
|
{
|
|
qWarning() << "AvsApp::showAvsDialog";
|
|
|
|
if (geometry.isNull())
|
|
m_avaControl->setVideoDialogProfile(m_dialogId, AvaVisibility::Visible);
|
|
else
|
|
m_avaControl->setVideoDialogGeometry(m_dialogId, geometry);
|
|
|
|
m_visible = true;
|
|
emit signalVisible();
|
|
}
|
|
|
|
void AvsApp::hideAvsDialog()
|
|
{
|
|
qWarning() << "AvsApp::hideAvsDialog()";
|
|
|
|
|
|
releaseStreams();
|
|
m_avaControl->setVideoDialogProfile(m_dialogId, AvaVisibility::Hidden);
|
|
m_visible = false;
|
|
}
|
|
|
|
void AvsApp::hideAndPauseAvsDialog()
|
|
{
|
|
m_visible = false;
|
|
m_avaControl->setVideoDialogProfile(m_dialogId, AvaVisibility::Hidden);
|
|
emit signalPause();
|
|
}
|
|
|
|
void AvsApp::showAndResumeAvsDialog()
|
|
{
|
|
m_visible = true;
|
|
emit signalResume();
|
|
emit signalVisible();
|
|
}
|
|
|
|
}
|