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