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