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') 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() void KODialogManager::showOptionsDialog( bool showSync ) { - int curLanguage = KOPrefs::instance()->mPreferredLanguage; + if (!mOptionsDialog) { mOptionsDialog = new KOPrefsDialog(mMainView); //mOptionsDialog->readConfig(); @@ -108,8 +108,7 @@ void KODialogManager::showOptionsDialog( bool showSync ) if ( 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 @@ -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") 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 @@ #ifndef KOPREFS_H #define KOPREFS_H -#include #include +#include class KConfig; class QFont; @@ -70,7 +70,6 @@ class KOPrefs : public KPimPrefs KOPrefs(); static KOPrefs *mInstance; - QDict *mLocaleDict; QStringList getDefaultList(); public: // preferences data @@ -158,7 +157,6 @@ class KOPrefs : public KPimPrefs int mWhatsNextDays; int mWhatsNextPrios; bool mEnableQuickTodo; - bool mLanguageChanged; bool mCompactDialogs; bool mVerticalScreen; @@ -253,21 +251,13 @@ class KOPrefs : public KPimPrefs 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 mCategoryColors; 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 @@ #include #include #include +#include #include "ktimeedit.h" #include "koprefs.h" @@ -111,7 +112,7 @@ KOTimeEdit::KOTimeEdit(QWidget *parent, QTime qt, const char *name) 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 ) @@ -238,7 +239,7 @@ 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(); 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) : 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 * ) ), -- cgit v0.9.0.2