311
311
rightLayout->setMargin(0);
312
312
topLayout->addLayout( rightLayout );
314
m_portSelectGroup = new Q3VButtonGroup(i18n("Port"), page);
314
m_portSelectGroup = new QGroupBox(i18n("Port"), page);
315
QVBoxLayout *vertLayout = new QVBoxLayout;
316
m_portSelectGroup->setLayout( vertLayout );
315
317
rightLayout->addWidget(m_portSelectGroup);
316
m_portSettingsGroup = new Q3GroupBox(1, Qt::Horizontal,i18n("Port Settings"), page);
318
m_portSettingsGroup = new QGroupBox(i18n("Port Settings"), page);
319
QVBoxLayout *lay = new QVBoxLayout;
320
m_portSettingsGroup->setLayout( lay );
317
321
rightLayout->addWidget(m_portSettingsGroup);
319
322
// Create port type selection radiobuttons.
320
m_serialRB = new QRadioButton(i18n("Serial"), m_portSelectGroup);
321
m_portSelectGroup->insert(m_serialRB, INDEX_SERIAL);
323
m_serialRB = new QRadioButton(i18n("Serial"));
324
vertLayout->addWidget(m_serialRB );
322
325
m_serialRB->setWhatsThis( i18n("If this option is checked, the camera has to be connected to one of the computer's serial ports (known as COM ports in Microsoft Windows.)"));
323
m_USBRB = new QRadioButton(i18n("USB"), m_portSelectGroup);
324
m_portSelectGroup->insert(m_USBRB, INDEX_USB);
326
m_USBRB = new QRadioButton(i18n("USB"));
327
vertLayout->addWidget(m_USBRB );
325
328
m_USBRB->setWhatsThis( i18n("If this option is checked, the camera has to be connected to one of the computer's USB ports, or to a USB hub."));
326
329
// Create port settings widget stack
327
m_settingsStack = new Q3WidgetStack(m_portSettingsGroup);
328
connect(m_portSelectGroup, SIGNAL(clicked(int)),
329
m_settingsStack, SLOT(raiseWidget(int)));
330
m_settingsStack = new QStackedWidget;
331
Q3Grid *grid2 = new Q3Grid(2, m_settingsStack);
332
grid2->setSpacing(KDialog::spacingHint());
333
new QLabel(i18n("Port"), grid2);
335
lay->addWidget(grid2);
336
lay->addWidget( m_settingsStack );
337
connect(m_serialRB, SIGNAL( toggled(bool) ),
338
this, SLOT( changeCurrentIndex() ) );
339
connect(m_USBRB, SIGNAL( toggled(bool) ),
340
this, SLOT( changeCurrentIndex() ) );
332
m_settingsStack->addWidget(new QLabel(i18n("No port type selected."),
333
m_settingsStack), INDEX_NONE);
342
m_settingsStack->insertWidget(INDEX_NONE, new QLabel(i18n("No port type selected."),
336
346
Q3Grid *grid = new Q3Grid(2, m_settingsStack);
339
349
m_serialPortCombo = new QComboBox(grid);
340
350
m_serialPortCombo->setEditable(true);
341
351
m_serialPortCombo->setWhatsThis( i18n("Specify here the serial port to which you connect the camera."));
342
m_settingsStack->addWidget(grid, INDEX_SERIAL);
344
grid = new Q3Grid(2, m_settingsStack);
345
grid->setSpacing(KDialog::spacingHint());
346
new QLabel(i18n("Port"), grid);
348
m_settingsStack->addWidget(new
352
m_settingsStack->insertWidget(INDEX_SERIAL, grid);
354
m_settingsStack->insertWidget(INDEX_USB, new
349
355
QLabel(i18n("No further configuration is required for USB cameras."),
350
m_settingsStack), INDEX_USB);
352
358
// query gphoto2 for existing serial ports
353
359
GPPortInfoList *list;
376
382
m_portSettingsGroup->setEnabled( false );
385
void KameraDeviceSelectDialog::changeCurrentIndex()
387
QRadioButton *send = dynamic_cast<QRadioButton*>( sender() );
390
if ( send == m_serialRB )
392
m_settingsStack->setCurrentIndex( INDEX_SERIAL );
394
else if ( send == m_USBRB )
397
m_settingsStack->setCurrentIndex( INDEX_USB );
379
402
bool KameraDeviceSelectDialog::populateCameraListView()
381
404
gp_abilities_list_new (&m_device->m_abilitylist);
401
424
m_device->setModel(m_modelSel->currentItem()->text(0));
403
if (m_portSelectGroup->selected()) {
404
QString type = m_portSelectGroup->selected()->text();
406
if(type == i18n("Serial"))
407
m_device->setPath("serial:" + m_serialPortCombo->currentText());
408
else if(type == i18n("USB"))
409
m_device->setPath("usb:");
411
// This camera has no port type (e.g. "Directory Browse" camera).
426
if (m_serialRB->isChecked())
427
m_device->setPath("serial:" + m_serialPortCombo->currentText());
428
else if ( m_USBRB->isChecked() )
429
m_device->setPath("usb:");
416
432
void KameraDeviceSelectDialog::load()
450
466
// enable radiobuttons for supported port types
451
467
m_serialRB->setEnabled(abilities.port & GP_PORT_SERIAL);
452
468
m_USBRB->setEnabled(abilities.port & GP_PORT_USB);
454
// turn off any selected port
455
QAbstractButton *selected = m_portSelectGroup->selected();
459
469
// if there's only one available port type, make sure it's selected
460
470
if (abilities.port == GP_PORT_SERIAL)
461
471
setPortType(INDEX_SERIAL);
470
480
void KameraDeviceSelectDialog::setPortType(int type)
472
482
// Enable the correct button
473
m_portSelectGroup->setButton(type);
483
if ( type == INDEX_USB )
484
m_USBRB->setChecked( true );
485
else if ( type == INDEX_SERIAL )
486
m_serialRB->setChecked( true );
475
// Bring the right tab to the front
476
m_settingsStack->raiseWidget(type);
488
// Bring the right tab to the front
489
m_settingsStack->setCurrentIndex(type);
479
492
void KameraDeviceSelectDialog::slot_error(const QString &message)