1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

refactor(AVForm): replace QDesktopWidget::screenCountChanged

This commit is contained in:
jenli669 2019-07-13 10:27:02 +02:00
parent 16452eff0c
commit fb3f44721e
No known key found for this signature in database
GPG Key ID: 8267F9F7C2BF7E5E
2 changed files with 10 additions and 2 deletions

View File

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

View File

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