Browse Source

refactor(AVForm): replace QDesktopWidget::screenCountChanged

reviewable/pr5745/r1
jenli669 6 years ago
parent
commit
fb3f44721e
No known key found for this signature in database
GPG Key ID: 8267F9F7C2BF7E5E
  1. 11
      src/widget/form/settings/avform.cpp
  2. 1
      src/widget/form/settings/avform.h

11
src/widget/form/settings/avform.cpp

@ -105,11 +105,14 @@ AVForm::AVForm(IAudioControl& audio, CoreAV* coreAV, CameraSource& camera, @@ -105,11 +105,14 @@ AVForm::AVForm(IAudioControl& audio, CoreAV* coreAV, CameraSource& camera,
eventsInit();
QDesktopWidget* desktop = QApplication::desktop();
connect(desktop, &QDesktopWidget::screenCountChanged, this, &AVForm::rescanDevices);
for (QScreen* qScreen : QGuiApplication::screens()) {
connect(qScreen, &QScreen::geometryChanged, this, &AVForm::rescanDevices);
}
auto* qGUIApp = qobject_cast<QGuiApplication *>(qApp);
assert (qGUIApp);
connect(qGUIApp, &QGuiApplication::screenAdded, this, &AVForm::trackNewScreenGeometry);
connect(qGUIApp, &QGuiApplication::screenAdded, this, &AVForm::rescanDevices);
connect(qGUIApp, &QGuiApplication::screenRemoved, this, &AVForm::rescanDevices);
Translator::registerHandler(std::bind(&AVForm::retranslateUi, this), this);
}
@ -160,6 +163,10 @@ void AVForm::open(const QString& devName, const VideoMode& mode) @@ -160,6 +163,10 @@ void AVForm::open(const QString& devName, const VideoMode& mode)
camera.setupDevice(devName, mode);
}
void AVForm::trackNewScreenGeometry(QScreen* qScreen) {
connect(qScreen, &QScreen::geometryChanged, this, &AVForm::rescanDevices);
}
void AVForm::rescanDevices()
{
getAudioInDevices();

1
src/widget/form/settings/avform.h

@ -95,6 +95,7 @@ private: @@ -95,6 +95,7 @@ private:
void open(const QString& devName, const VideoMode& mode);
int getStepsFromValue(qreal val, qreal valMin, qreal valMax);
qreal getValueFromSteps(int steps, qreal valMin, qreal valMax);
void trackNewScreenGeometry(QScreen* qScreen);
private:
IAudioControl& audio;

Loading…
Cancel
Save