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