-rw-r--r-- | korganizer/koprefs.cpp | 555 |
1 files changed, 555 insertions, 0 deletions
diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp new file mode 100644 index 0000000..2900a40 --- a/dev/null +++ b/korganizer/koprefs.cpp | |||
@@ -0,0 +1,555 @@ | |||
1 | /* | ||
2 | This file is part of KOrganizer. | ||
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | ||
4 | |||
5 | This program is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published by | ||
7 | the Free Software Foundation; either version 2 of the License, or | ||
8 | (at your option) any later version. | ||
9 | |||
10 | This program is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | GNU General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with this program; if not, write to the Free Software | ||
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
18 | |||
19 | As a special exception, permission is given to link this program | ||
20 | with any edition of Qt, and distribute the resulting executable, | ||
21 | without including the source code for Qt in the source distribution. | ||
22 | */ | ||
23 | |||
24 | #include <time.h> | ||
25 | #ifndef _WIN32_ | ||
26 | #include <unistd.h> | ||
27 | #endif | ||
28 | #include <qdir.h> | ||
29 | #include <qtextstream.h> | ||
30 | #include <qtextcodec.h> | ||
31 | #include <qstring.h> | ||
32 | #include <qfont.h> | ||
33 | #include <qcolor.h> | ||
34 | #include <qstringlist.h> | ||
35 | #include <stdlib.h> | ||
36 | |||
37 | #include <kglobal.h> | ||
38 | #include <kconfig.h> | ||
39 | #include <klocale.h> | ||
40 | #include <kdebug.h> | ||
41 | #include <kemailsettings.h> | ||
42 | #include <kstaticdeleter.h> | ||
43 | |||
44 | #include "koprefs.h" | ||
45 | #include "mainwindow.h" | ||
46 | |||
47 | const char *germanwords[][2] = { | ||
48 | #include "wordsgerman.h" | ||
49 | "", "" | ||
50 | }; | ||
51 | |||
52 | KOPrefs *KOPrefs::mInstance = 0; | ||
53 | static KStaticDeleter<KOPrefs> insd; | ||
54 | |||
55 | KOPrefs::KOPrefs() : | ||
56 | KPimPrefs("korganizerrc") | ||
57 | { | ||
58 | mCategoryColors.setAutoDelete(true); | ||
59 | mLocaleDict = 0; | ||
60 | fillMailDefaults(); | ||
61 | mDefaultCategoryColor = QColor(175,210,255);//196,196,196); | ||
62 | QColor defaultHolidayColor = QColor(255,0,0); | ||
63 | QColor defaultHighlightColor = QColor(129,112,255);//64,64,255); | ||
64 | QColor defaultAgendaBgColor = QColor(239,241,169);//128,128,128); | ||
65 | QColor defaultWorkingHoursColor = QColor(170,223,150);//160,160,160); | ||
66 | QColor defaultTodoDueTodayColor = QColor(255,220,100); | ||
67 | QColor defaultTodoOverdueColor = QColor(255,153,125); | ||
68 | |||
69 | mTimeBarFont = QFont("helvetica",10);//,QFont::Bold); | ||
70 | mDefaultViewFont = QFont("helvetica",10); | ||
71 | mDefaultMonthViewFont = QFont("helvetica",8); | ||
72 | mMarcusBainsFont= QFont("helvetica",10); | ||
73 | mDateNavigatorFont= QFont("helvetica",10, QFont::Bold); | ||
74 | mEditBoxFont = QFont("helvetica",12); | ||
75 | mJornalViewFont = QFont("helvetica",12); | ||
76 | |||
77 | KPrefs::setCurrentGroup("General"); | ||
78 | addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); | ||
79 | |||
80 | addItemBool("ShowIconNewTodo",&mShowIconNewTodo,true); | ||
81 | addItemBool("ShowIconNewEvent",&mShowIconNewEvent,true); | ||
82 | addItemBool("ShowIconSearch",&mShowIconSearch,true); | ||
83 | addItemBool("ShowIconList",&mShowIconList,true); | ||
84 | addItemBool("ShowIconDay1",&mShowIconDay1,true); | ||
85 | addItemBool("ShowIconDay5",&mShowIconDay5,true); | ||
86 | addItemBool("ShowIconDay7",&mShowIconDay7,true); | ||
87 | addItemBool("ShowIconMonth",&mShowIconMonth,true); | ||
88 | addItemBool("ShowIconTodoview",&mShowIconTodoview,true); | ||
89 | addItemBool("ShowIconBackFast",&mShowIconBackFast,true); | ||
90 | addItemBool("ShowIconBack",&mShowIconBack,true); | ||
91 | addItemBool("ShowIconToday",&mShowIconToday,true); | ||
92 | addItemBool("ShowIconForward",&mShowIconForward,true); | ||
93 | addItemBool("ShowIconForwardFast",&mShowIconForwardFast,true); | ||
94 | addItemBool("ShowIconWhatsThis",&mShowIconWhatsThis,false); | ||
95 | addItemBool("ShowIconNextDays",&mShowIconNextDays,true); | ||
96 | addItemBool("ShowIconNext",&mShowIconNext,true); | ||
97 | addItemBool("ShowIconJournal",&mShowIconJournal,true); | ||
98 | addItemBool("ShowIconStretch",&mShowIconStretch,true); | ||
99 | addItemBool("LanguageChanged",&mLanguageChanged,false); | ||
100 | |||
101 | addItemBool("AskForQuit",&mAskForQuit,false); | ||
102 | |||
103 | #ifndef DESKTOP_VERSION | ||
104 | addItemBool("ShowFullMenu",&mShowFullMenu,false); | ||
105 | #else | ||
106 | addItemBool("ShowFullMenu",&mShowFullMenu,true); | ||
107 | #endif | ||
108 | addItemBool("ToolBarHor",&mToolBarHor, true ); | ||
109 | addItemBool("ToolBarUp",&mToolBarUp, false ); | ||
110 | addItemBool("ToolBarMiniIcons",&mToolBarMiniIcons, false ); | ||
111 | addItemInt("Whats Next Days",&mWhatsNextDays,3); | ||
112 | addItemInt("Whats Next Prios",&mWhatsNextPrios,1); | ||
113 | |||
114 | addItemBool("ShowTodoInAgenda",&mShowTodoInAgenda,true); | ||
115 | addItemBool("ShowCompletedTodo",&mShowCompletedTodo,true); | ||
116 | addItemInt("AllDay Size",&mAllDaySize,28); | ||
117 | QString defAlarm = KGlobal::iconLoader()->iconPath()+"koalarm.wav"; | ||
118 | addItemString("DefaultAlarmFile",&mDefaultAlarmFile,defAlarm ); | ||
119 | |||
120 | addItemStringList("LocationDefaults",&mLocationDefaults ); | ||
121 | addItemStringList("EventSummary User",&mEventSummaryUser); | ||
122 | addItemStringList("TodoSummary User",&mTodoSummaryUser); | ||
123 | |||
124 | addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); | ||
125 | addItemBool("Enable Project View",&mEnableProjectView,false); | ||
126 | addItemBool("Auto Save",&mAutoSave,false); | ||
127 | addItemInt("Auto Save Interval",&mAutoSaveInterval,3); | ||
128 | addItemBool("Confirm Deletes",&mConfirm,true); | ||
129 | addItemString("Archive File",&mArchiveFile); | ||
130 | addItemString("Html Export File",&mHtmlExportFile, | ||
131 | QDir::homeDirPath() + "/" + i18n("Default export file", "calendar.html")); | ||
132 | addItemBool("Html With Save",&mHtmlWithSave,false); | ||
133 | |||
134 | KPrefs::setCurrentGroup("Personal Settings"); | ||
135 | |||
136 | addItemInt("Mail Client",&mMailClient,MailClientKMail); | ||
137 | addItemBool("Use Control Center Email",&mEmailControlCenter,false); | ||
138 | addItemBool("Bcc",&mBcc,false); | ||
139 | |||
140 | KPrefs::setCurrentGroup("Time & Date"); | ||
141 | |||
142 | // addItemString("Time Zone",&mTimeZone,"+0100"); | ||
143 | addItemString("TimeZoneName",&mTimeZoneId,i18n ("+01:00 Europe/Oslo(CET)") ); | ||
144 | // addItemInt("TimeZoneOffset",&mTimeZoneOffset,60); | ||
145 | addItemBool("UseDaylightsaving",&mUseDaylightsaving,true); | ||
146 | addItemInt("DaylightsavingStart",&mDaylightsavingStart,90); | ||
147 | addItemInt("DaylightsavingEnd",&mDaylightsavingEnd,304); | ||
148 | |||
149 | |||
150 | addItemInt("Default Start Time",&mStartTime,10); | ||
151 | addItemInt("Default Duration",&mDefaultDuration,2); | ||
152 | addItemInt("Default Alarm Time",&mAlarmTime,3); | ||
153 | addItemInt("Daylight Savings",&mDaylightSavings,0); | ||
154 | KPrefs::setCurrentGroup("AlarmSettings"); | ||
155 | addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20); | ||
156 | addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7); | ||
157 | addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5); | ||
158 | addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3); | ||
159 | |||
160 | |||
161 | KPrefs::setCurrentGroup("Calendar"); | ||
162 | |||
163 | addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar); | ||
164 | |||
165 | KPrefs::setCurrentGroup("Fonts"); | ||
166 | // qDebug(" KPrefs::setCurrentGroup(Fonts); "); | ||
167 | addItemFont("TimeBar Font",&mTimeBarFont); | ||
168 | addItemFont("MonthView Font",&mMonthViewFont); | ||
169 | addItemFont("AgendaView Font",&mAgendaViewFont); | ||
170 | addItemFont("MarcusBains Font",&mMarcusBainsFont); | ||
171 | addItemFont("TimeLabels Font",&mTimeLabelsFont); | ||
172 | addItemFont("TodoView Font",&mTodoViewFont); | ||
173 | addItemFont("ListView Font",&mListViewFont); | ||
174 | addItemFont("DateNavigator Font",&mDateNavigatorFont); | ||
175 | addItemFont("EditBox Font",&mEditBoxFont); | ||
176 | addItemFont("JournalView Font",&mJornalViewFont); | ||
177 | addItemFont("WhatsNextView Font",&mWhatsNextFont); | ||
178 | addItemFont("EventView Font",&mEventViewFont); | ||
179 | |||
180 | KPrefs::setCurrentGroup("SyncProfiles"); | ||
181 | addItemString("LocalMachineName",&mLocalMachineName, "undefined"); | ||
182 | addItemStringList("SyncProfileNames",&mSyncProfileNames); | ||
183 | |||
184 | KPrefs::setCurrentGroup("RemoteSyncing"); | ||
185 | addItemBool("UsePasswd",&mUsePassWd,false); | ||
186 | addItemBool("WriteBackFile",&mWriteBackFile,true); | ||
187 | addItemBool("WriteBackExistingOnly",&mWriteBackExistingOnly,false); | ||
188 | addItemBool("AskForPreferences",&mAskForPreferences,true); | ||
189 | addItemBool("ShowSyncSummary",&mShowSyncSummary,true); | ||
190 | addItemBool("ShowSyncEvents",&mShowSyncEvents,false); | ||
191 | addItemInt("LastSyncTime",&mLastSyncTime,0); | ||
192 | addItemInt("SyncAlgoPrefs",&mSyncAlgoPrefs,3); | ||
193 | addItemInt("RingSyncAlgoPrefs",&mRingSyncAlgoPrefs,3); | ||
194 | |||
195 | #ifdef _WIN32_ | ||
196 | QString hdp= locateLocal("data","korganizer")+"\\\\"; | ||
197 | #else | ||
198 | QString hdp= locateLocal("data","korganizer")+"/"; | ||
199 | #endif | ||
200 | addItemString("RemoteIP",&mRemoteIP, "192.168.0.65"); | ||
201 | addItemString("RemoteUser",&mRemoteUser, "zaurus"); | ||
202 | addItemString("RemotePassWd",&mRemotePassWd, ""); | ||
203 | addItemString("RemoteFile", &mRemoteFile, hdp+"mycalendar.ics"); | ||
204 | addItemString("LocalTempFile",&mLocalTempFile, "/tmp/tempsyncfile.ics" ); | ||
205 | |||
206 | |||
207 | KPrefs::setCurrentGroup("LoadSaveFileNames"); | ||
208 | |||
209 | addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" ); | ||
210 | addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" ); | ||
211 | addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" ); | ||
212 | addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" ); | ||
213 | addItemString("LastSyncedLocalFile", &mLastSyncedLocalFile ,hdp +"lastsync.ics" ); | ||
214 | |||
215 | |||
216 | KPrefs::setCurrentGroup("Locale"); | ||
217 | addItemInt("PreferredLanguage",&mPreferredLanguage,0); | ||
218 | addItemInt("PreferredTime",&mPreferredTime,0); | ||
219 | addItemInt("PreferredDate",&mPreferredDate,0); | ||
220 | addItemBool("WeekStartsOnSunday",&mWeekStartsOnSunday,false); | ||
221 | addItemBool("QuickSavingWOUnicode",&mUseQuicksave,false); | ||
222 | addItemBool("ShortDateInViewer",&mShortDateInViewer,false); | ||
223 | addItemString("UserDateFormatLong", &mUserDateFormatLong, "%A %d %b %y"); | ||
224 | addItemString("UserDateFormatShort", &mUserDateFormatShort, "%aK %d.%m.%y"); | ||
225 | |||
226 | |||
227 | KPrefs::setCurrentGroup("Colors"); | ||
228 | addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor); | ||
229 | addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor); | ||
230 | addItemColor("Event Color",&mEventColor,mDefaultCategoryColor); | ||
231 | addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor); | ||
232 | addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor); | ||
233 | addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor); | ||
234 | addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor); | ||
235 | addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 )); | ||
236 | addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 )); | ||
237 | addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 )); | ||
238 | addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true); | ||
239 | addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true); | ||
240 | addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false); | ||
241 | addItemColor("AppColor1",&mAppColor1,QColor( 130,170,255 )); | ||
242 | addItemColor("AppColor2",&mAppColor2,QColor( 174,216,255 )); | ||
243 | addItemBool("UseAppColors",&mUseAppColors,false); | ||
244 | |||
245 | |||
246 | |||
247 | KPrefs::setCurrentGroup("Views"); | ||
248 | addItemInt("Hour Size",&mHourSize,8); | ||
249 | addItemBool("Show Daily Recurrences",&mDailyRecur,true); | ||
250 | addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true); | ||
251 | addItemBool("Show Month Daily Recurrences",&mMonthDailyRecur,true); | ||
252 | addItemBool("Show Month Weekly Recurrences",&mMonthWeeklyRecur,true); | ||
253 | addItemBool("ShowShortMonthName",&mMonthShowShort,false); | ||
254 | addItemBool("ShowIconsInMonthCell",&mMonthShowIcons,true); | ||
255 | addItemBool("Enable ToolTips",&mEnableToolTips,false); | ||
256 | addItemBool("Enable MonthView ScrollBars",&mEnableMonthScroll,false); | ||
257 | addItemBool("Marcus Bains shows seconds",&mMarcusBainsShowSeconds,false); | ||
258 | addItemBool("Show Marcus Bains",&mMarcusBainsEnabled,true); | ||
259 | addItemBool("EditOnDoubleClick",&mEditOnDoubleClick,true); | ||
260 | addItemBool("ViewChangeHoldFullscreen",&mViewChangeHoldFullscreen,false); | ||
261 | addItemBool("ViewChangeHoldNonFullscreen",&mViewChangeHoldNonFullscreen,false); | ||
262 | addItemBool("CenterOnCurrentTime",&mCenterOnCurrentTime,false); | ||
263 | addItemBool("SetTimeToDayStartAt",&mSetTimeToDayStartAt,true); | ||
264 | addItemBool("HighlightCurrentDay",&mHighlightCurrentDay,true); | ||
265 | addItemBool("WNViewShowsParents",&mWNViewShowsParents,true); | ||
266 | addItemBool("WNViewShowLocation",&mWNViewShowLocation,false); | ||
267 | addItemBool("UseHighlightLightColor",&mUseHighlightLightColor,false); | ||
268 | addItemBool("ListViewMonthTimespan",&mListViewMonthTimespan,true); | ||
269 | addItemBool("TodoViewUsesCatColors",&mTodoViewUsesCatColors,false); | ||
270 | addItemBool("TodoViewShowsPercentage",&mTodoViewShowsPercentage,false); | ||
271 | addItemBool("TodoViewUsesSmallFont",&mTodoViewUsesSmallFont,false); | ||
272 | addItemBool("TodoViewUsesForegroundColor",&mTodoViewUsesForegroundColor,false); | ||
273 | addItemBool("MonthViewUsesForegroundColor",&mMonthViewUsesForegroundColor,false); | ||
274 | addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,false); | ||
275 | addItemInt("Day Begins",&mDayBegins,7); | ||
276 | addItemInt("Working Hours Start",&mWorkingHoursStart,8); | ||
277 | addItemInt("Working Hours End",&mWorkingHoursEnd,17); | ||
278 | addItemBool("Exclude Holidays",&mExcludeHolidays,true); | ||
279 | addItemBool("Exclude Saturdays",&mExcludeSaturdays,true); | ||
280 | |||
281 | addItemBool("Month View Uses Category Color",&mMonthViewUsesCategoryColor,false); | ||
282 | addItemBool("Full View Month",&mFullViewMonth,true); | ||
283 | addItemBool("Full View Todo",&mFullViewTodo,true); | ||
284 | addItemBool("Quick Todo",&mEnableQuickTodo,false); | ||
285 | |||
286 | addItemInt("Next X Days",&mNextXDays,3); | ||
287 | |||
288 | KPrefs::setCurrentGroup("Printer"); | ||
289 | |||
290 | KPrefs::setCurrentGroup("Layout"); | ||
291 | |||
292 | addItemBool("CompactDialogs",&mCompactDialogs,false); | ||
293 | addItemBool("VerticalScreen",&mVerticalScreen,true); | ||
294 | |||
295 | KPrefs::setCurrentGroup("KOrganizer Plugins"); | ||
296 | |||
297 | addItemStringList("SelectedPlugins",&mSelectedPlugins,"holidays"); | ||
298 | |||
299 | KPrefs::setCurrentGroup("Group Scheduling"); | ||
300 | |||
301 | addItemInt("IMIPScheduler",&mIMIPScheduler,IMIPKMail); | ||
302 | addItemInt("IMIPSend",&mIMIPSend,IMIPdirectsend); | ||
303 | addItemStringList("AdditionalMails",&mAdditionalMails,""); | ||
304 | addItemInt("IMIP auto refresh",&mIMIPAutoRefresh,neverAuto); | ||
305 | addItemInt("IMIP auto insert request",&mIMIPAutoInsertRequest,neverAuto); | ||
306 | addItemInt("IMIP auto insert reply",&mIMIPAutoInsertReply,neverAuto); | ||
307 | addItemInt("IMIP auto FreeBusy",&mIMIPAutoFreeBusy,neverAuto); | ||
308 | addItemInt("IMIP auto save FreeBusy",&mIMIPAutoFreeBusyReply,neverAuto); | ||
309 | |||
310 | KPrefs::setCurrentGroup( "Editors" ); | ||
311 | |||
312 | addItemStringList( "EventTemplates", &mEventTemplates ); | ||
313 | addItemStringList( "TodoTemplates", &mTodoTemplates ); | ||
314 | |||
315 | addItemInt("DestinationPolicy",&mDestination,standardDestination); | ||
316 | |||
317 | |||
318 | |||
319 | } | ||
320 | |||
321 | |||
322 | KOPrefs::~KOPrefs() | ||
323 | { | ||
324 | if (mInstance == this) | ||
325 | mInstance = insd.setObject(0); | ||
326 | setLocaleDict( 0 ); | ||
327 | if ( mLocaleDict ) | ||
328 | delete mLocaleDict; | ||
329 | //qDebug("KOPrefs::~KOPrefs() "); | ||
330 | } | ||
331 | |||
332 | |||
333 | KOPrefs *KOPrefs::instance() | ||
334 | { | ||
335 | if (!mInstance) { | ||
336 | mInstance = insd.setObject(new KOPrefs()); | ||
337 | mInstance->readConfig(); | ||
338 | } | ||
339 | |||
340 | return mInstance; | ||
341 | } | ||
342 | |||
343 | void KOPrefs::usrSetDefaults() | ||
344 | { | ||
345 | |||
346 | } | ||
347 | |||
348 | void KOPrefs::fillMailDefaults() | ||
349 | { | ||
350 | if (mName.isEmpty()) mName = i18n("Anonymous"); | ||
351 | if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere"); | ||
352 | } | ||
353 | |||
354 | void KOPrefs::setTimeZoneIdDefault() | ||
355 | { | ||
356 | mTimeZoneId = i18n("+01:00 Europe/Oslo(CET)"); | ||
357 | } | ||
358 | |||
359 | void KOPrefs::setCategoryDefaults() | ||
360 | { | ||
361 | mCustomCategories.clear(); | ||
362 | mCustomCategories = getDefaultList(); | ||
363 | |||
364 | QStringList::Iterator it; | ||
365 | for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { | ||
366 | setCategoryColor(*it,mDefaultCategoryColor); | ||
367 | } | ||
368 | } | ||
369 | |||
370 | QStringList KOPrefs::getDefaultList() | ||
371 | { | ||
372 | QStringList retval ; | ||
373 | retval << i18n("Anniversary") << i18n("Appointment") << i18n("Birthday") << i18n("Business") << i18n("Business Travel") << i18n("Cinema") << i18n("Customer") | ||
374 | << i18n("Break")<< i18n("Breakfast")<< i18n("Competition")<< i18n("Dinner") | ||
375 | << i18n("Education")<< i18n("Family") << i18n("Favorites") << i18n("Festival")<< i18n("Fishing")<< i18n("Flight") << i18n("Gifts") | ||
376 | << i18n("Holiday") << i18n("Holiday Cards")<< i18n("Hot Contacts") << i18n("Hiking") << i18n("Hunting") << i18n("Key Customer") << i18n("Kids") | ||
377 | << i18n("Lunch") << i18n("Meeting") << i18n("Miscellaneous") << i18n("Partner")<< i18n("Party") << i18n("Personal") << i18n("Personal Travel") | ||
378 | << i18n("PHB") << i18n("Phone Calls") << i18n("Projects") << i18n("Recurring") << i18n("School") << i18n("Shopping") | ||
379 | << i18n("Speach") << i18n("Special Occasion") << i18n("Sports") << i18n("Talk") << i18n("Travel") << i18n("TV")<< i18n("University") | ||
380 | << i18n("Vacation") << i18n("VIP") << i18n("SyncEvent") ; | ||
381 | retval.sort(); | ||
382 | return retval; | ||
383 | } | ||
384 | |||
385 | void KOPrefs::usrReadConfig() | ||
386 | { | ||
387 | mLocaleDict = 0; | ||
388 | // pending LR fix translation | ||
389 | // qDebug("KOPrefs::usrReadConfig() fix translation "); | ||
390 | if ( mPreferredLanguage == 1 ) { | ||
391 | mLocaleDict = new QDict<QString>; | ||
392 | int i = 0; | ||
393 | QString fw ( germanwords[i] [0]); | ||
394 | while ( !fw.isEmpty() ) { | ||
395 | mLocaleDict->insert( fw, new QString (germanwords[i] [1] )); | ||
396 | ++i; | ||
397 | fw = germanwords[i] [0]; | ||
398 | } | ||
399 | |||
400 | setLocaleDict( mLocaleDict ); | ||
401 | } | ||
402 | if ( mPreferredLanguage == 3 ) { | ||
403 | QString fileName = MainWindow::resourcePath()+"usertranslation.txt"; | ||
404 | QFile file( fileName ); | ||
405 | if (file.open( IO_ReadOnly ) ) { | ||
406 | QTextStream ts( &file ); | ||
407 | ts.setCodec( QTextCodec::codecForLocale() ); | ||
408 | QString text = ts.read(); | ||
409 | file.close(); | ||
410 | |||
411 | QString line; | ||
412 | QString we; | ||
413 | QString wt; | ||
414 | int br = 0; | ||
415 | int nbr; | ||
416 | nbr = text.find ( "},", br ); | ||
417 | line = text.mid( br, nbr - br ); | ||
418 | br = nbr+1; | ||
419 | int se, ee, st, et; | ||
420 | mLocaleDict = new QDict<QString>; | ||
421 | QString end = "{ \"\",\"\" }"; | ||
422 | while ( (line != end) && (br > 1) ) { | ||
423 | //qDebug("%d *%s* ", br, line.latin1()); | ||
424 | se = line.find("\"")+1; | ||
425 | et = line.findRev("\"",-1); | ||
426 | ee = line.find("\",\""); | ||
427 | st = ee+3; | ||
428 | we = line.mid( se, ee-se ); | ||
429 | wt = line.mid( st, et-st ); | ||
430 | //qDebug("*%s* *%s* ", we.latin1(), wt.latin1()); | ||
431 | mLocaleDict->insert( we, new QString (wt) ); | ||
432 | nbr = text.find ( "}", br ); | ||
433 | line = text.mid( br, nbr - br ); | ||
434 | br = nbr+1; | ||
435 | } | ||
436 | //qDebug("end *%s* ", end.latin1()); | ||
437 | |||
438 | setLocaleDict( mLocaleDict ); | ||
439 | } else { | ||
440 | qDebug("KO: Cannot find translation file usertranslation.txt"); | ||
441 | } | ||
442 | } | ||
443 | config()->setGroup("General"); | ||
444 | |||
445 | mCustomCategories = config()->readListEntry("Custom Categories"); | ||
446 | if ( KOPrefs::instance()->mLanguageChanged ) { | ||
447 | mLocationDefaults.clear(); | ||
448 | mEventSummaryUser.clear(); | ||
449 | mTodoSummaryUser.clear(); | ||
450 | } | ||
451 | if (mLocationDefaults.isEmpty()) { | ||
452 | mLocationDefaults << i18n("Home") << i18n("Office") << i18n("Libary") << i18n("School") << i18n("Doctor") << i18n("Beach") | ||
453 | << i18n("University") << i18n("Restaurant") << i18n("Bar") << i18n("Conference room") << i18n("Cinema") << i18n("Lake") << i18n("Kindergarden") | ||
454 | << i18n("Germany") << i18n("Sweden") << i18n("Forest") << i18n("Desert") << i18n("Kitchen") ; | ||
455 | // << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") | ||
456 | mLocationDefaults.sort(); | ||
457 | } | ||
458 | |||
459 | if (mEventSummaryUser.isEmpty()) { | ||
460 | mEventSummaryUser = getDefaultList() ; | ||
461 | } | ||
462 | if (mTodoSummaryUser.isEmpty()) { | ||
463 | mTodoSummaryUser = getDefaultList() ; | ||
464 | } | ||
465 | |||
466 | if (mCustomCategories.isEmpty()) setCategoryDefaults(); | ||
467 | |||
468 | config()->setGroup("Personal Settings"); | ||
469 | mName = config()->readEntry("user_name",""); | ||
470 | mEmail = config()->readEntry("user_email",""); | ||
471 | fillMailDefaults(); | ||
472 | |||
473 | config()->setGroup("Category Colors"); | ||
474 | QStringList::Iterator it; | ||
475 | for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { | ||
476 | setCategoryColor(*it,config()->readColorEntry(*it,&mDefaultCategoryColor)); | ||
477 | |||
478 | } | ||
479 | |||
480 | if (mTimeZoneId.isEmpty()) { | ||
481 | setTimeZoneIdDefault(); | ||
482 | } | ||
483 | KPimPrefs::usrReadConfig(); | ||
484 | } | ||
485 | |||
486 | |||
487 | void KOPrefs::usrWriteConfig() | ||
488 | { | ||
489 | config()->setGroup("General"); | ||
490 | config()->writeEntry("Custom Categories",mCustomCategories); | ||
491 | |||
492 | config()->setGroup("Personal Settings"); | ||
493 | config()->writeEntry("user_name",mName); | ||
494 | config()->writeEntry("user_email",mEmail); | ||
495 | |||
496 | config()->setGroup("Category Colors"); | ||
497 | QDictIterator<QColor> it(mCategoryColors); | ||
498 | while (it.current()) { | ||
499 | config()->writeEntry(it.currentKey(),*(it.current())); | ||
500 | ++it; | ||
501 | } | ||
502 | |||
503 | |||
504 | KPimPrefs::usrWriteConfig(); | ||
505 | } | ||
506 | |||
507 | void KOPrefs::setCategoryColor(QString cat,const QColor & color) | ||
508 | { | ||
509 | mCategoryColors.replace(cat,new QColor(color)); | ||
510 | } | ||
511 | |||
512 | QColor *KOPrefs::categoryColor(QString cat) | ||
513 | { | ||
514 | QColor *color = 0; | ||
515 | |||
516 | if (!cat.isEmpty()) color = mCategoryColors[cat]; | ||
517 | |||
518 | if (color) return color; | ||
519 | else return &mDefaultCategoryColor; | ||
520 | } | ||
521 | |||
522 | void KOPrefs::setFullName(const QString &name) | ||
523 | { | ||
524 | mName = name; | ||
525 | } | ||
526 | |||
527 | void KOPrefs::setEmail(const QString &email) | ||
528 | { | ||
529 | //qDebug(" KOPrefs::setEmai*********** %s",email.latin1() ); | ||
530 | mEmail = email; | ||
531 | } | ||
532 | |||
533 | QString KOPrefs::fullName() | ||
534 | { | ||
535 | if (mEmailControlCenter) { | ||
536 | KEMailSettings settings; | ||
537 | return settings.getSetting(KEMailSettings::RealName); | ||
538 | } else { | ||
539 | return mName; | ||
540 | } | ||
541 | } | ||
542 | |||
543 | QString KOPrefs::email() | ||
544 | { | ||
545 | if (mEmailControlCenter) { | ||
546 | KEMailSettings settings; | ||
547 | return settings.getSetting(KEMailSettings::EmailAddress); | ||
548 | } else { | ||
549 | return mEmail; | ||
550 | } | ||
551 | } | ||
552 | KConfig* KOPrefs::getConfig() | ||
553 | { | ||
554 | return config(); | ||
555 | } | ||