-rw-r--r-- | library/applnk.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/library/applnk.cpp b/library/applnk.cpp index 5185b5f..778ccab 100644 --- a/library/applnk.cpp +++ b/library/applnk.cpp | |||
@@ -215,257 +215,257 @@ AppLnk::AppLnk( const QString &file ) | |||
215 | QStringList::Iterator it; | 215 | QStringList::Iterator it; |
216 | for ( i = 0, it = sl.begin(); it != sl.end(); | 216 | for ( i = 0, it = sl.begin(); it != sl.end(); |
217 | ++it, i++ ) { | 217 | ++it, i++ ) { |
218 | 218 | ||
219 | bool number; | 219 | bool number; |
220 | int id = (*it).toInt( &number ); | 220 | int id = (*it).toInt( &number ); |
221 | if ( !number ) { | 221 | if ( !number ) { |
222 | // convert from old school... | 222 | // convert from old school... |
223 | id = cat.id( "Document Viewer", *it ); | 223 | id = cat.id( "Document Viewer", *it ); |
224 | if ( id == 0 ) | 224 | if ( id == 0 ) |
225 | id = cat.addCategory( "Document Viewer", *it ); | 225 | id = cat.addCategory( "Document Viewer", *it ); |
226 | } | 226 | } |
227 | d->mCat[i] = id; | 227 | d->mCat[i] = id; |
228 | } | 228 | } |
229 | mId = 0; | 229 | mId = 0; |
230 | } | 230 | } |
231 | 231 | ||
232 | /*! | 232 | /*! |
233 | Returns a small pixmap associated with the application. | 233 | Returns a small pixmap associated with the application. |
234 | */ | 234 | */ |
235 | const QPixmap& AppLnk::pixmap() const | 235 | const QPixmap& AppLnk::pixmap() const |
236 | { | 236 | { |
237 | if ( mPixmap.isNull() ) { | 237 | if ( mPixmap.isNull() ) { |
238 | AppLnk* that = (AppLnk*)this; | 238 | AppLnk* that = (AppLnk*)this; |
239 | if ( mIconFile.isEmpty() ) { | 239 | if ( mIconFile.isEmpty() ) { |
240 | MimeType mt(type()); | 240 | MimeType mt(type()); |
241 | that->mPixmap = mt.pixmap(); | 241 | that->mPixmap = mt.pixmap(); |
242 | if ( that->mPixmap.isNull() ) | 242 | if ( that->mPixmap.isNull() ) |
243 | that->mPixmap = Resource::loadPixmap("UnknownDocument-14"); | 243 | that->mPixmap = Resource::loadPixmap("UnknownDocument-14"); |
244 | return that->mPixmap; | 244 | return that->mPixmap; |
245 | } | 245 | } |
246 | QImage unscaledIcon = Resource::loadImage( that->mIconFile ); | 246 | QImage unscaledIcon = Resource::loadImage( that->mIconFile ); |
247 | that->mPixmap.convertFromImage( unscaledIcon.smoothScale( smallSize, smallSize ) ); | 247 | that->mPixmap.convertFromImage( unscaledIcon.smoothScale( smallSize, smallSize ) ); |
248 | that->mBigPixmap.convertFromImage( unscaledIcon.smoothScale( bigSize, bigSize ) ); | 248 | that->mBigPixmap.convertFromImage( unscaledIcon.smoothScale( bigSize, bigSize ) ); |
249 | return that->mPixmap; | 249 | return that->mPixmap; |
250 | } | 250 | } |
251 | return mPixmap; | 251 | return mPixmap; |
252 | } | 252 | } |
253 | 253 | ||
254 | /*! | 254 | /*! |
255 | Returns a large pixmap associated with the application. | 255 | Returns a large pixmap associated with the application. |
256 | */ | 256 | */ |
257 | const QPixmap& AppLnk::bigPixmap() const | 257 | const QPixmap& AppLnk::bigPixmap() const |
258 | { | 258 | { |
259 | if ( mBigPixmap.isNull() ) { | 259 | if ( mBigPixmap.isNull() ) { |
260 | AppLnk* that = (AppLnk*)this; | 260 | AppLnk* that = (AppLnk*)this; |
261 | if ( mIconFile.isEmpty() ) { | 261 | if ( mIconFile.isEmpty() ) { |
262 | MimeType mt(type()); | 262 | MimeType mt(type()); |
263 | that->mBigPixmap = mt.bigPixmap(); | 263 | that->mBigPixmap = mt.bigPixmap(); |
264 | if ( that->mBigPixmap.isNull() ) | 264 | if ( that->mBigPixmap.isNull() ) |
265 | that->mBigPixmap = Resource::loadPixmap("UnknownDocument"); | 265 | that->mBigPixmap = Resource::loadPixmap("UnknownDocument"); |
266 | return that->mBigPixmap; | 266 | return that->mBigPixmap; |
267 | } | 267 | } |
268 | QImage unscaledIcon = Resource::loadImage( that->mIconFile ); | 268 | QImage unscaledIcon = Resource::loadImage( that->mIconFile ); |
269 | that->mPixmap.convertFromImage( unscaledIcon.smoothScale( smallSize, smallSize ) ); | 269 | that->mPixmap.convertFromImage( unscaledIcon.smoothScale( smallSize, smallSize ) ); |
270 | that->mBigPixmap.convertFromImage( unscaledIcon.smoothScale( bigSize, bigSize ) ); | 270 | that->mBigPixmap.convertFromImage( unscaledIcon.smoothScale( bigSize, bigSize ) ); |
271 | return that->mBigPixmap; | 271 | return that->mBigPixmap; |
272 | } | 272 | } |
273 | return mBigPixmap; | 273 | return mBigPixmap; |
274 | } | 274 | } |
275 | 275 | ||
276 | /*! | 276 | /*! |
277 | Returns the type of the application. | 277 | Returns the type of the application. |
278 | */ | 278 | */ |
279 | QString AppLnk::type() const | 279 | QString AppLnk::type() const |
280 | { | 280 | { |
281 | if ( mType.isNull() ) { | 281 | if ( mType.isNull() ) { |
282 | AppLnk* that = (AppLnk*)this; | 282 | AppLnk* that = (AppLnk*)this; |
283 | MimeType mt(file()); | 283 | MimeType mt(file()); |
284 | that->mType = mt.id(); | 284 | that->mType = mt.id(); |
285 | return that->mType; | 285 | return that->mType; |
286 | } | 286 | } |
287 | return mType; | 287 | return mType; |
288 | } | 288 | } |
289 | 289 | ||
290 | /*! | 290 | /*! |
291 | Returns the file associated with the AppLnk. | 291 | Returns the file associated with the AppLnk. |
292 | 292 | ||
293 | \sa exec() | 293 | \sa exec() |
294 | */ | 294 | */ |
295 | QString AppLnk::file() const | 295 | QString AppLnk::file() const |
296 | { | 296 | { |
297 | if ( mFile.isNull() ) { | 297 | if ( mFile.isNull() ) { |
298 | AppLnk* that = (AppLnk*)this; // copy? | 298 | AppLnk* that = (AppLnk*)this; // copy? |
299 | QString ext = MimeType(mType).extension(); | 299 | QString ext = MimeType(mType).extension(); |
300 | if ( !ext.isEmpty() ) | 300 | if ( !ext.isEmpty() ) |
301 | ext = "." + ext; | 301 | ext = "." + ext; |
302 | if ( !mLinkFile.isEmpty() ) { | 302 | if ( !mLinkFile.isEmpty() ) { |
303 | that->mFile = | 303 | that->mFile = |
304 | mLinkFile.right(8)==".desktop" // 8 = strlen(".desktop") | 304 | mLinkFile.right(8)==".desktop" // 8 = strlen(".desktop") |
305 | ? mLinkFile.left(mLinkFile.length()-8) : mLinkFile; | 305 | ? mLinkFile.left(mLinkFile.length()-8) : mLinkFile; |
306 | } else if ( mType.contains('/') ) { | 306 | } else if ( mType.contains('/') ) { |
307 | that->mFile = | 307 | that->mFile = |
308 | QString(getenv("HOME"))+"/Documents/"+mType+"/"+safeFileName(that->mName); | 308 | QString(getenv("HOME"))+"/Documents/"+mType+"/"+safeFileName(that->mName); |
309 | if ( QFile::exists(that->mFile+ext) || QFile::exists(that->mFile+".desktop") ) { // a .desktop with the same name exists | 309 | if ( QFile::exists(that->mFile+ext) || QFile::exists(that->mFile+".desktop") ) { // a .desktop with the same name exists |
310 | int n=1; | 310 | int n=1; |
311 | qWarning("AppLnk::file() n=1 %s", that->mFile.latin1() ); | 311 | qWarning("AppLnk::file() n=1 %s", that->mFile.latin1() ); |
312 | QString nn; | 312 | QString nn; |
313 | while (QFile::exists((nn=(that->mFile+"_"+QString::number(n)))+ext) | 313 | while (QFile::exists((nn=(that->mFile+"_"+QString::number(n)))+ext) |
314 | || QFile::exists(nn+".desktop")) | 314 | || QFile::exists(nn+".desktop")) |
315 | n++; | 315 | n++; |
316 | that->mFile = nn; | 316 | that->mFile = nn; |
317 | qWarning("AppLnl::file() now mFile is %s", that->mFile.latin1() ); | 317 | qWarning("AppLnl::file() now mFile is %s", that->mFile.latin1() ); |
318 | } | 318 | } |
319 | that->mLinkFile = that->mFile+".desktop"; | 319 | that->mLinkFile = that->mFile+".desktop"; |
320 | that->mFile += ext; | 320 | that->mFile += ext; |
321 | } | 321 | } |
322 | prepareDirectories(that->mFile); | 322 | prepareDirectories(that->mFile); |
323 | QFile f(that->mFile); | 323 | QFile f(that->mFile); |
324 | if ( !f.open(IO_WriteOnly) ) | 324 | if ( !f.open(IO_WriteOnly) ) |
325 | that->mFile = QString::null; | 325 | that->mFile = QString::null; |
326 | return that->mFile; | 326 | return that->mFile; |
327 | } | 327 | } |
328 | return mFile; | 328 | return mFile; |
329 | } | 329 | } |
330 | 330 | ||
331 | /*! | 331 | /*! |
332 | Returns the desktop file coresponding to this AppLnk. | 332 | Returns the desktop file coresponding to this AppLnk. |
333 | 333 | ||
334 | \sa file(), exec() | 334 | \sa file(), exec() |
335 | */ | 335 | */ |
336 | QString AppLnk::linkFile() const | 336 | QString AppLnk::linkFile() const |
337 | { | 337 | { |
338 | if ( mLinkFile.isNull() ) { | 338 | if ( mLinkFile.isNull() ) { |
339 | AppLnk* that = (AppLnk*)this; | 339 | AppLnk* that = (AppLnk*)this; |
340 | if ( type().contains('/') ) { | 340 | if ( type().contains('/') ) { |
341 | StorageInfo storage; | 341 | StorageInfo storage; |
342 | const FileSystem *fs = storage.fileSystemOf( that->mFile ); | 342 | const FileSystem *fs = storage.fileSystemOf( that->mFile ); |
343 | if ( fs && fs->isRemovable() ) { | 343 | if ( fs && ( fs->isRemovable() || fs->disk() == "/dev/mtdblock6" || fs->disk() == "tmpfs" ) ) { |
344 | that->mLinkFile = fs->path(); | 344 | that->mLinkFile = fs->path(); |
345 | } else | 345 | } else |
346 | that->mLinkFile = getenv( "HOME" ); | 346 | that->mLinkFile = getenv( "HOME" ); |
347 | that->mLinkFile += "/Documents/"+type()+"/"+safeFileName(that->mName); | 347 | that->mLinkFile += "/Documents/"+type()+"/"+safeFileName(that->mName); |
348 | if ( QFile::exists(that->mLinkFile+".desktop") ) { // ok the file exists lets check if we point to the same file | 348 | if ( QFile::exists(that->mLinkFile+".desktop") ) { // ok the file exists lets check if we point to the same file |
349 | int n=1; | 349 | int n=1; |
350 | QString nn; | 350 | QString nn; |
351 | AppLnk lnk( that->mLinkFile+".desktop" ); | 351 | AppLnk lnk( that->mLinkFile+".desktop" ); |
352 | if(that->file() != lnk.file() ){ | 352 | if(that->file() != lnk.file() ){ |
353 | qWarning("AppLnk::linkFile exists %s", that->mLinkFile.latin1() ); | 353 | qWarning("AppLnk::linkFile exists %s", that->mLinkFile.latin1() ); |
354 | while (QFile::exists((nn=that->mLinkFile+"_"+QString::number(n))+".desktop")){ | 354 | while (QFile::exists((nn=that->mLinkFile+"_"+QString::number(n))+".desktop")){ |
355 | n++; | 355 | n++; |
356 | AppLnk lnk(nn ); // just to be sure | 356 | AppLnk lnk(nn ); // just to be sure |
357 | if(lnk.file() ==that->file() ){ | 357 | if(lnk.file() ==that->file() ){ |
358 | break; | 358 | break; |
359 | } | 359 | } |
360 | } | 360 | } |
361 | that->mLinkFile = nn; | 361 | that->mLinkFile = nn; |
362 | } | 362 | } |
363 | } | 363 | } |
364 | that->mLinkFile += ".desktop"; | 364 | that->mLinkFile += ".desktop"; |
365 | qWarning("AppLnk::linkFile is %s", that->mLinkFile.latin1() ); | 365 | qWarning("AppLnk::linkFile is %s", that->mLinkFile.latin1() ); |
366 | storeLink(); | 366 | storeLink(); |
367 | } | 367 | } |
368 | return that->mLinkFile; | 368 | return that->mLinkFile; |
369 | } | 369 | } |
370 | return mLinkFile; | 370 | return mLinkFile; |
371 | } | 371 | } |
372 | 372 | ||
373 | /*! | 373 | /*! |
374 | Copies \a copy. | 374 | Copies \a copy. |
375 | */ | 375 | */ |
376 | AppLnk::AppLnk( const AppLnk © ) | 376 | AppLnk::AppLnk( const AppLnk © ) |
377 | { | 377 | { |
378 | mName = copy.mName; | 378 | mName = copy.mName; |
379 | mPixmap = copy.mPixmap; | 379 | mPixmap = copy.mPixmap; |
380 | mBigPixmap = copy.mBigPixmap; | 380 | mBigPixmap = copy.mBigPixmap; |
381 | mExec = copy.mExec; | 381 | mExec = copy.mExec; |
382 | mType = copy.mType; | 382 | mType = copy.mType; |
383 | mRotation = copy.mRotation; | 383 | mRotation = copy.mRotation; |
384 | mComment = copy.mComment; | 384 | mComment = copy.mComment; |
385 | mFile = copy.mFile; | 385 | mFile = copy.mFile; |
386 | mLinkFile = copy.mLinkFile; | 386 | mLinkFile = copy.mLinkFile; |
387 | mIconFile = copy.mIconFile; | 387 | mIconFile = copy.mIconFile; |
388 | mMimeTypes = copy.mMimeTypes; | 388 | mMimeTypes = copy.mMimeTypes; |
389 | mMimeTypeIcons = copy.mMimeTypeIcons; | 389 | mMimeTypeIcons = copy.mMimeTypeIcons; |
390 | mId = 0; | 390 | mId = 0; |
391 | d = new AppLnkPrivate(); | 391 | d = new AppLnkPrivate(); |
392 | d->mCat = copy.d->mCat; | 392 | d->mCat = copy.d->mCat; |
393 | } | 393 | } |
394 | 394 | ||
395 | /*! | 395 | /*! |
396 | Destroys the AppLnk. Note that if the AppLnk is current a member of | 396 | Destroys the AppLnk. Note that if the AppLnk is current a member of |
397 | an AppLnkSet, this will produce a run-time warning. | 397 | an AppLnkSet, this will produce a run-time warning. |
398 | 398 | ||
399 | \sa AppLnkSet::add(), AppLnkSet::remove() | 399 | \sa AppLnkSet::add(), AppLnkSet::remove() |
400 | */ | 400 | */ |
401 | AppLnk::~AppLnk() | 401 | AppLnk::~AppLnk() |
402 | { | 402 | { |
403 | if ( mId ) | 403 | if ( mId ) |
404 | qWarning("Deleting AppLnk that is in an AppLnkSet"); | 404 | qWarning("Deleting AppLnk that is in an AppLnkSet"); |
405 | if ( d ) | 405 | if ( d ) |
406 | delete d; | 406 | delete d; |
407 | } | 407 | } |
408 | 408 | ||
409 | /*! | 409 | /*! |
410 | Executes the application associated with this AppLnk. | 410 | Executes the application associated with this AppLnk. |
411 | */ | 411 | */ |
412 | void AppLnk::execute() const | 412 | void AppLnk::execute() const |
413 | { | 413 | { |
414 | execute(QStringList()); | 414 | execute(QStringList()); |
415 | } | 415 | } |
416 | 416 | ||
417 | /*! | 417 | /*! |
418 | Executes the application associated with this AppLnk, with | 418 | Executes the application associated with this AppLnk, with |
419 | \a args as arguments. | 419 | \a args as arguments. |
420 | */ | 420 | */ |
421 | void AppLnk::execute(const QStringList& args) const | 421 | void AppLnk::execute(const QStringList& args) const |
422 | { | 422 | { |
423 | #ifdef Q_WS_QWS | 423 | #ifdef Q_WS_QWS |
424 | if ( !mRotation.isEmpty() ) { | 424 | if ( !mRotation.isEmpty() ) { |
425 | // ######## this will only work in the server | 425 | // ######## this will only work in the server |
426 | int rot = QPEApplication::defaultRotation(); | 426 | int rot = QPEApplication::defaultRotation(); |
427 | rot = (rot+mRotation.toInt())%360; | 427 | rot = (rot+mRotation.toInt())%360; |
428 | QCString old = getenv("QWS_DISPLAY"); | 428 | QCString old = getenv("QWS_DISPLAY"); |
429 | setenv("QWS_DISPLAY", QString("Transformed:Rot%1:0").arg(rot), 1); | 429 | setenv("QWS_DISPLAY", QString("Transformed:Rot%1:0").arg(rot), 1); |
430 | invoke(args); | 430 | invoke(args); |
431 | setenv("QWS_DISPLAY", old.data(), 1); | 431 | setenv("QWS_DISPLAY", old.data(), 1); |
432 | } else | 432 | } else |
433 | #endif | 433 | #endif |
434 | invoke(args); | 434 | invoke(args); |
435 | } | 435 | } |
436 | 436 | ||
437 | /*! | 437 | /*! |
438 | Invokes the application associated with this AppLnk, with | 438 | Invokes the application associated with this AppLnk, with |
439 | \a args as arguments. Rotation is not taken into account by | 439 | \a args as arguments. Rotation is not taken into account by |
440 | this function, you should not call it directly. | 440 | this function, you should not call it directly. |
441 | 441 | ||
442 | \sa execute() | 442 | \sa execute() |
443 | */ | 443 | */ |
444 | void AppLnk::invoke(const QStringList& args) const | 444 | void AppLnk::invoke(const QStringList& args) const |
445 | { | 445 | { |
446 | Global::execute( exec(), args[0] ); | 446 | Global::execute( exec(), args[0] ); |
447 | } | 447 | } |
448 | 448 | ||
449 | /*! | 449 | /*! |
450 | Sets the Exec property to \a exec. | 450 | Sets the Exec property to \a exec. |
451 | 451 | ||
452 | \sa exec() | 452 | \sa exec() |
453 | */ | 453 | */ |
454 | void AppLnk::setExec( const QString& exec ) | 454 | void AppLnk::setExec( const QString& exec ) |
455 | { | 455 | { |
456 | mExec = exec; | 456 | mExec = exec; |
457 | } | 457 | } |
458 | 458 | ||
459 | /*! | 459 | /*! |
460 | Sets the Name property to \a docname. | 460 | Sets the Name property to \a docname. |
461 | 461 | ||
462 | \sa name() | 462 | \sa name() |
463 | */ | 463 | */ |
464 | void AppLnk::setName( const QString& docname ) | 464 | void AppLnk::setName( const QString& docname ) |
465 | { | 465 | { |
466 | mName = docname; | 466 | mName = docname; |
467 | } | 467 | } |
468 | 468 | ||
469 | /*! | 469 | /*! |
470 | Sets the File property to \a filename. | 470 | Sets the File property to \a filename. |
471 | 471 | ||