author | ar <ar> | 2005-03-10 16:21:07 (UTC) |
---|---|---|
committer | ar <ar> | 2005-03-10 16:21:07 (UTC) |
commit | 3bf4809c4f2263f0130472c41aa6c85e46e61db9 (patch) (unidiff) | |
tree | 82c34fddb63bb6ca8cbd53709ab2642795241d38 /library/qpeapplication.cpp | |
parent | 95a99e7b75eddc5629e839698b762f594be42b9f (diff) | |
download | opie-3bf4809c4f2263f0130472c41aa6c85e46e61db9.zip opie-3bf4809c4f2263f0130472c41aa6c85e46e61db9.tar.gz opie-3bf4809c4f2263f0130472c41aa6c85e46e61db9.tar.bz2 |
- implement nomax.patch from openembedded
-rw-r--r-- | library/qpeapplication.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index 953f9d0..0f3e4a4 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp | |||
@@ -125,348 +125,350 @@ public: | |||
125 | Config cfg( "qpe" ); | 125 | Config cfg( "qpe" ); |
126 | cfg.setGroup( "Appearance" ); | 126 | cfg.setGroup( "Appearance" ); |
127 | useBigPixmaps = cfg.readBoolEntry( "useBigPixmaps", false ); | 127 | useBigPixmaps = cfg.readBoolEntry( "useBigPixmaps", false ); |
128 | fontFamily = cfg.readEntry( "FontFamily", "Vera" ); | 128 | fontFamily = cfg.readEntry( "FontFamily", "Vera" ); |
129 | fontSize = cfg.readNumEntry( "FontSize", 10 ); | 129 | fontSize = cfg.readNumEntry( "FontSize", 10 ); |
130 | smallIconSize = cfg.readNumEntry( "SmallIconSize", 14 ); | 130 | smallIconSize = cfg.readNumEntry( "SmallIconSize", 14 ); |
131 | bigIconSize = cfg.readNumEntry( "BigIconSize", 32 ); | 131 | bigIconSize = cfg.readNumEntry( "BigIconSize", 32 ); |
132 | #ifdef OPIE_WITHROHFEEDBACK | 132 | #ifdef OPIE_WITHROHFEEDBACK |
133 | RoH = 0; | 133 | RoH = 0; |
134 | #endif | 134 | #endif |
135 | } | 135 | } |
136 | 136 | ||
137 | int presstimer; | 137 | int presstimer; |
138 | QWidget* presswidget; | 138 | QWidget* presswidget; |
139 | QPoint presspos; | 139 | QPoint presspos; |
140 | #ifdef OPIE_WITHROHFEEDBACK | 140 | #ifdef OPIE_WITHROHFEEDBACK |
141 | Opie::Internal::RoHFeedback *RoH; | 141 | Opie::Internal::RoHFeedback *RoH; |
142 | #endif | 142 | #endif |
143 | 143 | ||
144 | bool rightpressed : 1; | 144 | bool rightpressed : 1; |
145 | bool kbgrabbed : 1; | 145 | bool kbgrabbed : 1; |
146 | bool notbusysent : 1; | 146 | bool notbusysent : 1; |
147 | bool preloaded : 1; | 147 | bool preloaded : 1; |
148 | bool forceshow : 1; | 148 | bool forceshow : 1; |
149 | bool nomaximize : 1; | 149 | bool nomaximize : 1; |
150 | bool keep_running : 1; | 150 | bool keep_running : 1; |
151 | bool qcopQok : 1; | 151 | bool qcopQok : 1; |
152 | 152 | ||
153 | QCString fontFamily; | 153 | QCString fontFamily; |
154 | int fontSize; | 154 | int fontSize; |
155 | int smallIconSize; | 155 | int smallIconSize; |
156 | int bigIconSize; | 156 | int bigIconSize; |
157 | 157 | ||
158 | QString appName; | 158 | QString appName; |
159 | struct QCopRec | 159 | struct QCopRec |
160 | { | 160 | { |
161 | QCopRec( const QCString &ch, const QCString &msg, | 161 | QCopRec( const QCString &ch, const QCString &msg, |
162 | const QByteArray &d ) : | 162 | const QByteArray &d ) : |
163 | channel( ch ), message( msg ), data( d ) | 163 | channel( ch ), message( msg ), data( d ) |
164 | { } | 164 | { } |
165 | 165 | ||
166 | QCString channel; | 166 | QCString channel; |
167 | QCString message; | 167 | QCString message; |
168 | QByteArray data; | 168 | QByteArray data; |
169 | }; | 169 | }; |
170 | QGuardedPtr<QWidget> qpe_main_widget; | 170 | QGuardedPtr<QWidget> qpe_main_widget; |
171 | QGuardedPtr<QWidget> lastraised; | 171 | QGuardedPtr<QWidget> lastraised; |
172 | QQueue<QCopRec> qcopq; | 172 | QQueue<QCopRec> qcopq; |
173 | QString styleName; | 173 | QString styleName; |
174 | QString decorationName; | 174 | QString decorationName; |
175 | 175 | ||
176 | void enqueueQCop( const QCString &ch, const QCString &msg, | 176 | void enqueueQCop( const QCString &ch, const QCString &msg, |
177 | const QByteArray &data ) | 177 | const QByteArray &data ) |
178 | { | 178 | { |
179 | qcopq.enqueue( new QCopRec( ch, msg, data ) ); | 179 | qcopq.enqueue( new QCopRec( ch, msg, data ) ); |
180 | } | 180 | } |
181 | void sendQCopQ() | 181 | void sendQCopQ() |
182 | { | 182 | { |
183 | if (!qcopQok ) | 183 | if (!qcopQok ) |
184 | return; | 184 | return; |
185 | 185 | ||
186 | QCopRec * r; | 186 | QCopRec * r; |
187 | 187 | ||
188 | while((r=qcopq.dequeue())) { | 188 | while((r=qcopq.dequeue())) { |
189 | // remove from queue before sending... | 189 | // remove from queue before sending... |
190 | // event loop can come around again before getting | 190 | // event loop can come around again before getting |
191 | // back from sendLocally | 191 | // back from sendLocally |
192 | #ifndef QT_NO_COP | 192 | #ifndef QT_NO_COP |
193 | QCopChannel::sendLocally( r->channel, r->message, r->data ); | 193 | QCopChannel::sendLocally( r->channel, r->message, r->data ); |
194 | #endif | 194 | #endif |
195 | 195 | ||
196 | delete r; | 196 | delete r; |
197 | } | 197 | } |
198 | } | 198 | } |
199 | 199 | ||
200 | static void show_mx(QWidget* mw, bool nomaximize, QString &strName) { | 200 | static void show_mx(QWidget* mw, bool nomaximize, QString &strName) { |
201 | if ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") ) | 201 | if ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") ) |
202 | { | 202 | { |
203 | ( ( QMainWindow* ) mw )->setUsesBigPixmaps( useBigPixmaps ); | 203 | ( ( QMainWindow* ) mw )->setUsesBigPixmaps( useBigPixmaps ); |
204 | } | 204 | } |
205 | QPoint p; | 205 | QPoint p; |
206 | QSize s; | 206 | QSize s; |
207 | bool max; | 207 | bool max; |
208 | 208 | ||
209 | if ( mw->isVisible() ) { | 209 | if ( mw->isVisible() ) { |
210 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { | 210 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { |
211 | mw->resize(s); | 211 | mw->resize(s); |
212 | mw->move(p); | 212 | mw->move(p); |
213 | } | 213 | } |
214 | mw->raise(); | 214 | mw->raise(); |
215 | } else { | 215 | } else { |
216 | 216 | ||
217 | if ( mw->layout() && mw->inherits("QDialog") ) { | 217 | if ( mw->layout() && mw->inherits("QDialog") ) { |
218 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { | 218 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { |
219 | mw->resize(s); | 219 | mw->resize(s); |
220 | mw->move(p); | 220 | mw->move(p); |
221 | 221 | ||
222 | if ( max && !nomaximize ) { | 222 | if ( max && !nomaximize ) { |
223 | mw->showMaximized(); | 223 | mw->showMaximized(); |
224 | } else { | 224 | } else { |
225 | mw->show(); | 225 | mw->show(); |
226 | } | 226 | } |
227 | } else { | 227 | } else { |
228 | QPEApplication::showDialog((QDialog*)mw,nomaximize); | 228 | QPEApplication::showDialog((QDialog*)mw,nomaximize); |
229 | } | 229 | } |
230 | } else { | 230 | } else { |
231 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { | 231 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { |
232 | mw->resize(s); | 232 | mw->resize(s); |
233 | mw->move(p); | 233 | mw->move(p); |
234 | } else { //no stored rectangle, make an estimation | 234 | } else { //no stored rectangle, make an estimation |
235 | int x = (qApp->desktop()->width()-mw->frameGeometry().width())/2; | 235 | int x = (qApp->desktop()->width()-mw->frameGeometry().width())/2; |
236 | int y = (qApp->desktop()->height()-mw->frameGeometry().height())/2; | 236 | int y = (qApp->desktop()->height()-mw->frameGeometry().height())/2; |
237 | mw->move( QMAX(x,0), QMAX(y,0) ); | 237 | mw->move( QMAX(x,0), QMAX(y,0) ); |
238 | #ifdef Q_WS_QWS | 238 | #ifdef Q_WS_QWS |
239 | if ( !nomaximize ) | 239 | if ( !nomaximize ) |
240 | mw->showMaximized(); | 240 | mw->showMaximized(); |
241 | #endif | 241 | #endif |
242 | } | 242 | } |
243 | if ( max && !nomaximize ) | 243 | if ( max && !nomaximize ) |
244 | mw->showMaximized(); | 244 | mw->showMaximized(); |
245 | else | 245 | else |
246 | mw->show(); | 246 | mw->show(); |
247 | } | 247 | } |
248 | } | 248 | } |
249 | } | 249 | } |
250 | 250 | ||
251 | static bool read_widget_rect(const QString &app, bool &maximized, QPoint &p, QSize &s) | 251 | static bool read_widget_rect(const QString &app, bool &maximized, QPoint &p, QSize &s) |
252 | { | 252 | { |
253 | #ifndef OPIE_NO_WINDOWED | ||
253 | maximized = TRUE; | 254 | maximized = TRUE; |
254 | // 350 is the trigger in qwsdefaultdecoration for providing a resize button | 255 | // 350 is the trigger in qwsdefaultdecoration for providing a resize button |
255 | if ( qApp->desktop()->width() <= 350 ) | 256 | if ( qApp->desktop()->width() <= 350 ) |
256 | return FALSE; | 257 | return FALSE; |
257 | 258 | ||
258 | Config cfg( "qpe" ); | 259 | Config cfg( "qpe" ); |
259 | cfg.setGroup("ApplicationPositions"); | 260 | cfg.setGroup("ApplicationPositions"); |
260 | QString str = cfg.readEntry( app, QString::null ); | 261 | QString str = cfg.readEntry( app, QString::null ); |
261 | QStringList l = QStringList::split(",", str); | 262 | QStringList l = QStringList::split(",", str); |
262 | 263 | ||
263 | if ( l.count() == 5) { | 264 | if ( l.count() == 5) { |
264 | p.setX( l[0].toInt() ); | 265 | p.setX( l[0].toInt() ); |
265 | p.setY( l[1].toInt() ); | 266 | p.setY( l[1].toInt() ); |
266 | 267 | ||
267 | s.setWidth( l[2].toInt() ); | 268 | s.setWidth( l[2].toInt() ); |
268 | s.setHeight( l[3].toInt() ); | 269 | s.setHeight( l[3].toInt() ); |
269 | 270 | ||
270 | maximized = l[4].toInt(); | 271 | maximized = l[4].toInt(); |
271 | 272 | ||
272 | return TRUE; | 273 | return TRUE; |
273 | } | 274 | } |
274 | 275 | #endif | |
275 | return FALSE; | 276 | return FALSE; |
276 | } | 277 | } |
277 | 278 | ||
278 | 279 | ||
279 | static bool validate_widget_size(const QWidget *w, QPoint &p, QSize &s) | 280 | static bool validate_widget_size(const QWidget *w, QPoint &p, QSize &s) |
280 | { | 281 | { |
281 | #ifndef Q_WS_QWS | 282 | #ifndef Q_WS_QWS |
282 | QRect qt_maxWindowRect = qApp->desktop()->geometry(); | 283 | QRect qt_maxWindowRect = qApp->desktop()->geometry(); |
283 | #endif | 284 | #endif |
284 | int maxX = qt_maxWindowRect.width(); | 285 | int maxX = qt_maxWindowRect.width(); |
285 | int maxY = qt_maxWindowRect.height(); | 286 | int maxY = qt_maxWindowRect.height(); |
286 | int wWidth = s.width() + ( w->frameGeometry().width() - w->geometry().width() ); | 287 | int wWidth = s.width() + ( w->frameGeometry().width() - w->geometry().width() ); |
287 | int wHeight = s.height() + ( w->frameGeometry().height() - w->geometry().height() ); | 288 | int wHeight = s.height() + ( w->frameGeometry().height() - w->geometry().height() ); |
288 | 289 | ||
289 | // total window size is not allowed to be larger than desktop window size | 290 | // total window size is not allowed to be larger than desktop window size |
290 | if ( ( wWidth >= maxX ) && ( wHeight >= maxY ) ) | 291 | if ( ( wWidth >= maxX ) && ( wHeight >= maxY ) ) |
291 | return FALSE; | 292 | return FALSE; |
292 | 293 | ||
293 | if ( wWidth > maxX ) { | 294 | if ( wWidth > maxX ) { |
294 | s.setWidth( maxX - (w->frameGeometry().width() - w->geometry().width() ) ); | 295 | s.setWidth( maxX - (w->frameGeometry().width() - w->geometry().width() ) ); |
295 | wWidth = maxX; | 296 | wWidth = maxX; |
296 | } | 297 | } |
297 | 298 | ||
298 | if ( wHeight > maxY ) { | 299 | if ( wHeight > maxY ) { |
299 | s.setHeight( maxY - (w->frameGeometry().height() - w->geometry().height() ) ); | 300 | s.setHeight( maxY - (w->frameGeometry().height() - w->geometry().height() ) ); |
300 | wHeight = maxY; | 301 | wHeight = maxY; |
301 | } | 302 | } |
302 | 303 | ||
303 | // any smaller than this and the maximize/close/help buttons will be overlapping | 304 | // any smaller than this and the maximize/close/help buttons will be overlapping |
304 | if ( wWidth < 80 || wHeight < 60 ) | 305 | if ( wWidth < 80 || wHeight < 60 ) |
305 | return FALSE; | 306 | return FALSE; |
306 | 307 | ||
307 | if ( p.x() < 0 ) | 308 | if ( p.x() < 0 ) |
308 | p.setX(0); | 309 | p.setX(0); |
309 | if ( p.y() < 0 ) | 310 | if ( p.y() < 0 ) |
310 | p.setY(0); | 311 | p.setY(0); |
311 | 312 | ||
312 | if ( p.x() + wWidth > maxX ) | 313 | if ( p.x() + wWidth > maxX ) |
313 | p.setX( maxX - wWidth ); | 314 | p.setX( maxX - wWidth ); |
314 | if ( p.y() + wHeight > maxY ) | 315 | if ( p.y() + wHeight > maxY ) |
315 | p.setY( maxY - wHeight ); | 316 | p.setY( maxY - wHeight ); |
316 | 317 | ||
317 | return TRUE; | 318 | return TRUE; |
318 | } | 319 | } |
319 | 320 | ||
320 | static void store_widget_rect(QWidget *w, QString &app) | 321 | static void store_widget_rect(QWidget *w, QString &app) |
321 | { | 322 | { |
322 | if( !w ) | 323 | if( !w ) |
323 | return; | 324 | return; |
324 | 325 | #ifndef OPIE_NO_WINDOWED | |
325 | // 350 is the trigger in qwsdefaultdecoration for providing a resize button | 326 | // 350 is the trigger in qwsdefaultdecoration for providing a resize button |
326 | if ( qApp->desktop()->width() <= 350 ) | 327 | if ( qApp->desktop()->width() <= 350 ) |
327 | return; | 328 | return; |
328 | // we use these to map the offset of geometry and pos. ( we can only use normalGeometry to | 329 | // we use these to map the offset of geometry and pos. ( we can only use normalGeometry to |
329 | // get the non-maximized version, so we have to do it the hard way ) | 330 | // get the non-maximized version, so we have to do it the hard way ) |
330 | int offsetX = w->x() - w->geometry().left(); | 331 | int offsetX = w->x() - w->geometry().left(); |
331 | int offsetY = w->y() - w->geometry().top(); | 332 | int offsetY = w->y() - w->geometry().top(); |
332 | 333 | ||
333 | QRect r; | 334 | QRect r; |
334 | if ( w->isMaximized() ) | 335 | if ( w->isMaximized() ) |
335 | r = ( (HackWidget *) w)->normalGeometry(); | 336 | r = ( (HackWidget *) w)->normalGeometry(); |
336 | else | 337 | else |
337 | r = w->geometry(); | 338 | r = w->geometry(); |
338 | 339 | ||
339 | // Stores the window placement as pos(), size() (due to the offset mapping) | 340 | // Stores the window placement as pos(), size() (due to the offset mapping) |
340 | Config cfg( "qpe" ); | 341 | Config cfg( "qpe" ); |
341 | cfg.setGroup("ApplicationPositions"); | 342 | cfg.setGroup("ApplicationPositions"); |
342 | QString s; | 343 | QString s; |
343 | s.sprintf("%d,%d,%d,%d,%d", r.left() + offsetX, r.top() + offsetY, r.width(), r.height(), w->isMaximized() ); | 344 | s.sprintf("%d,%d,%d,%d,%d", r.left() + offsetX, r.top() + offsetY, r.width(), r.height(), w->isMaximized() ); |
344 | cfg.writeEntry( app, s ); | 345 | cfg.writeEntry( app, s ); |
346 | #endif | ||
345 | } | 347 | } |
346 | 348 | ||
347 | static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) | 349 | static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) |
348 | { | 350 | { |
349 | /* | 351 | /* |
350 | // This works but disable it for now until it is safe to apply | 352 | // This works but disable it for now until it is safe to apply |
351 | // What is does is scan the .desktop files of all the apps for | 353 | // What is does is scan the .desktop files of all the apps for |
352 | // the applnk that has the corresponding argv[0] as this program | 354 | // the applnk that has the corresponding argv[0] as this program |
353 | // then it uses the name stored in the .desktop file as the caption | 355 | // then it uses the name stored in the .desktop file as the caption |
354 | // for the main widget. This saves duplicating translations for | 356 | // for the main widget. This saves duplicating translations for |
355 | // the app name in the program and in the .desktop files. | 357 | // the app name in the program and in the .desktop files. |
356 | 358 | ||
357 | AppLnkSet apps( appsPath ); | 359 | AppLnkSet apps( appsPath ); |
358 | 360 | ||
359 | QList<AppLnk> appsList = apps.children(); | 361 | QList<AppLnk> appsList = apps.children(); |
360 | for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { | 362 | for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { |
361 | if ( (*it)->exec() == appName ) { | 363 | if ( (*it)->exec() == appName ) { |
362 | mw->setCaption( (*it)->name() ); | 364 | mw->setCaption( (*it)->name() ); |
363 | return TRUE; | 365 | return TRUE; |
364 | } | 366 | } |
365 | } | 367 | } |
366 | */ | 368 | */ |
367 | return FALSE; | 369 | return FALSE; |
368 | } | 370 | } |
369 | 371 | ||
370 | 372 | ||
371 | void show(QWidget* mw, bool nomax) | 373 | void show(QWidget* mw, bool nomax) |
372 | { | 374 | { |
373 | setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); | 375 | setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); |
374 | nomaximize = nomax; | 376 | nomaximize = nomax; |
375 | qpe_main_widget = mw; | 377 | qpe_main_widget = mw; |
376 | qcopQok = TRUE; | 378 | qcopQok = TRUE; |
377 | #ifndef QT_NO_COP | 379 | #ifndef QT_NO_COP |
378 | 380 | ||
379 | sendQCopQ(); | 381 | sendQCopQ(); |
380 | #endif | 382 | #endif |
381 | 383 | ||
382 | if ( preloaded ) { | 384 | if ( preloaded ) { |
383 | if (forceshow) | 385 | if (forceshow) |
384 | show_mx(mw, nomax, appName); | 386 | show_mx(mw, nomax, appName); |
385 | } | 387 | } |
386 | else if ( keep_running ) { | 388 | else if ( keep_running ) { |
387 | show_mx(mw, nomax, appName); | 389 | show_mx(mw, nomax, appName); |
388 | } | 390 | } |
389 | } | 391 | } |
390 | 392 | ||
391 | void loadTextCodecs() | 393 | void loadTextCodecs() |
392 | { | 394 | { |
393 | QString path = QPEApplication::qpeDir() + "plugins/textcodecs"; | 395 | QString path = QPEApplication::qpeDir() + "plugins/textcodecs"; |
394 | #ifdef Q_OS_MACX | 396 | #ifdef Q_OS_MACX |
395 | QDir dir( path, "lib*.dylib" ); | 397 | QDir dir( path, "lib*.dylib" ); |
396 | #else | 398 | #else |
397 | QDir dir( path, "lib*.so" ); | 399 | QDir dir( path, "lib*.so" ); |
398 | #endif | 400 | #endif |
399 | QStringList list; | 401 | QStringList list; |
400 | if ( dir. exists ( )) | 402 | if ( dir. exists ( )) |
401 | list = dir.entryList(); | 403 | list = dir.entryList(); |
402 | QStringList::Iterator it; | 404 | QStringList::Iterator it; |
403 | for ( it = list.begin(); it != list.end(); ++it ) { | 405 | for ( it = list.begin(); it != list.end(); ++it ) { |
404 | TextCodecInterface *iface = 0; | 406 | TextCodecInterface *iface = 0; |
405 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 407 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
406 | if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { | 408 | if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { |
407 | QValueList<int> mibs = iface->mibEnums(); | 409 | QValueList<int> mibs = iface->mibEnums(); |
408 | for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { | 410 | for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { |
409 | (void)iface->createForMib(*i); | 411 | (void)iface->createForMib(*i); |
410 | // ### it exists now; need to remember if we can delete it | 412 | // ### it exists now; need to remember if we can delete it |
411 | } | 413 | } |
412 | } | 414 | } |
413 | else { | 415 | else { |
414 | lib->unload(); | 416 | lib->unload(); |
415 | delete lib; | 417 | delete lib; |
416 | } | 418 | } |
417 | } | 419 | } |
418 | } | 420 | } |
419 | 421 | ||
420 | void loadImageCodecs() | 422 | void loadImageCodecs() |
421 | { | 423 | { |
422 | QString path = QPEApplication::qpeDir() + "plugins/imagecodecs"; | 424 | QString path = QPEApplication::qpeDir() + "plugins/imagecodecs"; |
423 | #ifdef Q_OS_MACX | 425 | #ifdef Q_OS_MACX |
424 | QDir dir( path, "lib*.dylib" ); | 426 | QDir dir( path, "lib*.dylib" ); |
425 | #else | 427 | #else |
426 | QDir dir( path, "lib*.so" ); | 428 | QDir dir( path, "lib*.so" ); |
427 | #endif | 429 | #endif |
428 | QStringList list; | 430 | QStringList list; |
429 | if ( dir. exists ( )) | 431 | if ( dir. exists ( )) |
430 | list = dir.entryList(); | 432 | list = dir.entryList(); |
431 | QStringList::Iterator it; | 433 | QStringList::Iterator it; |
432 | for ( it = list.begin(); it != list.end(); ++it ) { | 434 | for ( it = list.begin(); it != list.end(); ++it ) { |
433 | ImageCodecInterface *iface = 0; | 435 | ImageCodecInterface *iface = 0; |
434 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 436 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
435 | if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { | 437 | if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { |
436 | QStringList formats = iface->keys(); | 438 | QStringList formats = iface->keys(); |
437 | for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { | 439 | for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { |
438 | (void)iface->installIOHandler(*i); | 440 | (void)iface->installIOHandler(*i); |
439 | // ### it exists now; need to remember if we can delete it | 441 | // ### it exists now; need to remember if we can delete it |
440 | } | 442 | } |
441 | } | 443 | } |
442 | else { | 444 | else { |
443 | lib->unload(); | 445 | lib->unload(); |
444 | delete lib; | 446 | delete lib; |
445 | } | 447 | } |
446 | } | 448 | } |
447 | } | 449 | } |
448 | 450 | ||
449 | }; | 451 | }; |
450 | 452 | ||
451 | class ResourceMimeFactory : public QMimeSourceFactory | 453 | class ResourceMimeFactory : public QMimeSourceFactory |
452 | { | 454 | { |
453 | public: | 455 | public: |
454 | ResourceMimeFactory() : resImage( 0 ) | 456 | ResourceMimeFactory() : resImage( 0 ) |
455 | { | 457 | { |
456 | setFilePath( Global::helpPath() ); | 458 | setFilePath( Global::helpPath() ); |
457 | setExtensionType( "html", "text/html;charset=UTF-8" ); | 459 | setExtensionType( "html", "text/html;charset=UTF-8" ); |
458 | } | 460 | } |
459 | ~ResourceMimeFactory() { | 461 | ~ResourceMimeFactory() { |
460 | delete resImage; | 462 | delete resImage; |
461 | } | 463 | } |
462 | 464 | ||
463 | const QMimeSource* data( const QString& abs_name ) const | 465 | const QMimeSource* data( const QString& abs_name ) const |
464 | { | 466 | { |
465 | const QMimeSource * r = QMimeSourceFactory::data( abs_name ); | 467 | const QMimeSource * r = QMimeSourceFactory::data( abs_name ); |
466 | if ( !r ) { | 468 | if ( !r ) { |
467 | int sl = abs_name.length(); | 469 | int sl = abs_name.length(); |
468 | do { | 470 | do { |
469 | sl = abs_name.findRev( '/', sl - 1 ); | 471 | sl = abs_name.findRev( '/', sl - 1 ); |
470 | QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; | 472 | QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; |
471 | int dot = name.findRev( '.' ); | 473 | int dot = name.findRev( '.' ); |
472 | if ( dot >= 0 ) | 474 | if ( dot >= 0 ) |