summaryrefslogtreecommitdiffabout
path: root/libkdepim/kcmconfigs
Unidiff
Diffstat (limited to 'libkdepim/kcmconfigs') (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/kcmconfigs/kcmkdepimconfig.cpp17
-rw-r--r--libkdepim/kcmconfigs/kcmkdepimconfig.h2
-rw-r--r--libkdepim/kcmconfigs/kdepimconfigwidget.cpp313
-rw-r--r--libkdepim/kcmconfigs/kdepimconfigwidget.h45
4 files changed, 277 insertions, 100 deletions
diff --git a/libkdepim/kcmconfigs/kcmkdepimconfig.cpp b/libkdepim/kcmconfigs/kcmkdepimconfig.cpp
index f26efe0..e77c5ab 100644
--- a/libkdepim/kcmconfigs/kcmkdepimconfig.cpp
+++ b/libkdepim/kcmconfigs/kcmkdepimconfig.cpp
@@ -35,45 +35,46 @@ $Id$
35//#include <klocale.h> 35//#include <klocale.h>
36//#include <stdlib.h> 36//#include <stdlib.h>
37 37
38#include "kdepimconfigwidget.h" 38#include "kdepimconfigwidget.h"
39 39
40#include "kcmkdepimconfig.h" 40#include "kcmkdepimconfig.h"
41#include "kprefs.h" 41#include "kprefs.h"
42#include "kpimglobalprefs.h" 42#include "kpimglobalprefs.h"
43 43
44#ifndef _WIN32_ 44#ifndef _WIN32_
45extern "C" 45extern "C"
46{ 46{
47 KCModule *create_kabconfig( KPimGlobalPrefs* prefs, QWidget *parent, const char * ) { 47 KCModule *create_kabconfig(QWidget *parent, const char * ) {
48 return new KCMKdePimConfig( prefs, parent, "kcmkdepimconfig" ); 48 return new KCMKdePimConfig(parent, "kcmkdepimconfig" );
49 } 49 }
50} 50}
51#endif 51#endif
52 52
53KCMKdePimConfig::KCMKdePimConfig( KPimGlobalPrefs* prefs, QWidget *parent, const char *name ) 53KCMKdePimConfig::KCMKdePimConfig(QWidget *parent, const char *name )
54 : KCModule( prefs, parent, name ) 54 : KCModule( KPimGlobalPrefs::instance(), parent, name )
55{ 55{
56 //abort(); 56 //abort();
57 QVBoxLayout *layout = new QVBoxLayout( this ); 57 QVBoxLayout *layout = new QVBoxLayout( this );
58 mConfigWidget = new KDEPIMConfigWidget( this, "mConfigWidget" ); 58 mConfigWidget = new KDEPIMConfigWidget( (KPimGlobalPrefs*)getPreferences(), this, "KDEPIMConfigWidget" );
59 layout->addWidget( mConfigWidget ); 59 layout->addWidget( mConfigWidget );
60 layout->setSpacing( 0 ); 60 layout->setSpacing( 0 );
61 layout->setMargin( 0 ); 61 layout->setMargin( 0 );
62 62
63 connect( mConfigWidget, SIGNAL( changed( bool ) ), SIGNAL( changed( bool ) ) ); 63 connect( mConfigWidget, SIGNAL( changed( bool ) ), SIGNAL( changed( bool ) ) );
64} 64}
65 65
66void KCMKdePimConfig::load() 66void KCMKdePimConfig::load()
67{ 67{
68 mConfigWidget->restoreSettings((KPimGlobalPrefs*)getPreferences()); 68 mConfigWidget->readConfig();
69} 69}
70 70
71void KCMKdePimConfig::save() 71void KCMKdePimConfig::save()
72{ 72{
73 mConfigWidget->saveSettings((KPimGlobalPrefs*)getPreferences()); 73 mConfigWidget->writeConfig();
74} 74}
75 75
76void KCMKdePimConfig::defaults() 76void KCMKdePimConfig::defaults()
77{ 77{
78 mConfigWidget->defaults((KPimGlobalPrefs*)getPreferences()); 78 qDebug("KCMKdePimConfig::defaults()");
79 mConfigWidget->setDefaults();
79} 80}
diff --git a/libkdepim/kcmconfigs/kcmkdepimconfig.h b/libkdepim/kcmconfigs/kcmkdepimconfig.h
index fa96eda..b471e53 100644
--- a/libkdepim/kcmconfigs/kcmkdepimconfig.h
+++ b/libkdepim/kcmconfigs/kcmkdepimconfig.h
@@ -32,23 +32,23 @@ $Id$
32#define KCMKDEPIMCONFIG_H 32#define KCMKDEPIMCONFIG_H
33 33
34#include <kcmodule.h> 34#include <kcmodule.h>
35 35
36class KDEPIMConfigWidget; 36class KDEPIMConfigWidget;
37class KPimGlobalPrefs; 37class KPimGlobalPrefs;
38 38
39class KCMKdePimConfig : public KCModule 39class KCMKdePimConfig : public KCModule
40{ 40{
41 Q_OBJECT 41 Q_OBJECT
42 42
43 public: 43 public:
44 KCMKdePimConfig( KPimGlobalPrefs* prefs, QWidget *parent = 0, const char *name = 0 ); 44 KCMKdePimConfig( QWidget *parent = 0, const char *name = 0 );
45 45
46 virtual void load(); 46 virtual void load();
47 virtual void save(); 47 virtual void save();
48 virtual void defaults(); 48 virtual void defaults();
49 49
50 private: 50 private:
51 KDEPIMConfigWidget *mConfigWidget; 51 KDEPIMConfigWidget *mConfigWidget;
52}; 52};
53 53
54#endif 54#endif
diff --git a/libkdepim/kcmconfigs/kdepimconfigwidget.cpp b/libkdepim/kcmconfigs/kdepimconfigwidget.cpp
index 703aeb1..00a07d9 100644
--- a/libkdepim/kcmconfigs/kdepimconfigwidget.cpp
+++ b/libkdepim/kcmconfigs/kdepimconfigwidget.cpp
@@ -25,29 +25,31 @@
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30 30
31#include <qlayout.h> 31#include <qlayout.h>
32#include <qtabwidget.h> 32#include <qtabwidget.h>
33#include <qcombobox.h> 33#include <qcombobox.h>
34#include <qgroupbox.h> 34#include <qgroupbox.h>
35#include <qlabel.h> 35#include <qlabel.h>
36#include <qlineedit.h> 36#include <qlineedit.h>
37#include <qbuttongroup.h>
37#include <qfile.h> 38#include <qfile.h>
38 39
39#include <kdialog.h> 40#include <kdialog.h>
40#include <klocale.h> 41#include <klocale.h>
41 42#include <kdateedit.h>
43#include <kglobal.h>
42#include <stdlib.h> 44#include <stdlib.h>
43 45
44/*US 46/*US
45#include <qcheckbox.h> 47#include <qcheckbox.h>
46#include <qframe.h> 48#include <qframe.h>
47#include <qpushbutton.h> 49#include <qpushbutton.h>
48#include <qcombobox.h> 50#include <qcombobox.h>
49#include <qlineedit.h> 51#include <qlineedit.h>
50#include <qlabel.h> 52#include <qlabel.h>
51#include <qfile.h> 53#include <qfile.h>
52 54
53#include <kconfig.h> 55#include <kconfig.h>
@@ -62,67 +64,74 @@ $Id$
62#ifndef KAB_EMBEDDED 64#ifndef KAB_EMBEDDED
63#include <ktrader.h> 65#include <ktrader.h>
64#else // KAB_EMBEDDED 66#else // KAB_EMBEDDED
65#include <mergewidget.h> 67#include <mergewidget.h>
66#include <distributionlistwidget.h> 68#include <distributionlistwidget.h>
67#endif // KAB_EMBEDDED 69#endif // KAB_EMBEDDED
68 70
69#include "addresseewidget.h" 71#include "addresseewidget.h"
70#include "extensionconfigdialog.h" 72#include "extensionconfigdialog.h"
71#include "extensionwidget.h" 73#include "extensionwidget.h"
72*/ 74*/
73 75
76#include "qapplication.h"
77
74#include "kpimglobalprefs.h" 78#include "kpimglobalprefs.h"
75 79
76#include "kdepimconfigwidget.h" 80#include "kdepimconfigwidget.h"
77 81
78 82
79KDEPIMConfigWidget::KDEPIMConfigWidget( QWidget *parent, const char *name ) 83KDEPIMConfigWidget::KDEPIMConfigWidget(KPimGlobalPrefs *prefs, QWidget *parent, const char *name )
80 : QWidget( parent, name ) 84 : KPrefsWidget(prefs, parent, name )
81{ 85{
82 mExternalAppsMap.insert(ExternalAppHandler::EMAIL, i18n("Email")); 86 mExternalAppsMap.insert(ExternalAppHandler::EMAIL, i18n("Email"));
83 mExternalAppsMap.insert(ExternalAppHandler::PHONE, i18n("Phone")); 87 mExternalAppsMap.insert(ExternalAppHandler::PHONE, i18n("Phone"));
84 mExternalAppsMap.insert(ExternalAppHandler::SMS, i18n("SMS")); 88 mExternalAppsMap.insert(ExternalAppHandler::SMS, i18n("SMS"));
85 mExternalAppsMap.insert(ExternalAppHandler::FAX, i18n("Fax")); 89 mExternalAppsMap.insert(ExternalAppHandler::FAX, i18n("Fax"));
86 mExternalAppsMap.insert(ExternalAppHandler::PAGER, i18n("Pager")); 90 mExternalAppsMap.insert(ExternalAppHandler::PAGER, i18n("Pager"));
87 mExternalAppsMap.insert(ExternalAppHandler::SIP, i18n("SIP")); 91 mExternalAppsMap.insert(ExternalAppHandler::SIP, i18n("SIP"));
88 92
89 93
90 QVBoxLayout *topLayout = new QVBoxLayout( this, 0, 94 QVBoxLayout *topLayout = new QVBoxLayout( this, 0,
91 KDialog::spacingHint() ); 95 KDialog::spacingHint() );
92 96
93 QTabWidget *tabWidget = new QTabWidget( this ); 97 tabWidget = new QTabWidget( this );
94 topLayout->addWidget( tabWidget ); 98 topLayout->addWidget( tabWidget );
95 99
96 100
101 setupLocaleTab();
102 setupLocaleDateTab();
103 setupTimeZoneTab();
104 setupExternalAppTab();
105
106}
97 107
98 // mailclient page 108void KDEPIMConfigWidget::setupExternalAppTab()
109{
99 QWidget *externalAppsPage = new QWidget( this ); 110 QWidget *externalAppsPage = new QWidget( this );
100 QVBoxLayout* layout = new QVBoxLayout( externalAppsPage, KDialog::marginHintSmall(), 111 QVBoxLayout* layout = new QVBoxLayout( externalAppsPage, KDialog::marginHintSmall(),
101 KDialog::spacingHintSmall() ); 112 KDialog::spacingHintSmall() );
102 113
103 mExternalApps = new QComboBox( externalAppsPage ); 114 mExternalApps = new QComboBox( externalAppsPage );
104 115
105 QMap<ExternalAppHandler::Types, QString>::Iterator it; 116 QMap<ExternalAppHandler::Types, QString>::Iterator it;
106 for( it = mExternalAppsMap.begin(); it != mExternalAppsMap.end(); ++it ) 117 for( it = mExternalAppsMap.begin(); it != mExternalAppsMap.end(); ++it )
107 mExternalApps->insertItem( it.data(), it.key() ); 118 mExternalApps->insertItem( it.data(), it.key() );
108 119
109 layout->addWidget( mExternalApps ); 120 layout->addWidget( mExternalApps );
110 121
111 connect( mExternalApps, SIGNAL( activated( int ) ), 122 connect( mExternalApps, SIGNAL( activated( int ) ),
112 this, SLOT (externalapp_changed( int ) ) ); 123 this, SLOT (externalapp_changed( int ) ) );
113 124
114 125
115
116
117 mExternalAppGroupBox = new QGroupBox( 0, Qt::Vertical, i18n( "Used Mail Client" ), externalAppsPage ); 126 mExternalAppGroupBox = new QGroupBox( 0, Qt::Vertical, i18n( "Used Mail Client" ), externalAppsPage );
118 QGridLayout *boxLayout = new QGridLayout( mExternalAppGroupBox->layout(), 4, 2, -1, "gridlayout" ); 127 QGridLayout *boxLayout = new QGridLayout( mExternalAppGroupBox->layout(), 4, 2, -1, "gridlayout" );
119 128
120 129
121 mClient = new QComboBox( mExternalAppGroupBox ); 130 mClient = new QComboBox( mExternalAppGroupBox );
122 boxLayout->addMultiCellWidget( mClient, 0, 0, 0, 1 ); 131 boxLayout->addMultiCellWidget( mClient, 0, 0, 0, 1 );
123 132
124 connect( mClient, SIGNAL( activated( int ) ), 133 connect( mClient, SIGNAL( activated( int ) ),
125 this, SLOT (client_changed( int ) ) ); 134 this, SLOT (client_changed( int ) ) );
126 135
127 QLabel* lab = new QLabel( i18n("Channel:"), mExternalAppGroupBox); 136 QLabel* lab = new QLabel( i18n("Channel:"), mExternalAppGroupBox);
128 boxLayout->addWidget( lab, 1, 0 ); 137 boxLayout->addWidget( lab, 1, 0 );
@@ -159,30 +168,200 @@ KDEPIMConfigWidget::KDEPIMConfigWidget( QWidget *parent, const char *name )
159 168
160 lab = new QLabel( i18n("HINT: Emails=%1,Attachments=%2"), mExternalAppGroupBox); 169 lab = new QLabel( i18n("HINT: Emails=%1,Attachments=%2"), mExternalAppGroupBox);
161 boxLayout->addMultiCellWidget( lab, 8, 8, 0, 1 ); 170 boxLayout->addMultiCellWidget( lab, 8, 8, 0, 1 );
162 171
163 172
164 connect( mChannel, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) ); 173 connect( mChannel, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) );
165 connect( mMessage, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) ); 174 connect( mMessage, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) );
166 connect( mParameters, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) ); 175 connect( mParameters, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) );
167 connect( mMessage2, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) ); 176 connect( mMessage2, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) );
168 connect( mParameters2, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) ); 177 connect( mParameters2, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) );
169 178
170 179
171
172 layout->addWidget( mExternalAppGroupBox ); 180 layout->addWidget( mExternalAppGroupBox );
173 tabWidget->addTab( externalAppsPage, i18n( "External Apps." ) ); 181 tabWidget->addTab( externalAppsPage, i18n( "External Apps." ) );
174 182
175} 183}
176 184
185
186void KDEPIMConfigWidget::setupLocaleDateTab()
187{
188 QWidget *topFrame = new QWidget( this );
189 QGridLayout *topLayout = new QGridLayout( topFrame, 3, 2);
190
191 topLayout->setSpacing(KDialog::spacingHint());
192 topLayout->setMargin(KDialog::marginHint());
193 int iii = 0;
194
195
196 KPrefsWidRadios *syncPrefsGroup =
197 addWidRadios(i18n("Date Format:"),&(KPimGlobalPrefs::instance()->mPreferredDate),topFrame);
198 QString format;
199 if ( QApplication::desktop()->width() < 480 )
200 format = "(%d.%m.%Y)";
201 else
202 format = "(%d.%m.%Y|%A %d %B %Y)";
203 syncPrefsGroup->addRadio(i18n("24.03.2004 "+format));
204 if ( QApplication::desktop()->width() < 480 )
205 format = "(%m.%d.%Y)";
206 else
207 format = "(%m.%d.%Y|%A %B %d %Y)";
208 syncPrefsGroup->addRadio(i18n("03.24.2004 "+format));
209 if ( QApplication::desktop()->width() < 480 )
210 format = "(%Y-%m-%d)";
211 else
212 format = "(%Y-%m-%d|%A %Y %B %d)";
213 syncPrefsGroup->addRadio(i18n("2004-03-24 "+format));
214 syncPrefsGroup->addRadio(i18n("User defined"));
215 topLayout->addMultiCellWidget( (QWidget*)syncPrefsGroup->groupBox(),iii,iii,0,1);
216 ++iii;
217 ++iii;
218 QLabel * lab;
219 mUserDateFormatLong = new QLineEdit(topFrame);
220 lab = new QLabel(mUserDateFormatLong, i18n("User long date:"), topFrame);
221 topLayout->addWidget(lab ,iii,0);
222 topLayout->addWidget(mUserDateFormatLong,iii,1);
223 ++iii;
224 mUserDateFormatShort = new QLineEdit(topFrame);
225 lab = new QLabel(mUserDateFormatShort, i18n("User short date:"), topFrame);
226 topLayout->addWidget(lab ,iii,0);
227 topLayout->addWidget(mUserDateFormatShort,iii,1);
228 ++iii;
229 lab = new QLabel( i18n("Monday 19 April 2004: %A %d %B %Y"), topFrame);
230 topLayout->addMultiCellWidget(lab ,iii,iii,0,1);
231 ++iii;
232 lab = new QLabel( i18n("Mon 19.04.04: %a %d.%m.%y"), topFrame);
233 topLayout->addMultiCellWidget(lab ,iii,iii,0,1);
234 ++iii;
235 lab = new QLabel( i18n("Mon, 19.Apr.04: %a, %d.%b.%y"), topFrame);
236 topLayout->addMultiCellWidget(lab ,iii,iii,0,1);
237 ++iii;
238
239 connect( mUserDateFormatLong, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) );
240 connect( mUserDateFormatShort, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) );
241
242
243 tabWidget->addTab( topFrame, i18n( "Date Format" ) );
244}
245
246void KDEPIMConfigWidget::setupLocaleTab()
247{
248
249 QWidget *topFrame = new QWidget( this );
250 QGridLayout *topLayout = new QGridLayout(topFrame,4,2);
251
252 topLayout->setSpacing(KDialog::spacingHint());
253 topLayout->setMargin(KDialog::marginHint());
254 int iii = 0;
255 KPrefsWidRadios *syncPrefsGroup =
256 addWidRadios(i18n("Language:(needs restart)"),&(KPimGlobalPrefs::instance()->mPreferredLanguage),topFrame);
257 syncPrefsGroup->addRadio(i18n("English"));
258 syncPrefsGroup->addRadio(i18n("German"));
259 syncPrefsGroup->addRadio(i18n("French"));
260 syncPrefsGroup->addRadio(i18n("User defined (usertranslation.txt)"));
261 if ( QApplication::desktop()->width() < 300 )
262 ;// syncPrefsGroup->groupBox()-> setOrientation (Qt::Vertical);
263 topLayout->addMultiCellWidget( (QWidget*)syncPrefsGroup->groupBox(),iii,iii,0,1);
264 ++iii;
265
266 syncPrefsGroup =
267 addWidRadios(i18n("Time Format(nr):"),&(KPimGlobalPrefs::instance()->mPreferredTime),topFrame);
268 if ( QApplication::desktop()->width() > 300 )
269 syncPrefsGroup->groupBox()->setOrientation (Qt::Vertical);
270 syncPrefsGroup->addRadio(i18n("24:00"));
271 syncPrefsGroup->addRadio(i18n("12:00am"));
272 syncPrefsGroup->groupBox()->setOrientation (Qt::Vertical);
273 topLayout->addMultiCellWidget( syncPrefsGroup->groupBox(),iii,iii,0,1);
274 ++iii;
275
276 KPrefsWidBool *sb = addWidBool(i18n("Week starts on Sunday"),
277 &(KPimGlobalPrefs::instance()->mWeekStartsOnSunday),topFrame);
278 topLayout->addMultiCellWidget((QWidget*)sb->checkBox(), iii,iii,0,1);
279 ++iii;
280
281
282 tabWidget->addTab( topFrame, i18n( "Locale" ) );
283
284}
285
286
287void KDEPIMConfigWidget::setupTimeZoneTab()
288{
289 QWidget *topFrame = new QWidget( this );
290 QGridLayout *topLayout = new QGridLayout( topFrame, 5, 2);
291 topLayout->setSpacing(KDialog::spacingHint());
292 topLayout->setMargin(KDialog::marginHint());
293
294 QHBox *timeZoneBox = new QHBox( topFrame );
295 topLayout->addMultiCellWidget( timeZoneBox, 0, 0, 0, 1 );
296
297 new QLabel( i18n("Timezone:"), timeZoneBox );
298 mTimeZoneCombo = new QComboBox( timeZoneBox );
299 if ( QApplication::desktop()->width() < 300 ) {
300 mTimeZoneCombo->setMaximumWidth(150);
301 }
302
303 QStringList list;
304 list = KGlobal::locale()->timeZoneList();
305 mTimeZoneCombo->insertStringList(list);
306
307 // find the currently set time zone and select it
308 QString sCurrentlySet = KPimGlobalPrefs::instance()->mTimeZoneId;
309 int nCurrentlySet = 11;
310 for (int i = 0; i < mTimeZoneCombo->count(); i++)
311 {
312 if (mTimeZoneCombo->text(i) == sCurrentlySet)
313 {
314 nCurrentlySet = i;
315 break;
316 }
317 }
318 mTimeZoneCombo->setCurrentItem(nCurrentlySet);
319 int iii = 1;
320 KPrefsWidBool *sb =
321 addWidBool(i18n("Timezone has daylight saving"),
322 &(KPimGlobalPrefs::instance()->mUseDaylightsaving),topFrame);
323 topLayout->addMultiCellWidget((QWidget*)sb->checkBox(), iii,iii,0,1);
324 ++iii;
325 QLabel* lab = new QLabel( i18n("Actual start and end is the\nsunday before this date."), topFrame );
326 topLayout->addMultiCellWidget(lab, iii,iii,0,1);
327 ++iii;
328 lab = new QLabel( i18n("The year in the date is ignored."), topFrame );
329 topLayout->addMultiCellWidget(lab, iii,iii,0,1);
330 ++iii;
331 lab = new QLabel( i18n("Daylight start:"), topFrame );
332 topLayout->addWidget(lab, iii,0);
333 mStartDateSavingEdit = new KDateEdit(topFrame);
334 topLayout->addWidget(mStartDateSavingEdit, iii,1);
335 ++iii;
336
337 lab = new QLabel( i18n("Daylight end:"), topFrame );
338 topLayout->addWidget(lab, iii,0);
339 mEndDateSavingEdit = new KDateEdit(topFrame);
340 topLayout->addWidget(mEndDateSavingEdit, iii,1);
341 ++iii;
342 QDate current ( 2001, 1,1);
343 mStartDateSavingEdit->setDate(current.addDays(KPimGlobalPrefs::instance()->mDaylightsavingStart-1));
344 mEndDateSavingEdit->setDate(current.addDays(KPimGlobalPrefs::instance()->mDaylightsavingEnd-1));
345
346 connect( mStartDateSavingEdit, SIGNAL( dateChanged(QDate)), this, SLOT( modified()) );
347 connect( mEndDateSavingEdit, SIGNAL( dateChanged(QDate)), this, SLOT( modified()) );
348 connect( mTimeZoneCombo, SIGNAL( activated( int ) ), this, SLOT (modified() ) );
349
350
351
352 tabWidget->addTab( topFrame, i18n( "Time Zone" ) );
353
354}
355
177void KDEPIMConfigWidget::externalapp_changed( int newApp ) 356void KDEPIMConfigWidget::externalapp_changed( int newApp )
178{ 357{
179 // first store the current data 358 // first store the current data
180 saveEditFieldSettings(); 359 saveEditFieldSettings();
181 360
182 // set mCurrentApp 361 // set mCurrentApp
183 mCurrentApp = (ExternalAppHandler::Types)newApp; 362 mCurrentApp = (ExternalAppHandler::Types)newApp;
184 363
185 // set mCurrentClient 364 // set mCurrentClient
186 switch(mCurrentApp) 365 switch(mCurrentApp)
187 { 366 {
188 case(ExternalAppHandler::EMAIL): 367 case(ExternalAppHandler::EMAIL):
@@ -219,25 +398,25 @@ void KDEPIMConfigWidget::client_changed( int newClient )
219 return; 398 return;
220 399
221 // first store the current data 400 // first store the current data
222 saveEditFieldSettings(); 401 saveEditFieldSettings();
223 402
224 403
225 //then reset the clientvariable 404 //then reset the clientvariable
226 mCurrentClient = newClient; 405 mCurrentClient = newClient;
227 406
228 // and at last update the widgets 407 // and at last update the widgets
229 updateClientWidgets(); 408 updateClientWidgets();
230 409
231 modified(); 410 KPrefsWidget::modified();
232} 411}
233 412
234void KDEPIMConfigWidget::saveEditFieldSettings() 413void KDEPIMConfigWidget::saveEditFieldSettings()
235{ 414{
236 415
237 switch(mCurrentApp) 416 switch(mCurrentApp)
238 { 417 {
239 case(ExternalAppHandler::EMAIL): 418 case(ExternalAppHandler::EMAIL):
240 mEmailClient = mClient->currentItem(); 419 mEmailClient = mClient->currentItem();
241 break; 420 break;
242 case(ExternalAppHandler::PHONE): 421 case(ExternalAppHandler::PHONE):
243 mPhoneClient= mClient->currentItem(); 422 mPhoneClient= mClient->currentItem();
@@ -435,32 +614,44 @@ void KDEPIMConfigWidget::updateClientWidgets()
435 } 614 }
436 615
437 if (enabled == true) { 616 if (enabled == true) {
438 mMessage2->setEnabled(mCurrentApp == ExternalAppHandler::EMAIL); 617 mMessage2->setEnabled(mCurrentApp == ExternalAppHandler::EMAIL);
439 mParameters2->setEnabled(mCurrentApp == ExternalAppHandler::EMAIL); 618 mParameters2->setEnabled(mCurrentApp == ExternalAppHandler::EMAIL);
440 } 619 }
441 620
442 621
443 blockSignals( blocked ); 622 blockSignals( blocked );
444 623
445} 624}
446 625
447 626void KDEPIMConfigWidget::usrReadConfig()
448
449
450void KDEPIMConfigWidget::restoreSettings(KPimGlobalPrefs* prefs)
451{ 627{
628 KPimGlobalPrefs* prefs = KPimGlobalPrefs::instance();
629
452 bool blocked = signalsBlocked(); 630 bool blocked = signalsBlocked();
453 blockSignals( true ); 631 blockSignals( true );
454 632
633 QString dummy = prefs->mUserDateFormatLong;
634 mUserDateFormatLong->setText(dummy.replace( QRegExp("K"), QString(",") ));
635 dummy = prefs->mUserDateFormatShort;
636 mUserDateFormatShort->setText(dummy.replace( QRegExp("K"), QString(",") ));
637
638 QDate current ( 2001, 1,1);
639 mStartDateSavingEdit->setDate(current.addDays(prefs->mDaylightsavingStart-1));
640 mEndDateSavingEdit->setDate(current.addDays(prefs->mDaylightsavingEnd-1));
641 setCombo(mTimeZoneCombo,i18n(prefs->mTimeZoneId));
642
643
644
645
455 mEmailClient = prefs->mEmailClient; 646 mEmailClient = prefs->mEmailClient;
456 mEmailOtherChannel = prefs->mEmailOtherChannel; 647 mEmailOtherChannel = prefs->mEmailOtherChannel;
457 mEmailOtherMessage = prefs->mEmailOtherMessage; 648 mEmailOtherMessage = prefs->mEmailOtherMessage;
458 mEmailOtherMessageParameters = prefs->mEmailOtherMessageParameters; 649 mEmailOtherMessageParameters = prefs->mEmailOtherMessageParameters;
459 mEmailOtherMessage2 = prefs->mEmailOtherMessage2; 650 mEmailOtherMessage2 = prefs->mEmailOtherMessage2;
460 mEmailOtherMessageParameters2 = prefs->mEmailOtherMessageParameters2; 651 mEmailOtherMessageParameters2 = prefs->mEmailOtherMessageParameters2;
461 652
462 mPhoneClient = prefs->mPhoneClient; 653 mPhoneClient = prefs->mPhoneClient;
463 mPhoneOtherChannel = prefs->mPhoneOtherChannel; 654 mPhoneOtherChannel = prefs->mPhoneOtherChannel;
464 mPhoneOtherMessage = prefs->mPhoneOtherMessage; 655 mPhoneOtherMessage = prefs->mPhoneOtherMessage;
465 mPhoneOtherMessageParameters = prefs->mPhoneOtherMessageParameters; 656 mPhoneOtherMessageParameters = prefs->mPhoneOtherMessageParameters;
466 657
@@ -482,32 +673,51 @@ void KDEPIMConfigWidget::restoreSettings(KPimGlobalPrefs* prefs)
482 mSipClient = prefs->mPagerClient; 673 mSipClient = prefs->mPagerClient;
483 mSipOtherChannel = prefs->mSipOtherChannel; 674 mSipOtherChannel = prefs->mSipOtherChannel;
484 mSipOtherMessage = prefs->mSipOtherMessage; 675 mSipOtherMessage = prefs->mSipOtherMessage;
485 mSipOtherMessageParameters = prefs->mSipOtherMessageParameters; 676 mSipOtherMessageParameters = prefs->mSipOtherMessageParameters;
486 677
487 mCurrentApp = ExternalAppHandler::EMAIL; 678 mCurrentApp = ExternalAppHandler::EMAIL;
488 mCurrentClient = mEmailClient; 679 mCurrentClient = mEmailClient;
489 680
490 updateClientWidgets(); 681 updateClientWidgets();
491 682
492 blockSignals( blocked ); 683 blockSignals( blocked );
493 684
494 emit changed( false );
495
496} 685}
497 686
498void KDEPIMConfigWidget::saveSettings(KPimGlobalPrefs* prefs) 687void KDEPIMConfigWidget::usrWriteConfig()
499{ 688{
689 KPimGlobalPrefs* prefs = KPimGlobalPrefs::instance();
690
500 saveEditFieldSettings(); 691 saveEditFieldSettings();
501 692
693
694 prefs->mUserDateFormatShort = mUserDateFormatShort->text().replace( QRegExp(","), QString("K") );
695 prefs->mUserDateFormatLong = mUserDateFormatLong->text().replace( QRegExp(","), QString("K") );
696
697 prefs->mTimeZoneId = mTimeZoneCombo->currentText();
698 QDate date;
699 date = mStartDateSavingEdit->date();
700 int sub = 0;
701 if ( QDate::leapYear( date.year() ) && date.dayOfYear() > 59 )
702 sub = 1;
703 prefs->mDaylightsavingStart = date.dayOfYear()-sub;
704 date = mEndDateSavingEdit->date();
705 if ( QDate::leapYear( date.year() ) && date.dayOfYear() > 59 )
706 sub = 1;
707 else
708 sub = 0;
709 prefs->mDaylightsavingEnd = date.dayOfYear()-sub;
710
711
502 prefs->mEmailClient = mEmailClient; 712 prefs->mEmailClient = mEmailClient;
503 prefs->mEmailOtherChannel = mEmailOtherChannel; 713 prefs->mEmailOtherChannel = mEmailOtherChannel;
504 prefs->mEmailOtherMessage = mEmailOtherMessage; 714 prefs->mEmailOtherMessage = mEmailOtherMessage;
505 prefs->mEmailOtherMessageParameters = mEmailOtherMessageParameters; 715 prefs->mEmailOtherMessageParameters = mEmailOtherMessageParameters;
506 prefs->mEmailOtherMessage2 = mEmailOtherMessage2; 716 prefs->mEmailOtherMessage2 = mEmailOtherMessage2;
507 prefs->mEmailOtherMessageParameters2 = mEmailOtherMessageParameters2; 717 prefs->mEmailOtherMessageParameters2 = mEmailOtherMessageParameters2;
508 718
509 prefs->mPhoneClient = mPhoneClient; 719 prefs->mPhoneClient = mPhoneClient;
510 prefs->mPhoneOtherChannel = mPhoneOtherChannel; 720 prefs->mPhoneOtherChannel = mPhoneOtherChannel;
511 prefs->mPhoneOtherMessage = mPhoneOtherMessage; 721 prefs->mPhoneOtherMessage = mPhoneOtherMessage;
512 prefs->mPhoneOtherMessageParameters = mPhoneOtherMessageParameters; 722 prefs->mPhoneOtherMessageParameters = mPhoneOtherMessageParameters;
513 723
@@ -523,82 +733,39 @@ void KDEPIMConfigWidget::saveSettings(KPimGlobalPrefs* prefs)
523 733
524 prefs->mPagerClient = mPagerClient; 734 prefs->mPagerClient = mPagerClient;
525 prefs->mPagerOtherChannel = mPagerOtherChannel; 735 prefs->mPagerOtherChannel = mPagerOtherChannel;
526 prefs->mPagerOtherMessage = mPagerOtherMessage; 736 prefs->mPagerOtherMessage = mPagerOtherMessage;
527 prefs->mPagerOtherMessageParameters = mPagerOtherMessageParameters; 737 prefs->mPagerOtherMessageParameters = mPagerOtherMessageParameters;
528 738
529 739
530 prefs->mSipClient = mSipClient; 740 prefs->mSipClient = mSipClient;
531 prefs->mSipOtherChannel = mSipOtherChannel; 741 prefs->mSipOtherChannel = mSipOtherChannel;
532 prefs->mSipOtherMessage = mSipOtherMessage; 742 prefs->mSipOtherMessage = mSipOtherMessage;
533 prefs->mSipOtherMessageParameters = mSipOtherMessageParameters; 743 prefs->mSipOtherMessageParameters = mSipOtherMessageParameters;
534 744
535 prefs->writeConfig();
536
537 //release the cache that other views can access the changed values instantanious 745 //release the cache that other views can access the changed values instantanious
538 ExternalAppHandler::instance()->loadConfig(); 746 ExternalAppHandler::instance()->loadConfig();
539 747
540 emit changed( false );
541} 748}
542 749
543void KDEPIMConfigWidget::defaults(KPimGlobalPrefs* prefs)
544{
545
546 DefaultAppItem* dai = ExternalAppHandler::instance()->getDefaultItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::NONE_EMC);
547
548 mEmailClient = dai->_id;
549 mEmailOtherChannel = dai->_channel;
550 mEmailOtherMessage = dai->_message;
551 mEmailOtherMessageParameters = dai->_parameters;
552 mEmailOtherMessage2 = dai->_message2;
553 mEmailOtherMessageParameters2 = dai->_parameters2;
554
555
556 dai = ExternalAppHandler::instance()->getDefaultItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::NONE_PHC);
557
558 mPhoneClient = dai->_id;
559 mPhoneOtherChannel = dai->_channel;
560 mPhoneOtherMessage = dai->_message;
561 mPhoneOtherMessageParameters = dai->_parameters;
562
563 dai = ExternalAppHandler::instance()->getDefaultItem(ExternalAppHandler::FAX, KPimGlobalPrefs::NONE_FAC);
564
565 mFaxClient = dai->_id;
566 mFaxOtherChannel = dai->_channel;
567 mFaxOtherMessage = dai->_message;
568 mFaxOtherMessageParameters = dai->_parameters;
569 750
570 dai = ExternalAppHandler::instance()->getDefaultItem(ExternalAppHandler::SMS, KPimGlobalPrefs::NONE_SMC); 751void KDEPIMConfigWidget::setCombo(QComboBox *combo, const QString & text,
571 752 const QStringList *tags)
572 mSMSClient = dai->_id;
573 mSMSOtherChannel = dai->_channel;
574 mSMSOtherMessage = dai->_message;
575 mSMSOtherMessageParameters = dai->_parameters;
576
577 dai = ExternalAppHandler::instance()->getDefaultItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::NONE_PAC);
578
579 mPagerClient = dai->_id;
580 mPagerOtherChannel = dai->_channel;
581 mPagerOtherMessage = dai->_message;
582 mPagerOtherMessageParameters = dai->_parameters;
583
584
585 dai = ExternalAppHandler::instance()->getDefaultItem(ExternalAppHandler::SIP, KPimGlobalPrefs::NONE_SIC);
586
587 mSipClient = dai->_id;
588 mSipOtherChannel = dai->_channel;
589 mSipOtherMessage = dai->_message;
590 mSipOtherMessageParameters = dai->_parameters;
591
592
593 emit changed( true );
594}
595
596void KDEPIMConfigWidget::modified()
597{ 753{
598 emit changed( true ); 754 if (tags) {
755 int i = tags->findIndex(text);
756 if (i > 0) combo->setCurrentItem(i);
757 } else {
758 for(int i=0;i<combo->count();++i) {
759 if (combo->text(i) == text) {
760 combo->setCurrentItem(i);
761 break;
762 }
763 }
764 }
599} 765}
600 766
767
601void KDEPIMConfigWidget::textChanged( const QString& text ) 768void KDEPIMConfigWidget::textChanged( const QString& text )
602{ 769{
603 emit changed( true ); 770 emit changed( true );
604} 771}
diff --git a/libkdepim/kcmconfigs/kdepimconfigwidget.h b/libkdepim/kcmconfigs/kdepimconfigwidget.h
index e3cfd81..6f26513 100644
--- a/libkdepim/kcmconfigs/kdepimconfigwidget.h
+++ b/libkdepim/kcmconfigs/kdepimconfigwidget.h
@@ -22,73 +22,82 @@
22*/ 22*/
23 23
24/* 24/*
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (c) 2004 Ulf Schenk
27 27
28$Id$ 28$Id$
29*/ 29*/
30 30
31#ifndef KDEPIMCONFIGWIDGET_H 31#ifndef KDEPIMCONFIGWIDGET_H
32#define KDEPIMCONFIGWIDGET_H 32#define KDEPIMCONFIGWIDGET_H
33 33
34#include <qwidget.h> 34#include <kprefswidget.h>
35#include <qmap.h> 35#include <qmap.h>
36 36
37#include "externalapphandler.h" 37#include "externalapphandler.h"
38 38
39 39
40/*
41class QCheckBox;
42class QListViewItem;
43class QPushButton;
44class KListView;
45*/
46class QComboBox; 40class QComboBox;
47class QLineEdit; 41class QLineEdit;
48class KPimGlobalPrefs; 42class KPimGlobalPrefs;
49class QGroupBox; 43class QGroupBox;
44class QTabWidget;
45class KDateEdit;
50 46
51class KDEPIMConfigWidget : public QWidget 47class KDEPIMConfigWidget : public KPrefsWidget
52{ 48{
53 Q_OBJECT 49 Q_OBJECT
54 50
55 public: 51 public:
56 KDEPIMConfigWidget( QWidget *parent, const char *name = 0 ); 52 KDEPIMConfigWidget(KPimGlobalPrefs *prefs, QWidget *parent, const char *name = 0 );
57
58 void restoreSettings(KPimGlobalPrefs* prefs);
59 void saveSettings(KPimGlobalPrefs* prefs);
60 void defaults(KPimGlobalPrefs* prefs);
61
62 signals:
63 void changed( bool );
64
65 53
66 public slots: 54 public slots:
67 void modified();
68 void textChanged( const QString& text ); 55 void textChanged( const QString& text );
69 56
57 protected:
58 /** Implement this to read custom configuration widgets. */
59 virtual void usrReadConfig();
60 /** Implement this to write custom configuration widgets. */
61 virtual void usrWriteConfig();
70 62
71 63
72 private slots: 64 private slots:
73// void configureExtension(); 65// void configureExtension();
74// void selectionChanged( QListViewItem* ); 66// void selectionChanged( QListViewItem* );
75// void itemClicked( QListViewItem* ); 67// void itemClicked( QListViewItem* );
76 void client_changed( int newClient ); 68 void client_changed( int newClient );
77 void externalapp_changed( int newApp ); 69 void externalapp_changed( int newApp );
78 70
79 private: 71 private:
72 void setupExternalAppTab();
73 void setupLocaleDateTab();
74 void setupLocaleTab();
75 void setupTimeZoneTab();
76
77 void setCombo(QComboBox *combo,const QString & text, const QStringList *tags = 0);
78
79
80 void saveEditFieldSettings(); 80 void saveEditFieldSettings();
81 void updateClientWidgets(); 81 void updateClientWidgets();
82 82
83 QTabWidget *tabWidget;
84
85
86 QLineEdit* mUserDateFormatShort;
87 QLineEdit* mUserDateFormatLong;
88 QComboBox* mTimeZoneCombo;
89 KDateEdit* mStartDateSavingEdit;
90 KDateEdit* mEndDateSavingEdit;
91
83// void restoreExtensionSettings(); 92// void restoreExtensionSettings();
84// void saveExtensionSettings(); 93// void saveExtensionSettings();
85 94
86// KListView *mExtensionView; 95// KListView *mExtensionView;
87 96
88// QCheckBox *mNameParsing; 97// QCheckBox *mNameParsing;
89// QCheckBox *mViewsSingleClickBox; 98// QCheckBox *mViewsSingleClickBox;
90// QPushButton *mConfigureButton; 99// QPushButton *mConfigureButton;
91 QComboBox* mExternalApps; 100 QComboBox* mExternalApps;
92 QGroupBox* mExternalAppGroupBox; 101 QGroupBox* mExternalAppGroupBox;
93 102
94 103