Diffstat (limited to 'noncore/apps/opie-console/btconfigwidget.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/apps/opie-console/btconfigwidget.cpp | 41 |
1 files changed, 36 insertions, 5 deletions
diff --git a/noncore/apps/opie-console/btconfigwidget.cpp b/noncore/apps/opie-console/btconfigwidget.cpp index 7673d0b..6246f92 100644 --- a/noncore/apps/opie-console/btconfigwidget.cpp +++ b/noncore/apps/opie-console/btconfigwidget.cpp @@ -1,12 +1,14 @@ #include <qlabel.h> #include <qlayout.h> #include <qlineedit.h> #include <qcombobox.h> +#include <qhbox.h> +#include <qradiobutton.h> #include "iolayerbase.h" #include "btconfigwidget.h" namespace { void setCurrent( const QString& str, QComboBox* bo ) { uint b = bo->count(); for (uint i = 0; i < bo->count(); i++ ) { @@ -21,30 +23,37 @@ namespace { } BTConfigWidget::BTConfigWidget( const QString& name, QWidget* parent, const char* na ) : ProfileDialogConnectionWidget( name, parent, na ) { m_lay = new QVBoxLayout(this ); + m_device = new QLabel(tr("Device"), this ); - m_deviceCmb = new QComboBox(this ); + QHBox *deviceBox = new QHBox( this ); + m_devRadio = new QRadioButton( deviceBox ); + connect( m_devRadio, SIGNAL( toggled( bool ) ), this, SLOT( slotDevRadio( bool ) ) ); + m_deviceCmb = new QComboBox( deviceBox ); m_deviceCmb->setEditable( TRUE ); QLabel *macLabel = new QLabel( this ); - macLabel->setText( tr("Enter peer mac address here:") ); - m_mac = new QLineEdit( this ); + macLabel->setText( tr( "Or peer mac address" ) ); + QHBox *macBox = new QHBox( this ); + m_macRadio = new QRadioButton( macBox ); + connect( m_macRadio, SIGNAL( toggled( bool ) ), this, SLOT( slotMacRadio( bool ) ) ); + m_mac = new QLineEdit( macBox ); m_base = new IOLayerBase(this, "base"); m_lay->addWidget( m_device ); - m_lay->addWidget( m_deviceCmb ); + m_lay->addWidget( deviceBox ); m_lay->addWidget( macLabel ); - m_lay->addWidget( m_mac ); + m_lay->addWidget( macBox ); m_lay->addWidget( m_base ); m_deviceCmb->insertItem( "/dev/ttyU0" ); m_deviceCmb->insertItem( "/dev/ttyU1" ); } BTConfigWidget::~BTConfigWidget() { @@ -52,16 +61,18 @@ BTConfigWidget::~BTConfigWidget() { void BTConfigWidget::load( const Profile& prof ) { int rad_flow = prof.readNumEntry("Flow"); int rad_parity = prof.readNumEntry("Parity"); int speed = prof.readNumEntry("Speed"); QString mac = prof.readEntry("Mac"); if (!mac.isEmpty() ) { m_mac->setText( mac ); + } else { + m_devRadio->setChecked( true ); } if (rad_flow == 1) { m_base->setFlow( IOLayerBase::Hardware ); } else if (rad_flow == 2) { m_base->setFlow( IOLayerBase::Software ); } else if (rad_flow == 0) { m_base->setFlow( IOLayerBase::None ); @@ -150,8 +161,28 @@ void BTConfigWidget::save( Profile& prof ) { break; } prof.writeEntry("Flow", flow); prof.writeEntry("Parity", parity); prof.writeEntry("Speed", speed); prof.writeEntry("Mac", m_mac->text() ); } + +void BTConfigWidget::slotMacRadio( bool on ) { + if ( on ) { + m_devRadio->setChecked( false ); + m_deviceCmb->setEnabled( false ); + m_mac->setEnabled( true ); + } else { + m_devRadio->setChecked( true ); + } +} + +void BTConfigWidget::slotDevRadio( bool on ) { + if ( on ) { + m_macRadio->setChecked( false ); + m_deviceCmb->setEnabled( true ); + m_mac->setEnabled( false ); + } else { + m_macRadio->setChecked( true ); + } +} |