24 #include <tqcheckbox.h>
26 #include <tqgroupbox.h>
29 #include <tqlineedit.h>
30 #include <tqpushbutton.h>
31 #include <tqtabwidget.h>
32 #include <tqtooltip.h>
33 #include <tqcombobox.h>
35 #include <tdeconfig.h>
38 #include <tdelistview.h>
39 #include <tdelocale.h>
40 #include <tdemessagebox.h>
43 #include "addresseewidget.h"
46 #include "kabconfigwidget.h"
48 KABConfigWidget::KABConfigWidget( TQWidget *parent,
const char *name )
49 : TQWidget( parent, name )
51 TQVBoxLayout *topLayout =
new TQVBoxLayout(
this, 0,
52 KDialog::spacingHint() );
54 TQTabWidget *tabWidget =
new TQTabWidget(
this );
55 topLayout->addWidget( tabWidget );
58 TQWidget *generalPage =
new TQWidget(
this );
59 TQVBoxLayout *layout =
new TQVBoxLayout( generalPage, KDialog::marginHint(),
60 KDialog::spacingHint() );
62 TQGroupBox *groupBox =
new TQGroupBox( 0, TQt::Vertical, i18n(
"General" ), generalPage );
63 TQBoxLayout *boxLayout =
new TQVBoxLayout( groupBox->layout() );
64 boxLayout->setAlignment( TQt::AlignTop );
66 mViewsSingleClickBox =
new TQCheckBox( i18n(
"Honor TDE single click" ), groupBox,
"msingle" );
67 boxLayout->addWidget( mViewsSingleClickBox );
69 mNameParsing =
new TQCheckBox( i18n(
"Automatic name parsing for new addressees" ), groupBox,
"mparse" );
70 boxLayout->addWidget( mNameParsing );
72 mTradeAsFamilyName =
new TQCheckBox( i18n(
"Trade single name component as family name" ), groupBox,
"mtrade" );
73 boxLayout->addWidget( mTradeAsFamilyName );
78 mTradeAsFamilyName->hide();
80 mLimitContactDisplay =
new TQCheckBox( i18n(
"Limit unfiltered display to 100 contacts" ), groupBox,
"mlimit" );
81 boxLayout->addWidget( mLimitContactDisplay );
83 TQBoxLayout *editorLayout =
new TQHBoxLayout( boxLayout, KDialog::spacingHint() );
85 TQLabel *label =
new TQLabel( i18n(
"Addressee editor type:" ), groupBox );
86 editorLayout->addWidget( label );
88 mEditorCombo =
new TQComboBox( groupBox );
89 mEditorCombo->insertItem( i18n(
"Full Editor" ) );
90 mEditorCombo->insertItem( i18n(
"Simple Editor" ) );
91 label->setBuddy( mEditorCombo );
92 editorLayout->addWidget( mEditorCombo );
94 editorLayout->addStretch( 1 );
97 layout->addWidget( groupBox );
99 groupBox =
new TQGroupBox( 0, TQt::Vertical, i18n(
"Script-Hooks" ), generalPage );
100 TQGridLayout *grid =
new TQGridLayout( groupBox->layout(), 3, 2,
101 KDialog::spacingHint() );
102 label =
new TQLabel( i18n(
"Phone:" ), groupBox );
103 grid->addWidget( label, 0, 0 );
105 mPhoneHook =
new TQLineEdit( groupBox );
106 TQToolTip::add( mPhoneHook, i18n(
"<ul><li>%N: Phone Number</li></ul>" ) );
107 grid->addWidget( mPhoneHook, 0, 1 );
109 label =
new TQLabel( i18n(
"Fax:" ), groupBox );
110 grid->addWidget( label, 1, 0 );
112 mFaxHook =
new TQLineEdit( groupBox );
113 TQToolTip::add( mFaxHook, i18n(
"<ul><li>%N: Fax Number</li></ul>" ) );
114 grid->addWidget( mFaxHook, 1, 1 );
117 label =
new TQLabel( i18n(
"SMS Text:" ), groupBox );
118 grid->addWidget( label, 2, 0 );
120 mSMSHook =
new TQLineEdit( groupBox );
121 TQToolTip::add( mSMSHook, i18n(
"<ul><li>%N: Phone Number</li><li>%F: File containing the text message(s)</li></ul>" ) );
122 grid->addWidget( mSMSHook, 2, 1 );
125 grid->setColStretch( 1, 1 );
127 layout->addWidget( groupBox );
129 groupBox =
new TQGroupBox( 0, TQt::Vertical, i18n(
"Location Map" ), generalPage );
130 boxLayout =
new TQVBoxLayout( groupBox->layout(), KDialog::spacingHint() );
131 boxLayout->setAlignment( TQt::AlignTop );
133 mLocationMapURL =
new TQComboBox(
true, groupBox );
134 mLocationMapURL->setSizePolicy( TQSizePolicy( TQSizePolicy::Preferred, TQSizePolicy::Fixed ) );
135 TQToolTip::add( mLocationMapURL, i18n(
"<ul> <li>%s: Street</li>"
136 "<li>%r: Region</li>"
137 "<li>%l: Location</li>"
138 "<li>%z: Zip Code</li>"
139 "<li>%c: Country ISO Code</li> </ul>" ) );
140 mLocationMapURL->insertStringList( KABPrefs::instance()->locationMapURLs() );
141 boxLayout->addWidget( mLocationMapURL );
142 layout->addWidget( groupBox );
144 connect( mNameParsing, TQ_SIGNAL( toggled(
bool ) ), TQ_SLOT( modified() ) );
145 connect( mViewsSingleClickBox, TQ_SIGNAL( toggled(
bool ) ), TQ_SLOT( modified() ) );
146 connect( mTradeAsFamilyName, TQ_SIGNAL( toggled(
bool ) ), TQ_SLOT( modified() ) );
147 connect( mLimitContactDisplay, TQ_SIGNAL( toggled(
bool ) ), TQ_SLOT( modified() ) );
148 connect( mPhoneHook, TQ_SIGNAL( textChanged(
const TQString& ) ), TQ_SLOT( modified() ) );
149 connect( mSMSHook, TQ_SIGNAL( textChanged(
const TQString& ) ), TQ_SLOT( modified() ) );
150 connect( mFaxHook, TQ_SIGNAL( textChanged(
const TQString& ) ), TQ_SLOT( modified() ) );
151 connect( mLocationMapURL, TQ_SIGNAL( textChanged(
const TQString& ) ), TQ_SLOT( modified() ) );
152 connect( mEditorCombo, TQ_SIGNAL( activated(
int ) ), TQ_SLOT( modified() ) );
154 tabWidget->addTab( generalPage, i18n(
"General" ) );
157 mAddresseeWidget =
new AddresseeWidget(
this );
158 tabWidget->addTab( mAddresseeWidget, i18n(
"Contact" ) );
159 connect( mAddresseeWidget, TQ_SIGNAL( modified() ), TQ_SLOT( modified() ) );
162 void KABConfigWidget::restoreSettings()
164 bool blocked = signalsBlocked();
165 blockSignals(
true );
167 mNameParsing->setChecked( KABPrefs::instance()->automaticNameParsing() );
168 mViewsSingleClickBox->setChecked( KABPrefs::instance()->honorSingleClick() );
169 mPhoneHook->setText( KABPrefs::instance()->phoneHookApplication() );
170 mSMSHook->setText( KABPrefs::instance()->sMSHookApplication() );
171 mFaxHook->setText( KABPrefs::instance()->faxHookApplication() );
172 mAddresseeWidget->restoreSettings();
173 mEditorCombo->setCurrentItem( KABPrefs::instance()->editorType() );
174 mLocationMapURL->setCurrentText( KABPrefs::instance()->locationMapURL().arg( TDEGlobal::locale()->country() ) );
175 mLocationMapURL->lineEdit()->setCursorPosition( 0 );
177 TDEConfig config(
"tdeabcrc",
false,
false );
178 config.setGroup(
"General" );
179 mTradeAsFamilyName->setChecked( config.readBoolEntry(
"TradeAsFamilyName",
true ) );
180 mLimitContactDisplay->setChecked( config.readBoolEntry(
"LimitContactDisplay",
true ) );
182 blockSignals( blocked );
184 emit changed(
false );
187 void KABConfigWidget::saveSettings()
189 KABPrefs::instance()->setAutomaticNameParsing( mNameParsing->isChecked() );
190 KABPrefs::instance()->setHonorSingleClick( mViewsSingleClickBox->isChecked() );
191 KABPrefs::instance()->setPhoneHookApplication( mPhoneHook->text() );
192 KABPrefs::instance()->setSMSHookApplication( mSMSHook->text() );
193 KABPrefs::instance()->setFaxHookApplication( mFaxHook->text() );
194 KABPrefs::instance()->setEditorType( mEditorCombo->currentItem() );
195 KABPrefs::instance()->setLocationMapURL( mLocationMapURL->currentText() );
196 mAddresseeWidget->saveSettings();
198 KABPrefs::instance()->writeConfig();
200 TDEConfig config(
"tdeabcrc",
false,
false );
201 config.setGroup(
"General" );
202 config.writeEntry(
"TradeAsFamilyName", mTradeAsFamilyName->isChecked() );
203 config.writeEntry(
"LimitContactDisplay", mLimitContactDisplay->isChecked() );
205 emit changed(
false );
208 void KABConfigWidget::defaults()
210 mNameParsing->setChecked(
true );
211 mViewsSingleClickBox->setChecked(
false );
212 mEditorCombo->setCurrentItem( 0 );
213 mLimitContactDisplay->setChecked(
true );
215 emit changed(
true );
218 void KABConfigWidget::modified()
220 emit changed(
true );
223 #include "kabconfigwidget.moc"