~ubuntu-branches/ubuntu/maverick/kdegraphics/maverick-proposed

« back to all changes in this revision

Viewing changes to kamera/kcontrol/kameradevice.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Thomas
  • Date: 2009-12-02 14:03:43 UTC
  • mfrom: (1.1.35 upstream)
  • Revision ID: james.westby@ubuntu.com-20091202140343-2732gbkj69g89arq
Tags: 4:4.3.80-0ubuntu1
* New upstream beta release:
  - Add build-depend on shared-desktop-ontologies for nepomuk integration
  - Bump .so versions for libkexiv, libkdcraw and libkipi
  - Update various .install files

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
*/
23
23
#include <qlayout.h>
24
 
#include <q3widgetstack.h>
 
24
#include <QStackedWidget>
25
25
 
26
26
#include <qcombobox.h>
27
27
#include <qlineedit.h>
28
28
#include <qradiobutton.h>
29
 
#include <Q3Button>
30
29
 
31
30
#include <qlabel.h>
32
31
#include <q3grid.h>
54
53
 
55
54
static const int INDEX_NONE= 0;
56
55
static const int INDEX_SERIAL = 1;
57
 
static const int INDEX_USB= 3;
 
56
static const int INDEX_USB= 2;
58
57
static GPContext *glob_context = 0;
59
58
 
60
59
KCamera::KCamera(const QString &name, const QString &path)
63
62
        m_model = name;
64
63
        m_path  = path;
65
64
        m_camera = NULL;
 
65
        m_abilitylist = NULL;
66
66
}
67
67
 
68
68
KCamera::~KCamera()
311
311
        rightLayout->setMargin(0);
312
312
        topLayout->addLayout( rightLayout );
313
313
 
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);
318
 
 
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);
330
334
 
 
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() ) );
331
341
        // none tab
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."),
 
343
                m_settingsStack));
334
344
 
335
345
        // serial tab
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);
343
 
 
344
 
        grid = new Q3Grid(2, m_settingsStack);
345
 
        grid->setSpacing(KDialog::spacingHint());
346
 
        new QLabel(i18n("Port"), grid);
347
 
 
348
 
        m_settingsStack->addWidget(new
 
352
        m_settingsStack->insertWidget(INDEX_SERIAL, grid);
 
353
 
 
354
        m_settingsStack->insertWidget(INDEX_USB, new
349
355
                QLabel(i18n("No further configuration is required for USB cameras."),
350
 
                m_settingsStack), INDEX_USB);
 
356
                m_settingsStack));
351
357
 
352
358
        // query gphoto2 for existing serial ports
353
359
        GPPortInfoList *list;
376
382
    m_portSettingsGroup->setEnabled( false );
377
383
}
378
384
 
 
385
void KameraDeviceSelectDialog::changeCurrentIndex()
 
386
{
 
387
    QRadioButton *send = dynamic_cast<QRadioButton*>( sender() );
 
388
    if ( send )
 
389
    {
 
390
        if ( send == m_serialRB )
 
391
        {
 
392
            m_settingsStack->setCurrentIndex( INDEX_SERIAL );
 
393
        }
 
394
        else if ( send == m_USBRB )
 
395
        {
 
396
 
 
397
            m_settingsStack->setCurrentIndex( INDEX_USB );
 
398
        }
 
399
    }
 
400
}
 
401
 
379
402
bool KameraDeviceSelectDialog::populateCameraListView()
380
403
{
381
404
        gp_abilities_list_new (&m_device->m_abilitylist);
400
423
{
401
424
        m_device->setModel(m_modelSel->currentItem()->text(0));
402
425
 
403
 
        if (m_portSelectGroup->selected()) {
404
 
                QString type = m_portSelectGroup->selected()->text();
405
 
 
406
 
                if(type == i18n("Serial"))
407
 
                        m_device->setPath("serial:" + m_serialPortCombo->currentText());
408
 
                else if(type == i18n("USB"))
409
 
                        m_device->setPath("usb:");
410
 
        } else {
411
 
                // This camera has no port type (e.g. "Directory Browse" camera).
412
 
                // Do nothing.
413
 
        }
 
426
        if (m_serialRB->isChecked())
 
427
            m_device->setPath("serial:" + m_serialPortCombo->currentText());
 
428
        else if ( m_USBRB->isChecked() )
 
429
            m_device->setPath("usb:");
414
430
}
415
431
 
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);
453
 
 
454
 
                // turn off any selected port
455
 
                QAbstractButton *selected = m_portSelectGroup->selected();
456
 
                if(selected != NULL)
457
 
                        selected->toggle();
458
 
 
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)
471
481
{
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 );
474
487
 
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);
477
490
}
478
491
 
479
492
void KameraDeviceSelectDialog::slot_error(const QString &message)