-rw-r--r-- | library/qpeapplication.cpp | 13 |
1 files changed, 1 insertions, 12 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index 755fb19..cf76000 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp | |||
@@ -83,204 +83,193 @@ | |||
83 | #endif | 83 | #endif |
84 | 84 | ||
85 | #include "alarmserver.h" | 85 | #include "alarmserver.h" |
86 | #include "applnk.h" | 86 | #include "applnk.h" |
87 | #include "qpemenubar.h" | 87 | #include "qpemenubar.h" |
88 | #include "textcodecinterface.h" | 88 | #include "textcodecinterface.h" |
89 | #include "imagecodecinterface.h" | 89 | #include "imagecodecinterface.h" |
90 | 90 | ||
91 | #include <unistd.h> | 91 | #include <unistd.h> |
92 | #include <sys/file.h> | 92 | #include <sys/file.h> |
93 | #include <sys/ioctl.h> | 93 | #include <sys/ioctl.h> |
94 | #ifndef QT_NO_SOUND | 94 | #ifndef QT_NO_SOUND |
95 | #include <sys/soundcard.h> | 95 | #include <sys/soundcard.h> |
96 | #endif | 96 | #endif |
97 | #include "qt_override_p.h" | 97 | #include "qt_override_p.h" |
98 | 98 | ||
99 | 99 | ||
100 | class QPEApplicationData | 100 | class QPEApplicationData |
101 | { | 101 | { |
102 | public: | 102 | public: |
103 | QPEApplicationData ( ) | 103 | QPEApplicationData ( ) |
104 | : presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ), | 104 | : presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ), |
105 | notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ), | 105 | notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ), |
106 | keep_running( true ), qcopQok( false ), qpe_main_widget( 0 ) | 106 | keep_running( true ), qcopQok( false ), qpe_main_widget( 0 ) |
107 | 107 | ||
108 | {} | 108 | {} |
109 | 109 | ||
110 | int presstimer; | 110 | int presstimer; |
111 | QWidget* presswidget; | 111 | QWidget* presswidget; |
112 | QPoint presspos; | 112 | QPoint presspos; |
113 | 113 | ||
114 | bool rightpressed : 1; | 114 | bool rightpressed : 1; |
115 | bool kbgrabbed : 1; | 115 | bool kbgrabbed : 1; |
116 | bool notbusysent : 1; | 116 | bool notbusysent : 1; |
117 | bool preloaded : 1; | 117 | bool preloaded : 1; |
118 | bool forceshow : 1; | 118 | bool forceshow : 1; |
119 | bool nomaximize : 1; | 119 | bool nomaximize : 1; |
120 | bool keep_running : 1; | 120 | bool keep_running : 1; |
121 | bool qcopQok : 1; | 121 | bool qcopQok : 1; |
122 | 122 | ||
123 | 123 | ||
124 | QStringList langs; | 124 | QStringList langs; |
125 | QString appName; | 125 | QString appName; |
126 | struct QCopRec | 126 | struct QCopRec |
127 | { | 127 | { |
128 | QCopRec( const QCString &ch, const QCString &msg, | 128 | QCopRec( const QCString &ch, const QCString &msg, |
129 | const QByteArray &d ) : | 129 | const QByteArray &d ) : |
130 | channel( ch ), message( msg ), data( d ) | 130 | channel( ch ), message( msg ), data( d ) |
131 | { } | 131 | { } |
132 | 132 | ||
133 | QCString channel; | 133 | QCString channel; |
134 | QCString message; | 134 | QCString message; |
135 | QByteArray data; | 135 | QByteArray data; |
136 | }; | 136 | }; |
137 | QWidget* qpe_main_widget; | 137 | QWidget* qpe_main_widget; |
138 | QGuardedPtr<QWidget> lastraised; | 138 | QGuardedPtr<QWidget> lastraised; |
139 | QQueue<QCopRec> qcopq; | 139 | QQueue<QCopRec> qcopq; |
140 | QString styleName; | 140 | QString styleName; |
141 | QString decorationName; | 141 | QString decorationName; |
142 | 142 | ||
143 | void enqueueQCop( const QCString &ch, const QCString &msg, | 143 | void enqueueQCop( const QCString &ch, const QCString &msg, |
144 | const QByteArray &data ) | 144 | const QByteArray &data ) |
145 | { | 145 | { |
146 | qcopq.enqueue( new QCopRec( ch, msg, data ) ); | 146 | qcopq.enqueue( new QCopRec( ch, msg, data ) ); |
147 | } | 147 | } |
148 | void sendQCopQ() | 148 | void sendQCopQ() |
149 | { | 149 | { |
150 | if (!qcopQok ) | 150 | if (!qcopQok ) |
151 | return; | 151 | return; |
152 | 152 | ||
153 | QCopRec * r; | 153 | QCopRec * r; |
154 | 154 | ||
155 | while((r=qcopq.dequeue())) { | 155 | while((r=qcopq.dequeue())) { |
156 | // remove from queue before sending... | 156 | // remove from queue before sending... |
157 | // event loop can come around again before getting | 157 | // event loop can come around again before getting |
158 | // back from sendLocally | 158 | // back from sendLocally |
159 | #ifndef QT_NO_COP | 159 | #ifndef QT_NO_COP |
160 | QCopChannel::sendLocally( r->channel, r->message, r->data ); | 160 | QCopChannel::sendLocally( r->channel, r->message, r->data ); |
161 | #endif | 161 | #endif |
162 | 162 | ||
163 | delete r; | 163 | delete r; |
164 | } | 164 | } |
165 | } | 165 | } |
166 | static void show_mx(QWidget* mw, bool nomaximize, const QString & = QString::null ) | 166 | static void show_mx(QWidget* mw, bool nomaximize, const QString & = QString::null ) |
167 | { | 167 | { |
168 | 168 | ||
169 | // ugly hack, remove that later after finding a sane solution | 169 | // ugly hack, remove that later after finding a sane solution |
170 | // Addendum: Only Sharp currently has models with high resolution but (physically) small displays, | 170 | // Addendum: Only Sharp currently has models with high resolution but (physically) small displays, |
171 | // so this is only useful if QT_QWS_SIMPAD is NOT defined. E.g. SIMpad has 800x600 but has | 171 | // so this is only useful if QT_QWS_SIMPAD is NOT defined. E.g. SIMpad has 800x600 but has |
172 | // a (physically) large enough display to use the small icons | 172 | // a (physically) large enough display to use the small icons |
173 | #if defined(OPIE_HIGH_RES_SMALL_PHY) | 173 | #if defined(OPIE_HIGH_RES_SMALL_PHY) |
174 | if ( QPEApplication::desktop() ->width() >= 600 && ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") ) ) { | 174 | if ( QPEApplication::desktop() ->width() >= 600 && ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") ) ) { |
175 | ( ( QMainWindow* ) mw )->setUsesBigPixmaps( true ); | 175 | ( ( QMainWindow* ) mw )->setUsesBigPixmaps( true ); |
176 | } | 176 | } |
177 | #endif | 177 | #endif |
178 | 178 | ||
179 | if ( mw->layout() && mw->inherits("QDialog") ) { | 179 | QPEApplication::showWidget( mw, nomaximize ); |
180 | QPEApplication::showDialog((QDialog*)mw, nomaximize); | ||
181 | } | ||
182 | else { | ||
183 | #ifdef Q_WS_QWS | ||
184 | if ( !nomaximize ) | ||
185 | mw->showMaximized(); | ||
186 | else | ||
187 | #endif | ||
188 | |||
189 | mw->show(); | ||
190 | } | ||
191 | } | 180 | } |
192 | static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) | 181 | static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) |
193 | { | 182 | { |
194 | /* | 183 | /* |
195 | // This works but disable it for now until it is safe to apply | 184 | // This works but disable it for now until it is safe to apply |
196 | // What is does is scan the .desktop files of all the apps for | 185 | // What is does is scan the .desktop files of all the apps for |
197 | // the applnk that has the corresponding argv[0] as this program | 186 | // the applnk that has the corresponding argv[0] as this program |
198 | // then it uses the name stored in the .desktop file as the caption | 187 | // then it uses the name stored in the .desktop file as the caption |
199 | // for the main widget. This saves duplicating translations for | 188 | // for the main widget. This saves duplicating translations for |
200 | // the app name in the program and in the .desktop files. | 189 | // the app name in the program and in the .desktop files. |
201 | 190 | ||
202 | AppLnkSet apps( appsPath ); | 191 | AppLnkSet apps( appsPath ); |
203 | 192 | ||
204 | QList<AppLnk> appsList = apps.children(); | 193 | QList<AppLnk> appsList = apps.children(); |
205 | for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { | 194 | for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { |
206 | if ( (*it)->exec() == appName ) { | 195 | if ( (*it)->exec() == appName ) { |
207 | mw->setCaption( (*it)->name() ); | 196 | mw->setCaption( (*it)->name() ); |
208 | return TRUE; | 197 | return TRUE; |
209 | } | 198 | } |
210 | } | 199 | } |
211 | */ | 200 | */ |
212 | return FALSE; | 201 | return FALSE; |
213 | } | 202 | } |
214 | 203 | ||
215 | 204 | ||
216 | void show(QWidget* mw, bool nomax) | 205 | void show(QWidget* mw, bool nomax) |
217 | { | 206 | { |
218 | setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); | 207 | setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); |
219 | nomaximize = nomax; | 208 | nomaximize = nomax; |
220 | qpe_main_widget = mw; | 209 | qpe_main_widget = mw; |
221 | qcopQok = TRUE; | 210 | qcopQok = TRUE; |
222 | #ifndef QT_NO_COP | 211 | #ifndef QT_NO_COP |
223 | 212 | ||
224 | sendQCopQ(); | 213 | sendQCopQ(); |
225 | #endif | 214 | #endif |
226 | 215 | ||
227 | if ( preloaded ) { | 216 | if ( preloaded ) { |
228 | if (forceshow) | 217 | if (forceshow) |
229 | show_mx(mw, nomax); | 218 | show_mx(mw, nomax); |
230 | } | 219 | } |
231 | else if ( keep_running ) { | 220 | else if ( keep_running ) { |
232 | show_mx(mw, nomax); | 221 | show_mx(mw, nomax); |
233 | } | 222 | } |
234 | } | 223 | } |
235 | 224 | ||
236 | void loadTextCodecs() | 225 | void loadTextCodecs() |
237 | { | 226 | { |
238 | QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; | 227 | QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; |
239 | #ifdef Q_OS_MACX | 228 | #ifdef Q_OS_MACX |
240 | QDir dir( path, "lib*.dylib" ); | 229 | QDir dir( path, "lib*.dylib" ); |
241 | #else | 230 | #else |
242 | QDir dir( path, "lib*.so" ); | 231 | QDir dir( path, "lib*.so" ); |
243 | #endif | 232 | #endif |
244 | QStringList list; | 233 | QStringList list; |
245 | if ( dir. exists ( )) | 234 | if ( dir. exists ( )) |
246 | list = dir.entryList(); | 235 | list = dir.entryList(); |
247 | QStringList::Iterator it; | 236 | QStringList::Iterator it; |
248 | for ( it = list.begin(); it != list.end(); ++it ) { | 237 | for ( it = list.begin(); it != list.end(); ++it ) { |
249 | TextCodecInterface *iface = 0; | 238 | TextCodecInterface *iface = 0; |
250 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 239 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
251 | if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { | 240 | if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { |
252 | QValueList<int> mibs = iface->mibEnums(); | 241 | QValueList<int> mibs = iface->mibEnums(); |
253 | for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { | 242 | for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { |
254 | (void)iface->createForMib(*i); | 243 | (void)iface->createForMib(*i); |
255 | // ### it exists now; need to remember if we can delete it | 244 | // ### it exists now; need to remember if we can delete it |
256 | } | 245 | } |
257 | } | 246 | } |
258 | else { | 247 | else { |
259 | lib->unload(); | 248 | lib->unload(); |
260 | delete lib; | 249 | delete lib; |
261 | } | 250 | } |
262 | } | 251 | } |
263 | } | 252 | } |
264 | 253 | ||
265 | void loadImageCodecs() | 254 | void loadImageCodecs() |
266 | { | 255 | { |
267 | QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; | 256 | QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; |
268 | #ifdef Q_OS_MACX | 257 | #ifdef Q_OS_MACX |
269 | QDir dir( path, "lib*.dylib" ); | 258 | QDir dir( path, "lib*.dylib" ); |
270 | #else | 259 | #else |
271 | QDir dir( path, "lib*.so" ); | 260 | QDir dir( path, "lib*.so" ); |
272 | #endif | 261 | #endif |
273 | QStringList list; | 262 | QStringList list; |
274 | if ( dir. exists ( )) | 263 | if ( dir. exists ( )) |
275 | list = dir.entryList(); | 264 | list = dir.entryList(); |
276 | QStringList::Iterator it; | 265 | QStringList::Iterator it; |
277 | for ( it = list.begin(); it != list.end(); ++it ) { | 266 | for ( it = list.begin(); it != list.end(); ++it ) { |
278 | ImageCodecInterface *iface = 0; | 267 | ImageCodecInterface *iface = 0; |
279 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 268 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
280 | if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { | 269 | if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { |
281 | QStringList formats = iface->keys(); | 270 | QStringList formats = iface->keys(); |
282 | for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { | 271 | for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { |
283 | (void)iface->installIOHandler(*i); | 272 | (void)iface->installIOHandler(*i); |
284 | // ### it exists now; need to remember if we can delete it | 273 | // ### it exists now; need to remember if we can delete it |
285 | } | 274 | } |
286 | } | 275 | } |