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