22 #include <kcombobox.h>
24 #include <tdeglobal.h>
25 #include <kiconloader.h>
26 #include <kinputdialog.h>
27 #include <klineedit.h>
28 #include <tdelocale.h>
29 #include <tdemessagebox.h>
33 #include <tqapplication.h>
34 #include <tqeventloop.h>
37 #include <tqpushbutton.h>
38 #include <tqspinbox.h>
39 #include <tqtabwidget.h>
40 #include <tqtooltip.h>
43 #include "configguiirmc.h"
45 ConfigGuiIRMC::ConfigGuiIRMC(
const QSync::Member &member, TQWidget *parent )
46 : ConfigGui( member, parent )
50 mConnectionType->insertItem( i18n(
"Bluetooth" ) );
51 mConnectionType->insertItem( i18n(
"InfraRed (IR)" ) );
52 mConnectionType->insertItem( i18n(
"Cable" ) );
54 connect( mConnectionType, TQT_SIGNAL( activated(
int ) ),
55 this, TQT_SLOT( connectionTypeChanged(
int ) ) );
57 connectionTypeChanged( 0 );
60 void ConfigGuiIRMC::load(
const TQString &xml )
63 doc.setContent( xml );
64 TQDomElement docElement = doc.documentElement();
66 for ( node = docElement.firstChild(); !node.isNull(); node = node.nextSibling() ) {
67 TQDomElement element = node.toElement();
68 if ( element.tagName() ==
"connectmedium" ) {
69 if ( element.text() ==
"bluetooth" ) {
70 mConnectionType->setCurrentItem( 0 );
71 connectionTypeChanged( 0 );
72 }
else if ( element.text() ==
"ir" ) {
73 mConnectionType->setCurrentItem( 1 );
74 connectionTypeChanged( 1 );
75 }
else if ( element.text() ==
"cable" ) {
76 mConnectionType->setCurrentItem( 2 );
77 connectionTypeChanged( 2 );
79 }
else if (element.tagName() ==
"btunit" ) {
80 mBluetoothWidget->setAddress( element.text() );
81 }
else if (element.tagName() ==
"btchannel" ) {
82 mBluetoothWidget->setChannel( element.text() );
83 }
else if (element.tagName() ==
"donttellsync" ) {
84 mDontTellSync->setChecked( element.text() ==
"true" );
90 mIRWidget->load( docElement );
91 mCableWidget->load( docElement );
94 TQString ConfigGuiIRMC::save()
const
97 TQDomElement config = doc.createElement(
"config" );
98 doc.appendChild( config );
100 TQDomElement element = doc.createElement(
"connectmedium" );
101 if ( mConnectionType->currentItem() == 0 )
102 element.appendChild( doc.createTextNode(
"bluetooth" ) );
103 if ( mConnectionType->currentItem() == 1 )
104 element.appendChild( doc.createTextNode(
"ir" ) );
105 if ( mConnectionType->currentItem() == 2 )
106 element.appendChild( doc.createTextNode(
"cable" ) );
108 config.appendChild( element );
110 if ( mConnectionType->currentItem() == 0 ) {
111 TQDomElement btunit = doc.createElement(
"btunit" );
112 if ( !mBluetoothWidget->address().isEmpty() )
113 btunit.appendChild( doc.createTextNode( mBluetoothWidget->address() ) );
115 TQDomElement btchannel = doc.createElement(
"btchannel" );
116 if ( !mBluetoothWidget->channel().isEmpty() )
117 btchannel.appendChild( doc.createTextNode( mBluetoothWidget->channel() ) );
119 config.appendChild( btunit );
120 config.appendChild( btchannel );
123 if ( mDontTellSync->isChecked() ) {
124 TQDomElement dontellsync = doc.createElement(
"donttellsync" );
125 dontellsync.appendChild( doc.createTextNode(
"true" ) );
126 config.appendChild( dontellsync );
129 mIRWidget->save( doc, config );
130 mCableWidget->save( doc, config );
132 return doc.toString();
135 void ConfigGuiIRMC::connectionTypeChanged(
int type )
137 mBluetoothWidget->hide();
139 mCableWidget->hide();
142 mBluetoothWidget->show();
143 else if ( type == 1 )
146 mCableWidget->show();
149 void ConfigGuiIRMC::initGUI()
151 TQTabWidget *tabWidget =
new TQTabWidget(
this );
152 topLayout()->addWidget( tabWidget );
154 TQVBox *connectionWidget =
new TQVBox( tabWidget );
155 connectionWidget->setMargin( KDialog::marginHint() );
156 connectionWidget->setSpacing( 5 );
158 tabWidget->addTab( connectionWidget, i18n(
"Connection" ) );
160 mConnectionType =
new KComboBox( connectionWidget );
161 TQToolTip::add( mConnectionType, i18n(
"Select your connection type." ) );
163 mBluetoothWidget =
new BluetoothWidget( connectionWidget );
164 mBluetoothWidget->hide();
166 mIRWidget =
new IRWidget( connectionWidget );
169 mCableWidget =
new CableWidget( connectionWidget );
170 mCableWidget->hide();
172 connectionWidget->setStretchFactor( mBluetoothWidget, 1 );
173 connectionWidget->setStretchFactor( mIRWidget, 1 );
174 connectionWidget->setStretchFactor( mCableWidget, 1 );
176 TQVBox *optionsWidget =
new TQVBox( tabWidget );
177 optionsWidget->setMargin( KDialog::marginHint() );
178 optionsWidget->setSpacing( 5 );
180 tabWidget->addTab( optionsWidget, i18n(
"Options" ) );
182 TQHBox *optionBox =
new TQHBox( optionsWidget );
183 optionBox->setSpacing( KDialog::spacingHint() );
185 TQLabel *label =
new TQLabel( i18n(
"Don't send OBEX UUID (IRMC-SYNC)" ), optionBox );
186 mDontTellSync =
new TQCheckBox( optionBox );
187 TQToolTip::add( mDontTellSync, i18n(
"Don't send OBEX UUID while connecting. Needed for older IrMC based mobile phones." ) );
188 label->setBuddy( mDontTellSync );
192 #include "configguiirmc.moc"