Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
+102
@@ -0,0 +1,102 @@
|
||||
/**
|
||||
* @RDE_HEADER@
|
||||
* PlaybackApp
|
||||
* $Id$
|
||||
* $HeadURL$
|
||||
* $Author$
|
||||
* Created by Christian Fröbel, NLSE, 2018-04-18
|
||||
*/
|
||||
|
||||
#include "playback_app.h"
|
||||
#include "avs_app.h"
|
||||
|
||||
#include <AudioVideoManagement/avs_dialog.h>
|
||||
#include <QtGlobal>
|
||||
|
||||
|
||||
namespace AudioVideoManagement
|
||||
{
|
||||
|
||||
PlaybackApp::PlaybackApp(const QString &dialogId, AvaControl *avaControl, AppType appType)
|
||||
: m_dialogId(dialogId)
|
||||
, m_autoHide(appType == AppType::AutoHide)
|
||||
{
|
||||
if (appType != AppType::AlwaysHidden)
|
||||
{
|
||||
m_app.reset(new AvsApp(m_dialogId, avaControl));
|
||||
m_objectWrapper = new ObjectWrapper(nullptr);
|
||||
QObject::connect(m_app.get(), &AvsApp::signalVisible,
|
||||
m_objectWrapper, &ObjectWrapper::signalVisible);
|
||||
QObject::connect(m_app.get(), &AvsApp::signalPause,
|
||||
m_objectWrapper, &ObjectWrapper::signalPause);
|
||||
QObject::connect(m_app.get(), &AvsApp::signalResume,
|
||||
m_objectWrapper, &ObjectWrapper::signalResume);
|
||||
}
|
||||
}
|
||||
|
||||
PlaybackApp::~PlaybackApp()
|
||||
{
|
||||
if (m_objectWrapper)
|
||||
m_objectWrapper->deleteLater();
|
||||
}
|
||||
|
||||
void PlaybackApp::acquire()
|
||||
{
|
||||
Q_ASSERT(!m_inUse);
|
||||
if (m_app)
|
||||
m_app->show();
|
||||
m_inUse = true;
|
||||
}
|
||||
|
||||
void PlaybackApp::setGeometry(const QRect &geometry)
|
||||
{
|
||||
Q_ASSERT(m_app);
|
||||
m_app->show(geometry);
|
||||
}
|
||||
|
||||
void PlaybackApp::acquire(const QRect &geometry)
|
||||
{
|
||||
Q_ASSERT(!m_inUse);
|
||||
setGeometry(geometry);
|
||||
m_inUse = true;
|
||||
}
|
||||
|
||||
void PlaybackApp::release()
|
||||
{
|
||||
Q_ASSERT(m_inUse);
|
||||
|
||||
// Hint: when m_autoHide == true, m_app is set.
|
||||
// Otherwise (appType == Normal or AlwaysHidden) m_app might not be set (when appType == AlwaysHidden).
|
||||
if (m_autoHide)
|
||||
m_app->hide(true /* and close */); // implicitly releases all streams
|
||||
else if (m_app)
|
||||
m_app->releaseStreams();
|
||||
m_inUse = false;
|
||||
}
|
||||
|
||||
void PlaybackApp::hide(bool andClose)
|
||||
{
|
||||
Q_ASSERT(m_inUse);
|
||||
|
||||
if (m_app)
|
||||
m_app->hide(andClose);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// PlaybackAppHandle
|
||||
PlaybackAppHandle::PlaybackAppHandle(PlaybackApp *app)
|
||||
: m_app(app, [] (PlaybackApp *app_) { app_->release(); })
|
||||
{
|
||||
Q_ASSERT(app);
|
||||
app->acquire();
|
||||
}
|
||||
|
||||
PlaybackAppHandle::PlaybackAppHandle(PlaybackApp *app, const QRect &geometry)
|
||||
: m_app(app, [] (PlaybackApp *app_) { app_->release(); })
|
||||
{
|
||||
Q_ASSERT(app);
|
||||
app->acquire(geometry);
|
||||
}
|
||||
|
||||
} // namespace AudioVideoManagement
|
||||
Reference in new issue
Block a user