-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 |
5 files changed, 14 insertions, 103 deletions
diff --git a/korganizer/kodialogmanager.cpp b/korganizer/kodialogmanager.cpp index 58198a2..db7c3f2 100644 --- a/korganizer/kodialogmanager.cpp +++ b/korganizer/kodialogmanager.cpp @@ -80,45 +80,44 @@ OutgoingDialog *KODialogManager::outgoingDialog() void KODialogManager::createOutgoingDialog() { if (!mOutgoingDialog) { mOutgoingDialog = new OutgoingDialog(mMainView->calendar(),mMainView); 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())); } mOptionsDialog->readConfig(); #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() { createOutgoingDialog(); mOutgoingDialog->show(); mOutgoingDialog->raise(); } diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp index ba1c6d1..f44debc 100644 --- a/korganizer/koprefs.cpp +++ b/korganizer/koprefs.cpp @@ -37,37 +37,31 @@ #include <kglobal.h> #include <kconfig.h> #include <klocale.h> #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); mTimeBarFont = QFont("helvetica",10);//,QFont::Bold); mDefaultViewFont = QFont("helvetica",10); mDefaultMonthViewFont = QFont("helvetica",8); @@ -91,25 +85,25 @@ KOPrefs::KOPrefs() : addItemBool("ShowIconMonth",&mShowIconMonth,true); addItemBool("ShowIconTodoview",&mShowIconTodoview,true); addItemBool("ShowIconBackFast",&mShowIconBackFast,true); addItemBool("ShowIconBack",&mShowIconBack,true); 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 addItemBool("ToolBarHor",&mToolBarHor, true ); addItemBool("ToolBarUp",&mToolBarUp, false ); addItemBool("ToolBarMiniIcons",&mToolBarMiniIcons, false ); addItemInt("Whats Next Days",&mWhatsNextDays,3); @@ -195,31 +189,25 @@ KOPrefs::KOPrefs() : QString hdp= locateLocal("data","korganizer")+"/"; #endif KPrefs::setCurrentGroup("LoadSaveFileNames"); 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); addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor); addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor); addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 )); addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 )); @@ -307,27 +295,25 @@ KOPrefs::KOPrefs() : addItemInt("DestinationPolicy",&mDestination,standardDestination); } 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()); mInstance->readConfig(); } return mInstance; @@ -368,98 +354,34 @@ QStringList KOPrefs::getDefaultList() << i18n("Education")<< i18n("Family") << i18n("Favorites") << i18n("Festival")<< i18n("Fishing")<< i18n("Flight") << i18n("Gifts") << i18n("Holiday") << i18n("Holiday Cards")<< i18n("Hot Contacts") << i18n("Hiking") << i18n("Hunting") << i18n("Key Customer") << i18n("Kids") << i18n("Lunch") << i18n("Meeting") << i18n("Miscellaneous") << i18n("Partner")<< i18n("Party") << i18n("Personal") << i18n("Personal Travel") << i18n("PHB") << i18n("Phone Calls") << i18n("Projects") << i18n("Recurring") << i18n("School") << i18n("Shopping") << 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(); } if (mEventSummaryUser.isEmpty()) { mEventSummaryUser = getDefaultList() ; } if (mTodoSummaryUser.isEmpty()) { diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h index c74b0ef..0656644 100644 --- a/korganizer/koprefs.h +++ b/korganizer/koprefs.h @@ -14,27 +14,27 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 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 { public: enum { FormatVCalendar, FormatICalendar }; enum { MailClientKMail, MailClientSendmail }; enum { IMIPDummy, IMIPKMail }; @@ -61,25 +61,24 @@ class KOPrefs : public KPimPrefs protected: void setTimeZoneIdDefault(); /** Fill empty mail fields with default values. */ 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(); QString mAdditional; bool mEmailControlCenter; @@ -149,25 +148,24 @@ class KOPrefs : public KPimPrefs bool mMonthShowShort; bool mEnableToolTips; bool mEnableMonthScroll; bool mFullViewMonth; 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; bool mShowIconDay1; bool mShowIconDay5; bool mShowIconDay7; bool mShowIconMonth; @@ -244,39 +242,31 @@ class KOPrefs : public KPimPrefs bool mHightlightDateTimeEdit; bool mShortDateInViewer; QStringList mLocationDefaults; 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; QString mName; QString mEmail; }; diff --git a/korganizer/ktimeedit.cpp b/korganizer/ktimeedit.cpp index cf07a1a..f5a1c50 100644 --- a/korganizer/ktimeedit.cpp +++ b/korganizer/ktimeedit.cpp @@ -22,24 +22,25 @@ */ #include <qkeycode.h> #include <qcombobox.h> #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 { public: KOTimeValidator(QWidget* parent, const char* name=0) : QValidator(parent, name) {} @@ -102,25 +103,25 @@ KOTimeEdit::KOTimeEdit(QWidget *parent, QTime qt, const char *name) } while (!timeEntry.isNull()); // Add end of day. insertItem( KGlobal::locale()->formatTime( QTime( 23, 59, 59 ) ) ); 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(); unsigned char red, green, blue; red = palette.color( QPalette::Normal , QColorGroup::Background ).red() - 10; green = palette.color( QPalette::Normal , QColorGroup::Background ).green() - 10; blue = palette.color( QPalette::Normal , QColorGroup::Background ).blue() - 10; @@ -229,25 +230,25 @@ void KOTimeEdit::keyReleaseEvent(QKeyEvent *e) } void KOTimeEdit::setSelect( int from, int to ) { if ( KOPrefs::instance()->mHightlightDateTimeEdit) 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; } // Tap -> Focus Next Widget if ( e->key() == Key_Tab ) { QComboBox::keyPressEvent(e); diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index fbfcd20..dc2026b 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp @@ -216,28 +216,27 @@ MainWindow::MainWindow( QWidget *parent, const char *name, QString msg) : qApp->processEvents(); } } mView->saveCalendar( defaultFileName() ); 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 ) ) ); connect( mView, SIGNAL( tempDisableBR(bool) ), SLOT( disableBR(bool) ) ); connect( &mSaveTimer, SIGNAL( timeout() ), SLOT( save() ) ); mView->setModified( false ); |