Skip to content
This repository has been archived by the owner on Feb 12, 2023. It is now read-only.

Commit

Permalink
feat(avform): Added automatic screen rescan
Browse files Browse the repository at this point in the history
  • Loading branch information
Diadlo committed Aug 24, 2016
1 parent eaccbf3 commit 0822973
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/widget/form/settings/avform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@
#include "src/core/coreav.h"
#include "src/core/recursivesignalblocker.h"

#include <QScreen>
#include <QDesktopWidget>
#include <QDebug>
#include <QScreen>
#include <QShowEvent>
#include <map>

Expand All @@ -57,12 +58,7 @@ AVForm::AVForm()
btnPlayTestSound->setToolTip(
tr("Play a test sound while changing the output volume."));

connect(rescanButton, &QPushButton::clicked, this, [=]()
{
getAudioInDevices();
getAudioOutDevices();
getVideoDevices();
});
connect(rescanButton, &QPushButton::clicked, this, &AVForm::rescanDevices);

playbackSlider->setTracking(false);
playbackSlider->setValue(s.getOutVolume());
Expand All @@ -87,6 +83,10 @@ AVForm::AVForm()
cb->setFocusPolicy(Qt::StrongFocus);
}

QDesktopWidget *desktop = QApplication::desktop();
connect(desktop, &QDesktopWidget::resized, this, &AVForm::rescanDevices);
connect(desktop, &QDesktopWidget::screenCountChanged, this, &AVForm::rescanDevices);

Translator::registerHandler(std::bind(&AVForm::retranslateUi, this), this);
}

Expand Down Expand Up @@ -138,6 +138,13 @@ void AVForm::open(const QString &devName, const VideoMode &mode)
camera.open(devName, mode);
}

void AVForm::rescanDevices()
{
getAudioInDevices();
getAudioOutDevices();
getVideoDevices();
}

void AVForm::on_videoModescomboBox_currentIndexChanged(int index)
{
if (index < 0 || index >= videoModes.size())
Expand Down
1 change: 1 addition & 0 deletions src/widget/form/settings/avform.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ private slots:
void on_videoDevCombobox_currentIndexChanged(int index);
void on_videoModescomboBox_currentIndexChanged(int index);

void rescanDevices();

protected:
void updateVideoModes(int curIndex);
Expand Down

0 comments on commit 0822973

Please sign in to comment.