Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
+217
@@ -0,0 +1,217 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* AvsApp
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Fröbel, NLSE, 2018-04-16
|
||||
*/
|
||||
|
||||
#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 = QGuiApplication::screenAt(pos); // since Qt 5.10
|
||||
QScreen *screen = screenAt(pos);
|
||||
return screen->geometry();
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
|
||||
|
||||
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 /* ltsScreenNormalOnly */, 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)";
|
||||
// return;
|
||||
}
|
||||
|
||||
// videos can now be hidden by swapping from main to secondary in mmm, so don't delete the helper - it might tell us to re-show the video later
|
||||
// now wait until screen placement helper was destroyed by, so don't set m_screenPlacementHelper to 0 yet
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param geometry is null in case we're not in MultiMonitorMode.
|
||||
*/
|
||||
void AvsApp::onWidgetPlaced(const QRect &geometry)
|
||||
{
|
||||
// In Multi-Monitor-Mode geometry is not Null.
|
||||
// But the given geometry does not cover the whole screen; some space for bordering is subtracted.
|
||||
// Thus we determine the screen geometry ourselves.
|
||||
// In Windowed-Mode we simply pass a Null-QRect to showAvsDialog().
|
||||
|
||||
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); // windowed mode; simply show the window as configured in AVS_Workstation.conf
|
||||
else
|
||||
m_avaControl->setVideoDialogGeometry(m_dialogId, geometry); // multi monitor mode
|
||||
|
||||
m_visible = true;
|
||||
emit signalVisible();
|
||||
}
|
||||
|
||||
void AvsApp::hideAvsDialog()
|
||||
{
|
||||
qWarning() << "AvsApp::hideAvsDialog()";
|
||||
//if (!m_visible) // don't return as we
|
||||
// return;
|
||||
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();
|
||||
}
|
||||
|
||||
} // namespace AudioVideoManagement
|
||||
Reference in new issue
Block a user