From 906ec7402b7d6a780e507efa1ab742d9022217e0 Mon Sep 17 00:00:00 2001 From: Ronan Abhamon Date: Thu, 20 Apr 2017 14:26:22 +0200 Subject: [PATCH] feat(ui/views/App/Settings/SettingsVideo): hide preview when at least on call exists --- .../src/components/camera/CameraPreview.cpp | 16 ++++++++-------- .../ui/views/App/Settings/SettingsVideo.js | 14 ++++++++++++++ .../ui/views/App/Settings/SettingsVideo.qml | 11 +++++++++++ 3 files changed, 33 insertions(+), 8 deletions(-) diff --git a/linphone-desktop/src/components/camera/CameraPreview.cpp b/linphone-desktop/src/components/camera/CameraPreview.cpp index 253e87188..4eebdf6ea 100644 --- a/linphone-desktop/src/components/camera/CameraPreview.cpp +++ b/linphone-desktop/src/components/camera/CameraPreview.cpp @@ -51,11 +51,11 @@ CameraPreviewRenderer::CameraPreviewRenderer () { CameraPreviewRenderer::~CameraPreviewRenderer () { qInfo() << QStringLiteral("Delete context info:") << mContextInfo; - CoreManager *core = CoreManager::getInstance(); + CoreManager *coreManager = CoreManager::getInstance(); - core->lockVideoRender(); - CoreManager::getInstance()->getCore()->setNativePreviewWindowId(nullptr); - core->unlockVideoRender(); + coreManager->lockVideoRender(); + coreManager->getCore()->setNativePreviewWindowId(nullptr); + coreManager->unlockVideoRender(); delete mContextInfo; } @@ -66,10 +66,10 @@ QOpenGLFramebufferObject *CameraPreviewRenderer::createFramebufferObject (const format.setInternalTextureFormat(GL_RGBA8); format.setSamples(4); - CoreManager *core = CoreManager::getInstance(); + CoreManager *coreManager = CoreManager::getInstance(); // It's not the same thread as render. - core->lockVideoRender(); + coreManager->lockVideoRender(); mContextInfo->width = size.width(); mContextInfo->height = size.height(); @@ -78,7 +78,7 @@ QOpenGLFramebufferObject *CameraPreviewRenderer::createFramebufferObject (const updateWindowId(); - core->unlockVideoRender(); + coreManager->unlockVideoRender(); return new QOpenGLFramebufferObject(size, format); } @@ -88,7 +88,7 @@ void CameraPreviewRenderer::render () { { 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); CoreManager *coreManager = CoreManager::getInstance(); diff --git a/linphone-desktop/ui/views/App/Settings/SettingsVideo.js b/linphone-desktop/ui/views/App/Settings/SettingsVideo.js index 219000130..5bfca55ea 100644 --- a/linphone-desktop/ui/views/App/Settings/SettingsVideo.js +++ b/linphone-desktop/ui/views/App/Settings/SettingsVideo.js @@ -2,6 +2,20 @@ // `SettingsVideo.qml` Logic. // ============================================================================= +.import Linphone 1.0 as Linphone + +// ============================================================================= + function showVideoPreview (account) { 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() + } +} diff --git a/linphone-desktop/ui/views/App/Settings/SettingsVideo.qml b/linphone-desktop/ui/views/App/Settings/SettingsVideo.qml index 26e2238e7..ce636799b 100644 --- a/linphone-desktop/ui/views/App/Settings/SettingsVideo.qml +++ b/linphone-desktop/ui/views/App/Settings/SettingsVideo.qml @@ -108,10 +108,21 @@ TabContainer { } TextButtonB { + id: showCameraPreview + anchors.right: parent.right + enabled: CallsListModel.rowCount() === 0 + text: qsTr('showCameraPreview') onClicked: Logic.showVideoPreview() + + Connections { + target: CallsListModel + + onRowsInserted: Logic.updateVideoPreview() + onRowsRemoved: Logic.updateVideoPreview() + } } // -------------------------------------------------------------------------