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