From 25b0233d54a6d4bea457fd843073e57183d8bea0 Mon Sep 17 00:00:00 2001 From: zautrix Date: Sat, 23 Oct 2004 11:40:59 +0000 Subject: global settings bugfixes --- (limited to 'korganizer/koprefs.cpp') 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 @@ #include "koprefs.h" #include "mainwindow.h" -const char *germanwords[][2] = { -#include "wordsgerman.h" - "", "" -}; - KOPrefs *KOPrefs::mInstance = 0; static KStaticDeleter insd; @@ -58,7 +53,6 @@ KOPrefs::KOPrefs() : KPimPrefs("korganizerrc") { mCategoryColors.setAutoDelete(true); - mLocaleDict = 0; fillMailDefaults(); mDefaultCategoryColor = QColor(175,210,255);//196,196,196); QColor defaultHolidayColor = QColor(255,0,0); @@ -100,7 +94,7 @@ KOPrefs::KOPrefs() : addItemBool("ShowIconNext",&mShowIconNext,true); addItemBool("ShowIconJournal",&mShowIconJournal,true); addItemBool("ShowIconStretch",&mShowIconStretch,true); - addItemBool("LanguageChanged",&mLanguageChanged,false); + addItemInt("LastLoadedLanguage",&mOldLanguage,0); addItemBool("AskForQuit",&mAskForQuit,false); @@ -204,13 +198,7 @@ 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"); KPrefs::setCurrentGroup("Colors"); @@ -316,9 +304,7 @@ KOPrefs::~KOPrefs() { if (mInstance == this) mInstance = insd.setObject(0); - setLocaleDict( 0 ); - if ( mLocaleDict ) - delete mLocaleDict; + //qDebug("KOPrefs::~KOPrefs() "); } @@ -377,80 +363,16 @@ 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; - 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 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") -- cgit v0.9.0.2