summaryrefslogtreecommitdiff
path: root/noncore/apps/opie-console/btconfigwidget.cpp
Unidiff
Diffstat (limited to 'noncore/apps/opie-console/btconfigwidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/opie-console/btconfigwidget.cpp45
1 files changed, 38 insertions, 7 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,10 +1,12 @@
1#include <qlabel.h> 1#include <qlabel.h>
2#include <qlayout.h> 2#include <qlayout.h>
3#include <qlineedit.h> 3#include <qlineedit.h>
4#include <qcombobox.h> 4#include <qcombobox.h>
5#include <qhbox.h>
6#include <qradiobutton.h>
5 7
6#include "iolayerbase.h" 8#include "iolayerbase.h"
7#include "btconfigwidget.h" 9#include "btconfigwidget.h"
8 10
9namespace { 11namespace {
10 void setCurrent( const QString& str, QComboBox* bo ) { 12 void setCurrent( const QString& str, QComboBox* bo ) {
@@ -22,27 +24,34 @@ namespace {
22 24
23BTConfigWidget::BTConfigWidget( const QString& name, 25BTConfigWidget::BTConfigWidget( const QString& name,
24 QWidget* parent, 26 QWidget* parent,
25 const char* na ) 27 const char* na )
26 : ProfileDialogConnectionWidget( name, parent, na ) { 28 : ProfileDialogConnectionWidget( name, parent, na ) {
27 29
28 m_lay = new QVBoxLayout(this ); 30 m_lay = new QVBoxLayout( this );
29 m_device = new QLabel(tr("Device"), this ); 31
30 m_deviceCmb = new QComboBox(this ); 32 m_device = new QLabel( tr( "Device" ), this );
33 QHBox *deviceBox = new QHBox( this );
34 m_devRadio = new QRadioButton( deviceBox );
35 connect( m_devRadio, SIGNAL( toggled( bool ) ), this, SLOT( slotDevRadio( bool ) ) );
36 m_deviceCmb = new QComboBox( deviceBox );
31 m_deviceCmb->setEditable( TRUE ); 37 m_deviceCmb->setEditable( TRUE );
32 38
33 QLabel *macLabel = new QLabel( this ); 39 QLabel *macLabel = new QLabel( this );
34 macLabel->setText( tr("Enter peer mac address here:") ); 40 macLabel->setText( tr( "Or peer mac address" ) );
35 m_mac = new QLineEdit( this ); 41 QHBox *macBox = new QHBox( this );
42 m_macRadio = new QRadioButton( macBox );
43 connect( m_macRadio, SIGNAL( toggled( bool ) ), this, SLOT( slotMacRadio( bool ) ) );
44 m_mac = new QLineEdit( macBox );
36 45
37 m_base = new IOLayerBase(this, "base"); 46 m_base = new IOLayerBase(this, "base");
38 47
39 m_lay->addWidget( m_device ); 48 m_lay->addWidget( m_device );
40 m_lay->addWidget( m_deviceCmb ); 49 m_lay->addWidget( deviceBox );
41 m_lay->addWidget( macLabel ); 50 m_lay->addWidget( macLabel );
42 m_lay->addWidget( m_mac ); 51 m_lay->addWidget( macBox );
43 m_lay->addWidget( m_base ); 52 m_lay->addWidget( m_base );
44 53
45 m_deviceCmb->insertItem( "/dev/ttyU0" ); 54 m_deviceCmb->insertItem( "/dev/ttyU0" );
46 m_deviceCmb->insertItem( "/dev/ttyU1" ); 55 m_deviceCmb->insertItem( "/dev/ttyU1" );
47} 56}
48 57
@@ -54,12 +63,14 @@ void BTConfigWidget::load( const Profile& prof ) {
54 int rad_parity = prof.readNumEntry("Parity"); 63 int rad_parity = prof.readNumEntry("Parity");
55 int speed = prof.readNumEntry("Speed"); 64 int speed = prof.readNumEntry("Speed");
56 QString mac = prof.readEntry("Mac"); 65 QString mac = prof.readEntry("Mac");
57 66
58 if (!mac.isEmpty() ) { 67 if (!mac.isEmpty() ) {
59 m_mac->setText( mac ); 68 m_mac->setText( mac );
69 } else {
70 m_devRadio->setChecked( true );
60 } 71 }
61 72
62 if (rad_flow == 1) { 73 if (rad_flow == 1) {
63 m_base->setFlow( IOLayerBase::Hardware ); 74 m_base->setFlow( IOLayerBase::Hardware );
64 } else if (rad_flow == 2) { 75 } else if (rad_flow == 2) {
65 m_base->setFlow( IOLayerBase::Software ); 76 m_base->setFlow( IOLayerBase::Software );
@@ -152,6 +163,26 @@ void BTConfigWidget::save( Profile& prof ) {
152 163
153 prof.writeEntry("Flow", flow); 164 prof.writeEntry("Flow", flow);
154 prof.writeEntry("Parity", parity); 165 prof.writeEntry("Parity", parity);
155 prof.writeEntry("Speed", speed); 166 prof.writeEntry("Speed", speed);
156 prof.writeEntry("Mac", m_mac->text() ); 167 prof.writeEntry("Mac", m_mac->text() );
157} 168}
169
170void BTConfigWidget::slotMacRadio( bool on ) {
171 if ( on ) {
172 m_devRadio->setChecked( false );
173 m_deviceCmb->setEnabled( false );
174 m_mac->setEnabled( true );
175 } else {
176 m_devRadio->setChecked( true );
177 }
178}
179
180void BTConfigWidget::slotDevRadio( bool on ) {
181 if ( on ) {
182 m_macRadio->setChecked( false );
183 m_deviceCmb->setEnabled( true );
184 m_mac->setEnabled( false );
185 } else {
186 m_macRadio->setChecked( true );
187 }
188}