summaryrefslogtreecommitdiffabout
path: root/libkdepim/kpimglobalprefs.cpp
Unidiff
Diffstat (limited to 'libkdepim/kpimglobalprefs.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libkdepim/kpimglobalprefs.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/libkdepim/kpimglobalprefs.cpp b/libkdepim/kpimglobalprefs.cpp
index 873f0eb..90321b2 100644
--- a/libkdepim/kpimglobalprefs.cpp
+++ b/libkdepim/kpimglobalprefs.cpp
@@ -1,216 +1,223 @@
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, "%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" );
115 addItemString("BackupDatadir",&mBackupDatadir,KGlobalSettings::backupDataDir());
116 addItemInt( "BackupNumbers", &mBackupNumbers, 3 );
117 addItemInt( "BackupDayCount", &mBackupDayCount, 2 );
118 addItemBool( "BackupUseDefaultDir",&mBackupUseDefaultDir, true );
119 addItemBool( "BackupEnabled",&mBackupEnabled, false );
120
114} 121}
115 122
116void KPimGlobalPrefs::setGlobalConfig() 123void KPimGlobalPrefs::setGlobalConfig()
117{ 124{
118 if ( mLocaleDict == 0 ) { 125 if ( mLocaleDict == 0 ) {
119 QString fileName ; 126 QString fileName ;
120 QString name = KGlobal::getAppName() +"/"; 127 QString name = KGlobal::getAppName() +"/";
121#ifndef DESKTOP_VERSION 128#ifndef DESKTOP_VERSION
122 fileName= QString(getenv("QPEDIR"))+"/pics/kdepim/"+name; 129 fileName= QString(getenv("QPEDIR"))+"/pics/kdepim/"+name;
123#else 130#else
124 fileName = qApp->applicationDirPath () + "/kdepim/"+ name; 131 fileName = qApp->applicationDirPath () + "/kdepim/"+ name;
125#endif 132#endif
126 mLocaleDict = 0; 133 mLocaleDict = 0;
127 if ( mPreferredLanguage > 0 && mPreferredLanguage < 5 ) { 134 if ( mPreferredLanguage > 0 && mPreferredLanguage < 5 ) {
128 135
129 if ( mPreferredLanguage == 1 ) 136 if ( mPreferredLanguage == 1 )
130 fileName = fileName+"germantranslation.txt"; 137 fileName = fileName+"germantranslation.txt";
131 else if ( mPreferredLanguage == 4 ) 138 else if ( mPreferredLanguage == 4 )
132 fileName = fileName+"usertranslation.txt"; 139 fileName = fileName+"usertranslation.txt";
133 else if ( mPreferredLanguage == 2 ) 140 else if ( mPreferredLanguage == 2 )
134 fileName = fileName+"frenchtranslation.txt"; 141 fileName = fileName+"frenchtranslation.txt";
135 else if ( mPreferredLanguage == 3 ) 142 else if ( mPreferredLanguage == 3 )
136 fileName = fileName+"italiantranslation.txt"; 143 fileName = fileName+"italiantranslation.txt";
137 QFile file( fileName ); 144 QFile file( fileName );
138 if (file.open( IO_ReadOnly ) ) { 145 if (file.open( IO_ReadOnly ) ) {
139 QTextStream ts( &file ); 146 QTextStream ts( &file );
140 ts.setEncoding( QTextStream::Latin1 ); 147 ts.setEncoding( QTextStream::Latin1 );
141 //ts.setCodec( QTextCodec::latin1 ); 148 //ts.setCodec( QTextCodec::latin1 );
142 QString text = ts.read(); 149 QString text = ts.read();
143 file.close(); 150 file.close();
144 text.replace( QRegExp("\\\\n"), "\n" ); 151 text.replace( QRegExp("\\\\n"), "\n" );
145 QString line; 152 QString line;
146 QString we; 153 QString we;
147 QString wt; 154 QString wt;
148 int br = 0; 155 int br = 0;
149 int nbr; 156 int nbr;
150 nbr = text.find ( "},", br ); 157 nbr = text.find ( "},", br );
151 line = text.mid( br, nbr - br ); 158 line = text.mid( br, nbr - br );
152 br = nbr+1; 159 br = nbr+1;
153 int se, ee, st, et; 160 int se, ee, st, et;
154 mLocaleDict = new QDict<QString>; 161 mLocaleDict = new QDict<QString>;
155 mLocaleDict->setAutoDelete( true ); 162 mLocaleDict->setAutoDelete( true );
156 QString end = "{ \"\",\"\" }"; 163 QString end = "{ \"\",\"\" }";
157 while ( (line != end) && (br > 1) ) { 164 while ( (line != end) && (br > 1) ) {
158 //qDebug("%d *%s* ", br, line.latin1()); 165 //qDebug("%d *%s* ", br, line.latin1());
159 se = line.find("\"")+1; 166 se = line.find("\"")+1;
160 et = line.findRev("\"",-1); 167 et = line.findRev("\"",-1);
161 ee = line.find("\",\""); 168 ee = line.find("\",\"");
162 st = ee+3; 169 st = ee+3;
163 we = line.mid( se, ee-se ); 170 we = line.mid( se, ee-se );
164 if ( mPreferredLanguage == 4 ) 171 if ( mPreferredLanguage == 4 )
165 wt = QString::fromUtf8(line.mid( st, et-st ).latin1()); 172 wt = QString::fromUtf8(line.mid( st, et-st ).latin1());
166 else 173 else
167 wt = line.mid( st, et-st ); 174 wt = line.mid( st, et-st );
168 //qDebug("*%s* *%s* ", we.latin1(), wt.latin1()); 175 //qDebug("*%s* *%s* ", we.latin1(), wt.latin1());
169 mLocaleDict->insert( we, new QString (wt) ); 176 mLocaleDict->insert( we, new QString (wt) );
170 nbr = text.find ( "}", br ); 177 nbr = text.find ( "}", br );
171 line = text.mid( br, nbr - br ); 178 line = text.mid( br, nbr - br );
172 br = nbr+1; 179 br = nbr+1;
173 } 180 }
174 //qDebug("end *%s* ", end.latin1()); 181 //qDebug("end *%s* ", end.latin1());
175 182
176 setLocaleDict( mLocaleDict ); 183 setLocaleDict( mLocaleDict );
177 } else { 184 } else {
178 qDebug("KO: Cannot find translation file %s",fileName.latin1() ); 185 qDebug("KO: Cannot find translation file %s",fileName.latin1() );
179 } 186 }
180 } 187 }
181 } 188 }
182 189
183 KGlobal::locale()->setHore24Format( !mPreferredTime ); 190 KGlobal::locale()->setHore24Format( !mPreferredTime );
184 KGlobal::locale()->setWeekStartMonday( !mWeekStartsOnSunday ); 191 KGlobal::locale()->setWeekStartMonday( !mWeekStartsOnSunday );
185 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)mPreferredDate ); 192 KGlobal::locale()->setIntDateFormat( (KLocale::IntDateFormat)mPreferredDate );
186 KGlobal::locale()->setLanguage( mPreferredLanguage ); 193 KGlobal::locale()->setLanguage( mPreferredLanguage );
187 QString dummy = mUserDateFormatLong; 194 QString dummy = mUserDateFormatLong;
188 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") )); 195 KGlobal::locale()->setDateFormat(dummy.replace( QRegExp("K"), QString(",") ));
189 dummy = mUserDateFormatShort; 196 dummy = mUserDateFormatShort;
190 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") )); 197 KGlobal::locale()->setDateFormatShort(dummy.replace( QRegExp("K"), QString(",") ));
191 KGlobal::locale()->setDaylightSaving( mUseDaylightsaving, 198 KGlobal::locale()->setDaylightSaving( mUseDaylightsaving,
192 mDaylightsavingStart, 199 mDaylightsavingStart,
193 mDaylightsavingEnd ); 200 mDaylightsavingEnd );
194 KGlobal::locale()->setTimezone( mTimeZoneId, mTimeZoneAdd30min ); 201 KGlobal::locale()->setTimezone( mTimeZoneId, mTimeZoneAdd30min );
195 KGlobalSettings::setAlternateBackgroundColor(mAlternateColor); 202 KGlobalSettings::setAlternateBackgroundColor(mAlternateColor);
196 203
197} 204}
198KPimGlobalPrefs::~KPimGlobalPrefs() 205KPimGlobalPrefs::~KPimGlobalPrefs()
199{ 206{
200 if (sInstance == this) 207 if (sInstance == this)
201 sInstance = staticDeleterGP.setObject(0); 208 sInstance = staticDeleterGP.setObject(0);
202 else 209 else
203 qDebug("Whats this? Error in KPimGlobalPrefs::~KPimGlobalPrefs() ?"); 210 qDebug("Whats this? Error in KPimGlobalPrefs::~KPimGlobalPrefs() ?");
204 if ( mLocaleDict ) 211 if ( mLocaleDict )
205 delete mLocaleDict; 212 delete mLocaleDict;
206} 213}
207 214
208KPimGlobalPrefs *KPimGlobalPrefs::instance() 215KPimGlobalPrefs *KPimGlobalPrefs::instance()
209{ 216{
210 if ( !sInstance ) { 217 if ( !sInstance ) {
211 sInstance = staticDeleterGP.setObject( new KPimGlobalPrefs() ); 218 sInstance = staticDeleterGP.setObject( new KPimGlobalPrefs() );
212 sInstance->readConfig(); 219 sInstance->readConfig();
213 } 220 }
214 221
215 return sInstance; 222 return sInstance;
216} 223}