kitchensync
configguiirmc.cpp00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <kcombobox.h>
00023 #include <kdialog.h>
00024 #include <kglobal.h>
00025 #include <kiconloader.h>
00026 #include <kinputdialog.h>
00027 #include <klineedit.h>
00028 #include <klocale.h>
00029 #include <kmessagebox.h>
00030
00031 #include <kdebug.h>
00032
00033 #include <tqapplication.h>
00034 #include <tqeventloop.h>
00035 #include <tqlabel.h>
00036 #include <tqlayout.h>
00037 #include <tqpushbutton.h>
00038 #include <tqspinbox.h>
00039 #include <tqtabwidget.h>
00040 #include <tqtooltip.h>
00041 #include <tqvbox.h>
00042
00043 #include "configguiirmc.h"
00044
00045 ConfigGuiIRMC::ConfigGuiIRMC( const QSync::Member &member, TQWidget *parent )
00046 : ConfigGui( member, parent )
00047 {
00048 initGUI();
00049
00050 mConnectionType->insertItem( i18n( "Bluetooth" ) );
00051 mConnectionType->insertItem( i18n( "InfraRed (IR)" ) );
00052 mConnectionType->insertItem( i18n( "Cable" ) );
00053
00054 connect( mConnectionType, TQT_SIGNAL( activated( int ) ),
00055 this, TQT_SLOT( connectionTypeChanged( int ) ) );
00056
00057 connectionTypeChanged( 0 );
00058 }
00059
00060 void ConfigGuiIRMC::load( const TQString &xml )
00061 {
00062 TQDomDocument doc;
00063 doc.setContent( xml );
00064 TQDomElement docElement = doc.documentElement();
00065 TQDomNode node;
00066 for ( node = docElement.firstChild(); !node.isNull(); node = node.nextSibling() ) {
00067 TQDomElement element = node.toElement();
00068 if ( element.tagName() == "connectmedium" ) {
00069 if ( element.text() == "bluetooth" ) {
00070 mConnectionType->setCurrentItem( 0 );
00071 connectionTypeChanged( 0 );
00072 } else if ( element.text() == "ir" ) {
00073 mConnectionType->setCurrentItem( 1 );
00074 connectionTypeChanged( 1 );
00075 } else if ( element.text() == "cable" ) {
00076 mConnectionType->setCurrentItem( 2 );
00077 connectionTypeChanged( 2 );
00078 }
00079 } else if (element.tagName() == "btunit" ) {
00080 mBluetoothWidget->setAddress( element.text() );
00081 } else if (element.tagName() == "btchannel" ) {
00082 mBluetoothWidget->setChannel( element.text() );
00083 } else if (element.tagName() == "donttellsync" ) {
00084 mDontTellSync->setChecked( element.text() == "true" );
00085 }
00086
00087
00088 }
00089
00090 mIRWidget->load( docElement );
00091 mCableWidget->load( docElement );
00092 }
00093
00094 TQString ConfigGuiIRMC::save() const
00095 {
00096 TQDomDocument doc;
00097 TQDomElement config = doc.createElement( "config" );
00098 doc.appendChild( config );
00099
00100 TQDomElement element = doc.createElement( "connectmedium" );
00101 if ( mConnectionType->currentItem() == 0 )
00102 element.appendChild( doc.createTextNode( "bluetooth" ) );
00103 if ( mConnectionType->currentItem() == 1 )
00104 element.appendChild( doc.createTextNode( "ir" ) );
00105 if ( mConnectionType->currentItem() == 2 )
00106 element.appendChild( doc.createTextNode( "cable" ) );
00107
00108 config.appendChild( element );
00109
00110 if ( mConnectionType->currentItem() == 0 ) {
00111 TQDomElement btunit = doc.createElement( "btunit" );
00112 if ( !mBluetoothWidget->address().isEmpty() )
00113 btunit.appendChild( doc.createTextNode( mBluetoothWidget->address() ) );
00114
00115 TQDomElement btchannel = doc.createElement( "btchannel" );
00116 if ( !mBluetoothWidget->channel().isEmpty() )
00117 btchannel.appendChild( doc.createTextNode( mBluetoothWidget->channel() ) );
00118
00119 config.appendChild( btunit );
00120 config.appendChild( btchannel );
00121 }
00122
00123 if ( mDontTellSync->isChecked() ) {
00124 TQDomElement dontellsync = doc.createElement( "donttellsync" );
00125 dontellsync.appendChild( doc.createTextNode( "true" ) );
00126 config.appendChild( dontellsync );
00127 }
00128
00129 mIRWidget->save( doc, config );
00130 mCableWidget->save( doc, config );
00131
00132 return doc.toString();
00133 }
00134
00135 void ConfigGuiIRMC::connectionTypeChanged( int type )
00136 {
00137 mBluetoothWidget->hide();
00138 mIRWidget->hide();
00139 mCableWidget->hide();
00140
00141 if ( type == 0 )
00142 mBluetoothWidget->show();
00143 else if ( type == 1 )
00144 mIRWidget->show();
00145 else
00146 mCableWidget->show();
00147 }
00148
00149 void ConfigGuiIRMC::initGUI()
00150 {
00151 TQTabWidget *tabWidget = new TQTabWidget( this );
00152 topLayout()->addWidget( tabWidget );
00153
00154 TQVBox *connectionWidget = new TQVBox( tabWidget );
00155 connectionWidget->setMargin( KDialog::marginHint() );
00156 connectionWidget->setSpacing( 5 );
00157
00158 tabWidget->addTab( connectionWidget, i18n( "Connection" ) );
00159
00160 mConnectionType = new KComboBox( connectionWidget );
00161 TQToolTip::add( mConnectionType, i18n( "Select your connection type." ) );
00162
00163 mBluetoothWidget = new BluetoothWidget( connectionWidget );
00164 mBluetoothWidget->hide();
00165
00166 mIRWidget = new IRWidget( connectionWidget );
00167 mIRWidget->hide();
00168
00169 mCableWidget = new CableWidget( connectionWidget );
00170 mCableWidget->hide();
00171
00172 connectionWidget->setStretchFactor( mBluetoothWidget, 1 );
00173 connectionWidget->setStretchFactor( mIRWidget, 1 );
00174 connectionWidget->setStretchFactor( mCableWidget, 1 );
00175
00176 TQVBox *optionsWidget = new TQVBox( tabWidget );
00177 optionsWidget->setMargin( KDialog::marginHint() );
00178 optionsWidget->setSpacing( 5 );
00179
00180 tabWidget->addTab( optionsWidget, i18n( "Options" ) );
00181
00182 TQHBox *optionBox = new TQHBox( optionsWidget );
00183 optionBox->setSpacing( KDialog::spacingHint() );
00184
00185 TQLabel *label = new TQLabel( i18n( "Don't send OBEX UUID (IRMC-SYNC)" ), optionBox );
00186 mDontTellSync = new TQCheckBox( optionBox );
00187 TQToolTip::add( mDontTellSync, i18n( "Don't send OBEX UUID while connecting. Needed for older IrMC based mobile phones." ) );
00188 label->setBuddy( mDontTellSync );
00189
00190 }
00191
00192 #include "configguiirmc.moc"
|