summaryrefslogtreecommitdiffabout
path: root/libkdepim/kpimglobalprefs.cpp
Unidiff
Diffstat (limited to 'libkdepim/kpimglobalprefs.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/kpimglobalprefs.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/libkdepim/kpimglobalprefs.cpp b/libkdepim/kpimglobalprefs.cpp
index ac7d205..a09b278 100644
--- a/libkdepim/kpimglobalprefs.cpp
+++ b/libkdepim/kpimglobalprefs.cpp
@@ -1,211 +1,211 @@
1/* 1/*
2 This file is part of libkdepim. 2 This file is part of libkdepim.
3 Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2002 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or 7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version. 8 (at your option) any later version.
9 9
10 This program is distributed in the hope that it will be useful, 10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details. 13 GNU General Public License for more details.
14 14
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/*
25Enhanced Version of the file for platform independent KDE tools. 25Enhanced Version of the file for platform independent KDE tools.
26Copyright (c) 2004 Ulf Schenk 26Copyright (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
45KPimGlobalPrefs *KPimGlobalPrefs::sInstance = 0; 45KPimGlobalPrefs *KPimGlobalPrefs::sInstance = 0;
46static KStaticDeleter<KPimGlobalPrefs> staticDeleterGP; 46static KStaticDeleter<KPimGlobalPrefs> staticDeleterGP;
47 47
48 48
49KPimGlobalPrefs::KPimGlobalPrefs( const QString &name ) 49KPimGlobalPrefs::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, "%A %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("Time & Date"); 63 KPrefs::setCurrentGroup("Time & Date");
64 64
65 addItemString("TimeZoneName",&mTimeZoneId, ("+01:00 Europe/Oslo(CET)") ); 65 addItemString("TimeZoneName",&mTimeZoneId, ("+01:00 Europe/Oslo(CET)") );
66 addItemBool("UseDaylightsaving",&mUseDaylightsaving,true); 66 addItemBool("UseDaylightsaving",&mUseDaylightsaving,true);
67 addItemBool("TimeZoneAdd30min",&mTimeZoneAdd30min,false); 67 addItemBool("TimeZoneAdd30min",&mTimeZoneAdd30min,false);
68 addItemInt("DaylightsavingStart",&mDaylightsavingStart,90); 68 addItemInt("DaylightsavingStart",&mDaylightsavingStart,90);
69 addItemInt("DaylightsavingEnd",&mDaylightsavingEnd,304); 69 addItemInt("DaylightsavingEnd",&mDaylightsavingEnd,304);
70 70
71 KPrefs::setCurrentGroup( "ExternalApplications" ); 71 KPrefs::setCurrentGroup( "ExternalApplications" );
72 72
73 addItemInt( "EmailChannelType", &mEmailClient, OMPI_EMC ); 73 addItemInt( "EmailChannelType", &mEmailClient, OMPI_EMC );
74 addItemString( "EmailChannel", &mEmailOtherChannel, "" ); 74 addItemString( "EmailChannel", &mEmailOtherChannel, "" );
75 addItemString( "EmailChannelMessage", &mEmailOtherMessage, "" ); 75 addItemString( "EmailChannelMessage", &mEmailOtherMessage, "" );
76 addItemString( "EmailChannelParameters", &mEmailOtherMessageParameters, "" ); 76 addItemString( "EmailChannelParameters", &mEmailOtherMessageParameters, "" );
77 addItemString( "EmailChannelMessage2", &mEmailOtherMessage2, "" ); 77 addItemString( "EmailChannelMessage2", &mEmailOtherMessage2, "" );
78 addItemString( "EmailChannelParameters2", &mEmailOtherMessageParameters2, "" ); 78 addItemString( "EmailChannelParameters2", &mEmailOtherMessageParameters2, "" );
79 79
80 addItemInt( "PhoneChannelType", &mPhoneClient, KPPI_PHC ); 80 addItemInt( "PhoneChannelType", &mPhoneClient, KPPI_PHC );
81 addItemString( "PhoneChannel", &mPhoneOtherChannel, "" ); 81 addItemString( "PhoneChannel", &mPhoneOtherChannel, "" );
82 addItemString( "PhoneChannelMessage", &mPhoneOtherMessage, "" ); 82 addItemString( "PhoneChannelMessage", &mPhoneOtherMessage, "" );
83 addItemString( "PhoneChannelParameters", &mPhoneOtherMessageParameters, "" ); 83 addItemString( "PhoneChannelParameters", &mPhoneOtherMessageParameters, "" );
84 84
85 addItemInt( "FaxChannelType", &mFaxClient, NONE_FAC ); 85 addItemInt( "FaxChannelType", &mFaxClient, NONE_FAC );
86 addItemString( "FaxChannel", &mFaxOtherChannel, "" ); 86 addItemString( "FaxChannel", &mFaxOtherChannel, "" );
87 addItemString( "FaxChannelMessage", &mFaxOtherMessage, "" ); 87 addItemString( "FaxChannelMessage", &mFaxOtherMessage, "" );
88 addItemString( "FaxChannelParameters", &mFaxOtherMessageParameters, "" ); 88 addItemString( "FaxChannelParameters", &mFaxOtherMessageParameters, "" );
89 89
90 addItemInt( "SMSChannelType", &mSMSClient, NONE_SMC ); 90 addItemInt( "SMSChannelType", &mSMSClient, NONE_SMC );
91 addItemString( "SMSChannel", &mSMSOtherChannel, "" ); 91 addItemString( "SMSChannel", &mSMSOtherChannel, "" );
92 addItemString( "SMSChannelMessage", &mSMSOtherMessage, "" ); 92 addItemString( "SMSChannelMessage", &mSMSOtherMessage, "" );
93 addItemString( "SMSChannelParameters", &mSMSOtherMessageParameters, "" ); 93 addItemString( "SMSChannelParameters", &mSMSOtherMessageParameters, "" );
94 94
95 addItemInt( "PagerChannelType", &mPagerClient, NONE_PAC ); 95 addItemInt( "PagerChannelType", &mPagerClient, NONE_PAC );
96 addItemString( "PagerChannel", &mPagerOtherChannel, "" ); 96 addItemString( "PagerChannel", &mPagerOtherChannel, "" );
97 addItemString( "PagerChannelMessage", &mPagerOtherMessage, "" ); 97 addItemString( "PagerChannelMessage", &mPagerOtherMessage, "" );
98 addItemString( "PagerChannelParameters", &mPagerOtherMessageParameters, "" ); 98 addItemString( "PagerChannelParameters", &mPagerOtherMessageParameters, "" );
99 99
100 addItemInt( "SIPChannelType", &mSipClient, KPPI_SIC ); 100 addItemInt( "SIPChannelType", &mSipClient, KPPI_SIC );
101 addItemString( "SIPChannel", &mSipOtherChannel, "" ); 101 addItemString( "SIPChannel", &mSipOtherChannel, "" );
102 addItemString( "SIPChannelMessage", &mSipOtherMessage, "" ); 102 addItemString( "SIPChannelMessage", &mSipOtherMessage, "" );
103 addItemString( "SIPChannelParameters", &mSipOtherMessageParameters, "" ); 103 addItemString( "SIPChannelParameters", &mSipOtherMessageParameters, "" );
104 104
105 KPrefs::setCurrentGroup( "PhoneAccess" ); 105 KPrefs::setCurrentGroup( "PhoneAccess" );
106 addItemString("Ex2PhoneDevice",&mEx2PhoneDevice,"/dev/ircomm"); 106 addItemString("Ex2PhoneDevice",&mEx2PhoneDevice,"/dev/ircomm");
107 addItemString("Ex2PhoneConnection",&mEx2PhoneConnection,"irda"); 107 addItemString("Ex2PhoneConnection",&mEx2PhoneConnection,"irda");
108 addItemString("Ex2PhoneModel",&mEx2PhoneModel,"6310i"); 108 addItemString("Ex2PhoneModel",&mEx2PhoneModel,"6310i");
109 109
110} 110}
111 111
112void KPimGlobalPrefs::setGlobalConfig() 112void KPimGlobalPrefs::setGlobalConfig()
113{ 113{
114 if ( mLocaleDict == 0 ) { 114 if ( mLocaleDict == 0 ) {
115 QString fileName ; 115 QString fileName ;
116 QString name = KGlobal::getAppName() +"/"; 116 QString name = KGlobal::getAppName() +"/";
117#ifndef DESKTOP_VERSION 117#ifndef DESKTOP_VERSION
118 fileName= QString(getenv("QPEDIR"))+"/pics/kdepim/"+name; 118 fileName= QString(getenv("QPEDIR"))+"/pics/kdepim/"+name;
119#else 119#else
120 fileName = qApp->applicationDirPath () + "/kdepim/"+ name; 120 fileName = qApp->applicationDirPath () + "/kdepim/"+ name;
121#endif 121#endif
122 mLocaleDict = 0; 122 mLocaleDict = 0;
123 if ( mPreferredLanguage > 0 && mPreferredLanguage < 5 ) { 123 if ( mPreferredLanguage > 0 && mPreferredLanguage < 5 ) {
124 124
125 if ( mPreferredLanguage == 1 ) 125 if ( mPreferredLanguage == 1 )
126 fileName = fileName+"germantranslation.txt"; 126 fileName = fileName+"germantranslation.txt";
127 else if ( mPreferredLanguage == 4 ) 127 else if ( mPreferredLanguage == 4 )
128 fileName = fileName+"usertranslation.txt"; 128 fileName = fileName+"usertranslation.txt";
129 else if ( mPreferredLanguage == 2 ) 129 else if ( mPreferredLanguage == 2 )
130 fileName = fileName+"frenchtranslation.txt"; 130 fileName = fileName+"frenchtranslation.txt";
131 else if ( mPreferredLanguage == 3 ) 131 else if ( mPreferredLanguage == 3 )
132 fileName = fileName+"italiantranslation.txt"; 132 fileName = fileName+"italiantranslation.txt";
133 QFile file( fileName ); 133 QFile file( fileName );
134 if (file.open( IO_ReadOnly ) ) { 134 if (file.open( IO_ReadOnly ) ) {
135 QTextStream ts( &file ); 135 QTextStream ts( &file );
136 ts.setEncoding( QTextStream::Latin1 ); 136 ts.setEncoding( QTextStream::Latin1 );
137 //ts.setCodec( QTextCodec::latin1 ); 137 //ts.setCodec( QTextCodec::latin1 );
138 QString text = ts.read(); 138 QString text = ts.read();
139 file.close(); 139 file.close();
140 text.replace( QRegExp("\\\\n"), "\n" ); 140 text.replace( QRegExp("\\\\n"), "\n" );
141 QString line; 141 QString line;
142 QString we; 142 QString we;
143 QString wt; 143 QString wt;
144 int br = 0; 144 int br = 0;
145 int nbr; 145 int nbr;
146 nbr = text.find ( "},", br ); 146 nbr = text.find ( "},", br );
147 line = text.mid( br, nbr - br ); 147 line = text.mid( br, nbr - br );
148 br = nbr+1; 148 br = nbr+1;
149 int se, ee, st, et; 149 int se, ee, st, et;
150 mLocaleDict = new QDict<QString>; 150 mLocaleDict = new QDict<QString>;
151 mLocaleDict->setAutoDelete( true ); 151 mLocaleDict->setAutoDelete( true );
152 QString end = "{ \"\",\"\" }"; 152 QString end = "{ \"\",\"\" }";
153 while ( (line != end) && (br > 1) ) { 153 while ( (line != end) && (br > 1) ) {
154 //qDebug("%d *%s* ", br, line.latin1()); 154 //qDebug("%d *%s* ", br, line.latin1());
155 se = line.find("\"")+1; 155 se = line.find("\"")+1;
156 et = line.findRev("\"",-1); 156 et = line.findRev("\"",-1);
157 ee = line.find("\",\""); 157 ee = line.find("\",\"");
158 st = ee+3; 158 st = ee+3;
159 we = line.mid( se, ee-se ); 159 we = line.mid( se, ee-se );
160 if ( mPreferredLanguage == 4 ) 160 if ( mPreferredLanguage == 4 )
161 wt = QString::fromUtf8(line.mid( st, et-st ).latin1()); 161 wt = QString::fromUtf8(line.mid( st, et-st ).latin1());
162 else 162 else
163 wt = line.mid( st, et-st ); 163 wt = line.mid( st, et-st );
164 //qDebug("*%s* *%s* ", we.latin1(), wt.latin1()); 164 //qDebug("*%s* *%s* ", we.latin1(), wt.latin1());
165 mLocaleDict->insert( we, new QString (wt) ); 165 mLocaleDict->insert( we, new QString (wt) );
166 nbr = text.find ( "}", br ); 166 nbr = text.find ( "}", br );
167 line = text.mid( br, nbr - br ); 167 line = text.mid( br, nbr - br );
168 br = nbr+1; 168 br = nbr+1;
169 } 169 }
170 //qDebug("end *%s* ", end.latin1()); 170 //qDebug("end *%s* ", end.latin1());
171 171
172 setLocaleDict( mLocaleDict ); 172 setLocaleDict( mLocaleDict );
173 } else { 173 } else {
174 qDebug("KO: Cannot find translation file %s",fileName.latin1() ); 174 qDebug("KO: Cannot find translation file %s",fileName.latin1() );
175 } 175 }
176 } 176 }
177 } 177 }
178 178
179 KGlobal::locale()->setHore24Format( !mPreferredTime ); 179 KGlobal::locale()->setHore24Format( !mPreferredTime );
180 KGlobal::locale()->setWeekStartMonday( !mWeekStartsOnSunday ); 180 KGlobal::locale()->setWeekStartMonday( !mWeekStartsOnSunday );
181 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)mPreferredDate ); 181 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)mPreferredDate );
182 KGlobal::locale()->setLanguage( mPreferredLanguage ); 182 KGlobal::locale()->setLanguage( mPreferredLanguage );
183 QString dummy = mUserDateFormatLong; 183 QString dummy = mUserDateFormatLong;
184 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); 184 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") ));
185 dummy = mUserDateFormatShort; 185 dummy = mUserDateFormatShort;
186 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); 186 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") ));
187 KGlobal::locale()->setDaylightSaving( mUseDaylightsaving, 187 KGlobal::locale()->setDaylightSaving( mUseDaylightsaving,
188 mDaylightsavingStart, 188 mDaylightsavingStart,
189 mDaylightsavingEnd ); 189 mDaylightsavingEnd );
190 KGlobal::locale()->setTimezone( mTimeZoneId, mTimeZoneAdd30min ); 190 KGlobal::locale()->setTimezone( mTimeZoneId, mTimeZoneAdd30min );
191 191
192} 192}
193KPimGlobalPrefs::~KPimGlobalPrefs() 193KPimGlobalPrefs::~KPimGlobalPrefs()
194{ 194{
195 if (sInstance == this) 195 if (sInstance == this)
196 sInstance = staticDeleterGP.setObject(0); 196 sInstance = staticDeleterGP.setObject(0);
197 else 197 else
198 qDebug("Whats this? Error in KPimGlobalPrefs::~KPimGlobalPrefs() ?"); 198 qDebug("Whats this? Error in KPimGlobalPrefs::~KPimGlobalPrefs() ?");
199 if ( mLocaleDict ) 199 if ( mLocaleDict )
200 delete mLocaleDict; 200 delete mLocaleDict;
201} 201}
202 202
203KPimGlobalPrefs *KPimGlobalPrefs::instance() 203KPimGlobalPrefs *KPimGlobalPrefs::instance()
204{ 204{
205 if ( !sInstance ) { 205 if ( !sInstance ) {
206 sInstance = staticDeleterGP.setObject( new KPimGlobalPrefs() ); 206 sInstance = staticDeleterGP.setObject( new KPimGlobalPrefs() );
207 sInstance->readConfig(); 207 sInstance->readConfig();
208 } 208 }
209 209
210 return sInstance; 210 return sInstance;
211} 211}