author | ulf69 <ulf69> | 2004-07-01 01:38:10 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-07-01 01:38:10 (UTC) |
commit | d419ee83db7d2549c701fe89b678be619a7ce4d3 (patch) (unidiff) | |
tree | 2c6974dd047c51d7703d74f04217eafa6924b756 | |
parent | e3e162fb75c497b95a9a9b43792fa88c998b265c (diff) | |
download | kdepimpi-d419ee83db7d2549c701fe89b678be619a7ce4d3.zip kdepimpi-d419ee83db7d2549c701fe89b678be619a7ce4d3.tar.gz kdepimpi-d419ee83db7d2549c701fe89b678be619a7ce4d3.tar.bz2 |
adding reentrant flag, to avoid recursive call
-rw-r--r-- | microkde/kglobal.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/microkde/kglobal.cpp b/microkde/kglobal.cpp index 0aba952..6fa0dd6 100644 --- a/microkde/kglobal.cpp +++ b/microkde/kglobal.cpp | |||
@@ -1,166 +1,174 @@ | |||
1 | #include "kglobal.h" | 1 | #include "kglobal.h" |
2 | #include "kstandarddirs.h" | ||
2 | #include <qkeycode.h> | 3 | #include <qkeycode.h> |
3 | #include <qapplication.h> | 4 | #include <qapplication.h> |
4 | 5 | ||
5 | KLocale *KGlobal::mLocale = 0; | 6 | KLocale *KGlobal::mLocale = 0; |
6 | KConfig *KGlobal::mConfig = 0; | 7 | KConfig *KGlobal::mConfig = 0; |
7 | KIconLoader *KGlobal::mIconLoader = 0; | 8 | KIconLoader *KGlobal::mIconLoader = 0; |
8 | KStandardDirs *KGlobal::mDirs = 0; | 9 | KStandardDirs *KGlobal::mDirs = 0; |
9 | 10 | ||
10 | QString KGlobal::mAppName = "godot"; | 11 | QString KGlobal::mAppName = "godot"; |
11 | 12 | ||
12 | KLocale *KGlobal::locale() | 13 | KLocale *KGlobal::locale() |
13 | { | 14 | { |
14 | if ( !mLocale ) { | 15 | if ( !mLocale ) { |
15 | ASSERT(mAppName); | 16 | ASSERT(mAppName); |
16 | 17 | ||
17 | mLocale = new KLocale();//mAppName); | 18 | mLocale = new KLocale();//mAppName); |
18 | } | 19 | } |
19 | 20 | ||
20 | return mLocale; | 21 | return mLocale; |
21 | } | 22 | } |
22 | 23 | ||
23 | //US | 24 | //US |
24 | void KGlobal::setLocale(KLocale *kg) | 25 | void KGlobal::setLocale(KLocale *kg) |
25 | { | 26 | { |
26 | mLocale = kg; | 27 | mLocale = kg; |
27 | } | 28 | } |
28 | 29 | ||
29 | KConfig *KGlobal::config() | 30 | KConfig *KGlobal::config() |
30 | { | 31 | { |
32 | static bool reentrant = false; | ||
33 | |||
34 | if (reentrant) | ||
35 | return 0; | ||
36 | |||
31 | if ( !mConfig ) { | 37 | if ( !mConfig ) { |
32 | mConfig = new KConfig( KStandardDirs::appDir() + mAppName + "rc" ); | 38 | reentrant = true; |
39 | mConfig = new KConfig( locateLocal("config", mAppName + "rc" ) ); | ||
40 | reentrant = false; | ||
33 | } | 41 | } |
34 | 42 | ||
35 | return mConfig; | 43 | return mConfig; |
36 | } | 44 | } |
37 | 45 | ||
38 | KGlobal::Size KGlobal::getDesktopSize() | 46 | KGlobal::Size KGlobal::getDesktopSize() |
39 | { | 47 | { |
40 | #ifdef DESKTOP_VERSION | 48 | #ifdef DESKTOP_VERSION |
41 | return KGlobal::Desktop; | 49 | return KGlobal::Desktop; |
42 | #else | 50 | #else |
43 | if ( QApplication::desktop()->width() < 480 ) | 51 | if ( QApplication::desktop()->width() < 480 ) |
44 | return KGlobal::Small; | 52 | return KGlobal::Small; |
45 | else | 53 | else |
46 | return KGlobal::Medium; | 54 | return KGlobal::Medium; |
47 | #endif | 55 | #endif |
48 | } | 56 | } |
49 | 57 | ||
50 | KGlobal::Orientation KGlobal::getOrientation() | 58 | KGlobal::Orientation KGlobal::getOrientation() |
51 | { | 59 | { |
52 | if (QApplication::desktop()->width() > QApplication::desktop()->height()) | 60 | if (QApplication::desktop()->width() > QApplication::desktop()->height()) |
53 | return KGlobal::Landscape; | 61 | return KGlobal::Landscape; |
54 | else | 62 | else |
55 | return KGlobal::Portrait; | 63 | return KGlobal::Portrait; |
56 | } | 64 | } |
57 | 65 | ||
58 | int KGlobal::getDesktopWidth() | 66 | int KGlobal::getDesktopWidth() |
59 | { | 67 | { |
60 | return QApplication::desktop()->width(); | 68 | return QApplication::desktop()->width(); |
61 | } | 69 | } |
62 | 70 | ||
63 | int KGlobal::getDesktopHeight() | 71 | int KGlobal::getDesktopHeight() |
64 | { | 72 | { |
65 | return QApplication::desktop()->height(); | 73 | return QApplication::desktop()->height(); |
66 | } | 74 | } |
67 | 75 | ||
68 | 76 | ||
69 | KIconLoader *KGlobal::iconLoader() | 77 | KIconLoader *KGlobal::iconLoader() |
70 | { | 78 | { |
71 | if ( !mIconLoader ) { | 79 | if ( !mIconLoader ) { |
72 | mIconLoader = new KIconLoader(); | 80 | mIconLoader = new KIconLoader(); |
73 | } | 81 | } |
74 | 82 | ||
75 | return mIconLoader; | 83 | return mIconLoader; |
76 | } | 84 | } |
77 | 85 | ||
78 | KStandardDirs *KGlobal::dirs() | 86 | KStandardDirs *KGlobal::dirs() |
79 | { | 87 | { |
80 | if ( !mDirs ) { | 88 | if ( !mDirs ) { |
81 | mDirs = new KStandardDirs(); | 89 | mDirs = new KStandardDirs(); |
82 | } | 90 | } |
83 | 91 | ||
84 | return mDirs; | 92 | return mDirs; |
85 | } | 93 | } |
86 | 94 | ||
87 | void KGlobal::setAppName( const QString &appName ) | 95 | void KGlobal::setAppName( const QString &appName ) |
88 | { | 96 | { |
89 | mAppName = appName; | 97 | mAppName = appName; |
90 | } | 98 | } |
91 | 99 | ||
92 | //US | 100 | //US |
93 | QString KGlobal::getAppName() | 101 | QString KGlobal::getAppName() |
94 | { | 102 | { |
95 | return mAppName; | 103 | return mAppName; |
96 | } | 104 | } |
97 | QString KGlobal::formatMessage ( QString mess, int maxlen ) | 105 | QString KGlobal::formatMessage ( QString mess, int maxlen ) |
98 | { | 106 | { |
99 | //int maxlen = 80; | 107 | //int maxlen = 80; |
100 | int start = 0; | 108 | int start = 0; |
101 | int end = mess.length(); | 109 | int end = mess.length(); |
102 | QString retVal = ""; | 110 | QString retVal = ""; |
103 | int nl, space; | 111 | int nl, space; |
104 | while ( (end - start) > maxlen ) { | 112 | while ( (end - start) > maxlen ) { |
105 | nl = mess.find( "\n", start ); | 113 | nl = mess.find( "\n", start ); |
106 | if ( nl > 0 && nl < start + maxlen ) { | 114 | if ( nl > 0 && nl < start + maxlen ) { |
107 | nl += 1; | 115 | nl += 1; |
108 | retVal += mess.mid( start, nl - start); | 116 | retVal += mess.mid( start, nl - start); |
109 | start = nl; | 117 | start = nl; |
110 | } else { | 118 | } else { |
111 | space = mess.findRev( " ", start + maxlen ); | 119 | space = mess.findRev( " ", start + maxlen ); |
112 | if ( space < start ) { | 120 | if ( space < start ) { |
113 | retVal += mess.mid( start, maxlen) +"\n"; | 121 | retVal += mess.mid( start, maxlen) +"\n"; |
114 | start += maxlen ; | 122 | start += maxlen ; |
115 | } else { | 123 | } else { |
116 | retVal += mess.mid( start, space - start ) +"\n"; | 124 | retVal += mess.mid( start, space - start ) +"\n"; |
117 | start = space+ 1; | 125 | start = space+ 1; |
118 | } | 126 | } |
119 | } | 127 | } |
120 | } | 128 | } |
121 | retVal += mess.mid( start, end - start ); | 129 | retVal += mess.mid( start, end - start ); |
122 | return retVal; | 130 | return retVal; |
123 | } | 131 | } |
124 | int KGlobal::knumkeykonv( int k ) | 132 | int KGlobal::knumkeykonv( int k ) |
125 | { | 133 | { |
126 | int key; | 134 | int key; |
127 | switch( k ) { | 135 | switch( k ) { |
128 | case Qt::Key_Q : | 136 | case Qt::Key_Q : |
129 | key = Qt::Key_1; | 137 | key = Qt::Key_1; |
130 | break; | 138 | break; |
131 | case Qt::Key_W : | 139 | case Qt::Key_W : |
132 | key = Qt::Key_2; | 140 | key = Qt::Key_2; |
133 | break; | 141 | break; |
134 | case Qt::Key_E : | 142 | case Qt::Key_E : |
135 | key = Qt::Key_3; | 143 | key = Qt::Key_3; |
136 | break; | 144 | break; |
137 | case Qt::Key_R : | 145 | case Qt::Key_R : |
138 | key = Qt::Key_4; | 146 | key = Qt::Key_4; |
139 | break; | 147 | break; |
140 | case Qt::Key_T : | 148 | case Qt::Key_T : |
141 | key = Qt::Key_5; | 149 | key = Qt::Key_5; |
142 | break; | 150 | break; |
143 | case Qt::Key_Z : | 151 | case Qt::Key_Z : |
144 | key = Qt::Key_6; | 152 | key = Qt::Key_6; |
145 | break; | 153 | break; |
146 | case Qt::Key_Y : | 154 | case Qt::Key_Y : |
147 | key = Qt::Key_6; | 155 | key = Qt::Key_6; |
148 | break; | 156 | break; |
149 | case Qt::Key_U : | 157 | case Qt::Key_U : |
150 | key = Qt::Key_7; | 158 | key = Qt::Key_7; |
151 | break; | 159 | break; |
152 | case Qt::Key_I : | 160 | case Qt::Key_I : |
153 | key = Qt::Key_8; | 161 | key = Qt::Key_8; |
154 | break; | 162 | break; |
155 | case Qt::Key_O : | 163 | case Qt::Key_O : |
156 | key = Qt::Key_9; | 164 | key = Qt::Key_9; |
157 | break; | 165 | break; |
158 | case Qt::Key_P : | 166 | case Qt::Key_P : |
159 | key = Qt::Key_0; | 167 | key = Qt::Key_0; |
160 | break; | 168 | break; |
161 | default: | 169 | default: |
162 | key = k; | 170 | key = k; |
163 | break; | 171 | break; |
164 | } // switch | 172 | } // switch |
165 | return key; | 173 | return key; |
166 | } | 174 | } |