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 <qcheckbox.h>
00025 #include <qframe.h>
00026 #include <qgroupbox.h>
00027 #include <qlabel.h>
00028 #include <qlayout.h>
00029 #include <qlineedit.h>
00030 #include <qpushbutton.h>
00031 #include <qtabwidget.h>
00032 #include <qtooltip.h>
00033 #include <qcombobox.h>
00034
00035 #include <kconfig.h>
00036 #include <kdebug.h>
00037 #include <kdialog.h>
00038 #include <klistview.h>
00039 #include <klocale.h>
00040 #include <kmessagebox.h>
00041 #include <ktrader.h>
00042
00043 #include "addresseewidget.h"
00044 #include "kabprefs.h"
00045
00046 #include "kabconfigwidget.h"
00047
00048 KABConfigWidget::KABConfigWidget( QWidget *parent, const char *name )
00049 : QWidget( parent, name )
00050 {
00051 QVBoxLayout *topLayout = new QVBoxLayout( this, 0,
00052 KDialog::spacingHint() );
00053
00054 QTabWidget *tabWidget = new QTabWidget( this );
00055 topLayout->addWidget( tabWidget );
00056
00057
00058 QWidget *generalPage = new QWidget( this );
00059 QVBoxLayout *layout = new QVBoxLayout( generalPage, KDialog::marginHint(),
00060 KDialog::spacingHint() );
00061
00062 QGroupBox *groupBox = new QGroupBox( 0, Qt::Vertical, i18n( "General" ), generalPage );
00063 QBoxLayout *boxLayout = new QVBoxLayout( groupBox->layout() );
00064 boxLayout->setAlignment( Qt::AlignTop );
00065
00066 mViewsSingleClickBox = new QCheckBox( i18n( "Honor KDE single click" ), groupBox, "msingle" );
00067 boxLayout->addWidget( mViewsSingleClickBox );
00068
00069 mNameParsing = new QCheckBox( i18n( "Automatic name parsing for new addressees" ), groupBox, "mparse" );
00070 boxLayout->addWidget( mNameParsing );
00071
00072 mTradeAsFamilyName = new QCheckBox( i18n( "Trade single name component as family name" ), groupBox, "mtrade" );
00073 boxLayout->addWidget( mTradeAsFamilyName );
00078 mTradeAsFamilyName->hide();
00079
00080 mLimitContactDisplay = new QCheckBox( i18n( "Limit unfiltered display to 100 contacts" ), groupBox, "mlimit" );
00081 boxLayout->addWidget( mLimitContactDisplay );
00082
00083 QBoxLayout *editorLayout = new QHBoxLayout( boxLayout, KDialog::spacingHint() );
00084
00085 QLabel *label = new QLabel( i18n( "Addressee editor type:" ), groupBox );
00086 editorLayout->addWidget( label );
00087
00088 mEditorCombo = new QComboBox( 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 QGroupBox( 0, Qt::Vertical, i18n( "Script-Hooks" ), generalPage );
00100 QGridLayout *grid = new QGridLayout( groupBox->layout(), 3, 2,
00101 KDialog::spacingHint() );
00102 label = new QLabel( i18n( "Phone:" ), groupBox );
00103 grid->addWidget( label, 0, 0 );
00104
00105 mPhoneHook = new QLineEdit( groupBox );
00106 QToolTip::add( mPhoneHook, i18n( "<ul><li>%N: Phone Number</li></ul>" ) );
00107 grid->addWidget( mPhoneHook, 0, 1 );
00108
00109 label = new QLabel( i18n( "Fax:" ), groupBox );
00110 grid->addWidget( label, 1, 0 );
00111
00112 mFaxHook = new QLineEdit( groupBox );
00113 QToolTip::add( mFaxHook, i18n( "<ul><li>%N: Fax Number</li></ul>" ) );
00114 grid->addWidget( mFaxHook, 1, 1 );
00115
00116
00117 label = new QLabel( i18n( "SMS Text:" ), groupBox );
00118 grid->addWidget( label, 2, 0 );
00119
00120 mSMSHook = new QLineEdit( groupBox );
00121 QToolTip::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 QGroupBox( 0, Qt::Vertical, i18n( "Location Map" ), generalPage );
00130 boxLayout = new QVBoxLayout( groupBox->layout(), KDialog::spacingHint() );
00131 boxLayout->setAlignment( Qt::AlignTop );
00132
00133 mLocationMapURL = new QComboBox( true, groupBox );
00134 mLocationMapURL->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Fixed ) );
00135 QToolTip::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, SIGNAL( toggled( bool ) ), SLOT( modified() ) );
00145 connect( mViewsSingleClickBox, SIGNAL( toggled( bool ) ), SLOT( modified() ) );
00146 connect( mTradeAsFamilyName, SIGNAL( toggled( bool ) ), SLOT( modified() ) );
00147 connect( mLimitContactDisplay, SIGNAL( toggled( bool ) ), SLOT( modified() ) );
00148 connect( mPhoneHook, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) );
00149 connect( mSMSHook, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) );
00150 connect( mFaxHook, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) );
00151 connect( mLocationMapURL, SIGNAL( textChanged( const QString& ) ), SLOT( modified() ) );
00152 connect( mEditorCombo, SIGNAL( activated( int ) ), 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, SIGNAL( modified() ), 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( KGlobal::locale()->country() ) );
00175 mLocationMapURL->lineEdit()->setCursorPosition( 0 );
00176
00177 KConfig config( "kabcrc", 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 KConfig config( "kabcrc", 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"