summaryrefslogtreecommitdiffabout
path: root/microkde
Unidiff
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
@@ -1,174 +1,166 @@
1#include "kglobal.h" 1#include "kglobal.h"
2#include "kstandarddirs.h" 2#include "kstandarddirs.h"
3#include <qkeycode.h> 3#include <qkeycode.h>
4#include <qapplication.h> 4#include <qapplication.h>
5 5
6KLocale *KGlobal::mLocale = 0; 6KLocale *KGlobal::mLocale = 0;
7KConfig *KGlobal::mConfig = 0; 7KConfig *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()
67{ 57{
68 return QApplication::desktop()->width(); 58 return QApplication::desktop()->width();
69} 59}
70 60
71int KGlobal::getDesktopHeight() 61int KGlobal::getDesktopHeight()
72{ 62{
73 return QApplication::desktop()->height(); 63 return QApplication::desktop()->height();
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";
122 start += maxlen ; 114 start += maxlen ;
123 } else { 115 } else {
124 retVal += mess.mid( start, space - start ) +"\n"; 116 retVal += mess.mid( start, space - start ) +"\n";
125 start = space+ 1; 117 start = space+ 1;
126 } 118 }
127 } 119 }
128 } 120 }
129 retVal += mess.mid( start, end - start ); 121 retVal += mess.mid( start, end - start );
130 return retVal; 122 return retVal;
131} 123}
132int KGlobal::knumkeykonv( int k ) 124int KGlobal::knumkeykonv( int k )
133{ 125{
134 int key; 126 int key;
135switch( k ) { 127switch( k ) {
136 case Qt::Key_Q : 128 case Qt::Key_Q :
137 key = Qt::Key_1; 129 key = Qt::Key_1;
138 break; 130 break;
139 case Qt::Key_W : 131 case Qt::Key_W :
140 key = Qt::Key_2; 132 key = Qt::Key_2;
141 break; 133 break;
142 case Qt::Key_E : 134 case Qt::Key_E :
143 key = Qt::Key_3; 135 key = Qt::Key_3;
144 break; 136 break;
145 case Qt::Key_R : 137 case Qt::Key_R :
146 key = Qt::Key_4; 138 key = Qt::Key_4;
147 break; 139 break;
148 case Qt::Key_T : 140 case Qt::Key_T :
149 key = Qt::Key_5; 141 key = Qt::Key_5;
150 break; 142 break;
151 case Qt::Key_Z : 143 case Qt::Key_Z :
152 key = Qt::Key_6; 144 key = Qt::Key_6;
153 break; 145 break;
154 case Qt::Key_Y : 146 case Qt::Key_Y :
155 key = Qt::Key_6; 147 key = Qt::Key_6;
156 break; 148 break;
157 case Qt::Key_U : 149 case Qt::Key_U :
158 key = Qt::Key_7; 150 key = Qt::Key_7;
159 break; 151 break;
160 case Qt::Key_I : 152 case Qt::Key_I :
161 key = Qt::Key_8; 153 key = Qt::Key_8;
162 break; 154 break;
163 case Qt::Key_O : 155 case Qt::Key_O :
164 key = Qt::Key_9; 156 key = Qt::Key_9;
165 break; 157 break;
166 case Qt::Key_P : 158 case Qt::Key_P :
167 key = Qt::Key_0; 159 key = Qt::Key_0;
168 break; 160 break;
169 default: 161 default:
170 key = k; 162 key = k;
171 break; 163 break;
172 } // switch 164 } // switch
173 return key; 165 return key;
174} 166}