summaryrefslogtreecommitdiffabout
authorzautrix <zautrix>2004-10-23 11:40:59 (UTC)
committer zautrix <zautrix>2004-10-23 11:40:59 (UTC)
commit25b0233d54a6d4bea457fd843073e57183d8bea0 (patch) (side-by-side diff)
tree4d85c3cec59e8b085738be7111c7e2bb0ee7219e
parentba2583db0431059cd7368be23c9653e81af16d29 (diff)
downloadkdepimpi-25b0233d54a6d4bea457fd843073e57183d8bea0.zip
kdepimpi-25b0233d54a6d4bea457fd843073e57183d8bea0.tar.gz
kdepimpi-25b0233d54a6d4bea457fd843073e57183d8bea0.tar.bz2
global settings bugfixes
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,5 +1,5 @@
#############################################################################
# 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
# Template: subdirs
diff --git a/kaddressbook/kabprefs.cpp b/kaddressbook/kabprefs.cpp
index 01c935f..3cbcc9a 100644
--- a/kaddressbook/kabprefs.cpp
+++ b/kaddressbook/kabprefs.cpp
@@ -44,11 +44,9 @@
KABPrefs *KABPrefs::sInstance = 0;
-static KStaticDeleter<KABPrefs> staticDeleter;
+static KStaticDeleter<KABPrefs> staticDeleterAB;
KABPrefs::KABPrefs()
: KPimPrefs("kaddressbookrc")
{
-
- mLocaleDict = 0;
mDetailsFont = QFont("helvetica",12);
KPrefs::setCurrentGroup( "Views" );
@@ -97,7 +95,6 @@ KABPrefs::~KABPrefs()
{
//qDebug("KABPrefs::~KABPrefs() ");
- setLocaleDict( 0 );
- if ( mLocaleDict )
- delete mLocaleDict;
+ if (sInstance == this)
+ sInstance = staticDeleterAB.setObject(0);
}
@@ -106,8 +103,8 @@ KABPrefs *KABPrefs::instance()
if ( !sInstance ) {
#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
sInstance->readConfig();
@@ -132,64 +129,4 @@ KConfig* KABPrefs::getConfig()
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
@@ -90,5 +90,4 @@ class KABPrefs : public KPimPrefs
KABPrefs();
- 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
@@ -24,5 +24,4 @@
#define KOPREFS_H
-#include <qdict.h>
#include <libkdepim/kpimprefs.h>
@@ -63,5 +62,4 @@ class KOPrefs : public KPimPrefs
static KOPrefs *mInstance;
- QDict<QString> *mLocaleDict;
public:
// preferences data
diff --git a/korganizer/kodialogmanager.cpp b/korganizer/kodialogmanager.cpp
index 58198a2..db7c3f2 100644
--- a/korganizer/kodialogmanager.cpp
+++ b/korganizer/kodialogmanager.cpp
@@ -90,5 +90,5 @@ void KODialogManager::createOutgoingDialog()
void KODialogManager::showOptionsDialog( bool showSync )
{
- int curLanguage = KOPrefs::instance()->mPreferredLanguage;
+
if (!mOptionsDialog) {
mOptionsDialog = new KOPrefsDialog(mMainView);
@@ -109,6 +109,5 @@ void KODialogManager::showOptionsDialog( bool showSync )
mOptionsDialog->showSyncPage();
mOptionsDialog->exec();
- if ( curLanguage != KOPrefs::instance()->mPreferredLanguage )
- KOPrefs::instance()->mLanguageChanged = true;
+
}
void KODialogManager::showSyncOptions()
diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp
index ba1c6d1..f44debc 100644
--- a/korganizer/koprefs.cpp
+++ b/korganizer/koprefs.cpp
@@ -47,9 +47,4 @@
#include "mainwindow.h"
-const char *germanwords[][2] = {
-#include "wordsgerman.h"
- "", ""
-};
-
KOPrefs *KOPrefs::mInstance = 0;
static KStaticDeleter<KOPrefs> insd;
@@ -59,5 +54,4 @@ KOPrefs::KOPrefs() :
{
mCategoryColors.setAutoDelete(true);
- mLocaleDict = 0;
fillMailDefaults();
mDefaultCategoryColor = QColor(175,210,255);//196,196,196);
@@ -101,5 +95,5 @@ KOPrefs::KOPrefs() :
addItemBool("ShowIconJournal",&mShowIconJournal,true);
addItemBool("ShowIconStretch",&mShowIconStretch,true);
- addItemBool("LanguageChanged",&mLanguageChanged,false);
+ addItemInt("LastLoadedLanguage",&mOldLanguage,0);
addItemBool("AskForQuit",&mAskForQuit,false);
@@ -205,11 +199,5 @@ 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");
@@ -317,7 +305,5 @@ KOPrefs::~KOPrefs()
if (mInstance == this)
mInstance = insd.setObject(0);
- setLocaleDict( 0 );
- if ( mLocaleDict )
- delete mLocaleDict;
+
//qDebug("KOPrefs::~KOPrefs() ");
}
@@ -378,78 +364,14 @@ QStringList KOPrefs::getDefaultList()
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");
mCustomCategories = config()->readListEntry("Custom Categories");
- if ( KOPrefs::instance()->mLanguageChanged ) {
+ if ( KPimGlobalPrefs::instance()->mPreferredLanguage != mOldLanguage ) {
mLocationDefaults.clear();
mEventSummaryUser.clear();
mTodoSummaryUser.clear();
}
+ mOldLoadedLanguage = mOldLanguage ;
+ mOldLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage;
if (mLocationDefaults.isEmpty()) {
mLocationDefaults << i18n("Home") << i18n("Office") << i18n("Library") << i18n("School") << i18n("Doctor") << i18n("Beach")
diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h
index c74b0ef..0656644 100644
--- a/korganizer/koprefs.h
+++ b/korganizer/koprefs.h
@@ -24,7 +24,7 @@
#define KOPREFS_H
-#include <qdict.h>
#include <libkdepim/kpimprefs.h>
+#include <qdict.h>
class KConfig;
@@ -71,5 +71,4 @@ class KOPrefs : public KPimPrefs
static KOPrefs *mInstance;
- QDict<QString> *mLocaleDict;
QStringList getDefaultList();
public:
@@ -159,5 +158,4 @@ class KOPrefs : public KPimPrefs
int mWhatsNextPrios;
bool mEnableQuickTodo;
- bool mLanguageChanged;
bool mCompactDialogs;
@@ -254,4 +252,6 @@ class KOPrefs : public KPimPrefs
int mAlarmSuspendCount;
int mAlarmBeepInterval;
+ int mOldLanguage;
+ int mOldLoadedLanguage;
@@ -259,14 +259,4 @@ class KOPrefs : public KPimPrefs
QString mActiveSyncIP;
-
- //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:
QDict<QColor> mCategoryColors;
diff --git a/korganizer/ktimeedit.cpp b/korganizer/ktimeedit.cpp
index cf07a1a..f5a1c50 100644
--- a/korganizer/ktimeedit.cpp
+++ b/korganizer/ktimeedit.cpp
@@ -32,4 +32,5 @@
#include <kdebug.h>
#include <klocale.h>
+#include <kpimglobalprefs.h>
#include "ktimeedit.h"
@@ -112,5 +113,5 @@ KOTimeEdit::KOTimeEdit(QWidget *parent, QTime qt, const char *name)
QFontMetrics fm ( font() );
QString timeString = "24:00";
- if ( KOPrefs::instance()->mPreferredTime == 1 )
+ if ( KPimGlobalPrefs::instance()->mPreferredTime == 1 )
timeString = "02:00pm";
int addSpace = 32;
@@ -239,5 +240,5 @@ void KOTimeEdit::keyPressEvent(QKeyEvent *e)
qApp->processEvents();
- bool hour12Format = ( KOPrefs::instance()->mPreferredTime == 1 );
+ bool hour12Format = ( KPimGlobalPrefs::instance()->mPreferredTime == 1 );
int maxpos = hour12Format?7:5;
if ( e->isAutoRepeat() && !mFlagKeyPressed ) {
diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp
index fbfcd20..dc2026b 100644
--- a/korganizer/mainwindow.cpp
+++ b/korganizer/mainwindow.cpp
@@ -226,8 +226,7 @@ MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) :
qDebug("KO: Calendar loading time: %d ms",msNeeded );
- if ( KOPrefs::instance()->mLanguageChanged ) {
+ if ( KPimGlobalPrefs::instance()->mPreferredLanguage != KOPrefs::instance()->mOldLoadedLanguage ) {
KOPrefs::instance()->setCategoryDefaults();
int count = mView->addCategories();
- KOPrefs::instance()->mLanguageChanged = false;
}
processIncidenceSelection( 0 );
diff --git a/libkdepim/kpimglobalprefs.cpp b/libkdepim/kpimglobalprefs.cpp
index 0a580ca..5298f0c 100644
--- a/libkdepim/kpimglobalprefs.cpp
+++ b/libkdepim/kpimglobalprefs.cpp
@@ -36,8 +36,11 @@ $Id$
#include <qregexp.h>
+#include <qfile.h>
+#include <qtextstream.h>
+#include <qapplication.h>
#include "kpimglobalprefs.h"
KPimGlobalPrefs *KPimGlobalPrefs::sInstance = 0;
-static KStaticDeleter<KPimGlobalPrefs> staticDeleter;
+static KStaticDeleter<KPimGlobalPrefs> staticDeleterGP;
@@ -45,5 +48,5 @@ KPimGlobalPrefs::KPimGlobalPrefs( const QString &name )
: KPrefs("microkdeglobalrc")
{
-
+ mLocaleDict = 0;
KPrefs::setCurrentGroup("Locale");
addItemInt("PreferredLanguage",&mPreferredLanguage,0);
@@ -105,7 +108,66 @@ 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() );
+ }
+ }
+ }
KGlobal::locale()->setHore24Format( !mPreferredTime );
@@ -125,6 +187,12 @@ void KPimGlobalPrefs::setGlobalConfig()
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;
}
@@ -132,5 +200,5 @@ 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
@@ -33,4 +33,5 @@ $Id$
#include "kprefs.h"
+#include <qdict.h>
class KPimGlobalPrefs : public KPrefs
@@ -84,4 +85,5 @@ 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
@@ -29,8 +29,9 @@ class KStaticDeleter
public:
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
@@ -32,5 +32,5 @@
PWMPrefs *PWMPrefs::sInstance = 0;
-static KStaticDeleter<PWMPrefs> staticDeleter;
+static KStaticDeleter<PWMPrefs> staticDeleterPP;
PWMPrefs::PWMPrefs()
@@ -69,5 +69,9 @@ PWMPrefs::PWMPrefs()
PWMPrefs::~PWMPrefs()
-{
+{
+ if (sInstance == this)
+ sInstance = staticDeleterPP.setObject(0);
+ else
+ qDebug("Whats this? Error in PWMPrefs::~PWMPrefs()?");
}
@@ -76,8 +80,8 @@ PWMPrefs *PWMPrefs::instance()
if ( !sInstance ) {
#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
sInstance->readConfig();