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