Commit 2d0e0a45 authored by Andreas Traczyk's avatar Andreas Traczyk Committed by Ming Rui Zhang

video: fix device event response

Change-Id: Ib98cb3410071c0abb1c2a8be31bb3986e1b5c557
parent 1fd183de
......@@ -219,6 +219,9 @@ CallWidget::CallWidget(QWidget* parent) :
}
});
connect(LRCInstance::renderer(), &RenderManager::videoDeviceListChanged,
this, &CallWidget::slotVideoDeviceListChanged);
// set first view to welcome view
ui->stackedWidget->setCurrentWidget(ui->welcomePage);
ui->btnConversations->setChecked(true);
......@@ -575,6 +578,14 @@ void CallWidget::slotSetChatVisibility(bool visible)
ui->messagesWidget->setVisible(visible);
}
void
CallWidget::slotVideoDeviceListChanged()
{
if (LRCInstance::hasVideoCall()) {
LRCInstance::renderer()->startPreviewing();
}
}
void
CallWidget::conversationsButtonClicked()
{
......
......@@ -102,6 +102,7 @@ private slots:
void on_btnVideoCall_clicked();
void smartListSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected);
void slotSetChatVisibility(bool visible);
void slotVideoDeviceListChanged();
private:
void onIncomingMessage(const std::string& accountId, const std::string& convUid,
......
......@@ -196,6 +196,12 @@ RenderManager::~RenderManager()
}
}
bool
RenderManager::isPreviewing()
{
return previewFrameWrapper_->isRendering();
}
QImage*
RenderManager::getPreviewFrame()
{
......
......@@ -148,6 +148,10 @@ public:
explicit RenderManager(AVModel& avModel);
~RenderManager();
/**
* Check if the preview is active
*/
bool isPreviewing();
/**
* Get the most recently rendered preview frame as a QImage.
* @return the rendered preview image
......
......@@ -128,11 +128,11 @@ SettingsWidget::SettingsWidget(QWidget* parent)
// btnExitSettings
connect(ui->btnExitSettings, &QPushButton::clicked, this, &SettingsWidget::leaveSettingsSlot);
connect(ui->accountSettingsButton, &QPushButton::clicked, [this]() { setSelected(Button::accountSettingsButton); });
connect(ui->accountSettingsButton, &QPushButton::clicked, [this]() { setSelected(SettingsMenu::Account); });
connect(ui->generalSettingsButton, &QPushButton::clicked, [this]() { setSelected(Button::generalSettingsButton); });
connect(ui->generalSettingsButton, &QPushButton::clicked, [this]() { setSelected(SettingsMenu::General); });
connect(ui->mediaSettingsButton, &QPushButton::clicked, [this]() { setSelected(Button::mediaSettingsButton); });
connect(ui->mediaSettingsButton, &QPushButton::clicked, [this]() { setSelected(SettingsMenu::Media); });
connect(ui->advancedAccountSettingsSIPButton, &QPushButton::clicked, this, &SettingsWidget::toggleAdvancedSIPSettings);
......@@ -267,7 +267,7 @@ SettingsWidget::SettingsWidget(QWidget* parent)
void SettingsWidget::slotAccountListChanged()
{
if (!LRCInstance::accountModel().getAccountList().size()) {
setSelected(Button::accountSettingsButton);
setSelected(SettingsMenu::Account);
} else {
disconnectAccountConnections();
}
......@@ -281,7 +281,7 @@ void SettingsWidget::navigated(bool to)
{
ui->containerWidget->setVisible(to);
if (to) {
setSelected(Button::accountSettingsButton);
setSelected(SettingsMenu::Account);
updateAccountInfoDisplayed();
// hide banned list
ui->bannedContactsListWidget->setVisible(false);
......@@ -316,17 +316,17 @@ SettingsWidget::~SettingsWidget()
{
delete ui;
}
void SettingsWidget::setSelected(Button sel)
void SettingsWidget::setSelected(SettingsMenu sel)
{
switch (sel) {
case Button::accountSettingsButton:
case SettingsMenu::Account:
connectCurrentAccount();
ui->accountSettingsButton->setChecked(true);
ui->generalSettingsButton->setChecked(false);
ui->mediaSettingsButton->setChecked(false);
if (pastButton_ == sel && pastAccount_ == LRCInstance::getCurrentAccountInfo().profileInfo.type) {
if (selectedMenu_ == sel && pastAccount_ == LRCInstance::getCurrentAccountInfo().profileInfo.type) {
return;
}
......@@ -353,12 +353,12 @@ void SettingsWidget::setSelected(Button sel)
break;
case Button::generalSettingsButton:
case SettingsMenu::General:
ui->generalSettingsButton->setChecked(true);
ui->accountSettingsButton->setChecked(false);
ui->mediaSettingsButton->setChecked(false);
if (pastButton_ == sel) { return; }
if (selectedMenu_ == sel) { return; }
stopAudioMeter();
stopPreviewing();
......@@ -368,11 +368,11 @@ void SettingsWidget::setSelected(Button sel)
break;
case Button::mediaSettingsButton:
case SettingsMenu::Media:
ui->mediaSettingsButton->setChecked(true);
ui->generalSettingsButton->setChecked(false);
ui->accountSettingsButton->setChecked(false);
if (pastButton_ == sel) { return; }
if (selectedMenu_ == sel) { return; }
ui->stackedWidget->setCurrentWidget(ui->avSettings);
......@@ -383,7 +383,7 @@ void SettingsWidget::setSelected(Button sel)
break;
}
pastButton_ = sel;
selectedMenu_ = sel;
}
// called to update current settings information when navigating to settingsWidget
void SettingsWidget::updateAccountInfoDisplayed()
......@@ -1183,7 +1183,13 @@ SettingsWidget::populateVideoSettings()
ui->deviceBox->setCurrentIndex(deviceIndex);
setFormatListForDevice(LRCInstance::avModel().getCurrentVideoCaptureDevice());
startPreviewing(false);
bool isSIP = LRCInstance::getCurrentAccountInfo().profileInfo.type == lrc::api::profile::Type::SIP;
auto photoBooth = isSIP ? ui->currentSIPAccountAvatar : ui->currentAccountAvatar;
if ( (photoBooth->isVisible() && LRCInstance::renderer()->isPreviewing()) ||
selectedMenu_ == SettingsMenu::Media) {
startPreviewing(false);
}
}
connect(ui->deviceBox, QOverload<int>::of(&QComboBox::currentIndexChanged),
......
......@@ -56,10 +56,10 @@ public slots:
private:
Ui::SettingsWidget* ui;
enum Button {
accountSettingsButton,
generalSettingsButton,
mediaSettingsButton
enum SettingsMenu {
Account,
General,
Media
};
enum RegName {
BLANK,
......@@ -70,7 +70,7 @@ private:
};
void setAvatar(PhotoboothWidget* avatarWidget);
void setSelected(Button sel);
void setSelected(SettingsMenu sel);
void updateAccountInfoDisplayed();
void resizeEvent(QResizeEvent* event);
bool sipPasswordHidden_ {false};
......@@ -96,7 +96,7 @@ private:
lrc::api::account::ConfProperties_t confProps_;
AdvancedSettingsWidget* advancedSettingsWidget_;
QScrollArea* scrollArea_;
Button pastButton_ = Button::generalSettingsButton;
SettingsMenu selectedMenu_ = SettingsMenu::General;
lrc::api::profile::Type pastAccount_ = lrc::api::profile::Type::INVALID;
bool advancedSettingsDropped_ = false;
QList<QPair<std::string, float>> formatIndexList_;
......
......@@ -509,6 +509,10 @@ VideoView::resetPreview()
if (device.empty()) {
device = LRCInstance::avModel().getDefaultDeviceName();
}
if (device.empty()) {
previewWidget_->setVisible(false);
return;
}
auto settings = LRCInstance::avModel().getDeviceSettings(device);
width = QString::fromStdString(settings.size).split("x")[0].toInt();
height = QString::fromStdString(settings.size).split("x")[1].toInt();
......
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