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