Commit 46f4294a authored by Ming Rui Zhang's avatar Ming Rui Zhang Committed by Andreas Traczyk

video: refactor/separate preview from the distant renderer

Change-Id: I9af9e0a4bb07a83b68647015dc8a4e2a21cd2170
parent 35ccab3b
......@@ -50,6 +50,7 @@
#include <QScrollBar>
#include <QWebEngineScript>
#include <QMimeData>
#include <QtConcurrent/QtConcurrent>
#include <algorithm>
#include <memory>
......@@ -222,6 +223,8 @@ CallWidget::CallWidget(QWidget* parent) :
setCallPanelVisibility(false);
ui->containerWidget->setVisible(false);
previewRenderer_ = PreviewRenderWidget::attachPreview();
}
CallWidget::~CallWidget()
......@@ -256,6 +259,16 @@ CallWidget::navigated(bool to)
} else {
backToWelcomePage();
}
// reset preview renderer
if (LRCInstance::getActiveCalls().size() && !LRCInstance::getCurrentCallModel()->getCall(conversation->callId).isAudioOnly) {
previewRenderer_->setParent(ui->videoWidget);
previewRenderer_->changeToRoundedBoarder();
previewRenderer_->setCurrentConainerGeo(ui->videoWidget->width(), ui->videoWidget->height());
previewRenderer_->setPhotoMode(false);
previewRenderer_->setNeedToCentre(false);
previewRenderer_->triggerResetPreviewAfterImageReloaded();
previewRenderer_->show();
}
} else {
QObject::disconnect(smartlistSelectionConnection_);
smartListModel_.reset(nullptr);
......@@ -676,6 +689,16 @@ CallWidget::slotShowCallView(const std::string& accountId,
}
ui->callStackWidget->setCurrentWidget(ui->videoPage);
hideMiniSpinner();
// reset preview renderer when call is not audio only
if (!LRCInstance::getCurrentCallModel()->getCall(convInfo.callId).isAudioOnly) {
previewRenderer_->setParent(ui->videoWidget);
previewRenderer_->changeToRoundedBoarder();
previewRenderer_->setCurrentConainerGeo(ui->videoWidget->width(), ui->videoWidget->height());
previewRenderer_->setPhotoMode(false);
previewRenderer_->setNeedToCentre(false);
previewRenderer_->triggerResetPreviewAfterImageReloaded();
}
ui->videoWidget->pushRenderer(convInfo.callId, LRCInstance::accountModel().getAccountInfo(accountId).profileInfo.type == lrc::api::profile::Type::SIP);
ui->videoWidget->setFocus();
}
......@@ -1412,13 +1435,26 @@ CallWidget::Copy()
}
void
CallWidget::disconnectRendering()
CallWidget::reconnectRenderingVideoDeviceChanged()
{
ui->videoWidget->disconnectRendering();
// for distant renderer to reconnect rendering
ui->videoWidget->reconnectRenderingVideoDeviceChanged();
}
void
CallWidget::connectRendering(bool started)
{
ui->videoWidget->connectRendering(started);
CallWidget::restartPreviewWhenSwitchDevice()
{
previewRenderer_->setCurrentConainerGeo(ui->videoWidget->width(), ui->videoWidget->height());
// since there is the possiblity of image not reloaded properly
// after rendering reconnect, so trigger reset after image reloaded
previewRenderer_->triggerResetPreviewAfterImageReloaded();
if (LRCInstance::getActiveCalls().size() && !LRCInstance::getIfCurrentSelectedCallIsAudioOnly()) {
// if no active calls, or device is changed -> reactive preview
previewRenderer_->connectRendering();
QtConcurrent::run(
[this] {
LRCInstance::avModel().stopPreview();
LRCInstance::avModel().startPreview();
});
}
}
......@@ -32,6 +32,7 @@
#include "navwidget.h"
#include "smartlistmodel.h"
#include "previewrender.h"
// new LRC
#include "api/account.h"
......@@ -57,11 +58,9 @@ public:
explicit CallWidget(QWidget* parent = 0);
~CallWidget();
void restartPreviewWhenSwitchDevice();
int getLeftPanelWidth();
void disconnectRendering();
// if started is true, only update, stop signals are connected
void connectRendering(bool started = false);
void reconnectRenderingVideoDeviceChanged();
// NavWidget
virtual void navigated(bool to);
......@@ -143,6 +142,7 @@ private:
QMenu* menu_;
QClipboard* clipboard_;
PreviewRenderWidget* previewRenderer_;
Ui::CallWidget* ui;
QMovie* miniSpinner_;
......
......@@ -74,7 +74,8 @@ HEADERS += ./aboutdialog.h \
./sipinputpanel.h \
./callaudioonlyavataroverlay.h \
./overlaybutton.h \
./accountmigrationdialog.h
./accountmigrationdialog.h \
./previewrender.h
SOURCES += ./aboutdialog.cpp \
./banneditemwidget.cpp \
./conversationsfilterwidget.cpp \
......@@ -130,7 +131,9 @@ SOURCES += ./aboutdialog.cpp \
./sipinputpanel.cpp \
./callaudioonlyavataroverlay.cpp \
./overlaybutton.cpp \
./accountmigrationdialog.cpp
./accountmigrationdialog.cpp \
./previewrender.cpp \
./lrcinstance.cpp
FORMS += ./aboutdialog.ui \
./advancedsipsettingwidget.ui \
./callwidget.ui \
......@@ -156,5 +159,6 @@ FORMS += ./aboutdialog.ui \
./videoview.ui \
./sipkeypad.ui \
./callaudioonlyavataroverlay.ui \
./accountmigration.ui
./accountmigration.ui \
./previewrender.ui
RESOURCES += ressources.qrc
/**************************************************************************
| Copyright (C) 2019 by Savoir-faire Linux |
| Author: Mingrui Zhang <mingrui.zhang@savoirfairelinux.com> |
| |
| This program is free software; you can redistribute it and/or modify |
| it under the terms of the GNU General Public License as published by |
| the Free Software Foundation; either version 3 of the License, or |
| (at your option) any later version. |
| |
| This program is distributed in the hope that it will be useful, |
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| GNU General Public License for more details. |
| |
| You should have received a copy of the GNU General Public License |
| along with this program. If not, see <https://www.gnu.org/licenses/>. |
**************************************************************************/
#include "lrcinstance.h"
FrameWrapper::FrameWrapper(bool isPreview) :
isPreview_(isPreview)
{
}
FrameWrapper::~FrameWrapper()
{
}
void
FrameWrapper::connectPreviewRendering()
{
QObject::disconnect(frameWrapperConnections_.started);
if (isPreview_) {
frameWrapperConnections_.started = connect(
&LRCInstance::avModel(),
&lrc::api::AVModel::rendererStarted,
this,
&FrameWrapper::slotPreviewStarted);
}
}
void
FrameWrapper::slotPreviewStarted(const std::string& id)
{
if (id != lrc::api::video::PREVIEW_RENDERER_ID)
return;
QObject::disconnect(frameWrapperConnections_.started);
QObject::disconnect(frameWrapperConnections_.updated);
frameWrapperConnections_.updated = connect(
&LRCInstance::avModel(),
&lrc::api::AVModel::frameUpdated,
this,
&FrameWrapper::slotPreviewUpdated);
QObject::disconnect(frameWrapperConnections_.stopped);
frameWrapperConnections_.stopped = connect(
&LRCInstance::avModel(),
&lrc::api::AVModel::rendererStopped,
this,
&FrameWrapper::slotPreviewStoped);
}
void
FrameWrapper::slotPreviewUpdated(const std::string& id)
{
if (id != lrc::api::video::PREVIEW_RENDERER_ID)
return;
auto avModel = &LRCInstance::avModel();
auto renderer = &avModel->getRenderer(id);
if (!renderer->isRendering()) {
return;
}
previewRenderer_ = const_cast<lrc::api::video::Renderer*>(renderer);
renderFrame(id);
}
void
FrameWrapper::renderFrame(const std::string& id)
{
auto avModel = &LRCInstance::avModel();
using namespace lrc::api::video;
auto renderer = &avModel->getRenderer(id);
if (renderer && renderer->isRendering()) {
{
QMutexLocker lock(&mutex_);
auto tmp = renderer->currentFrame();
if (tmp.storage.size()) {
previewFrame_ = tmp;
}
}
emit previewRenderReady();
}
}
void
FrameWrapper::slotPreviewStoped(const std::string& id)
{
if (id != lrc::api::video::PREVIEW_RENDERER_ID)
return;
QObject::disconnect(frameWrapperConnections_.updated);
QObject::disconnect(frameWrapperConnections_.stopped);
previewRenderer_ = nullptr;
emit previewRenderStopped();
}
RenderDistributer::RenderDistributer()
{
previewFrameWrapper_ = std::make_unique<FrameWrapper>(true);
connect(previewFrameWrapper_.get(), &FrameWrapper::previewRenderReady,
[this]() {
emit previewRenderReady();
});
connect(previewFrameWrapper_.get(), &FrameWrapper::previewRenderStopped,
[this]() {
emit previewRenderStopped();
});
}
RenderDistributer::~RenderDistributer()
{
previewFrameWrapper_.reset();
}
......@@ -2,6 +2,7 @@
| Copyright (C) 2019 by Savoir-faire Linux |
| Author: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com> |
| Author: Isa Nanic <isa.nanic@savoirfairelinux.com> |
| Author: Mingrui Zhang <mingrui.zhang@savoirfairelinux.com> |
| |
| This program is free software; you can redistribute it and/or modify |
| it under the terms of the GNU General Public License as published by |
......@@ -23,6 +24,7 @@
#endif
#include <QObject>
#include <QMutex>
#include <QSettings>
#include <QRegularExpression>
#include <QPixmap>
......@@ -30,6 +32,7 @@
#include "settingskey.h"
#include "accountlistmodel.h"
#include "utils.h"
#include "api/lrc.h"
#include "api/account.h"
......@@ -46,6 +49,67 @@
#include "api/conversationmodel.h"
#include "api/peerdiscoverymodel.h"
#include <memory>
class FrameWrapper : public QObject
{
Q_OBJECT
public:
FrameWrapper(bool isPreview);
~FrameWrapper();
void connectPreviewRendering();
lrc::api::video::Renderer* getPreviewRenderer() { return previewRenderer_; }
lrc::api::video::Frame getPreviewFrame() { return previewFrame_; }
signals:
void previewRenderReady();
void previewRenderStopped();
private slots:
void slotPreviewStarted(const std::string& id = {});
void slotPreviewUpdated(const std::string& id = {});
void slotPreviewStoped(const std::string& id = {});
private:
bool isPreview_;
lrc::api::video::Renderer* previewRenderer_;
lrc::api::video::Frame previewFrame_;
QMutex mutex_;
struct frameWrapperConnections {
QMetaObject::Connection started, stopped, updated;
} frameWrapperConnections_;
void renderFrame(const std::string& id);
};
class RenderDistributer : public QObject
{
Q_OBJECT
public:
RenderDistributer();
~RenderDistributer();
lrc::api::video::Renderer* getPreviewRenderer() { return previewFrameWrapper_->getPreviewRenderer(); }
lrc::api::video::Frame getPreviewFrame() { return previewFrameWrapper_->getPreviewFrame(); }
void connectPreviewRendering() { previewFrameWrapper_->connectPreviewRendering(); }
signals:
void previewRenderReady();
void previewRenderStopped();
private:
// one preview to rule them all
std::unique_ptr<FrameWrapper> previewFrameWrapper_;
// distant for each call/conf/conversation
//std::map<std::string, std::unique_ptr<FrameWrapper>> distantFrames_;
};
using namespace lrc::api;
using migrateCallback = std::function<void()>;
......@@ -67,6 +131,9 @@ public:
static Lrc& getAPI() {
return *(instance().lrc_);
};
static RenderDistributer* getRenderDistributer() {
return instance().renderer_.get();
}
static void connectivityChanged() {
instance().lrc_->connectivityChanged();
};
......@@ -132,11 +199,22 @@ public:
instance().selectedConvUid_ = convUid;
};
static bool getIfCurrentSelectedCallIsAudioOnly() {
auto isAudioOnly = false;
auto convInfo = Utils::getSelectedConversation();
if (!convInfo.uid.empty()) {
isAudioOnly = LRCInstance::getCurrentCallModel()->getCall(convInfo.callId).isAudioOnly;
}
return isAudioOnly;
};
static void reset(bool newInstance = false) {
if (newInstance) {
instance().lrc_.reset(new Lrc());
instance().renderer_.reset(new RenderDistributer());
} else {
instance().lrc_.reset();
instance().renderer_.reset();
}
};
......@@ -189,8 +267,11 @@ private:
LRCInstance(migrateCallback willMigrateCb = {},
migrateCallback didMigrateCb = {}) {
lrc_ = std::make_unique<Lrc>(willMigrateCb, didMigrateCb);
renderer_ = std::make_unique<RenderDistributer>();
};
std::string selectedAccountId_;
std::string selectedConvUid_;
std::unique_ptr<RenderDistributer> renderer_;
};
......@@ -21,7 +21,6 @@
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QtConcurrent/QtConcurrent>
#include <QDesktopWidget>
#include <QDir>
#include <QScreen>
......@@ -43,9 +42,7 @@
MainWindow::MainWindow(QWidget* parent)
: QMainWindow(parent)
,
ui(new Ui::MainWindow)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
......@@ -187,17 +184,10 @@ MainWindow::MainWindow(QWidget* parent)
});
timer->start(1000);
#endif
connect(ui->settingswidget, &SettingsWidget::switchCallWidgetToSettingsWidgetPreview,
this, &MainWindow::slotSwitchVideoWidget);
connect(ui->settingswidget, &SettingsWidget::switchSettingsWidgetPreviewToCallWidget,
this, &MainWindow::slotSwitchVideoWidget);
connect(ui->settingswidget, &SettingsWidget::switchCallWidgetToSettingsWidgetPhotoBooth,
this, &MainWindow::slotSwitchVideoWidget);
connect(ui->settingswidget, &SettingsWidget::switchSettingsWidgetPhotoBoothToCallWidget,
this, &MainWindow::slotSwitchVideoWidget);
connect(ui->settingswidget, &SettingsWidget::videoInputDeviceConnectionLost,
this, &MainWindow::slotSwitchVideoWidget);
// preview renderer is initialized firstly here
previewRenderer_ = PreviewRenderWidget::attachPreview(this);
connect(ui->settingswidget, &SettingsWidget::videoDeviceChanged, this, &MainWindow::slotVideoDeviceChanged);
connect(&LRCInstance::accountModel(), &lrc::api::NewAccountModel::accountRemoved,
[this](const std::string& accountId) {
Q_UNUSED(accountId);
......@@ -429,69 +419,11 @@ void MainWindow::slotAccountListChanged()
}
}
void MainWindow::slotSwitchVideoWidget(Utils::VideoWidgetSwapType type)
void MainWindow::slotVideoDeviceChanged(const std::string& device, bool avSettingOrAccountSettingVisible)
{
auto convInfo = Utils::getCurrentConvInfo();
bool isAudioOnly = LRCInstance::getCurrentCallModel()->getCall(convInfo.callId).isAudioOnly;
switch (type)
{
case Utils::VideoWidgetSwapType::CallWidgetToSettingsWidgetPreview: {
// switch local rendering from call to setting preview
ui->callwidget->disconnectRendering();
ui->settingswidget->connectStartedRenderingToPreview();
if (isAudioOnly) {
QtConcurrent::run(
[this] {
LRCInstance::avModel().stopPreview();
LRCInstance::avModel().startPreview();
});
break;
}
break;
}
case Utils::VideoWidgetSwapType::CallWidgetToSettingsWidgetPhotoBooth: {
// switch local rendering from call to setting photo booth
ui->callwidget->disconnectRendering();
ui->settingswidget->connectStartedRenderingToPhotoBooth();
if (isAudioOnly) {
QtConcurrent::run(
[this] {
LRCInstance::avModel().stopPreview();
LRCInstance::avModel().startPreview();
});
break;
}
break;
}
case Utils::VideoWidgetSwapType::SettingsWidgetPreviewToCallWidget: {
// switch local rendering from setting preview to call
ui->settingswidget->disconnectPreviewRendering();
if (isAudioOnly) {
QtConcurrent::run([this] { LRCInstance::avModel().stopPreview(); });
break;
}
ui->callwidget->connectRendering(true);
break;
}
case Utils::VideoWidgetSwapType::SettingsWidgetPhotoBoothToCallWidget: {
// switch local rendering from setting photo booth to call
ui->settingswidget->disconnectPhotoBoothRendering();
if (isAudioOnly) {
QtConcurrent::run([this] { LRCInstance::avModel().stopPreview(); });
break;
}
ui->callwidget->connectRendering(true);
break;
}
case Utils::VideoWidgetSwapType::VideoInputDeviceConnectionLost: {
if (isAudioOnly) {
break;
}
ui->callwidget->connectRendering(false);
break;
}
default: {
break;
}
}
Q_UNUSED(device)
ui->callwidget->reconnectRenderingVideoDeviceChanged();
// if the device is not changed in avSettings, then restart preview manually
if(!avSettingOrAccountSettingVisible)
ui->callwidget->restartPreviewWhenSwitchDevice();
}
......@@ -22,6 +22,7 @@
#include "settingswidget.h"
#include "utils.h"
#include "connectivitymonitor.h"
#include "previewrender.h"
#include "globalsystemtray.h"
#include <QMainWindow>
......@@ -55,8 +56,7 @@ public:
void showWindow();
public slots:
// A slot where covers all cases of video rendering switch between widgets
void slotSwitchVideoWidget(Utils::VideoWidgetSwapType Type);
void slotVideoDeviceChanged(const std::string&, bool);
protected:
bool nativeEvent(const QByteArray& eventType, void* message, long* result);
......@@ -96,6 +96,7 @@ private:
std::unique_ptr<ConnectivityMonitor> connectivityMonitor_;
QMetaObject::Connection screenChangedConnection_;
PreviewRenderWidget* previewRenderer_;
QTimer *updateTimer_;
};
......@@ -238,6 +238,7 @@ void NewWizardWidget::changePage(QWidget* toPage)
&LRCInstance::accountModel(), &lrc::api::NewAccountModel::registeredNameFound,
this, &NewWizardWidget::slotRegisteredNameFound);
validateWizardProgression();
ui->setAvatarWidget->setUpPreviewRenderer();
ui->setAvatarWidget->startBooth();
} else if (toPage == ui->createSIPAccountPage) {
ui->SIPusernameEdit->clear();
......@@ -248,6 +249,7 @@ void NewWizardWidget::changePage(QWidget* toPage)
ui->SIPusernameEdit->setEnabled(true);
setNavBarVisibility(true);
ui->nextButton->setEnabled(true);
ui->setSIPAvatarWidget->setUpPreviewRenderer();
ui->setSIPAvatarWidget->startBooth();
} else if (toPage == ui->importFromDevicePage) {
ui->pinFromDevice->clear();
......
......@@ -20,7 +20,6 @@
#include "photoboothwidget.h"
#include "ui_photoboothwidget.h"
#include "settingswidget.h"
#include <QFileDialog>
#include <QStandardPaths>
......@@ -37,8 +36,8 @@ PhotoboothWidget::PhotoboothWidget(QWidget *parent) :
hasAvatar_(false)
{
ui->setupUi(this);
ui->videoFeed->setIsFullPreview(true);
ui->videoFeed->setPhotoMode(true);
previewRenderer_ = PreviewRenderWidget::attachPreview();
flashOverlay_ = new QLabel(this);
flashOverlay_->setStyleSheet("background-color:#fff");
......@@ -53,6 +52,8 @@ PhotoboothWidget::PhotoboothWidget(QWidget *parent) :
flashAnimation_->setEndValue(0);
flashAnimation_->setEasingCurve(QEasingCurve::OutCubic);
Utils::drawBlackCircularImageOntoLabel(ui->previewContainer);
ui->previewContainer->hide();
ui->takePhotoButton->setIcon(QIcon(":/images/icons/baseline-camera_alt-24px.svg"));
}
......@@ -66,28 +67,18 @@ void
PhotoboothWidget::startBooth(bool isDeviceChanged)
{
hasAvatar_ = false;
ui->videoFeed->setResetPreview(true);
if (!LRCInstance::getActiveCalls().size() || isDeviceChanged) {
if (!LRCInstance::getActiveCalls().size() || isDeviceChanged || LRCInstance::getIfCurrentSelectedCallIsAudioOnly()) {
// if no active calls
ui->videoFeed->connectPreviewOnlyRendering();
previewRenderer_->connectRendering();
QtConcurrent::run(
[this] {
LRCInstance::avModel().stopPreview();
LRCInstance::avModel().startPreview();
});
} else if (settingsPreviewed_) {
// if setting preview is viewed
emit leaveSettingsWidgetPreviewToSettingsWidgetPhotoBooth(
Utils::VideoWidgetSwapType::SettingsWidgetPreviewToSettingsWidgetPhotoBooth);
hasConnection_ = true;
} else {
// call video rendering direct to photo booth
emit enterSettingsWidgetPhotoBoothFromCallWidget(
Utils::VideoWidgetSwapType::CallWidgetToSettingsWidgetPhotoBooth);
hasConnection_ = true;
}
takePhotoState_ = true;
ui->videoFeed->show();
ui->previewContainer->show();
setUpPreviewRenderer();
ui->avatarLabel->hide();
ui->takePhotoButton->setIcon(QIcon(":/images/icons/baseline-camera_alt-24px.svg"));
}
......@@ -95,14 +86,9 @@ PhotoboothWidget::startBooth(bool isDeviceChanged)
void
PhotoboothWidget::stopBooth()
{
if (!LRCInstance::getActiveCalls().size() && takePhotoState_) {
if ((!LRCInstance::getActiveCalls().size() || LRCInstance::getIfCurrentSelectedCallIsAudioOnly()) && takePhotoState_) {
// if no active calls
QtConcurrent::run([this] { LRCInstance::avModel().stopPreview(); });
} else if(hasConnection_){
// if video connection is still on photo booth (now stopBooth will onlt be called once leaving the setting widget)
emit enterCallWidgetFromSettingsWidgetPhotoBooth(
Utils::VideoWidgetSwapType::SettingsWidgetPhotoBoothToCallWidget);
hasConnection_ = false;
}
resetToAvatarLabel();
}
......@@ -118,8 +104,6 @@ PhotoboothWidget::on_importButton_clicked()
picturesDir,
tr("Image Files") + " (*.jpg *.jpeg *.png)");
if (fileName_.isEmpty()) {
ui->videoFeed->connectRendering();
LRCInstance::avModel().startPreview();
return;
}
auto image = Utils::cropImage(QImage(fileName_));
......@@ -143,8 +127,8 @@ PhotoboothWidget::on_takePhotoButton_clicked()
startBooth();
return;
} else {
auto videoRect = ui->videoFeed->rect();
QPoint avatarLabelPos = ui->videoFeed->mapTo(this, videoRect.topLeft());
auto videoRect = previewRenderer_->rect();
QPoint avatarLabelPos = previewRenderer_->mapTo(this, videoRect.topLeft());
flashOverlay_->setGeometry(
avatarLabelPos.x(),
avatarLabelPos.y(),
......@@ -156,7 +140,7 @@ PhotoboothWidget::on_takePhotoButton_clicked()
QtConcurrent::run(
[this] {
auto photo = Utils::cropImage(ui->videoFeed->takePhoto());
auto photo = Utils::cropImage(previewRenderer_->takePhoto());
auto avatar = photo.scaled(224, 224, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation);
avatarPixmap_ = QPixmap::fromImage(avatar);
ui->avatarLabel->setPixmap(QPixmap::fromImage(Utils::getCirclePhoto(avatar, ui->avatarLabel->width())));
......@@ -205,23 +189,10 @@ PhotoboothWidget::hasAvatar()
return hasAvatar_;
}
void
PhotoboothWidget::connectRendering()
{
// connect only local preview
ui->videoFeed->rendererStartedWithoutDistantRender();
}
void
PhotoboothWidget::disconnectRendering()
{
ui->videoFeed->disconnectRendering();
}
void
PhotoboothWidget::resetToAvatarLabel()
{
ui->videoFeed->hide();
ui->previewContainer->hide();
ui->avatarLabel->show();
takePhotoState_ = false;
if (!hasAvatar_) {
......@@ -230,3 +201,14 @@ PhotoboothWidget::resetToAvatarLabel()
ui->takePhotoButton->setIcon(QIcon(":/images/icons/baseline-refresh-24px.svg"));
}
}
void
PhotoboothWidget::setUpPreviewRenderer()
{
previewRenderer_->setParent(ui->previewContainer);
previewRenderer_->setGeometry(ui->previewContainer->rect());
previewRenderer_->resetBoarder();
previewRenderer_->setPhotoMode(true);
previewRenderer_->setNeedToCentre(false);
previewRenderer_->show();
}
......@@ -20,6 +20,7 @@
#pragma once
#include "utils.h"
#include "previewrender.h"
#include <QWidget>
#include <QLabel>
......@@ -42,21 +43,9 @@ public:
void setAvatarPixmap(const QPixmap& avatarPixmap, bool default = false, bool stopPhotoboothPreview = false);
const QPixmap& getAvatarPixmap();
bool hasAvatar();
void connectRendering();
void disconnectRendering();
// hasConnection_ decides whether the video rendering connection is still in photobooth
// (connection transmitted from other video widget)
bool isPhotoBoothOpened() { return takePhotoState_; }
bool isPhotoBoothConnected() { return hasConnection_; }
void resetTakePhotoState(bool state) { takePhotoState_ = state; }
// settingsPreviewed_ changed once the setting's preview is previewed
void setIsSettingsPreviewed(bool state) { settingsPreviewed_ = state; }
signals:
void enterSettingsWidgetPhotoBoothFromCallWidget(Utils::VideoWidgetSwapType type);
void enterCallWidgetFromSettingsWidgetPhotoBooth(Utils::VideoWidgetSwapType type);
void leaveSettingsWidgetPreviewToSettingsWidgetPhotoBooth(Utils::VideoWidgetSwapType type);
bool isPhotoBoothOpened() { return takePhotoState_; }
void resetTakePhotoState(bool state) { takePhotoState_ = state; }
void setUpPreviewRenderer();
private slots:
void on_importButton_clicked();
......@@ -68,14 +57,13 @@ private:
QString fileName_;
Ui::PhotoboothWidget *ui;
PreviewRenderWidget* previewRenderer_;
QLabel* flashOverlay_;
QPropertyAnimation *flashAnimation_;
QPixmap avatarPixmap_;
bool hasAvatar_;
bool takePhotoState_ { false };