@@ -87,6 +87,7 @@ MainWindow::MainWindow(QWidget *parent) :
87
87
connect (ui->exposureSlider , SIGNAL (valueChanged (int )),this , SLOT (onExposureSlider (int )));
88
88
connect (ui->whitebalanceSlider , SIGNAL (valueChanged (int )),this , SLOT (onWhiteBalanceSlider (int )));
89
89
connect (ui->autoGain , SIGNAL (toggled (bool )), this , SLOT (onAutoGain (bool )));
90
+ connect (ui->autoFocus , SIGNAL (toggled (bool )), this , SLOT (onAutoFocus (bool )));
90
91
connect (ui->gainSlider , SIGNAL (valueChanged (int )), this , SLOT (onGainSlider (int )));
91
92
connect (ui->contrastSlider , SIGNAL (valueChanged (int )), this , SLOT (onContrastSlider (int )));
92
93
connect (ui->brightnessSlider , SIGNAL (valueChanged (int )), this , SLOT (onBrightnessSlider (int )));
@@ -226,6 +227,13 @@ void MainWindow::onAutoGain(bool state)
226
227
ui->gainSlider ->setEnabled ((!state) & m_hasGain);
227
228
}
228
229
230
+ void MainWindow::onAutoFocus (bool state)
231
+ {
232
+ qDebug () << " Auto focus set to " << state;
233
+ Cap_setAutoProperty (m_ctx, m_streamID, CAPPROPID_FOCUS, state ? 1 : 0 );
234
+ ui->gainSlider ->setEnabled ((!state) & m_hasGain);
235
+ }
236
+
229
237
void MainWindow::readCameraSettings ()
230
238
{
231
239
qDebug () << " readCameraSettings -> Context = " << m_ctx;
@@ -248,6 +256,7 @@ void MainWindow::readCameraSettings()
248
256
ui->exposureSlider ->setEnabled (false );
249
257
ui->gainSlider ->setEnabled (false );
250
258
ui->whitebalanceSlider ->setEnabled (false );
259
+ ui->focusSlider ->setEnabled (false );
251
260
252
261
// ********************************************************************************
253
262
// AUTO EXPOSURE
@@ -295,6 +304,23 @@ void MainWindow::readCameraSettings()
295
304
ui->autoWhiteBalance ->setCheckState ((bValue==0 ) ? Qt::Unchecked : Qt::Checked);
296
305
}
297
306
307
+ // ********************************************************************************
308
+ // AUTO FOCUS
309
+ // ********************************************************************************
310
+
311
+ if (Cap_getAutoProperty (m_ctx, m_streamID, CAPPROPID_FOCUS, &bValue) != CAPRESULT_OK)
312
+ {
313
+ qDebug () << " Autofocus unsupported" ;
314
+ ui->autoFocus ->setEnabled (false );
315
+ ui->autoFocus ->setCheckState (Qt::Unchecked);
316
+ }
317
+ else
318
+ {
319
+ qDebug () << " Autofocus supported" ;
320
+ ui->autoFocus ->setEnabled (true );
321
+ ui->autoFocus ->setCheckState ((bValue==0 ) ? Qt::Unchecked : Qt::Checked);
322
+ }
323
+
298
324
// ********************************************************************************
299
325
// EXPOSURE
300
326
// ********************************************************************************
0 commit comments