summaryrefslogtreecommitdiffabout
Side-by-side diff
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
@@ -2,3 +2,3 @@
# Makefile for building: kdepim-desktop
-# Generated by qmake (1.07a) (Qt 3.3.3) on: Sat Oct 23 09:29:11 2004
+# Generated by qmake (1.07a) (Qt 3.3.3) on: Sat Oct 23 12:23:49 2004
# Project: 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
@@ -45,3 +45,3 @@
KABPrefs *KABPrefs::sInstance = 0;
-static KStaticDeleter<KABPrefs> staticDeleter;
+static KStaticDeleter<KABPrefs> staticDeleterAB;
@@ -50,4 +50,2 @@ KABPrefs::KABPrefs()
{
-
- mLocaleDict = 0;
mDetailsFont = QFont("helvetica",12);
@@ -98,5 +96,4 @@ KABPrefs::~KABPrefs()
//qDebug("KABPrefs::~KABPrefs() ");
- setLocaleDict( 0 );
- if ( mLocaleDict )
- delete mLocaleDict;
+ if (sInstance == this)
+ sInstance = staticDeleterAB.setObject(0);
}
@@ -107,6 +104,6 @@ KABPrefs *KABPrefs::instance()
#ifdef KAB_EMBEDDED
- sInstance = staticDeleter.setObject( new KABPrefs() );
+ sInstance = staticDeleterAB.setObject( new KABPrefs() );
#else //KAB_EMBEDDED
//US the following line has changed ???. Why
- staticDeleter.setObject( sInstance, new KABPrefs() );
+ staticDeleterAB.setObject( sInstance, new KABPrefs() );
#endif //KAB_EMBEDDED
@@ -133,62 +130,2 @@ void KABPrefs::usrReadConfig()
{
- QString fileName ;
-#ifndef DESKTOP_VERSION
- fileName= QString(getenv("QPEDIR"))+"/pics/kdepim/kaddressbook/";
-#else
- fileName = qApp->applicationDirPath () + "/kdepim/kaddressbook/";
-#endif
- int mPreferredLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage;
- mLocaleDict = 0;
- if ( mPreferredLanguage > 0 && mPreferredLanguage < 5 ) {
-
- if ( mPreferredLanguage == 1 )
- fileName = fileName+"germantranslation.txt";
- else if ( mPreferredLanguage == 4 )
- fileName = fileName+"usertranslation.txt";
- else if ( mPreferredLanguage == 2 )
- fileName = fileName+"frenchtranslation.txt";
- else if ( mPreferredLanguage == 3 )
- fileName = fileName+"italiantranslation.txt";
- QFile file( fileName );
- if (file.open( IO_ReadOnly ) ) {
- QTextStream ts( &file );
- ts.setEncoding( QTextStream::Latin1 );
- //ts.setCodec( QTextCodec::latin1 );
- QString text = ts.read();
- file.close();
- text.replace( QRegExp("\\\\n"), "\n" );
- QString line;
- QString we;
- QString wt;
- int br = 0;
- int nbr;
- nbr = text.find ( "},", br );
- line = text.mid( br, nbr - br );
- br = nbr+1;
- int se, ee, st, et;
- mLocaleDict = new QDict<QString>;
- QString end = "{ \"\",\"\" }";
- while ( (line != end) && (br > 1) ) {
- //qDebug("%d *%s* ", br, line.latin1());
- se = line.find("\"")+1;
- et = line.findRev("\"",-1);
- ee = line.find("\",\"");
- st = ee+3;
- we = line.mid( se, ee-se );
- wt = line.mid( st, et-st );
- //qDebug("*%s* *%s* ", we.latin1(), wt.latin1());
- mLocaleDict->insert( we, new QString (wt) );
- nbr = text.find ( "}", br );
- line = text.mid( br, nbr - br );
- br = nbr+1;
- }
- //qDebug("end *%s* ", end.latin1());
-
- setLocaleDict( mLocaleDict );
- } else {
- qDebug("KO: Cannot find translation file %s",fileName.latin1() );
- }
-
-
- }
KPimPrefs::usrReadConfig();
diff --git a/kaddressbook/kabprefs.h b/kaddressbook/kabprefs.h
index 1098f4c..cc8413e 100644
--- a/kaddressbook/kabprefs.h
+++ b/kaddressbook/kabprefs.h
@@ -91,3 +91,2 @@ class KABPrefs : public KPimPrefs
- QDict<QString> *mLocaleDict;
static KABPrefs *sInstance;
diff --git a/kmicromail/koprefs.h b/kmicromail/koprefs.h
index a47642b..f0a4463 100644
--- a/kmicromail/koprefs.h
+++ b/kmicromail/koprefs.h
@@ -25,3 +25,2 @@
-#include <qdict.h>
@@ -64,3 +63,2 @@ class KOPrefs : public KPimPrefs
static KOPrefs *mInstance;
- QDict<QString> *mLocaleDict;
public:
diff --git a/korganizer/kodialogmanager.cpp b/korganizer/kodialogmanager.cpp
index 58198a2..db7c3f2 100644
--- a/korganizer/kodialogmanager.cpp
+++ b/korganizer/kodialogmanager.cpp
@@ -91,3 +91,3 @@ void KODialogManager::showOptionsDialog( bool showSync )
{
- int curLanguage = KOPrefs::instance()->mPreferredLanguage;
+
if (!mOptionsDialog) {
@@ -110,4 +110,3 @@ void KODialogManager::showOptionsDialog( bool showSync )
mOptionsDialog->exec();
- if ( curLanguage != KOPrefs::instance()->mPreferredLanguage )
- KOPrefs::instance()->mLanguageChanged = true;
+
}
diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp
index ba1c6d1..f44debc 100644
--- a/korganizer/koprefs.cpp
+++ b/korganizer/koprefs.cpp
@@ -48,7 +48,2 @@
-const char *germanwords[][2] = {
-#include "wordsgerman.h"
- "", ""
-};
-
KOPrefs *KOPrefs::mInstance = 0;
@@ -60,3 +55,2 @@ KOPrefs::KOPrefs() :
mCategoryColors.setAutoDelete(true);
- mLocaleDict = 0;
fillMailDefaults();
@@ -102,3 +96,3 @@ KOPrefs::KOPrefs() :
addItemBool("ShowIconStretch",&mShowIconStretch,true);
- addItemBool("LanguageChanged",&mLanguageChanged,false);
+ addItemInt("LastLoadedLanguage",&mOldLanguage,0);
@@ -206,9 +200,3 @@ KOPrefs::KOPrefs() :
KPrefs::setCurrentGroup("Locale");
- addItemInt("PreferredLanguage",&mPreferredLanguage,0);
- addItemInt("PreferredTime",&mPreferredTime,0);
- addItemInt("PreferredDate",&mPreferredDate,0);
- addItemBool("WeekStartsOnSunday",&mWeekStartsOnSunday,false);
addItemBool("ShortDateInViewer",&mShortDateInViewer,false);
- addItemString("UserDateFormatLong", &mUserDateFormatLong, "%A %d %b %y");
- addItemString("UserDateFormatShort", &mUserDateFormatShort, "%aK %d.%m.%y");
@@ -318,5 +306,3 @@ KOPrefs::~KOPrefs()
mInstance = insd.setObject(0);
- setLocaleDict( 0 );
- if ( mLocaleDict )
- delete mLocaleDict;
+
//qDebug("KOPrefs::~KOPrefs() ");
@@ -379,68 +365,2 @@ void KOPrefs::usrReadConfig()
{
- mPreferredLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage;
- mLocaleDict = 0;
- // pending LR fix translation
- // qDebug("KOPrefs::usrReadConfig() fix translation ");
- if ( mPreferredLanguage > 0 && mPreferredLanguage < 5 ) {
- if ( mPreferredLanguage == 1 ) {
- mLocaleDict = new QDict<QString>;
- int i = 0;
- QString fw ( germanwords[i] [0]);
- while ( !fw.isEmpty() ) {
- mLocaleDict->insert( fw, new QString (germanwords[i] [1] ));
- ++i;
- fw = germanwords[i] [0];
- }
-
- setLocaleDict( mLocaleDict );
- } else {
- QString fileName ;
- if ( mPreferredLanguage == 4 )
- fileName = MainWindow::resourcePath()+"usertranslation.txt";
- else if ( mPreferredLanguage == 2 )
- fileName = MainWindow::resourcePath()+"frenchtranslation.txt";
- else if ( mPreferredLanguage == 3 )
- fileName = MainWindow::resourcePath()+"italiantranslation.txt";
- QFile file( fileName );
- if (file.open( IO_ReadOnly ) ) {
- QTextStream ts( &file );
- ts.setEncoding( QTextStream::Latin1 );
- //ts.setCodec( QTextCodec::latin1 );
- QString text = ts.read();
- file.close();
- text.replace( QRegExp("\\\\n"), "\n" );
- QString line;
- QString we;
- QString wt;
- int br = 0;
- int nbr;
- nbr = text.find ( "},", br );
- line = text.mid( br, nbr - br );
- br = nbr+1;
- int se, ee, st, et;
- mLocaleDict = new QDict<QString>;
- QString end = "{ \"\",\"\" }";
- while ( (line != end) && (br > 1) ) {
- //qDebug("%d *%s* ", br, line.latin1());
- se = line.find("\"")+1;
- et = line.findRev("\"",-1);
- ee = line.find("\",\"");
- st = ee+3;
- we = line.mid( se, ee-se );
- wt = line.mid( st, et-st );
- //qDebug("*%s* *%s* ", we.latin1(), wt.latin1());
- mLocaleDict->insert( we, new QString (wt) );
- nbr = text.find ( "}", br );
- line = text.mid( br, nbr - br );
- br = nbr+1;
- }
- //qDebug("end *%s* ", end.latin1());
-
- setLocaleDict( mLocaleDict );
- } else {
- qDebug("KO: Cannot find translation file %s",fileName.latin1() );
- }
-
- }
- }
config()->setGroup("General");
@@ -448,3 +368,3 @@ void KOPrefs::usrReadConfig()
mCustomCategories = config()->readListEntry("Custom Categories");
- if ( KOPrefs::instance()->mLanguageChanged ) {
+ if ( KPimGlobalPrefs::instance()->mPreferredLanguage != mOldLanguage ) {
mLocationDefaults.clear();
@@ -453,2 +373,4 @@ void KOPrefs::usrReadConfig()
}
+ mOldLoadedLanguage = mOldLanguage ;
+ mOldLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage;
if (mLocationDefaults.isEmpty()) {
diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h
index c74b0ef..0656644 100644
--- a/korganizer/koprefs.h
+++ b/korganizer/koprefs.h
@@ -25,5 +25,5 @@
-#include <qdict.h>
#include <libkdepim/kpimprefs.h>
+#include <qdict.h>
@@ -72,3 +72,2 @@ class KOPrefs : public KPimPrefs
static KOPrefs *mInstance;
- QDict<QString> *mLocaleDict;
QStringList getDefaultList();
@@ -160,3 +159,2 @@ class KOPrefs : public KPimPrefs
bool mEnableQuickTodo;
- bool mLanguageChanged;
@@ -255,2 +253,4 @@ class KOPrefs : public KPimPrefs
int mAlarmBeepInterval;
+ int mOldLanguage;
+ int mOldLoadedLanguage;
@@ -260,12 +260,2 @@ class KOPrefs : public KPimPrefs
-
- //US I copied the following settings into KPimGlobalPrefs
- // that allows us later to easily remove the settings from here.
- int mPreferredDate;
- QString mUserDateFormatLong;
- QString mUserDateFormatShort;
- int mPreferredLanguage;
- int mPreferredTime;
- bool mWeekStartsOnSunday;
-
private:
diff --git a/korganizer/ktimeedit.cpp b/korganizer/ktimeedit.cpp
index cf07a1a..f5a1c50 100644
--- a/korganizer/ktimeedit.cpp
+++ b/korganizer/ktimeedit.cpp
@@ -33,2 +33,3 @@
#include <klocale.h>
+#include <kpimglobalprefs.h>
@@ -113,3 +114,3 @@ KOTimeEdit::KOTimeEdit(QWidget *parent, QTime qt, const char *name)
QString timeString = "24:00";
- if ( KOPrefs::instance()->mPreferredTime == 1 )
+ if ( KPimGlobalPrefs::instance()->mPreferredTime == 1 )
timeString = "02:00pm";
@@ -240,3 +241,3 @@ void KOTimeEdit::keyPressEvent(QKeyEvent *e)
qApp->processEvents();
- bool hour12Format = ( KOPrefs::instance()->mPreferredTime == 1 );
+ bool hour12Format = ( KPimGlobalPrefs::instance()->mPreferredTime == 1 );
int maxpos = hour12Format?7:5;
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index fbfcd20..dc2026b 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -227,6 +227,5 @@ MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
- if ( KOPrefs::instance()->mLanguageChanged ) {
+ if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) {
KOPrefs::instance()->setCategoryDefaults();
int count = mView->addCategories();
- KOPrefs::instance()->mLanguageChanged = false;
}
diff --git a/libkdepim/kpimglobalprefs.cpp b/libkdepim/kpimglobalprefs.cpp
index 0a580ca..5298f0c 100644
--- a/libkdepim/kpimglobalprefs.cpp
+++ b/libkdepim/kpimglobalprefs.cpp
@@ -37,2 +37,5 @@ $Id$
#include <qregexp.h>
+#include <qfile.h>
+#include <qtextstream.h>
+#include <qapplication.h>
#include "kpimglobalprefs.h"
@@ -40,3 +43,3 @@ $Id$
KPimGlobalPrefs *KPimGlobalPrefs::sInstance = 0;
-static KStaticDeleter<KPimGlobalPrefs> staticDeleter;
+static KStaticDeleter<KPimGlobalPrefs> staticDeleterGP;
@@ -46,3 +49,3 @@ KPimGlobalPrefs::KPimGlobalPrefs( const QString &name )
{
-
+ mLocaleDict = 0;
KPrefs::setCurrentGroup("Locale");
@@ -106,5 +109,64 @@ KPimGlobalPrefs::KPimGlobalPrefs( const QString &name )
-
void KPimGlobalPrefs::setGlobalConfig()
{
+ if ( mLocaleDict == 0 ) {
+ QString fileName ;
+ QString name = KGlobal::getAppName() +"/";
+#ifndef DESKTOP_VERSION
+ fileName= QString(getenv("QPEDIR"))+"/pics/kdepim/"+name
+#else
+ fileName = qApp->applicationDirPath () + "/kdepim/"+ name;
+#endif
+ mLocaleDict = 0;
+ if ( mPreferredLanguage > 0 && mPreferredLanguage < 5 ) {
+
+ if ( mPreferredLanguage == 1 )
+ fileName = fileName+"germantranslation.txt";
+ else if ( mPreferredLanguage == 4 )
+ fileName = fileName+"usertranslation.txt";
+ else if ( mPreferredLanguage == 2 )
+ fileName = fileName+"frenchtranslation.txt";
+ else if ( mPreferredLanguage == 3 )
+ fileName = fileName+"italiantranslation.txt";
+ QFile file( fileName );
+ if (file.open( IO_ReadOnly ) ) {
+ QTextStream ts( &file );
+ ts.setEncoding( QTextStream::Latin1 );
+ //ts.setCodec( QTextCodec::latin1 );
+ QString text = ts.read();
+ file.close();
+ text.replace( QRegExp("\\\\n"), "\n" );
+ QString line;
+ QString we;
+ QString wt;
+ int br = 0;
+ int nbr;
+ nbr = text.find ( "},", br );
+ line = text.mid( br, nbr - br );
+ br = nbr+1;
+ int se, ee, st, et;
+ mLocaleDict = new QDict<QString>;
+ QString end = "{ \"\",\"\" }";
+ while ( (line != end) && (br > 1) ) {
+ //qDebug("%d *%s* ", br, line.latin1());
+ se = line.find("\"")+1;
+ et = line.findRev("\"",-1);
+ ee = line.find("\",\"");
+ st = ee+3;
+ we = line.mid( se, ee-se );
+ wt = line.mid( st, et-st );
+ //qDebug("*%s* *%s* ", we.latin1(), wt.latin1());
+ mLocaleDict->insert( we, new QString (wt) );
+ nbr = text.find ( "}", br );
+ line = text.mid( br, nbr - br );
+ br = nbr+1;
+ }
+ //qDebug("end *%s* ", end.latin1());
+
+ setLocaleDict( mLocaleDict );
+ } else {
+ qDebug("KO: Cannot find translation file %s",fileName.latin1() );
+ }
+ }
+ }
@@ -126,4 +188,10 @@ KPimGlobalPrefs::~KPimGlobalPrefs()
{
+ if (sInstance == this)
+ sInstance = staticDeleterGP.setObject(0);
+ else
+ qDebug("Whats this? Error in KPimGlobalPrefs::~KPimGlobalPrefs() ?");
//qDebug("KPimGlobalPrefs::~KPimGlobalPrefs() ");
writeConfig();
+ if ( mLocaleDict )
+ delete mLocaleDict;
}
@@ -133,3 +201,3 @@ KPimGlobalPrefs *KPimGlobalPrefs::instance()
if ( !sInstance ) {
- sInstance = staticDeleter.setObject( new KPimGlobalPrefs() );
+ sInstance = staticDeleterGP.setObject( new KPimGlobalPrefs() );
sInstance->readConfig();
diff --git a/libkdepim/kpimglobalprefs.h b/libkdepim/kpimglobalprefs.h
index d09c3da..11c534a 100644
--- a/libkdepim/kpimglobalprefs.h
+++ b/libkdepim/kpimglobalprefs.h
@@ -34,2 +34,3 @@ $Id$
#include "kprefs.h"
+#include <qdict.h>
@@ -85,2 +86,3 @@ class KPimGlobalPrefs : public KPrefs
static KPimGlobalPrefs *sInstance;
+ QDict<QString> *mLocaleDict;
diff --git a/microkde/kstaticdeleter.h b/microkde/kstaticdeleter.h
index dfd3929..d9c2b72 100644
--- a/microkde/kstaticdeleter.h
+++ b/microkde/kstaticdeleter.h
@@ -30,6 +30,7 @@ class KStaticDeleter
KStaticDeleter() {};
- type *setObject( type *obj, bool isArray = false) { _mobj = obj;return obj; }
- virtual ~KStaticDeleter() {delete _mobj;};
+ type *setObject( type *obj, bool isArray = false) { _mobj = obj;_isArray = isArray;return obj; }
+ virtual ~KStaticDeleter() {if (_isArray) delete[] _mobj; else delete _mobj;};
private:
type* _mobj;
+ bool _isArray;
};
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
@@ -33,3 +33,3 @@
PWMPrefs *PWMPrefs::sInstance = 0;
-static KStaticDeleter<PWMPrefs> staticDeleter;
+static KStaticDeleter<PWMPrefs> staticDeleterPP;
@@ -70,3 +70,7 @@ PWMPrefs::PWMPrefs()
PWMPrefs::~PWMPrefs()
-{
+{
+ if (sInstance == this)
+ sInstance = staticDeleterPP.setObject(0);
+ else
+ qDebug("Whats this? Error in PWMPrefs::~PWMPrefs()?");
}
@@ -77,6 +81,6 @@ PWMPrefs *PWMPrefs::instance()
#ifdef PWM_EMBEDDED
- sInstance = staticDeleter.setObject( new PWMPrefs() );
+ sInstance = staticDeleterPP.setObject( new PWMPrefs() );
#else //PWM_EMBEDDED
//US the following line has changed ???. Why
- staticDeleter.setObject( sInstance, new PWMPrefs() );
+ staticDeleterPP.setObject( sInstance, new PWMPrefs() );
#endif //KAB_EMBEDDED