00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <tqcheckbox.h>
00025 #include <tqframe.h>
00026 #include <tqgroupbox.h>
00027 #include <tqlabel.h>
00028 #include <tqlayout.h>
00029 #include <tqlineedit.h>
00030 #include <tqpushbutton.h>
00031 #include <tqtabwidget.h>
00032 #include <tqtooltip.h>
00033 #include <tqcombobox.h>
00034
00035 #include <tdeconfig.h>
00036 #include <kdebug.h>
00037 #include <kdialog.h>
00038 #include <tdelistview.h>
00039 #include <tdelocale.h>
00040 #include <tdemessagebox.h>
00041 #include <ktrader.h>
00042
00043 #include "addresseewidget.h"
00044 #include "kabprefs.h"
00045
00046 #include "kabconfigwidget.h"
00047
00048 KABConfigWidget::KABConfigWidget( TQWidget *parent, const char *name )
00049 : TQWidget( parent, name )
00050 {
00051 TQVBoxLayout *topLayout = new TQVBoxLayout( this, 0,
00052 KDialog::spacingHint() );
00053
00054 TQTabWidget *tabWidget = new TQTabWidget( this );
00055 topLayout->addWidget( tabWidget );
00056
00057
00058 TQWidget *generalPage = new TQWidget( this );
00059 TQVBoxLayout *layout = new TQVBoxLayout( generalPage, KDialog::marginHint(),
00060 KDialog::spacingHint() );
00061
00062 TQGroupBox *groupBox = new TQGroupBox( 0, Qt::Vertical, i18n( "General" ), generalPage );
00063 TQBoxLayout *boxLayout = new TQVBoxLayout( groupBox->layout() );
00064 boxLayout->setAlignment( TQt::AlignTop );
00065
00066 mViewsSingleClickBox = new TQCheckBox( i18n( "Honor TDE single click" ), groupBox, "msingle" );
00067 boxLayout->addWidget( mViewsSingleClickBox );
00068
00069 mNameParsing = new TQCheckBox( i18n( "Automatic name parsing for new addressees" ), groupBox, "mparse" );
00070 boxLayout->addWidget( mNameParsing );
00071
00072 mTradeAsFamilyName = new TQCheckBox( i18n( "Trade single name component as family name" ), groupBox, "mtrade" );
00073 boxLayout->addWidget( mTradeAsFamilyName );
00078 mTradeAsFamilyName->hide();
00079
00080 mLimitContactDisplay = new TQCheckBox( i18n( "Limit unfiltered display to 100 contacts" ), groupBox, "mlimit" );
00081 boxLayout->addWidget( mLimitContactDisplay );
00082
00083 TQBoxLayout *editorLayout = new TQHBoxLayout( boxLayout, KDialog::spacingHint() );
00084
00085 TQLabel *label = new TQLabel( i18n( "Addressee editor type:" ), groupBox );
00086 editorLayout->addWidget( label );
00087
00088 mEditorCombo = new TQComboBox( groupBox );
00089 mEditorCombo->insertItem( i18n( "Full Editor" ) );
00090 mEditorCombo->insertItem( i18n( "Simple Editor" ) );
00091 label->setBuddy( mEditorCombo );
00092 editorLayout->addWidget( mEditorCombo );
00093
00094 editorLayout->addStretch( 1 );
00095
00096
00097 layout->addWidget( groupBox );
00098
00099 groupBox = new TQGroupBox( 0, Qt::Vertical, i18n( "Script-Hooks" ), generalPage );
00100 TQGridLayout *grid = new TQGridLayout( groupBox->layout(), 3, 2,
00101 KDialog::spacingHint() );
00102 label = new TQLabel( i18n( "Phone:" ), groupBox );
00103 grid->addWidget( label, 0, 0 );
00104
00105 mPhoneHook = new TQLineEdit( groupBox );
00106 TQToolTip::add( mPhoneHook, i18n( "<ul><li>%N: Phone Number</li></ul>" ) );
00107 grid->addWidget( mPhoneHook, 0, 1 );
00108
00109 label = new TQLabel( i18n( "Fax:" ), groupBox );
00110 grid->addWidget( label, 1, 0 );
00111
00112 mFaxHook = new TQLineEdit( groupBox );
00113 TQToolTip::add( mFaxHook, i18n( "<ul><li>%N: Fax Number</li></ul>" ) );
00114 grid->addWidget( mFaxHook, 1, 1 );
00115
00116
00117 label = new TQLabel( i18n( "SMS Text:" ), groupBox );
00118 grid->addWidget( label, 2, 0 );
00119
00120 mSMSHook = new TQLineEdit( groupBox );
00121 TQToolTip::add( mSMSHook, i18n( "<ul><li>%N: Phone Number</li><li>%F: File containing the text message(s)</li></ul>" ) );
00122 grid->addWidget( mSMSHook, 2, 1 );
00123
00124
00125 grid->setColStretch( 1, 1 );
00126
00127 layout->addWidget( groupBox );
00128
00129 groupBox = new TQGroupBox( 0, Qt::Vertical, i18n( "Location Map" ), generalPage );
00130 boxLayout = new TQVBoxLayout( groupBox->layout(), KDialog::spacingHint() );
00131 boxLayout->setAlignment( TQt::AlignTop );
00132
00133 mLocationMapURL = new TQComboBox( true, groupBox );
00134 mLocationMapURL->setSizePolicy( TQSizePolicy( TQSizePolicy::Preferred, TQSizePolicy::Fixed ) );
00135 TQToolTip::add( mLocationMapURL, i18n( "<ul> <li>%s: Street</li>"
00136 "<li>%r: Region</li>"
00137 "<li>%l: Location</li>"
00138 "<li>%z: Zip Code</li>"
00139 "<li>%c: Country ISO Code</li> </ul>" ) );
00140 mLocationMapURL->insertStringList( KABPrefs::instance()->locationMapURLs() );
00141 boxLayout->addWidget( mLocationMapURL );
00142 layout->addWidget( groupBox );
00143
00144 connect( mNameParsing, TQT_SIGNAL( toggled( bool ) ), TQT_SLOT( modified() ) );
00145 connect( mViewsSingleClickBox, TQT_SIGNAL( toggled( bool ) ), TQT_SLOT( modified() ) );
00146 connect( mTradeAsFamilyName, TQT_SIGNAL( toggled( bool ) ), TQT_SLOT( modified() ) );
00147 connect( mLimitContactDisplay, TQT_SIGNAL( toggled( bool ) ), TQT_SLOT( modified() ) );
00148 connect( mPhoneHook, TQT_SIGNAL( textChanged( const TQString& ) ), TQT_SLOT( modified() ) );
00149 connect( mSMSHook, TQT_SIGNAL( textChanged( const TQString& ) ), TQT_SLOT( modified() ) );
00150 connect( mFaxHook, TQT_SIGNAL( textChanged( const TQString& ) ), TQT_SLOT( modified() ) );
00151 connect( mLocationMapURL, TQT_SIGNAL( textChanged( const TQString& ) ), TQT_SLOT( modified() ) );
00152 connect( mEditorCombo, TQT_SIGNAL( activated( int ) ), TQT_SLOT( modified() ) );
00153
00154 tabWidget->addTab( generalPage, i18n( "General" ) );
00155
00156
00157 mAddresseeWidget = new AddresseeWidget( this );
00158 tabWidget->addTab( mAddresseeWidget, i18n( "Contact" ) );
00159 connect( mAddresseeWidget, TQT_SIGNAL( modified() ), TQT_SLOT( modified() ) );
00160 }
00161
00162 void KABConfigWidget::restoreSettings()
00163 {
00164 bool blocked = signalsBlocked();
00165 blockSignals( true );
00166
00167 mNameParsing->setChecked( KABPrefs::instance()->automaticNameParsing() );
00168 mViewsSingleClickBox->setChecked( KABPrefs::instance()->honorSingleClick() );
00169 mPhoneHook->setText( KABPrefs::instance()->phoneHookApplication() );
00170 mSMSHook->setText( KABPrefs::instance()->sMSHookApplication() );
00171 mFaxHook->setText( KABPrefs::instance()->faxHookApplication() );
00172 mAddresseeWidget->restoreSettings();
00173 mEditorCombo->setCurrentItem( KABPrefs::instance()->editorType() );
00174 mLocationMapURL->setCurrentText( KABPrefs::instance()->locationMapURL().arg( TDEGlobal::locale()->country() ) );
00175 mLocationMapURL->lineEdit()->setCursorPosition( 0 );
00176
00177 TDEConfig config( "tdeabcrc", false, false );
00178 config.setGroup( "General" );
00179 mTradeAsFamilyName->setChecked( config.readBoolEntry( "TradeAsFamilyName", true ) );
00180 mLimitContactDisplay->setChecked( config.readBoolEntry( "LimitContactDisplay", true ) );
00181
00182 blockSignals( blocked );
00183
00184 emit changed( false );
00185 }
00186
00187 void KABConfigWidget::saveSettings()
00188 {
00189 KABPrefs::instance()->setAutomaticNameParsing( mNameParsing->isChecked() );
00190 KABPrefs::instance()->setHonorSingleClick( mViewsSingleClickBox->isChecked() );
00191 KABPrefs::instance()->setPhoneHookApplication( mPhoneHook->text() );
00192 KABPrefs::instance()->setSMSHookApplication( mSMSHook->text() );
00193 KABPrefs::instance()->setFaxHookApplication( mFaxHook->text() );
00194 KABPrefs::instance()->setEditorType( mEditorCombo->currentItem() );
00195 KABPrefs::instance()->setLocationMapURL( mLocationMapURL->currentText() );
00196 mAddresseeWidget->saveSettings();
00197
00198 KABPrefs::instance()->writeConfig();
00199
00200 TDEConfig config( "tdeabcrc", false, false );
00201 config.setGroup( "General" );
00202 config.writeEntry( "TradeAsFamilyName", mTradeAsFamilyName->isChecked() );
00203 config.writeEntry( "LimitContactDisplay", mLimitContactDisplay->isChecked() );
00204
00205 emit changed( false );
00206 }
00207
00208 void KABConfigWidget::defaults()
00209 {
00210 mNameParsing->setChecked( true );
00211 mViewsSingleClickBox->setChecked( false );
00212 mEditorCombo->setCurrentItem( 0 );
00213 mLimitContactDisplay->setChecked( true );
00214
00215 emit changed( true );
00216 }
00217
00218 void KABConfigWidget::modified()
00219 {
00220 emit changed( true );
00221 }
00222
00223 #include "kabconfigwidget.moc"