-rw-r--r-- | libkdepim/kpimglobalprefs.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/libkdepim/kpimglobalprefs.cpp b/libkdepim/kpimglobalprefs.cpp index a09b278..873f0eb 100644 --- a/libkdepim/kpimglobalprefs.cpp +++ b/libkdepim/kpimglobalprefs.cpp | |||
@@ -15,96 +15,100 @@ | |||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | /* | 24 | /* |
25 | Enhanced Version of the file for platform independent KDE tools. | 25 | Enhanced Version of the file for platform independent KDE tools. |
26 | Copyright (c) 2004 Ulf Schenk | 26 | Copyright (c) 2004 Ulf Schenk |
27 | 27 | ||
28 | $Id$ | 28 | $Id$ |
29 | */ | 29 | */ |
30 | 30 | ||
31 | #include <kglobal.h> | 31 | #include <kglobal.h> |
32 | #include <kconfig.h> | 32 | #include <kconfig.h> |
33 | #include <klocale.h> | 33 | #include <klocale.h> |
34 | #include <kdebug.h> | 34 | #include <kdebug.h> |
35 | #include <kglobalsettings.h> | 35 | #include <kglobalsettings.h> |
36 | #include <kstaticdeleter.h> | 36 | #include <kstaticdeleter.h> |
37 | 37 | ||
38 | #include <qregexp.h> | 38 | #include <qregexp.h> |
39 | #include <qfile.h> | 39 | #include <qfile.h> |
40 | #include <stdlib.h> | 40 | #include <stdlib.h> |
41 | #include <qtextstream.h> | 41 | #include <qtextstream.h> |
42 | #include <qapplication.h> | 42 | #include <qapplication.h> |
43 | #include "kpimglobalprefs.h" | 43 | #include "kpimglobalprefs.h" |
44 | 44 | ||
45 | KPimGlobalPrefs *KPimGlobalPrefs::sInstance = 0; | 45 | KPimGlobalPrefs *KPimGlobalPrefs::sInstance = 0; |
46 | static KStaticDeleter<KPimGlobalPrefs> staticDeleterGP; | 46 | static KStaticDeleter<KPimGlobalPrefs> staticDeleterGP; |
47 | 47 | ||
48 | 48 | ||
49 | KPimGlobalPrefs::KPimGlobalPrefs( const QString &name ) | 49 | KPimGlobalPrefs::KPimGlobalPrefs( const QString &name ) |
50 | : KPrefs("microkdeglobalrc") | 50 | : KPrefs("microkdeglobalrc") |
51 | { | 51 | { |
52 | mLocaleDict = 0; | 52 | mLocaleDict = 0; |
53 | KPrefs::setCurrentGroup("Fonts"); | 53 | KPrefs::setCurrentGroup("Fonts"); |
54 | addItemFont("ApplicationFont",&mApplicationFont,KGlobalSettings::generalFont() ); | 54 | addItemFont("ApplicationFont",&mApplicationFont,KGlobalSettings::generalFont() ); |
55 | KPrefs::setCurrentGroup("Locale"); | 55 | KPrefs::setCurrentGroup("Locale"); |
56 | addItemInt("PreferredLanguage",&mPreferredLanguage,0); | 56 | addItemInt("PreferredLanguage",&mPreferredLanguage,0); |
57 | addItemInt("PreferredTime",&mPreferredTime,0); | 57 | addItemInt("PreferredTime",&mPreferredTime,0); |
58 | addItemInt("PreferredDate",&mPreferredDate,0); | 58 | addItemInt("PreferredDate",&mPreferredDate,0); |
59 | addItemBool("WeekStartsOnSunday",&mWeekStartsOnSunday,false); | 59 | addItemBool("WeekStartsOnSunday",&mWeekStartsOnSunday,false); |
60 | addItemString("UserDateFormatLong", &mUserDateFormatLong, "%AK %d. %b %y"); | 60 | addItemString("UserDateFormatLong", &mUserDateFormatLong, "%AK %d. %b %y"); |
61 | addItemString("UserDateFormatShort", &mUserDateFormatShort, "%aK %d.%m.%y"); | 61 | addItemString("UserDateFormatShort", &mUserDateFormatShort, "%aK %d.%m.%y"); |
62 | 62 | ||
63 | KPrefs::setCurrentGroup("Colors"); | ||
64 | addItemColor("AlternateBGcolor",&mAlternateColor,KGlobalSettings::alternateBackgroundColor()); | ||
65 | |||
66 | |||
63 | KPrefs::setCurrentGroup("Time & Date"); | 67 | KPrefs::setCurrentGroup("Time & Date"); |
64 | 68 | ||
65 | addItemString("TimeZoneName",&mTimeZoneId, ("+01:00 Europe/Oslo(CET)") ); | 69 | addItemString("TimeZoneName",&mTimeZoneId, ("+01:00 Europe/Oslo(CET)") ); |
66 | addItemBool("UseDaylightsaving",&mUseDaylightsaving,true); | 70 | addItemBool("UseDaylightsaving",&mUseDaylightsaving,true); |
67 | addItemBool("TimeZoneAdd30min",&mTimeZoneAdd30min,false); | 71 | addItemBool("TimeZoneAdd30min",&mTimeZoneAdd30min,false); |
68 | addItemInt("DaylightsavingStart",&mDaylightsavingStart,90); | 72 | addItemInt("DaylightsavingStart",&mDaylightsavingStart,90); |
69 | addItemInt("DaylightsavingEnd",&mDaylightsavingEnd,304); | 73 | addItemInt("DaylightsavingEnd",&mDaylightsavingEnd,304); |
70 | 74 | ||
71 | KPrefs::setCurrentGroup( "ExternalApplications" ); | 75 | KPrefs::setCurrentGroup( "ExternalApplications" ); |
72 | 76 | ||
73 | addItemInt( "EmailChannelType", &mEmailClient, OMPI_EMC ); | 77 | addItemInt( "EmailChannelType", &mEmailClient, OMPI_EMC ); |
74 | addItemString( "EmailChannel", &mEmailOtherChannel, "" ); | 78 | addItemString( "EmailChannel", &mEmailOtherChannel, "" ); |
75 | addItemString( "EmailChannelMessage", &mEmailOtherMessage, "" ); | 79 | addItemString( "EmailChannelMessage", &mEmailOtherMessage, "" ); |
76 | addItemString( "EmailChannelParameters", &mEmailOtherMessageParameters, "" ); | 80 | addItemString( "EmailChannelParameters", &mEmailOtherMessageParameters, "" ); |
77 | addItemString( "EmailChannelMessage2", &mEmailOtherMessage2, "" ); | 81 | addItemString( "EmailChannelMessage2", &mEmailOtherMessage2, "" ); |
78 | addItemString( "EmailChannelParameters2", &mEmailOtherMessageParameters2, "" ); | 82 | addItemString( "EmailChannelParameters2", &mEmailOtherMessageParameters2, "" ); |
79 | 83 | ||
80 | addItemInt( "PhoneChannelType", &mPhoneClient, KPPI_PHC ); | 84 | addItemInt( "PhoneChannelType", &mPhoneClient, KPPI_PHC ); |
81 | addItemString( "PhoneChannel", &mPhoneOtherChannel, "" ); | 85 | addItemString( "PhoneChannel", &mPhoneOtherChannel, "" ); |
82 | addItemString( "PhoneChannelMessage", &mPhoneOtherMessage, "" ); | 86 | addItemString( "PhoneChannelMessage", &mPhoneOtherMessage, "" ); |
83 | addItemString( "PhoneChannelParameters", &mPhoneOtherMessageParameters, "" ); | 87 | addItemString( "PhoneChannelParameters", &mPhoneOtherMessageParameters, "" ); |
84 | 88 | ||
85 | addItemInt( "FaxChannelType", &mFaxClient, NONE_FAC ); | 89 | addItemInt( "FaxChannelType", &mFaxClient, NONE_FAC ); |
86 | addItemString( "FaxChannel", &mFaxOtherChannel, "" ); | 90 | addItemString( "FaxChannel", &mFaxOtherChannel, "" ); |
87 | addItemString( "FaxChannelMessage", &mFaxOtherMessage, "" ); | 91 | addItemString( "FaxChannelMessage", &mFaxOtherMessage, "" ); |
88 | addItemString( "FaxChannelParameters", &mFaxOtherMessageParameters, "" ); | 92 | addItemString( "FaxChannelParameters", &mFaxOtherMessageParameters, "" ); |
89 | 93 | ||
90 | addItemInt( "SMSChannelType", &mSMSClient, NONE_SMC ); | 94 | addItemInt( "SMSChannelType", &mSMSClient, NONE_SMC ); |
91 | addItemString( "SMSChannel", &mSMSOtherChannel, "" ); | 95 | addItemString( "SMSChannel", &mSMSOtherChannel, "" ); |
92 | addItemString( "SMSChannelMessage", &mSMSOtherMessage, "" ); | 96 | addItemString( "SMSChannelMessage", &mSMSOtherMessage, "" ); |
93 | addItemString( "SMSChannelParameters", &mSMSOtherMessageParameters, "" ); | 97 | addItemString( "SMSChannelParameters", &mSMSOtherMessageParameters, "" ); |
94 | 98 | ||
95 | addItemInt( "PagerChannelType", &mPagerClient, NONE_PAC ); | 99 | addItemInt( "PagerChannelType", &mPagerClient, NONE_PAC ); |
96 | addItemString( "PagerChannel", &mPagerOtherChannel, "" ); | 100 | addItemString( "PagerChannel", &mPagerOtherChannel, "" ); |
97 | addItemString( "PagerChannelMessage", &mPagerOtherMessage, "" ); | 101 | addItemString( "PagerChannelMessage", &mPagerOtherMessage, "" ); |
98 | addItemString( "PagerChannelParameters", &mPagerOtherMessageParameters, "" ); | 102 | addItemString( "PagerChannelParameters", &mPagerOtherMessageParameters, "" ); |
99 | 103 | ||
100 | addItemInt( "SIPChannelType", &mSipClient, KPPI_SIC ); | 104 | addItemInt( "SIPChannelType", &mSipClient, KPPI_SIC ); |
101 | addItemString( "SIPChannel", &mSipOtherChannel, "" ); | 105 | addItemString( "SIPChannel", &mSipOtherChannel, "" ); |
102 | addItemString( "SIPChannelMessage", &mSipOtherMessage, "" ); | 106 | addItemString( "SIPChannelMessage", &mSipOtherMessage, "" ); |
103 | addItemString( "SIPChannelParameters", &mSipOtherMessageParameters, "" ); | 107 | addItemString( "SIPChannelParameters", &mSipOtherMessageParameters, "" ); |
104 | 108 | ||
105 | KPrefs::setCurrentGroup( "PhoneAccess" ); | 109 | KPrefs::setCurrentGroup( "PhoneAccess" ); |
106 | addItemString("Ex2PhoneDevice",&mEx2PhoneDevice,"/dev/ircomm"); | 110 | addItemString("Ex2PhoneDevice",&mEx2PhoneDevice,"/dev/ircomm"); |
107 | addItemString("Ex2PhoneConnection",&mEx2PhoneConnection,"irda"); | 111 | addItemString("Ex2PhoneConnection",&mEx2PhoneConnection,"irda"); |
108 | addItemString("Ex2PhoneModel",&mEx2PhoneModel,"6310i"); | 112 | addItemString("Ex2PhoneModel",&mEx2PhoneModel,"6310i"); |
109 | 113 | ||
110 | } | 114 | } |
@@ -143,69 +147,70 @@ void KPimGlobalPrefs::setGlobalConfig() | |||
143 | QString wt; | 147 | QString wt; |
144 | int br = 0; | 148 | int br = 0; |
145 | int nbr; | 149 | int nbr; |
146 | nbr = text.find ( "},", br ); | 150 | nbr = text.find ( "},", br ); |
147 | line = text.mid( br, nbr - br ); | 151 | line = text.mid( br, nbr - br ); |
148 | br = nbr+1; | 152 | br = nbr+1; |
149 | int se, ee, st, et; | 153 | int se, ee, st, et; |
150 | mLocaleDict = new QDict<QString>; | 154 | mLocaleDict = new QDict<QString>; |
151 | mLocaleDict->setAutoDelete( true ); | 155 | mLocaleDict->setAutoDelete( true ); |
152 | QString end = "{ \"\",\"\" }"; | 156 | QString end = "{ \"\",\"\" }"; |
153 | while ( (line != end) && (br > 1) ) { | 157 | while ( (line != end) && (br > 1) ) { |
154 | //qDebug("%d *%s* ", br, line.latin1()); | 158 | //qDebug("%d *%s* ", br, line.latin1()); |
155 | se = line.find("\"")+1; | 159 | se = line.find("\"")+1; |
156 | et = line.findRev("\"",-1); | 160 | et = line.findRev("\"",-1); |
157 | ee = line.find("\",\""); | 161 | ee = line.find("\",\""); |
158 | st = ee+3; | 162 | st = ee+3; |
159 | we = line.mid( se, ee-se ); | 163 | we = line.mid( se, ee-se ); |
160 | if ( mPreferredLanguage == 4 ) | 164 | if ( mPreferredLanguage == 4 ) |
161 | wt = QString::fromUtf8(line.mid( st, et-st ).latin1()); | 165 | wt = QString::fromUtf8(line.mid( st, et-st ).latin1()); |
162 | else | 166 | else |
163 | wt = line.mid( st, et-st ); | 167 | wt = line.mid( st, et-st ); |
164 | //qDebug("*%s* *%s* ", we.latin1(), wt.latin1()); | 168 | //qDebug("*%s* *%s* ", we.latin1(), wt.latin1()); |
165 | mLocaleDict->insert( we, new QString (wt) ); | 169 | mLocaleDict->insert( we, new QString (wt) ); |
166 | nbr = text.find ( "}", br ); | 170 | nbr = text.find ( "}", br ); |
167 | line = text.mid( br, nbr - br ); | 171 | line = text.mid( br, nbr - br ); |
168 | br = nbr+1; | 172 | br = nbr+1; |
169 | } | 173 | } |
170 | //qDebug("end *%s* ", end.latin1()); | 174 | //qDebug("end *%s* ", end.latin1()); |
171 | 175 | ||
172 | setLocaleDict( mLocaleDict ); | 176 | setLocaleDict( mLocaleDict ); |
173 | } else { | 177 | } else { |
174 | qDebug("KO: Cannot find translation file %s",fileName.latin1() ); | 178 | qDebug("KO: Cannot find translation file %s",fileName.latin1() ); |
175 | } | 179 | } |
176 | } | 180 | } |
177 | } | 181 | } |
178 | 182 | ||
179 | KGlobal::locale()->setHore24Format( !mPreferredTime ); | 183 | KGlobal::locale()->setHore24Format( !mPreferredTime ); |
180 | KGlobal::locale()->setWeekStartMonday( !mWeekStartsOnSunday ); | 184 | KGlobal::locale()->setWeekStartMonday( !mWeekStartsOnSunday ); |
181 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)mPreferredDate ); | 185 | KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)mPreferredDate ); |
182 | KGlobal::locale()->setLanguage( mPreferredLanguage ); | 186 | KGlobal::locale()->setLanguage( mPreferredLanguage ); |
183 | QString dummy = mUserDateFormatLong; | 187 | QString dummy = mUserDateFormatLong; |
184 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); | 188 | KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); |
185 | dummy = mUserDateFormatShort; | 189 | dummy = mUserDateFormatShort; |
186 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); | 190 | KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); |
187 | KGlobal::locale()->setDaylightSaving( mUseDaylightsaving, | 191 | KGlobal::locale()->setDaylightSaving( mUseDaylightsaving, |
188 | mDaylightsavingStart, | 192 | mDaylightsavingStart, |
189 | mDaylightsavingEnd ); | 193 | mDaylightsavingEnd ); |
190 | KGlobal::locale()->setTimezone( mTimeZoneId, mTimeZoneAdd30min ); | 194 | KGlobal::locale()->setTimezone( mTimeZoneId, mTimeZoneAdd30min ); |
195 | KGlobalSettings::setAlternateBackgroundColor(mAlternateColor); | ||
191 | 196 | ||
192 | } | 197 | } |
193 | KPimGlobalPrefs::~KPimGlobalPrefs() | 198 | KPimGlobalPrefs::~KPimGlobalPrefs() |
194 | { | 199 | { |
195 | if (sInstance == this) | 200 | if (sInstance == this) |
196 | sInstance = staticDeleterGP.setObject(0); | 201 | sInstance = staticDeleterGP.setObject(0); |
197 | else | 202 | else |
198 | qDebug("Whats this? Error in KPimGlobalPrefs::~KPimGlobalPrefs() ?"); | 203 | qDebug("Whats this? Error in KPimGlobalPrefs::~KPimGlobalPrefs() ?"); |
199 | if ( mLocaleDict ) | 204 | if ( mLocaleDict ) |
200 | delete mLocaleDict; | 205 | delete mLocaleDict; |
201 | } | 206 | } |
202 | 207 | ||
203 | KPimGlobalPrefs *KPimGlobalPrefs::instance() | 208 | KPimGlobalPrefs *KPimGlobalPrefs::instance() |
204 | { | 209 | { |
205 | if ( !sInstance ) { | 210 | if ( !sInstance ) { |
206 | sInstance = staticDeleterGP.setObject( new KPimGlobalPrefs() ); | 211 | sInstance = staticDeleterGP.setObject( new KPimGlobalPrefs() ); |
207 | sInstance->readConfig(); | 212 | sInstance->readConfig(); |
208 | } | 213 | } |
209 | 214 | ||
210 | return sInstance; | 215 | return sInstance; |
211 | } | 216 | } |