-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | kaddressbook/kabprefs.cpp | 73 | ||||
-rw-r--r-- | kaddressbook/kabprefs.h | 1 | ||||
-rw-r--r-- | kmicromail/koprefs.h | 2 | ||||
-rw-r--r-- | korganizer/kodialogmanager.cpp | 5 | ||||
-rw-r--r-- | korganizer/koprefs.cpp | 88 | ||||
-rw-r--r-- | korganizer/koprefs.h | 16 | ||||
-rw-r--r-- | korganizer/ktimeedit.cpp | 5 | ||||
-rw-r--r-- | korganizer/mainwindow.cpp | 3 | ||||
-rw-r--r-- | libkdepim/kpimglobalprefs.cpp | 76 | ||||
-rw-r--r-- | libkdepim/kpimglobalprefs.h | 2 | ||||
-rw-r--r-- | microkde/kstaticdeleter.h | 5 | ||||
-rw-r--r-- | pwmanager/pwmanager/pwmprefs.cpp | 12 |
13 files changed, 105 insertions, 185 deletions
@@ -1,11 +1,11 @@ ############################################################################# # 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 # Command: $(QMAKE) "CONFIG+=thread" "CONFIG+=debug" -o Makefile kdepim-desktop.pro ############################################################################# MAKEFILE = Makefile QMAKE = qmake DEL_FILE = rm -f diff --git a/kaddressbook/kabprefs.cpp b/kaddressbook/kabprefs.cpp index 01c935f..3cbcc9a 100644 --- a/kaddressbook/kabprefs.cpp +++ b/kaddressbook/kabprefs.cpp @@ -38,23 +38,21 @@ #include "kabprefs.h" #ifdef DESKTOP_VERSION #include <qapplication.h> #endif 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" ); addItemBool( "HonorSingleClick", &mHonorSingleClick, false ); KPrefs::setCurrentGroup( "General" ); addItemBool( "AutomaticNameParsing", &mAutomaticNameParsing, true ); addItemInt( "CurrentIncSearchField", &mCurrentIncSearchField, 0 ); @@ -91,29 +89,28 @@ KABPrefs::KABPrefs() KPrefs::setCurrentGroup( "Filters" ); addItemInt( "CurrentFilter", &mCurrentFilter, 0 ); } KABPrefs::~KABPrefs() { //qDebug("KABPrefs::~KABPrefs() "); - setLocaleDict( 0 ); - if ( mLocaleDict ) - delete mLocaleDict; + if (sInstance == this) + sInstance = staticDeleterAB.setObject(0); } 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(); } return sInstance; } void KABPrefs::setCategoryDefaults() @@ -126,76 +123,16 @@ void KABPrefs::setCategoryDefaults() // US introduce a nonconst way to return the config object. KConfig* KABPrefs::getConfig() { return config(); } 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(); } /*US void KABPrefs::usrSetDefaults() { KPimPrefs::usrSetDefaults(); diff --git a/kaddressbook/kabprefs.h b/kaddressbook/kabprefs.h index 1098f4c..cc8413e 100644 --- a/kaddressbook/kabprefs.h +++ b/kaddressbook/kabprefs.h @@ -84,13 +84,12 @@ class KABPrefs : public KPimPrefs int mCurrentFilter; void setCategoryDefaults(); QFont mDetailsFont; private: KABPrefs(); - QDict<QString> *mLocaleDict; static KABPrefs *sInstance; }; #endif diff --git a/kmicromail/koprefs.h b/kmicromail/koprefs.h index a47642b..f0a4463 100644 --- a/kmicromail/koprefs.h +++ b/kmicromail/koprefs.h @@ -18,17 +18,16 @@ As a special exception, permission is given to link this program with any edition of Qt, and distribute the resulting executable, without including the source code for Qt in the source distribution. */ #ifndef KOPREFS_H #define KOPREFS_H -#include <qdict.h> #include <libkdepim/kpimprefs.h> class KConfig; class QFont; class QColor; class QStringList; @@ -57,17 +56,16 @@ class KOPrefs : public KPimPrefs void fillMailDefaults(); private: /** Constructor disabled for public. Use instance() to create a KOPrefs object. */ KOPrefs(); static KOPrefs *mInstance; - QDict<QString> *mLocaleDict; public: // preferences data KConfig* getConfig(); QFont mAppFont; QFont mComposeFont; QFont mReadFont; QString mName; QString mEmail; diff --git a/korganizer/kodialogmanager.cpp b/korganizer/kodialogmanager.cpp index 58198a2..db7c3f2 100644 --- a/korganizer/kodialogmanager.cpp +++ b/korganizer/kodialogmanager.cpp @@ -84,17 +84,17 @@ void KODialogManager::createOutgoingDialog() if (mIncomingDialog) mIncomingDialog->setOutgoingDialog(mOutgoingDialog); connect(mOutgoingDialog,SIGNAL(numMessagesChanged(int)), mMainView,SIGNAL(numOutgoingChanged(int))); } } void KODialogManager::showOptionsDialog( bool showSync ) { - int curLanguage = KOPrefs::instance()->mPreferredLanguage; + if (!mOptionsDialog) { mOptionsDialog = new KOPrefsDialog(mMainView); //mOptionsDialog->readConfig(); connect(mOptionsDialog,SIGNAL(configChanged()), mMainView,SLOT(updateConfig())); //connect(mCategoryEditDialog,SIGNAL(categoryConfigChanged()), // mOptionsDialog,SLOT(updateCategories())); @@ -103,18 +103,17 @@ void KODialogManager::showOptionsDialog( bool showSync ) #ifndef DESKTOP_VERSION mOptionsDialog->showMaximized(); #else mOptionsDialog->show(); #endif if ( showSync ) mOptionsDialog->showSyncPage(); mOptionsDialog->exec(); - if ( curLanguage != KOPrefs::instance()->mPreferredLanguage ) - KOPrefs::instance()->mLanguageChanged = true; + } void KODialogManager::showSyncOptions() { showOptionsDialog( true ); } void KODialogManager::showOutgoingDialog() { diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp index ba1c6d1..f44debc 100644 --- a/korganizer/koprefs.cpp +++ b/korganizer/koprefs.cpp @@ -41,29 +41,23 @@ #include <kdebug.h> #include <kemailsettings.h> #include <kstaticdeleter.h> #include <libkdepim/kpimglobalprefs.h> #include "koprefs.h" #include "mainwindow.h" -const char *germanwords[][2] = { -#include "wordsgerman.h" - "", "" -}; - KOPrefs *KOPrefs::mInstance = 0; static KStaticDeleter<KOPrefs> insd; KOPrefs::KOPrefs() : KPimPrefs("korganizerrc") { mCategoryColors.setAutoDelete(true); - mLocaleDict = 0; fillMailDefaults(); mDefaultCategoryColor = QColor(175,210,255);//196,196,196); QColor defaultHolidayColor = QColor(255,0,0); QColor defaultHighlightColor = QColor(129,112,255);//64,64,255); QColor defaultAgendaBgColor = QColor(239,241,169);//128,128,128); QColor defaultWorkingHoursColor = QColor(170,223,150);//160,160,160); QColor defaultTodoDueTodayColor = QColor(255,220,100); QColor defaultTodoOverdueColor = QColor(255,153,125); @@ -95,17 +89,17 @@ KOPrefs::KOPrefs() : addItemBool("ShowIconToday",&mShowIconToday,true); addItemBool("ShowIconForward",&mShowIconForward,true); addItemBool("ShowIconForwardFast",&mShowIconForwardFast,true); addItemBool("ShowIconWhatsThis",&mShowIconWhatsThis,false); addItemBool("ShowIconNextDays",&mShowIconNextDays,true); addItemBool("ShowIconNext",&mShowIconNext,true); addItemBool("ShowIconJournal",&mShowIconJournal,true); addItemBool("ShowIconStretch",&mShowIconStretch,true); - addItemBool("LanguageChanged",&mLanguageChanged,false); + addItemInt("LastLoadedLanguage",&mOldLanguage,0); addItemBool("AskForQuit",&mAskForQuit,false); #ifndef DESKTOP_VERSION addItemBool("ShowFullMenu",&mShowFullMenu,false); #else addItemBool("ShowFullMenu",&mShowFullMenu,true); #endif @@ -199,23 +193,17 @@ KOPrefs::KOPrefs() : addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" ); addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" ); addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" ); addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" ); 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"); KPrefs::setCurrentGroup("Colors"); addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor); addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor); addItemColor("Event Color",&mEventColor,mDefaultCategoryColor); addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor); addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor); @@ -311,19 +299,17 @@ KOPrefs::KOPrefs() : } KOPrefs::~KOPrefs() { if (mInstance == this) mInstance = insd.setObject(0); - setLocaleDict( 0 ); - if ( mLocaleDict ) - delete mLocaleDict; + //qDebug("KOPrefs::~KOPrefs() "); } KOPrefs *KOPrefs::instance() { if (!mInstance) { mInstance = insd.setObject(new KOPrefs()); @@ -372,90 +358,26 @@ QStringList KOPrefs::getDefaultList() << i18n("Speach") << i18n("Special Occasion") << i18n("Sports") << i18n("Talk") << i18n("Travel") << i18n("TV")<< i18n("University") << i18n("Vacation") << i18n("VIP") << i18n("SyncEvent") ; retval.sort(); return retval; } 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") << i18n("University") << i18n("Restaurant") << i18n("Bar") << i18n("Conference room") << i18n("Cinema") << i18n("Lake") << i18n("Kindergarten") << i18n("Germany") << i18n("Sweden") << i18n("Forest") << i18n("Desert") << i18n("Kitchen") ; // << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") mLocationDefaults.sort(); } diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h index c74b0ef..0656644 100644 --- a/korganizer/koprefs.h +++ b/korganizer/koprefs.h @@ -18,19 +18,19 @@ As a special exception, permission is given to link this program with any edition of Qt, and distribute the resulting executable, without including the source code for Qt in the source distribution. */ #ifndef KOPREFS_H #define KOPREFS_H -#include <qdict.h> #include <libkdepim/kpimprefs.h> +#include <qdict.h> class KConfig; class QFont; class QColor; class QStringList; class KOPrefs : public KPimPrefs { @@ -65,17 +65,16 @@ class KOPrefs : public KPimPrefs void fillMailDefaults(); private: /** Constructor disabled for public. Use instance() to create a KOPrefs object. */ KOPrefs(); static KOPrefs *mInstance; - QDict<QString> *mLocaleDict; QStringList getDefaultList(); public: // preferences data KConfig* getConfig(); void setFullName(const QString &); QString fullName(); void setEmail(const QString &); QString email(); @@ -153,17 +152,16 @@ class KOPrefs : public KPimPrefs bool mMonthViewUsesCategoryColor; bool mFullViewTodo; bool mShowCompletedTodo; bool mMarcusBainsEnabled; int mNextXDays; int mWhatsNextDays; int mWhatsNextPrios; bool mEnableQuickTodo; - bool mLanguageChanged; bool mCompactDialogs; bool mVerticalScreen; bool mShowIconNewTodo; bool mShowIconNewEvent; bool mShowIconSearch; bool mShowIconList; @@ -248,31 +246,23 @@ class KOPrefs : public KPimPrefs QStringList mEventSummaryUser; QStringList mTodoSummaryUser; bool mUseInternalAlarmNotification; int mAlarmPlayBeeps; int mAlarmSuspendTime; int mAlarmSuspendCount; int mAlarmBeepInterval; + int mOldLanguage; + int mOldLoadedLanguage; QString mActiveSyncPort; 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; QColor mDefaultCategoryColor; QFont mDefaultTimeBarFont; QFont mDefaultViewFont; QFont mDefaultMonthViewFont; diff --git a/korganizer/ktimeedit.cpp b/korganizer/ktimeedit.cpp index cf07a1a..f5a1c50 100644 --- a/korganizer/ktimeedit.cpp +++ b/korganizer/ktimeedit.cpp @@ -26,16 +26,17 @@ #include <qdatetime.h> #include <qlineedit.h> #include <qapplication.h> #include <kmessagebox.h> #include <kglobal.h> #include <kdebug.h> #include <klocale.h> +#include <kpimglobalprefs.h> #include "ktimeedit.h" #include "koprefs.h" #include <qvalidator.h> // Validator for a time value with only hours and minutes (no seconds) // Mostly locale aware. Author: David Faure <faure@kde.org> class KOTimeValidator : public QValidator @@ -106,17 +107,17 @@ KOTimeEdit::KOTimeEdit(QWidget *parent, QTime qt, const char *name) updateText(); setFocusPolicy(QWidget::StrongFocus); connect(this, SIGNAL(activated(int)), this, SLOT(activ(int))); connect(this, SIGNAL(highlighted(int)), this, SLOT(hilit(int))); connect(this,SIGNAL(textChanged(const QString&)),this,SLOT(changedText())); QFontMetrics fm ( font() ); QString timeString = "24:00"; - if ( KOPrefs::instance()->mPreferredTime == 1 ) + if ( KPimGlobalPrefs::instance()->mPreferredTime == 1 ) timeString = "02:00pm"; int addSpace = 32; if ( QApplication::desktop()->width() > 320 ) timeString += ":00"; setFixedWidth(fm.width( timeString ) + 32 ); // Highlight Background and Textcolor change from default QPalette palette = QWidget::palette(); @@ -233,17 +234,17 @@ void KOTimeEdit::setSelect( int from, int to ) lineEdit()->setSelection( from , to ); } 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 ) { e->ignore(); // qDebug(" ignore %d",e->isAutoRepeat() ); return; } if (! e->isAutoRepeat() ) { mFlagKeyPressed = true; diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index fbfcd20..dc2026b 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp @@ -220,20 +220,19 @@ MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : newFile = true; } QTime neededSaveTime = QDateTime::currentDateTime().time(); mView->openCalendar( defaultFileName() ); int msNeeded = neededSaveTime.msecsTo( QDateTime::currentDateTime().time() ); 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 ); connect( mView, SIGNAL( incidenceSelected( Incidence * ) ), SLOT( processIncidenceSelection( Incidence * ) ) ); connect( mView, SIGNAL( modifiedChanged( bool ) ), SLOT( slotModifiedChanged( bool ) ) ); diff --git a/libkdepim/kpimglobalprefs.cpp b/libkdepim/kpimglobalprefs.cpp index 0a580ca..5298f0c 100644 --- a/libkdepim/kpimglobalprefs.cpp +++ b/libkdepim/kpimglobalprefs.cpp @@ -30,26 +30,29 @@ $Id$ #include <kglobal.h> #include <kconfig.h> #include <klocale.h> #include <kdebug.h> #include <kstaticdeleter.h> #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; KPimGlobalPrefs::KPimGlobalPrefs( const QString &name ) : KPrefs("microkdeglobalrc") { - + mLocaleDict = 0; KPrefs::setCurrentGroup("Locale"); addItemInt("PreferredLanguage",&mPreferredLanguage,0); addItemInt("PreferredTime",&mPreferredTime,0); addItemInt("PreferredDate",&mPreferredDate,0); addItemBool("WeekStartsOnSunday",&mWeekStartsOnSunday,false); //addItemBool("QuickSavingWOUnicode",&mUseQuicksave,false); // addItemBool("ShortDateInViewer",&mShortDateInViewer,false); addItemString("UserDateFormatLong", &mUserDateFormatLong, "%A %d %b %y"); @@ -99,19 +102,78 @@ KPimGlobalPrefs::KPimGlobalPrefs( const QString &name ) KPrefs::setCurrentGroup( "PhoneAccess" ); addItemString("Ex2PhoneDevice",&mEx2PhoneDevice,"/dev/ircomm"); addItemString("Ex2PhoneConnection",&mEx2PhoneConnection,"irda"); addItemString("Ex2PhoneModel",&mEx2PhoneModel,"6310i"); } - 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 ); KGlobal::locale()->setWeekStartMonday( !mWeekStartsOnSunday ); KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)mPreferredDate ); KGlobal::locale()->setLanguage( mPreferredLanguage ); QString dummy = mUserDateFormatLong; KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); dummy = mUserDateFormatShort; @@ -119,21 +181,27 @@ void KPimGlobalPrefs::setGlobalConfig() KGlobal::locale()->setDaylightSaving( mUseDaylightsaving, mDaylightsavingStart, mDaylightsavingEnd ); KGlobal::locale()->setTimezone( mTimeZoneId, mTimeZoneAdd30min ); } 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; } KPimGlobalPrefs *KPimGlobalPrefs::instance() { if ( !sInstance ) { - sInstance = staticDeleter.setObject( new KPimGlobalPrefs() ); + sInstance = staticDeleterGP.setObject( new KPimGlobalPrefs() ); sInstance->readConfig(); } return sInstance; } diff --git a/libkdepim/kpimglobalprefs.h b/libkdepim/kpimglobalprefs.h index d09c3da..11c534a 100644 --- a/libkdepim/kpimglobalprefs.h +++ b/libkdepim/kpimglobalprefs.h @@ -27,16 +27,17 @@ Copyright (c) 2004 Ulf Schenk $Id$ */ #ifndef KPIMGLOBALPREFS_H #define KPIMGLOBALPREFS_H #include "kprefs.h" +#include <qdict.h> class KPimGlobalPrefs : public KPrefs { public: void setGlobalConfig(); static KPimGlobalPrefs *instance(); @@ -78,16 +79,17 @@ class KPimGlobalPrefs : public KPrefs OTHER_SIC = 1, KPPI_SIC = 2 }; private: KPimGlobalPrefs( const QString &name = QString::null ); static KPimGlobalPrefs *sInstance; + QDict<QString> *mLocaleDict; public: //US I copied the following "locale" settings from KOPrefs int mPreferredDate; QString mUserDateFormatLong; QString mUserDateFormatShort; int mPreferredLanguage; diff --git a/microkde/kstaticdeleter.h b/microkde/kstaticdeleter.h index dfd3929..d9c2b72 100644 --- a/microkde/kstaticdeleter.h +++ b/microkde/kstaticdeleter.h @@ -23,15 +23,16 @@ #ifndef _KSTATIC_DELETER_H_ #define _KSTATIC_DELETER_H_ template<class type> 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; }; #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 @@ -26,17 +26,17 @@ #include <kconfig.h> #include <klocale.h> #include <kstaticdeleter.h> #include "pwmprefs.h" PWMPrefs *PWMPrefs::sInstance = 0; -static KStaticDeleter<PWMPrefs> staticDeleter; +static KStaticDeleter<PWMPrefs> staticDeleterPP; PWMPrefs::PWMPrefs() : KPimPrefs("pwmanagerrc") { KPrefs::setCurrentGroup( "Global" ); addItemString( "autoStart", &mAutoStart, "" ); addItemString( "browserCommand", &mBrowserCommand, "" ); @@ -63,27 +63,31 @@ PWMPrefs::PWMPrefs() addItemInt( "MainViewStyle", &mMainViewStyle, CONF_DEFAULT_MAINVIEWSTYLE ); addItemBool( "autoMinimizeOnStart", &mAutoMinimizeOnStart, CONF_DEFAULT_AUTOMINIMIZE ); addItemBool( "close", &mClose, CONF_DEFAULT_WNDCLOSE ); addItemIntList( "commentSplitter", &mCommentSplitter ); addItemIntList( "categorySplitter", &mCategorySplitter ); } PWMPrefs::~PWMPrefs() -{ +{ + if (sInstance == this) + sInstance = staticDeleterPP.setObject(0); + else + qDebug("Whats this? Error in PWMPrefs::~PWMPrefs()?"); } 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(); } return sInstance; } // US introduce a nonconst way to return the config object. |