summaryrefslogtreecommitdiffabout
path: root/microkde
authorulf69 <ulf69>2004-07-02 15:33:56 (UTC)
committer ulf69 <ulf69>2004-07-02 15:33:56 (UTC)
commitbb7ad945c1541684a02e853fdaabd0e3ba74f8df (patch) (unidiff)
tree4ccde1ffdcb3b14cc6ef4945be87a6e82ff174b4 /microkde
parentdf5b4df6bc00ea8acfee0b11a335a9d2f39d04dc (diff)
downloadkdepimpi-bb7ad945c1541684a02e853fdaabd0e3ba74f8df.zip
kdepimpi-bb7ad945c1541684a02e853fdaabd0e3ba74f8df.tar.gz
kdepimpi-bb7ad945c1541684a02e853fdaabd0e3ba74f8df.tar.bz2
removed reentrant solution, for something better
Diffstat (limited to 'microkde') (more/less context) (ignore whitespace changes)
-rw-r--r--microkde/kglobal.cpp14
1 files changed, 3 insertions, 11 deletions
diff --git a/microkde/kglobal.cpp b/microkde/kglobal.cpp
index 6fa0dd6..2b1bd34 100644
--- a/microkde/kglobal.cpp
+++ b/microkde/kglobal.cpp
@@ -8,59 +8,49 @@ KConfig *KGlobal::mConfig = 0;
8KIconLoader *KGlobal::mIconLoader = 0; 8KIconLoader *KGlobal::mIconLoader = 0;
9KStandardDirs *KGlobal::mDirs = 0; 9KStandardDirs *KGlobal::mDirs = 0;
10 10
11QString KGlobal::mAppName = "godot"; 11QString KGlobal::mAppName = "godot";
12 12
13KLocale *KGlobal::locale() 13KLocale *KGlobal::locale()
14{ 14{
15 if ( !mLocale ) { 15 if ( !mLocale ) {
16 ASSERT(mAppName); 16 ASSERT(mAppName);
17 17
18 mLocale = new KLocale();//mAppName); 18 mLocale = new KLocale();//mAppName);
19 } 19 }
20 20
21 return mLocale; 21 return mLocale;
22} 22}
23 23
24//US 24//US
25void KGlobal::setLocale(KLocale *kg) 25void KGlobal::setLocale(KLocale *kg)
26{ 26{
27 mLocale = kg; 27 mLocale = kg;
28} 28}
29 29
30KConfig *KGlobal::config() 30KConfig *KGlobal::config()
31{ 31{
32 static bool reentrant = false; 32 //mConfig is set inside setAppName. Though it has to be the first function you call.
33
34 if (reentrant)
35 return 0;
36
37 if ( !mConfig ) {
38 reentrant = true;
39 mConfig = new KConfig( locateLocal("config", mAppName + "rc" ) );
40 reentrant = false;
41 }
42
43 return mConfig; 33 return mConfig;
44} 34}
45 35
46KGlobal::Size KGlobal::getDesktopSize() 36KGlobal::Size KGlobal::getDesktopSize()
47{ 37{
48#ifdef DESKTOP_VERSION 38#ifdef DESKTOP_VERSION
49 return KGlobal::Desktop; 39 return KGlobal::Desktop;
50#else 40#else
51 if ( QApplication::desktop()->width() < 480 ) 41 if ( QApplication::desktop()->width() < 480 )
52 return KGlobal::Small; 42 return KGlobal::Small;
53 else 43 else
54 return KGlobal::Medium; 44 return KGlobal::Medium;
55#endif 45#endif
56} 46}
57 47
58KGlobal::Orientation KGlobal::getOrientation() 48KGlobal::Orientation KGlobal::getOrientation()
59{ 49{
60 if (QApplication::desktop()->width() > QApplication::desktop()->height()) 50 if (QApplication::desktop()->width() > QApplication::desktop()->height())
61 return KGlobal::Landscape; 51 return KGlobal::Landscape;
62 else 52 else
63 return KGlobal::Portrait; 53 return KGlobal::Portrait;
64} 54}
65 55
66int KGlobal::getDesktopWidth() 56int KGlobal::getDesktopWidth()
@@ -74,48 +64,50 @@ int KGlobal::getDesktopHeight()
74} 64}
75 65
76 66
77KIconLoader *KGlobal::iconLoader() 67KIconLoader *KGlobal::iconLoader()
78{ 68{
79 if ( !mIconLoader ) { 69 if ( !mIconLoader ) {
80 mIconLoader = new KIconLoader(); 70 mIconLoader = new KIconLoader();
81 } 71 }
82 72
83 return mIconLoader; 73 return mIconLoader;
84} 74}
85 75
86KStandardDirs *KGlobal::dirs() 76KStandardDirs *KGlobal::dirs()
87{ 77{
88 if ( !mDirs ) { 78 if ( !mDirs ) {
89 mDirs = new KStandardDirs(); 79 mDirs = new KStandardDirs();
90 } 80 }
91 81
92 return mDirs; 82 return mDirs;
93} 83}
94 84
95void KGlobal::setAppName( const QString &appName ) 85void KGlobal::setAppName( const QString &appName )
96{ 86{
97 mAppName = appName; 87 mAppName = appName;
88
89 mConfig = new KConfig( locateLocal("config", mAppName + "rc" ) );
98} 90}
99 91
100//US 92//US
101QString KGlobal::getAppName() 93QString KGlobal::getAppName()
102{ 94{
103 return mAppName; 95 return mAppName;
104} 96}
105QString KGlobal::formatMessage ( QString mess, int maxlen ) 97QString KGlobal::formatMessage ( QString mess, int maxlen )
106{ 98{
107 //int maxlen = 80; 99 //int maxlen = 80;
108 int start = 0; 100 int start = 0;
109 int end = mess.length(); 101 int end = mess.length();
110 QString retVal = ""; 102 QString retVal = "";
111 int nl, space; 103 int nl, space;
112 while ( (end - start) > maxlen ) { 104 while ( (end - start) > maxlen ) {
113 nl = mess.find( "\n", start ); 105 nl = mess.find( "\n", start );
114 if ( nl > 0 && nl < start + maxlen ) { 106 if ( nl > 0 && nl < start + maxlen ) {
115 nl += 1; 107 nl += 1;
116 retVal += mess.mid( start, nl - start); 108 retVal += mess.mid( start, nl - start);
117 start = nl; 109 start = nl;
118 } else { 110 } else {
119 space = mess.findRev( " ", start + maxlen ); 111 space = mess.findRev( " ", start + maxlen );
120 if ( space < start ) { 112 if ( space < start ) {
121 retVal += mess.mid( start, maxlen) +"\n"; 113 retVal += mess.mid( start, maxlen) +"\n";