Commit 906ec740 authored by Ronan Abhamon's avatar Ronan Abhamon

feat(ui/views/App/Settings/SettingsVideo): hide preview when at least on call exists

parent c6cae422
...@@ -51,11 +51,11 @@ CameraPreviewRenderer::CameraPreviewRenderer () { ...@@ -51,11 +51,11 @@ CameraPreviewRenderer::CameraPreviewRenderer () {
CameraPreviewRenderer::~CameraPreviewRenderer () { CameraPreviewRenderer::~CameraPreviewRenderer () {
qInfo() << QStringLiteral("Delete context info:") << mContextInfo; qInfo() << QStringLiteral("Delete context info:") << mContextInfo;
CoreManager *core = CoreManager::getInstance(); CoreManager *coreManager = CoreManager::getInstance();
core->lockVideoRender(); coreManager->lockVideoRender();
CoreManager::getInstance()->getCore()->setNativePreviewWindowId(nullptr); coreManager->getCore()->setNativePreviewWindowId(nullptr);
core->unlockVideoRender(); coreManager->unlockVideoRender();
delete mContextInfo; delete mContextInfo;
} }
...@@ -66,10 +66,10 @@ QOpenGLFramebufferObject *CameraPreviewRenderer::createFramebufferObject (const ...@@ -66,10 +66,10 @@ QOpenGLFramebufferObject *CameraPreviewRenderer::createFramebufferObject (const
format.setInternalTextureFormat(GL_RGBA8); format.setInternalTextureFormat(GL_RGBA8);
format.setSamples(4); format.setSamples(4);
CoreManager *core = CoreManager::getInstance(); CoreManager *coreManager = CoreManager::getInstance();
// It's not the same thread as render. // It's not the same thread as render.
core->lockVideoRender(); coreManager->lockVideoRender();
mContextInfo->width = size.width(); mContextInfo->width = size.width();
mContextInfo->height = size.height(); mContextInfo->height = size.height();
...@@ -78,7 +78,7 @@ QOpenGLFramebufferObject *CameraPreviewRenderer::createFramebufferObject (const ...@@ -78,7 +78,7 @@ QOpenGLFramebufferObject *CameraPreviewRenderer::createFramebufferObject (const
updateWindowId(); updateWindowId();
core->unlockVideoRender(); coreManager->unlockVideoRender();
return new QOpenGLFramebufferObject(size, format); return new QOpenGLFramebufferObject(size, format);
} }
...@@ -88,7 +88,7 @@ void CameraPreviewRenderer::render () { ...@@ -88,7 +88,7 @@ void CameraPreviewRenderer::render () {
{ {
QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions(); QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions();
f->glClearColor(0.f, 0.f, 0.f, 0.f); f->glClearColor(0.f, 0.f, 0.f, 1.f);
f->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); f->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
CoreManager *coreManager = CoreManager::getInstance(); CoreManager *coreManager = CoreManager::getInstance();
......
...@@ -2,6 +2,20 @@ ...@@ -2,6 +2,20 @@
// `SettingsVideo.qml` Logic. // `SettingsVideo.qml` Logic.
// ============================================================================= // =============================================================================
.import Linphone 1.0 as Linphone
// =============================================================================
function showVideoPreview (account) { function showVideoPreview (account) {
window.attachVirtualWindow(Qt.resolvedUrl('SettingsVideoPreview.qml')) window.attachVirtualWindow(Qt.resolvedUrl('SettingsVideoPreview.qml'))
} }
function updateVideoPreview () {
var count = Linphone.CallsListModel.rowCount()
if (count === 0) {
showCameraPreview.enabled = true
} else if (count === 1) {
showCameraPreview.enabled = false
window.detachVirtualWindow()
}
}
...@@ -108,10 +108,21 @@ TabContainer { ...@@ -108,10 +108,21 @@ TabContainer {
} }
TextButtonB { TextButtonB {
id: showCameraPreview
anchors.right: parent.right anchors.right: parent.right
enabled: CallsListModel.rowCount() === 0
text: qsTr('showCameraPreview') text: qsTr('showCameraPreview')
onClicked: Logic.showVideoPreview() onClicked: Logic.showVideoPreview()
Connections {
target: CallsListModel
onRowsInserted: Logic.updateVideoPreview()
onRowsRemoved: Logic.updateVideoPreview()
}
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment