Diffstat (limited to 'libkdepim/kpimglobalprefs.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libkdepim/kpimglobalprefs.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/libkdepim/kpimglobalprefs.cpp b/libkdepim/kpimglobalprefs.cpp index e8fd2d1..81e3cb1 100644 --- a/libkdepim/kpimglobalprefs.cpp +++ b/libkdepim/kpimglobalprefs.cpp | |||
@@ -61,145 +61,148 @@ KPimGlobalPrefs::KPimGlobalPrefs( const QString &name ) | |||
61 | 61 | ||
62 | addItemString("TimeZoneName",&mTimeZoneId, ("+01:00 Europe/Oslo(CET)") ); | 62 | addItemString("TimeZoneName",&mTimeZoneId, ("+01:00 Europe/Oslo(CET)") ); |
63 | addItemBool("UseDaylightsaving",&mUseDaylightsaving,true); | 63 | addItemBool("UseDaylightsaving",&mUseDaylightsaving,true); |
64 | addItemBool("TimeZoneAdd30min",&mTimeZoneAdd30min,false); | 64 | addItemBool("TimeZoneAdd30min",&mTimeZoneAdd30min,false); |
65 | addItemInt("DaylightsavingStart",&mDaylightsavingStart,90); | 65 | addItemInt("DaylightsavingStart",&mDaylightsavingStart,90); |
66 | addItemInt("DaylightsavingEnd",&mDaylightsavingEnd,304); | 66 | addItemInt("DaylightsavingEnd",&mDaylightsavingEnd,304); |
67 | 67 | ||
68 | KPrefs::setCurrentGroup( "ExternalApplications" ); | 68 | KPrefs::setCurrentGroup( "ExternalApplications" ); |
69 | 69 | ||
70 | addItemInt( "EmailChannelType", &mEmailClient, OMPI_EMC ); | 70 | addItemInt( "EmailChannelType", &mEmailClient, OMPI_EMC ); |
71 | addItemString( "EmailChannel", &mEmailOtherChannel, "" ); | 71 | addItemString( "EmailChannel", &mEmailOtherChannel, "" ); |
72 | addItemString( "EmailChannelMessage", &mEmailOtherMessage, "" ); | 72 | addItemString( "EmailChannelMessage", &mEmailOtherMessage, "" ); |
73 | addItemString( "EmailChannelParameters", &mEmailOtherMessageParameters, "" ); | 73 | addItemString( "EmailChannelParameters", &mEmailOtherMessageParameters, "" ); |
74 | addItemString( "EmailChannelMessage2", &mEmailOtherMessage2, "" ); | 74 | addItemString( "EmailChannelMessage2", &mEmailOtherMessage2, "" ); |
75 | addItemString( "EmailChannelParameters2", &mEmailOtherMessageParameters2, "" ); | 75 | addItemString( "EmailChannelParameters2", &mEmailOtherMessageParameters2, "" ); |
76 | 76 | ||
77 | addItemInt( "PhoneChannelType", &mPhoneClient, KPPI_PHC ); | 77 | addItemInt( "PhoneChannelType", &mPhoneClient, KPPI_PHC ); |
78 | addItemString( "PhoneChannel", &mPhoneOtherChannel, "" ); | 78 | addItemString( "PhoneChannel", &mPhoneOtherChannel, "" ); |
79 | addItemString( "PhoneChannelMessage", &mPhoneOtherMessage, "" ); | 79 | addItemString( "PhoneChannelMessage", &mPhoneOtherMessage, "" ); |
80 | addItemString( "PhoneChannelParameters", &mPhoneOtherMessageParameters, "" ); | 80 | addItemString( "PhoneChannelParameters", &mPhoneOtherMessageParameters, "" ); |
81 | 81 | ||
82 | addItemInt( "FaxChannelType", &mFaxClient, NONE_FAC ); | 82 | addItemInt( "FaxChannelType", &mFaxClient, NONE_FAC ); |
83 | addItemString( "FaxChannel", &mFaxOtherChannel, "" ); | 83 | addItemString( "FaxChannel", &mFaxOtherChannel, "" ); |
84 | addItemString( "FaxChannelMessage", &mFaxOtherMessage, "" ); | 84 | addItemString( "FaxChannelMessage", &mFaxOtherMessage, "" ); |
85 | addItemString( "FaxChannelParameters", &mFaxOtherMessageParameters, "" ); | 85 | addItemString( "FaxChannelParameters", &mFaxOtherMessageParameters, "" ); |
86 | 86 | ||
87 | addItemInt( "SMSChannelType", &mSMSClient, NONE_SMC ); | 87 | addItemInt( "SMSChannelType", &mSMSClient, NONE_SMC ); |
88 | addItemString( "SMSChannel", &mSMSOtherChannel, "" ); | 88 | addItemString( "SMSChannel", &mSMSOtherChannel, "" ); |
89 | addItemString( "SMSChannelMessage", &mSMSOtherMessage, "" ); | 89 | addItemString( "SMSChannelMessage", &mSMSOtherMessage, "" ); |
90 | addItemString( "SMSChannelParameters", &mSMSOtherMessageParameters, "" ); | 90 | addItemString( "SMSChannelParameters", &mSMSOtherMessageParameters, "" ); |
91 | 91 | ||
92 | addItemInt( "PagerChannelType", &mPagerClient, NONE_PAC ); | 92 | addItemInt( "PagerChannelType", &mPagerClient, NONE_PAC ); |
93 | addItemString( "PagerChannel", &mPagerOtherChannel, "" ); | 93 | addItemString( "PagerChannel", &mPagerOtherChannel, "" ); |
94 | addItemString( "PagerChannelMessage", &mPagerOtherMessage, "" ); | 94 | addItemString( "PagerChannelMessage", &mPagerOtherMessage, "" ); |
95 | addItemString( "PagerChannelParameters", &mPagerOtherMessageParameters, "" ); | 95 | addItemString( "PagerChannelParameters", &mPagerOtherMessageParameters, "" ); |
96 | 96 | ||
97 | addItemInt( "SIPChannelType", &mSipClient, KPPI_SIC ); | 97 | addItemInt( "SIPChannelType", &mSipClient, KPPI_SIC ); |
98 | addItemString( "SIPChannel", &mSipOtherChannel, "" ); | 98 | addItemString( "SIPChannel", &mSipOtherChannel, "" ); |
99 | addItemString( "SIPChannelMessage", &mSipOtherMessage, "" ); | 99 | addItemString( "SIPChannelMessage", &mSipOtherMessage, "" ); |
100 | addItemString( "SIPChannelParameters", &mSipOtherMessageParameters, "" ); | 100 | addItemString( "SIPChannelParameters", &mSipOtherMessageParameters, "" ); |
101 | 101 | ||
102 | KPrefs::setCurrentGroup( "PhoneAccess" ); | 102 | KPrefs::setCurrentGroup( "PhoneAccess" ); |
103 | addItemString("Ex2PhoneDevice",&mEx2PhoneDevice,"/dev/ircomm"); | 103 | addItemString("Ex2PhoneDevice",&mEx2PhoneDevice,"/dev/ircomm"); |
104 | addItemString("Ex2PhoneConnection",&mEx2PhoneConnection,"irda"); | 104 | addItemString("Ex2PhoneConnection",&mEx2PhoneConnection,"irda"); |
105 | addItemString("Ex2PhoneModel",&mEx2PhoneModel,"6310i"); | 105 | addItemString("Ex2PhoneModel",&mEx2PhoneModel,"6310i"); |
106 | 106 | ||
107 | } | 107 | } |
108 | 108 | ||
109 | void KPimGlobalPrefs::setGlobalConfig() | 109 | void KPimGlobalPrefs::setGlobalConfig() |
110 | { | 110 | { |
111 | if ( mLocaleDict == 0 ) { | 111 | if ( mLocaleDict == 0 ) { |
112 | QString fileName ; | 112 | QString fileName ; |
113 | QString name = KGlobal::getAppName() +"/"; | 113 | QString name = KGlobal::getAppName() +"/"; |
114 | #ifndef DESKTOP_VERSION | 114 | #ifndef DESKTOP_VERSION |
115 | fileName= QString(getenv("QPEDIR"))+"/pics/kdepim/"+name; | 115 | fileName= QString(getenv("QPEDIR"))+"/pics/kdepim/"+name; |
116 | #else | 116 | #else |
117 | fileName = qApp->applicationDirPath () + "/kdepim/"+ name; | 117 | fileName = qApp->applicationDirPath () + "/kdepim/"+ name; |
118 | #endif | 118 | #endif |
119 | mLocaleDict = 0; | 119 | mLocaleDict = 0; |
120 | if ( mPreferredLanguage > 0 && mPreferredLanguage < 5 ) { | 120 | if ( mPreferredLanguage > 0 && mPreferredLanguage < 5 ) { |
121 | 121 | ||
122 | if ( mPreferredLanguage == 1 ) | 122 | if ( mPreferredLanguage == 1 ) |
123 | fileName = fileName+"germantranslation.txt"; | 123 | fileName = fileName+"germantranslation.txt"; |
124 | else if ( mPreferredLanguage == 4 ) | 124 | else if ( mPreferredLanguage == 4 ) |
125 | fileName = fileName+"usertranslation.txt"; | 125 | fileName = fileName+"usertranslation.txt"; |
126 | else if ( mPreferredLanguage == 2 ) | 126 | else if ( mPreferredLanguage == 2 ) |
127 | fileName = fileName+"frenchtranslation.txt"; | 127 | fileName = fileName+"frenchtranslation.txt"; |
128 | else if ( mPreferredLanguage == 3 ) | 128 | else if ( mPreferredLanguage == 3 ) |
129 | fileName = fileName+"italiantranslation.txt"; | 129 | fileName = fileName+"italiantranslation.txt"; |
130 | QFile file( fileName ); | 130 | QFile file( fileName ); |
131 | if (file.open( IO_ReadOnly ) ) { | 131 | if (file.open( IO_ReadOnly ) ) { |
132 | QTextStream ts( &file ); | 132 | QTextStream ts( &file ); |
133 | ts.setEncoding( QTextStream::Latin1 ); | 133 | ts.setEncoding( QTextStream::Latin1 ); |
134 | //ts.setCodec( QTextCodec::latin1 ); | 134 | //ts.setCodec( QTextCodec::latin1 ); |
135 | QString text = ts.read(); | 135 | QString text = ts.read(); |
136 | file.close(); | 136 | file.close(); |
137 | text.replace( QRegExp("\\\\n"), "\n" ); | 137 | text.replace( QRegExp("\\\\n"), "\n" ); |
138 | QString line; | 138 | QString line; |
139 | QString we; | 139 | QString we; |
140 | QString wt; | 140 | QString wt; |
141 | int br = 0; | 141 | int br = 0; |
142 | int nbr; | 142 | int nbr; |
143 | nbr = text.find ( "},", br ); | 143 | nbr = text.find ( "},", br ); |
144 | line = text.mid( br, nbr - br ); | 144 | line = text.mid( br, nbr - br ); |
145 | br = nbr+1; | 145 | br = nbr+1; |
146 | int se, ee, st, et; | 146 | int se, ee, st, et; |
147 | mLocaleDict = new QDict<QString>; | 147 | mLocaleDict = new QDict<QString>; |
148 | mLocaleDict->setAutoDelete( true ); | 148 | mLocaleDict->setAutoDelete( true ); |
149 | QString end = "{ \"\",\"\" }"; | 149 | QString end = "{ \"\",\"\" }"; |
150 | while ( (line != end) && (br > 1) ) { | 150 | while ( (line != end) && (br > 1) ) { |
151 | //qDebug("%d *%s* ", br, line.latin1()); | 151 | //qDebug("%d *%s* ", br, line.latin1()); |
152 | se = line.find("\"")+1; | 152 | se = line.find("\"")+1; |
153 | et = line.findRev("\"",-1); | 153 | et = line.findRev("\"",-1); |
154 | ee = line.find("\",\""); | 154 | ee = line.find("\",\""); |
155 | st = ee+3; | 155 | st = ee+3; |
156 | we = line.mid( se, ee-se ); | 156 | we = line.mid( se, ee-se ); |
157 | wt = line.mid( st, et-st ); | 157 | if ( mPreferredLanguage == 4 ) |
158 | wt = QString::fromUtf8(line.mid( st, et-st ).latin1()); | ||
159 | else | ||
160 | wt = line.mid( st, et-st ); | ||
158 | //qDebug("*%s* *%s* ", we.latin1(), wt.latin1()); | 161 | //qDebug("*%s* *%s* ", we.latin1(), wt.latin1()); |
159 | mLocaleDict->insert( we, new QString (wt) ); | 162 | mLocaleDict->insert( we, new QString (wt) ); |
160 | nbr = text.find ( "}", br ); | 163 | nbr = text.find ( "}", br ); |
161 | line = text.mid( br, nbr - br ); | 164 | line = text.mid( br, nbr - br ); |
162 | br = nbr+1; | 165 | br = nbr+1; |
163 | } | 166 | } |
164 | //qDebug("end *%s* ", end.latin1()); | 167 | //qDebug("end *%s* ", end.latin1()); |
165 | 168 | ||
166 | setLocaleDict( mLocaleDict ); | 169 | setLocaleDict( mLocaleDict ); |
167 | } else { | 170 | } else { |
168 | qDebug("KO: Cannot find translation file %s",fileName.latin1() ); | 171 | qDebug("KO: Cannot find translation file %s",fileName.latin1() ); |
169 | } | 172 | } |
170 | } | 173 | } |
171 | } | 174 | } |
172 | 175 | ||
173 | KGlobal::locale()->setHore24Format( !mPreferredTime ); | 176 | KGlobal::locale()->setHore24Format( !mPreferredTime ); |
174 | KGlobal::locale()->setWeekStartMonday( !mWeekStartsOnSunday ); | 177 | KGlobal::locale()->setWeekStartMonday( !mWeekStartsOnSunday ); |
175 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)mPreferredDate ); | 178 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)mPreferredDate ); |
176 | KGlobal::locale()->setLanguage( mPreferredLanguage ); | 179 | KGlobal::locale()->setLanguage( mPreferredLanguage ); |
177 | QString dummy = mUserDateFormatLong; | 180 | QString dummy = mUserDateFormatLong; |
178 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); | 181 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); |
179 | dummy = mUserDateFormatShort; | 182 | dummy = mUserDateFormatShort; |
180 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); | 183 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); |
181 | KGlobal::locale()->setDaylightSaving( mUseDaylightsaving, | 184 | KGlobal::locale()->setDaylightSaving( mUseDaylightsaving, |
182 | mDaylightsavingStart, | 185 | mDaylightsavingStart, |
183 | mDaylightsavingEnd ); | 186 | mDaylightsavingEnd ); |
184 | KGlobal::locale()->setTimezone( mTimeZoneId, mTimeZoneAdd30min ); | 187 | KGlobal::locale()->setTimezone( mTimeZoneId, mTimeZoneAdd30min ); |
185 | 188 | ||
186 | } | 189 | } |
187 | KPimGlobalPrefs::~KPimGlobalPrefs() | 190 | KPimGlobalPrefs::~KPimGlobalPrefs() |
188 | { | 191 | { |
189 | if (sInstance == this) | 192 | if (sInstance == this) |
190 | sInstance = staticDeleterGP.setObject(0); | 193 | sInstance = staticDeleterGP.setObject(0); |
191 | else | 194 | else |
192 | qDebug("Whats this? Error in KPimGlobalPrefs::~KPimGlobalPrefs() ?"); | 195 | qDebug("Whats this? Error in KPimGlobalPrefs::~KPimGlobalPrefs() ?"); |
193 | if ( mLocaleDict ) | 196 | if ( mLocaleDict ) |
194 | delete mLocaleDict; | 197 | delete mLocaleDict; |
195 | } | 198 | } |
196 | 199 | ||
197 | KPimGlobalPrefs *KPimGlobalPrefs::instance() | 200 | KPimGlobalPrefs *KPimGlobalPrefs::instance() |
198 | { | 201 | { |
199 | if ( !sInstance ) { | 202 | if ( !sInstance ) { |
200 | sInstance = staticDeleterGP.setObject( new KPimGlobalPrefs() ); | 203 | sInstance = staticDeleterGP.setObject( new KPimGlobalPrefs() ); |
201 | sInstance->readConfig(); | 204 | sInstance->readConfig(); |
202 | } | 205 | } |
203 | 206 | ||
204 | return sInstance; | 207 | return sInstance; |
205 | } | 208 | } |