summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--Makefile2
-rw-r--r--kaddressbook/kabprefs.cpp73
-rw-r--r--kaddressbook/kabprefs.h1
-rw-r--r--kmicromail/koprefs.h2
-rw-r--r--korganizer/kodialogmanager.cpp5
-rw-r--r--korganizer/koprefs.cpp88
-rw-r--r--korganizer/koprefs.h16
-rw-r--r--korganizer/ktimeedit.cpp5
-rw-r--r--korganizer/mainwindow.cpp3
-rw-r--r--libkdepim/kpimglobalprefs.cpp76
-rw-r--r--libkdepim/kpimglobalprefs.h2
-rw-r--r--microkde/kstaticdeleter.h5
-rw-r--r--pwmanager/pwmanager/pwmprefs.cpp12
13 files changed, 105 insertions, 185 deletions
diff --git a/Makefile b/Makefile
index 2f5691a..a88bd06 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
1############################################################################# 1#############################################################################
2# Makefile for building: kdepim-desktop 2# Makefile for building: kdepim-desktop
3# Generated by qmake (1.07a) (Qt 3.3.3) on: Sat Oct 23 09:29:11 2004 3# Generated by qmake (1.07a) (Qt 3.3.3) on: Sat Oct 23 12:23:49 2004
4# Project: kdepim-desktop.pro 4# Project: kdepim-desktop.pro
5# Template: subdirs 5# Template: subdirs
6# Command: $(QMAKE) "CONFIG+=thread" "CONFIG+=debug" -o Makefile kdepim-desktop.pro 6# Command: $(QMAKE) "CONFIG+=thread" "CONFIG+=debug" -o Makefile kdepim-desktop.pro
diff --git a/kaddressbook/kabprefs.cpp b/kaddressbook/kabprefs.cpp
index 01c935f..3cbcc9a 100644
--- a/kaddressbook/kabprefs.cpp
+++ b/kaddressbook/kabprefs.cpp
@@ -43,13 +43,11 @@
43#endif 43#endif
44 44
45KABPrefs *KABPrefs::sInstance = 0; 45KABPrefs *KABPrefs::sInstance = 0;
46static KStaticDeleter<KABPrefs> staticDeleter; 46static KStaticDeleter<KABPrefs> staticDeleterAB;
47 47
48KABPrefs::KABPrefs() 48KABPrefs::KABPrefs()
49 : KPimPrefs("kaddressbookrc") 49 : KPimPrefs("kaddressbookrc")
50{ 50{
51
52 mLocaleDict = 0;
53 mDetailsFont = QFont("helvetica",12); 51 mDetailsFont = QFont("helvetica",12);
54 KPrefs::setCurrentGroup( "Views" ); 52 KPrefs::setCurrentGroup( "Views" );
55 addItemBool( "HonorSingleClick", &mHonorSingleClick, false ); 53 addItemBool( "HonorSingleClick", &mHonorSingleClick, false );
@@ -96,19 +94,18 @@ KABPrefs::KABPrefs()
96KABPrefs::~KABPrefs() 94KABPrefs::~KABPrefs()
97{ 95{
98 //qDebug("KABPrefs::~KABPrefs() "); 96 //qDebug("KABPrefs::~KABPrefs() ");
99 setLocaleDict( 0 ); 97 if (sInstance == this)
100 if ( mLocaleDict ) 98 sInstance = staticDeleterAB.setObject(0);
101 delete mLocaleDict;
102} 99}
103 100
104KABPrefs *KABPrefs::instance() 101KABPrefs *KABPrefs::instance()
105{ 102{
106 if ( !sInstance ) { 103 if ( !sInstance ) {
107#ifdef KAB_EMBEDDED 104#ifdef KAB_EMBEDDED
108 sInstance = staticDeleter.setObject( new KABPrefs() ); 105 sInstance = staticDeleterAB.setObject( new KABPrefs() );
109#else //KAB_EMBEDDED 106#else //KAB_EMBEDDED
110 //US the following line has changed ???. Why 107 //US the following line has changed ???. Why
111 staticDeleter.setObject( sInstance, new KABPrefs() ); 108 staticDeleterAB.setObject( sInstance, new KABPrefs() );
112#endif //KAB_EMBEDDED 109#endif //KAB_EMBEDDED
113 sInstance->readConfig(); 110 sInstance->readConfig();
114 } 111 }
@@ -131,66 +128,6 @@ KConfig* KABPrefs::getConfig()
131} 128}
132void KABPrefs::usrReadConfig() 129void KABPrefs::usrReadConfig()
133{ 130{
134 QString fileName ;
135#ifndef DESKTOP_VERSION
136 fileName= QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/";
137#else
138 fileName = qApp->applicationDirPath () + "/kdepim/kaddressbook/";
139#endif
140 int mPreferredLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage;
141 mLocaleDict = 0;
142 if ( mPreferredLanguage > 0 && mPreferredLanguage < 5 ) {
143
144 if ( mPreferredLanguage == 1 )
145 fileName = fileName+"germantranslation.txt";
146 else if ( mPreferredLanguage == 4 )
147 fileName = fileName+"usertranslation.txt";
148 else if ( mPreferredLanguage == 2 )
149 fileName = fileName+"frenchtranslation.txt";
150 else if ( mPreferredLanguage == 3 )
151 fileName = fileName+"italiantranslation.txt";
152 QFile file( fileName );
153 if (file.open( IO_ReadOnly ) ) {
154 QTextStream ts( &file );
155 ts.setEncoding( QTextStream::Latin1 );
156 //ts.setCodec( QTextCodec::latin1 );
157 QString text = ts.read();
158 file.close();
159 text.replace( QRegExp("\\\\n"), "\n" );
160 QString line;
161 QString we;
162 QString wt;
163 int br = 0;
164 int nbr;
165 nbr = text.find ( "},", br );
166 line = text.mid( br, nbr - br );
167 br = nbr+1;
168 int se, ee, st, et;
169 mLocaleDict = new QDict<QString>;
170 QString end = "{ \"\",\"\" }";
171 while ( (line != end) && (br > 1) ) {
172 //qDebug("%d *%s* ", br, line.latin1());
173 se = line.find("\"")+1;
174 et = line.findRev("\"",-1);
175 ee = line.find("\",\"");
176 st = ee+3;
177 we = line.mid( se, ee-se );
178 wt = line.mid( st, et-st );
179 //qDebug("*%s* *%s* ", we.latin1(), wt.latin1());
180 mLocaleDict->insert( we, new QString (wt) );
181 nbr = text.find ( "}", br );
182 line = text.mid( br, nbr - br );
183 br = nbr+1;
184 }
185 //qDebug("end *%s* ", end.latin1());
186
187 setLocaleDict( mLocaleDict );
188 } else {
189 qDebug("KO: Cannot find translation file %s",fileName.latin1() );
190 }
191
192
193 }
194 KPimPrefs::usrReadConfig(); 131 KPimPrefs::usrReadConfig();
195} 132}
196 133
diff --git a/kaddressbook/kabprefs.h b/kaddressbook/kabprefs.h
index 1098f4c..cc8413e 100644
--- a/kaddressbook/kabprefs.h
+++ b/kaddressbook/kabprefs.h
@@ -89,7 +89,6 @@ class KABPrefs : public KPimPrefs
89 private: 89 private:
90 KABPrefs(); 90 KABPrefs();
91 91
92 QDict<QString> *mLocaleDict;
93 static KABPrefs *sInstance; 92 static KABPrefs *sInstance;
94}; 93};
95 94
diff --git a/kmicromail/koprefs.h b/kmicromail/koprefs.h
index a47642b..f0a4463 100644
--- a/kmicromail/koprefs.h
+++ b/kmicromail/koprefs.h
@@ -23,7 +23,6 @@
23#ifndef KOPREFS_H 23#ifndef KOPREFS_H
24#define KOPREFS_H 24#define KOPREFS_H
25 25
26#include <qdict.h>
27 26
28#include <libkdepim/kpimprefs.h> 27#include <libkdepim/kpimprefs.h>
29 28
@@ -62,7 +61,6 @@ class KOPrefs : public KPimPrefs
62 KOPrefs(); 61 KOPrefs();
63 62
64 static KOPrefs *mInstance; 63 static KOPrefs *mInstance;
65 QDict<QString> *mLocaleDict;
66 public: 64 public:
67 // preferences data 65 // preferences data
68 KConfig* getConfig(); 66 KConfig* getConfig();
diff --git a/korganizer/kodialogmanager.cpp b/korganizer/kodialogmanager.cpp
index 58198a2..db7c3f2 100644
--- a/korganizer/kodialogmanager.cpp
+++ b/korganizer/kodialogmanager.cpp
@@ -89,7 +89,7 @@ void KODialogManager::createOutgoingDialog()
89 89
90void KODialogManager::showOptionsDialog( bool showSync ) 90void KODialogManager::showOptionsDialog( bool showSync )
91{ 91{
92 int curLanguage = KOPrefs::instance()->mPreferredLanguage; 92
93 if (!mOptionsDialog) { 93 if (!mOptionsDialog) {
94 mOptionsDialog = new KOPrefsDialog(mMainView); 94 mOptionsDialog = new KOPrefsDialog(mMainView);
95 //mOptionsDialog->readConfig(); 95 //mOptionsDialog->readConfig();
@@ -108,8 +108,7 @@ void KODialogManager::showOptionsDialog( bool showSync )
108 if ( showSync ) 108 if ( showSync )
109 mOptionsDialog->showSyncPage(); 109 mOptionsDialog->showSyncPage();
110 mOptionsDialog->exec(); 110 mOptionsDialog->exec();
111 if ( curLanguage != KOPrefs::instance()->mPreferredLanguage ) 111
112 KOPrefs::instance()->mLanguageChanged = true;
113} 112}
114void KODialogManager::showSyncOptions() 113void KODialogManager::showSyncOptions()
115{ 114{
diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp
index ba1c6d1..f44debc 100644
--- a/korganizer/koprefs.cpp
+++ b/korganizer/koprefs.cpp
@@ -46,11 +46,6 @@
46#include "koprefs.h" 46#include "koprefs.h"
47#include "mainwindow.h" 47#include "mainwindow.h"
48 48
49const char *germanwords[][2] = {
50#include "wordsgerman.h"
51 "", ""
52};
53
54KOPrefs *KOPrefs::mInstance = 0; 49KOPrefs *KOPrefs::mInstance = 0;
55static KStaticDeleter<KOPrefs> insd; 50static KStaticDeleter<KOPrefs> insd;
56 51
@@ -58,7 +53,6 @@ KOPrefs::KOPrefs() :
58 KPimPrefs("korganizerrc") 53 KPimPrefs("korganizerrc")
59{ 54{
60 mCategoryColors.setAutoDelete(true); 55 mCategoryColors.setAutoDelete(true);
61 mLocaleDict = 0;
62 fillMailDefaults(); 56 fillMailDefaults();
63 mDefaultCategoryColor = QColor(175,210,255);//196,196,196); 57 mDefaultCategoryColor = QColor(175,210,255);//196,196,196);
64 QColor defaultHolidayColor = QColor(255,0,0); 58 QColor defaultHolidayColor = QColor(255,0,0);
@@ -100,7 +94,7 @@ KOPrefs::KOPrefs() :
100 addItemBool("ShowIconNext",&mShowIconNext,true); 94 addItemBool("ShowIconNext",&mShowIconNext,true);
101 addItemBool("ShowIconJournal",&mShowIconJournal,true); 95 addItemBool("ShowIconJournal",&mShowIconJournal,true);
102 addItemBool("ShowIconStretch",&mShowIconStretch,true); 96 addItemBool("ShowIconStretch",&mShowIconStretch,true);
103 addItemBool("LanguageChanged",&mLanguageChanged,false); 97 addItemInt("LastLoadedLanguage",&mOldLanguage,0);
104 98
105 addItemBool("AskForQuit",&mAskForQuit,false); 99 addItemBool("AskForQuit",&mAskForQuit,false);
106 100
@@ -204,13 +198,7 @@ KOPrefs::KOPrefs() :
204 198
205 199
206 KPrefs::setCurrentGroup("Locale"); 200 KPrefs::setCurrentGroup("Locale");
207 addItemInt("PreferredLanguage",&mPreferredLanguage,0);
208 addItemInt("PreferredTime",&mPreferredTime,0);
209 addItemInt("PreferredDate",&mPreferredDate,0);
210 addItemBool("WeekStartsOnSunday",&mWeekStartsOnSunday,false);
211 addItemBool("ShortDateInViewer",&mShortDateInViewer,false); 201 addItemBool("ShortDateInViewer",&mShortDateInViewer,false);
212 addItemString("UserDateFormatLong", &mUserDateFormatLong, "%A %d %b %y");
213 addItemString("UserDateFormatShort", &mUserDateFormatShort, "%aK %d.%m.%y");
214 202
215 203
216 KPrefs::setCurrentGroup("Colors"); 204 KPrefs::setCurrentGroup("Colors");
@@ -316,9 +304,7 @@ KOPrefs::~KOPrefs()
316{ 304{
317 if (mInstance == this) 305 if (mInstance == this)
318 mInstance = insd.setObject(0); 306 mInstance = insd.setObject(0);
319 setLocaleDict( 0 ); 307
320 if ( mLocaleDict )
321 delete mLocaleDict;
322 //qDebug("KOPrefs::~KOPrefs() "); 308 //qDebug("KOPrefs::~KOPrefs() ");
323} 309}
324 310
@@ -377,80 +363,16 @@ QStringList KOPrefs::getDefaultList()
377 363
378void KOPrefs::usrReadConfig() 364void KOPrefs::usrReadConfig()
379{ 365{
380 mPreferredLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage;
381 mLocaleDict = 0;
382 // pending LR fix translation
383 // qDebug("KOPrefs::usrReadConfig() fix translation ");
384 if ( mPreferredLanguage > 0 && mPreferredLanguage < 5 ) {
385 if ( mPreferredLanguage == 1 ) {
386 mLocaleDict = new QDict<QString>;
387 int i = 0;
388 QString fw ( germanwords[i] [0]);
389 while ( !fw.isEmpty() ) {
390 mLocaleDict->insert( fw, new QString (germanwords[i] [1] ));
391 ++i;
392 fw = germanwords[i] [0];
393 }
394
395 setLocaleDict( mLocaleDict );
396 } else {
397 QString fileName ;
398 if ( mPreferredLanguage == 4 )
399 fileName = MainWindow::resourcePath()+"usertranslation.txt";
400 else if ( mPreferredLanguage == 2 )
401 fileName = MainWindow::resourcePath()+"frenchtranslation.txt";
402 else if ( mPreferredLanguage == 3 )
403 fileName = MainWindow::resourcePath()+"italiantranslation.txt";
404 QFile file( fileName );
405 if (file.open( IO_ReadOnly ) ) {
406 QTextStream ts( &file );
407 ts.setEncoding( QTextStream::Latin1 );
408 //ts.setCodec( QTextCodec::latin1 );
409 QString text = ts.read();
410 file.close();
411 text.replace( QRegExp("\\\\n"), "\n" );
412 QString line;
413 QString we;
414 QString wt;
415 int br = 0;
416 int nbr;
417 nbr = text.find ( "},", br );
418 line = text.mid( br, nbr - br );
419 br = nbr+1;
420 int se, ee, st, et;
421 mLocaleDict = new QDict<QString>;
422 QString end = "{ \"\",\"\" }";
423 while ( (line != end) && (br > 1) ) {
424 //qDebug("%d *%s* ", br, line.latin1());
425 se = line.find("\"")+1;
426 et = line.findRev("\"",-1);
427 ee = line.find("\",\"");
428 st = ee+3;
429 we = line.mid( se, ee-se );
430 wt = line.mid( st, et-st );
431 //qDebug("*%s* *%s* ", we.latin1(), wt.latin1());
432 mLocaleDict->insert( we, new QString (wt) );
433 nbr = text.find ( "}", br );
434 line = text.mid( br, nbr - br );
435 br = nbr+1;
436 }
437 //qDebug("end *%s* ", end.latin1());
438
439 setLocaleDict( mLocaleDict );
440 } else {
441 qDebug("KO: Cannot find translation file %s",fileName.latin1() );
442 }
443
444 }
445 }
446 config()->setGroup("General"); 366 config()->setGroup("General");
447 367
448 mCustomCategories = config()->readListEntry("Custom Categories"); 368 mCustomCategories = config()->readListEntry("Custom Categories");
449 if ( KOPrefs::instance()->mLanguageChanged ) { 369 if ( KPimGlobalPrefs::instance()->mPreferredLanguage != mOldLanguage ) {
450 mLocationDefaults.clear(); 370 mLocationDefaults.clear();
451 mEventSummaryUser.clear(); 371 mEventSummaryUser.clear();
452 mTodoSummaryUser.clear(); 372 mTodoSummaryUser.clear();
453 } 373 }
374 mOldLoadedLanguage = mOldLanguage ;
375 mOldLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage;
454 if (mLocationDefaults.isEmpty()) { 376 if (mLocationDefaults.isEmpty()) {
455 mLocationDefaults << i18n("Home") << i18n("Office") << i18n("Library") << i18n("School") << i18n("Doctor") << i18n("Beach") 377 mLocationDefaults << i18n("Home") << i18n("Office") << i18n("Library") << i18n("School") << i18n("Doctor") << i18n("Beach")
456 << i18n("University") << i18n("Restaurant") << i18n("Bar") << i18n("Conference room") << i18n("Cinema") << i18n("Lake") << i18n("Kindergarten") 378 << i18n("University") << i18n("Restaurant") << i18n("Bar") << i18n("Conference room") << i18n("Cinema") << i18n("Lake") << i18n("Kindergarten")
diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h
index c74b0ef..0656644 100644
--- a/korganizer/koprefs.h
+++ b/korganizer/koprefs.h
@@ -23,9 +23,9 @@
23#ifndef KOPREFS_H 23#ifndef KOPREFS_H
24#define KOPREFS_H 24#define KOPREFS_H
25 25
26#include <qdict.h>
27 26
28#include <libkdepim/kpimprefs.h> 27#include <libkdepim/kpimprefs.h>
28#include <qdict.h>
29 29
30class KConfig; 30class KConfig;
31class QFont; 31class QFont;
@@ -70,7 +70,6 @@ class KOPrefs : public KPimPrefs
70 KOPrefs(); 70 KOPrefs();
71 71
72 static KOPrefs *mInstance; 72 static KOPrefs *mInstance;
73 QDict<QString> *mLocaleDict;
74 QStringList getDefaultList(); 73 QStringList getDefaultList();
75 public: 74 public:
76 // preferences data 75 // preferences data
@@ -158,7 +157,6 @@ class KOPrefs : public KPimPrefs
158 int mWhatsNextDays; 157 int mWhatsNextDays;
159 int mWhatsNextPrios; 158 int mWhatsNextPrios;
160 bool mEnableQuickTodo; 159 bool mEnableQuickTodo;
161 bool mLanguageChanged;
162 160
163 bool mCompactDialogs; 161 bool mCompactDialogs;
164 bool mVerticalScreen; 162 bool mVerticalScreen;
@@ -253,21 +251,13 @@ class KOPrefs : public KPimPrefs
253 int mAlarmSuspendTime; 251 int mAlarmSuspendTime;
254 int mAlarmSuspendCount; 252 int mAlarmSuspendCount;
255 int mAlarmBeepInterval; 253 int mAlarmBeepInterval;
254 int mOldLanguage;
255 int mOldLoadedLanguage;
256 256
257 257
258 QString mActiveSyncPort; 258 QString mActiveSyncPort;
259 QString mActiveSyncIP; 259 QString mActiveSyncIP;
260 260
261
262 //US I copied the following settings into KPimGlobalPrefs
263 // that allows us later to easily remove the settings from here.
264 int mPreferredDate;
265 QString mUserDateFormatLong;
266 QString mUserDateFormatShort;
267 int mPreferredLanguage;
268 int mPreferredTime;
269 bool mWeekStartsOnSunday;
270
271 private: 261 private:
272 QDict<QColor> mCategoryColors; 262 QDict<QColor> mCategoryColors;
273 QColor mDefaultCategoryColor; 263 QColor mDefaultCategoryColor;
diff --git a/korganizer/ktimeedit.cpp b/korganizer/ktimeedit.cpp
index cf07a1a..f5a1c50 100644
--- a/korganizer/ktimeedit.cpp
+++ b/korganizer/ktimeedit.cpp
@@ -31,6 +31,7 @@
31#include <kglobal.h> 31#include <kglobal.h>
32#include <kdebug.h> 32#include <kdebug.h>
33#include <klocale.h> 33#include <klocale.h>
34#include <kpimglobalprefs.h>
34 35
35#include "ktimeedit.h" 36#include "ktimeedit.h"
36#include "koprefs.h" 37#include "koprefs.h"
@@ -111,7 +112,7 @@ KOTimeEdit::KOTimeEdit(QWidget *parent, QTime qt, const char *name)
111 connect(this,SIGNAL(textChanged(const QString&)),this,SLOT(changedText())); 112 connect(this,SIGNAL(textChanged(const QString&)),this,SLOT(changedText()));
112 QFontMetrics fm ( font() ); 113 QFontMetrics fm ( font() );
113 QString timeString = "24:00"; 114 QString timeString = "24:00";
114 if ( KOPrefs::instance()->mPreferredTime == 1 ) 115 if ( KPimGlobalPrefs::instance()->mPreferredTime == 1 )
115 timeString = "02:00pm"; 116 timeString = "02:00pm";
116 int addSpace = 32; 117 int addSpace = 32;
117 if ( QApplication::desktop()->width() > 320 ) 118 if ( QApplication::desktop()->width() > 320 )
@@ -238,7 +239,7 @@ void KOTimeEdit::keyPressEvent(QKeyEvent *e)
238{ 239{
239 240
240 qApp->processEvents(); 241 qApp->processEvents();
241 bool hour12Format = ( KOPrefs::instance()->mPreferredTime == 1 ); 242 bool hour12Format = ( KPimGlobalPrefs::instance()->mPreferredTime == 1 );
242 int maxpos = hour12Format?7:5; 243 int maxpos = hour12Format?7:5;
243 if ( e->isAutoRepeat() && !mFlagKeyPressed ) { 244 if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
244 e->ignore(); 245 e->ignore();
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index fbfcd20..dc2026b 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -225,10 +225,9 @@ MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
225 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 225 int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() );
226 qDebug("KO: Calendar loading time: %d ms",msNeeded ); 226 qDebug("KO: Calendar loading time: %d ms",msNeeded );
227 227
228 if ( KOPrefs::instance()->mLanguageChanged ) { 228 if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) {
229 KOPrefs::instance()->setCategoryDefaults(); 229 KOPrefs::instance()->setCategoryDefaults();
230 int count = mView->addCategories(); 230 int count = mView->addCategories();
231 KOPrefs::instance()->mLanguageChanged = false;
232 } 231 }
233 processIncidenceSelection( 0 ); 232 processIncidenceSelection( 0 );
234 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), 233 connect( mView, SIGNAL( incidenceSelected( Incidence * ) ),
diff --git a/libkdepim/kpimglobalprefs.cpp b/libkdepim/kpimglobalprefs.cpp
index 0a580ca..5298f0c 100644
--- a/libkdepim/kpimglobalprefs.cpp
+++ b/libkdepim/kpimglobalprefs.cpp
@@ -35,16 +35,19 @@ $Id$
35#include <kstaticdeleter.h> 35#include <kstaticdeleter.h>
36 36
37#include <qregexp.h> 37#include <qregexp.h>
38#include <qfile.h>
39#include <qtextstream.h>
40#include <qapplication.h>
38#include "kpimglobalprefs.h" 41#include "kpimglobalprefs.h"
39 42
40KPimGlobalPrefs *KPimGlobalPrefs::sInstance = 0; 43KPimGlobalPrefs *KPimGlobalPrefs::sInstance = 0;
41static KStaticDeleter<KPimGlobalPrefs> staticDeleter; 44static KStaticDeleter<KPimGlobalPrefs> staticDeleterGP;
42 45
43 46
44KPimGlobalPrefs::KPimGlobalPrefs( const QString &name ) 47KPimGlobalPrefs::KPimGlobalPrefs( const QString &name )
45 : KPrefs("microkdeglobalrc") 48 : KPrefs("microkdeglobalrc")
46{ 49{
47 50 mLocaleDict = 0;
48 KPrefs::setCurrentGroup("Locale"); 51 KPrefs::setCurrentGroup("Locale");
49 addItemInt("PreferredLanguage",&mPreferredLanguage,0); 52 addItemInt("PreferredLanguage",&mPreferredLanguage,0);
50 addItemInt("PreferredTime",&mPreferredTime,0); 53 addItemInt("PreferredTime",&mPreferredTime,0);
@@ -104,9 +107,68 @@ KPimGlobalPrefs::KPimGlobalPrefs( const QString &name )
104 107
105} 108}
106 109
107
108void KPimGlobalPrefs::setGlobalConfig() 110void KPimGlobalPrefs::setGlobalConfig()
109{ 111{
112 if ( mLocaleDict == 0 ) {
113 QString fileName ;
114 QString name = KGlobal::getAppName() +"/";
115#ifndef DESKTOP_VERSION
116 fileName= QString(getenv("QPEDIR"))+"/pics/kdepim/"+name
117#else
118 fileName = qApp->applicationDirPath () + "/kdepim/"+ name;
119#endif
120 mLocaleDict = 0;
121 if ( mPreferredLanguage > 0 && mPreferredLanguage < 5 ) {
122
123 if ( mPreferredLanguage == 1 )
124 fileName = fileName+"germantranslation.txt";
125 else if ( mPreferredLanguage == 4 )
126 fileName = fileName+"usertranslation.txt";
127 else if ( mPreferredLanguage == 2 )
128 fileName = fileName+"frenchtranslation.txt";
129 else if ( mPreferredLanguage == 3 )
130 fileName = fileName+"italiantranslation.txt";
131 QFile file( fileName );
132 if (file.open( IO_ReadOnly ) ) {
133 QTextStream ts( &file );
134 ts.setEncoding( QTextStream::Latin1 );
135 //ts.setCodec( QTextCodec::latin1 );
136 QString text = ts.read();
137 file.close();
138 text.replace( QRegExp("\\\\n"), "\n" );
139 QString line;
140 QString we;
141 QString wt;
142 int br = 0;
143 int nbr;
144 nbr = text.find ( "},", br );
145 line = text.mid( br, nbr - br );
146 br = nbr+1;
147 int se, ee, st, et;
148 mLocaleDict = new QDict<QString>;
149 QString end = "{ \"\",\"\" }";
150 while ( (line != end) && (br > 1) ) {
151 //qDebug("%d *%s* ", br, line.latin1());
152 se = line.find("\"")+1;
153 et = line.findRev("\"",-1);
154 ee = line.find("\",\"");
155 st = ee+3;
156 we = line.mid( se, ee-se );
157 wt = line.mid( st, et-st );
158 //qDebug("*%s* *%s* ", we.latin1(), wt.latin1());
159 mLocaleDict->insert( we, new QString (wt) );
160 nbr = text.find ( "}", br );
161 line = text.mid( br, nbr - br );
162 br = nbr+1;
163 }
164 //qDebug("end *%s* ", end.latin1());
165
166 setLocaleDict( mLocaleDict );
167 } else {
168 qDebug("KO: Cannot find translation file %s",fileName.latin1() );
169 }
170 }
171 }
110 172
111 KGlobal::locale()->setHore24Format( !mPreferredTime ); 173 KGlobal::locale()->setHore24Format( !mPreferredTime );
112 KGlobal::locale()->setWeekStartMonday( !mWeekStartsOnSunday ); 174 KGlobal::locale()->setWeekStartMonday( !mWeekStartsOnSunday );
@@ -124,14 +186,20 @@ void KPimGlobalPrefs::setGlobalConfig()
124} 186}
125KPimGlobalPrefs::~KPimGlobalPrefs() 187KPimGlobalPrefs::~KPimGlobalPrefs()
126{ 188{
189 if (sInstance == this)
190 sInstance = staticDeleterGP.setObject(0);
191 else
192 qDebug("Whats this? Error in KPimGlobalPrefs::~KPimGlobalPrefs() ?");
127 //qDebug("KPimGlobalPrefs::~KPimGlobalPrefs() "); 193 //qDebug("KPimGlobalPrefs::~KPimGlobalPrefs() ");
128 writeConfig(); 194 writeConfig();
195 if ( mLocaleDict )
196 delete mLocaleDict;
129} 197}
130 198
131KPimGlobalPrefs *KPimGlobalPrefs::instance() 199KPimGlobalPrefs *KPimGlobalPrefs::instance()
132{ 200{
133 if ( !sInstance ) { 201 if ( !sInstance ) {
134 sInstance = staticDeleter.setObject( new KPimGlobalPrefs() ); 202 sInstance = staticDeleterGP.setObject( new KPimGlobalPrefs() );
135 sInstance->readConfig(); 203 sInstance->readConfig();
136 } 204 }
137 205
diff --git a/libkdepim/kpimglobalprefs.h b/libkdepim/kpimglobalprefs.h
index d09c3da..11c534a 100644
--- a/libkdepim/kpimglobalprefs.h
+++ b/libkdepim/kpimglobalprefs.h
@@ -32,6 +32,7 @@ $Id$
32#define KPIMGLOBALPREFS_H 32#define KPIMGLOBALPREFS_H
33 33
34#include "kprefs.h" 34#include "kprefs.h"
35#include <qdict.h>
35 36
36class KPimGlobalPrefs : public KPrefs 37class KPimGlobalPrefs : public KPrefs
37{ 38{
@@ -83,6 +84,7 @@ class KPimGlobalPrefs : public KPrefs
83 KPimGlobalPrefs( const QString &name = QString::null ); 84 KPimGlobalPrefs( const QString &name = QString::null );
84 85
85 static KPimGlobalPrefs *sInstance; 86 static KPimGlobalPrefs *sInstance;
87 QDict<QString> *mLocaleDict;
86 88
87 89
88 public: 90 public:
diff --git a/microkde/kstaticdeleter.h b/microkde/kstaticdeleter.h
index dfd3929..d9c2b72 100644
--- a/microkde/kstaticdeleter.h
+++ b/microkde/kstaticdeleter.h
@@ -28,10 +28,11 @@ class KStaticDeleter
28{ 28{
29 public: 29 public:
30 KStaticDeleter() {}; 30 KStaticDeleter() {};
31 type *setObject( type *obj, bool isArray = false) { _mobj = obj;return obj; } 31 type *setObject( type *obj, bool isArray = false) { _mobj = obj;_isArray = isArray;return obj; }
32 virtual ~KStaticDeleter() {delete _mobj;}; 32 virtual ~KStaticDeleter() {if (_isArray) delete[] _mobj; else delete _mobj;};
33 private: 33 private:
34 type* _mobj; 34 type* _mobj;
35 bool _isArray;
35}; 36};
36 37
37#endif 38#endif
diff --git a/pwmanager/pwmanager/pwmprefs.cpp b/pwmanager/pwmanager/pwmprefs.cpp
index fdc34e0..68d5b68 100644
--- a/pwmanager/pwmanager/pwmprefs.cpp
+++ b/pwmanager/pwmanager/pwmprefs.cpp
@@ -31,7 +31,7 @@
31#include "pwmprefs.h" 31#include "pwmprefs.h"
32 32
33PWMPrefs *PWMPrefs::sInstance = 0; 33PWMPrefs *PWMPrefs::sInstance = 0;
34static KStaticDeleter<PWMPrefs> staticDeleter; 34static KStaticDeleter<PWMPrefs> staticDeleterPP;
35 35
36PWMPrefs::PWMPrefs() 36PWMPrefs::PWMPrefs()
37 : KPimPrefs("pwmanagerrc") 37 : KPimPrefs("pwmanagerrc")
@@ -68,17 +68,21 @@ PWMPrefs::PWMPrefs()
68} 68}
69 69
70PWMPrefs::~PWMPrefs() 70PWMPrefs::~PWMPrefs()
71{ 71{
72 if (sInstance == this)
73 sInstance = staticDeleterPP.setObject(0);
74 else
75 qDebug("Whats this? Error in PWMPrefs::~PWMPrefs()?");
72} 76}
73 77
74PWMPrefs *PWMPrefs::instance() 78PWMPrefs *PWMPrefs::instance()
75{ 79{
76 if ( !sInstance ) { 80 if ( !sInstance ) {
77#ifdef PWM_EMBEDDED 81#ifdef PWM_EMBEDDED
78 sInstance = staticDeleter.setObject( new PWMPrefs() ); 82 sInstance = staticDeleterPP.setObject( new PWMPrefs() );
79#else //PWM_EMBEDDED 83#else //PWM_EMBEDDED
80 //US the following line has changed ???. Why 84 //US the following line has changed ???. Why
81 staticDeleter.setObject( sInstance, new PWMPrefs() ); 85 staticDeleterPP.setObject( sInstance, new PWMPrefs() );
82#endif //KAB_EMBEDDED 86#endif //KAB_EMBEDDED
83 sInstance->readConfig(); 87 sInstance->readConfig();
84 } 88 }