-rw-r--r-- | noncore/apps/zsafe/zsafe.cpp | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/noncore/apps/zsafe/zsafe.cpp b/noncore/apps/zsafe/zsafe.cpp index 43565ee..ee1da77 100644 --- a/noncore/apps/zsafe/zsafe.cpp +++ b/noncore/apps/zsafe/zsafe.cpp | |||
@@ -358,75 +358,81 @@ static const char* const general_data[] = { | |||
358 | 358 | ||
359 | // save the configuration into the file | 359 | // save the configuration into the file |
360 | void ZSafe::saveConf () | 360 | void ZSafe::saveConf () |
361 | { | 361 | { |
362 | if (conf) | 362 | if (conf) |
363 | { | 363 | { |
364 | delete conf; | 364 | delete conf; |
365 | 365 | ||
366 | #ifdef DESKTOP | 366 | #ifdef DESKTOP |
367 | #ifndef WIN32 | 367 | #ifndef WIN32 |
368 | conf = new QSettings (); | 368 | conf = new QSettings (); |
369 | conf->insertSearchPath (QSettings::Unix, QDir::homeDirPath()); | 369 | conf->insertSearchPath (QSettings::Unix, QDir::homeDirPath()); |
370 | #else | 370 | #else |
371 | conf = new QSettings (cfgFile); | 371 | conf = new QSettings (cfgFile); |
372 | conf->insertSearchPath (QSettings::Unix, cfgFile); | 372 | conf->insertSearchPath (QSettings::Unix, cfgFile); |
373 | #endif | 373 | #endif |
374 | #else | 374 | #else |
375 | conf = new Config (cfgFile, Config::File); | 375 | conf = new Config (cfgFile, Config::File); |
376 | conf->setGroup ("zsafe"); | 376 | conf->setGroup ("zsafe"); |
377 | #endif | 377 | #endif |
378 | } | 378 | } |
379 | } | 379 | } |
380 | 380 | ||
381 | 381 | ||
382 | /* | 382 | /* |
383 | * Constructs a ZSafe which is a child of 'parent', with the | 383 | * Constructs a ZSafe which is a child of 'parent', with the |
384 | * name 'name' and widget flags set to 'f' | 384 | * name 'name' and widget flags set to 'f' |
385 | * | 385 | * |
386 | * The dialog will by default be modeless, unless you set 'modal' to | 386 | * The dialog will by default be modeless, unless you set 'modal' to |
387 | * TRUE to construct a modal dialog. | 387 | * TRUE to construct a modal dialog. |
388 | */ | 388 | */ |
389 | ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl ) | 389 | ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl ) |
390 | : QDialog( parent, name, modal, fl ) | 390 | : QDialog( parent, name, modal, fl ), |
391 | Edit(0l), Delete(0l), Find(0l), New(0l), ListView(0l) | ||
391 | { | 392 | { |
392 | IsCut = false; | 393 | IsCut = false; |
393 | IsCopy = false; | 394 | IsCopy = false; |
394 | modified = false; | 395 | modified = false; |
395 | 396 | ||
396 | // set the config file | 397 | // set the config file |
397 | cfgFile=QDir::homeDirPath(); | 398 | cfgFile=QDir::homeDirPath(); |
398 | cfgFile += "/.zsafe.cfg"; | 399 | cfgFile += "/.zsafe.cfg"; |
399 | // set the icon path | 400 | // set the icon path |
401 | #ifdef NO_OPIE | ||
400 | QString qpedir ((const char *)getenv("QPEDIR")); | 402 | QString qpedir ((const char *)getenv("QPEDIR")); |
403 | #else | ||
404 | QString qpedir ((const char *)getenv("OPIEDIR")); | ||
405 | #endif | ||
406 | |||
401 | #ifdef DESKTOP | 407 | #ifdef DESKTOP |
402 | iconPath = QDir::homeDirPath() + "/pics/"; | 408 | iconPath = QDir::homeDirPath() + "/pics/"; |
403 | #else | 409 | #else |
404 | if (qpedir.isEmpty()) | 410 | if (qpedir.isEmpty()) |
405 | iconPath = "/home/QtPalmtop/pics/"; | 411 | iconPath = "/home/QtPalmtop/pics/"; |
406 | else | 412 | else |
407 | iconPath = qpedir + "/pics/"; | 413 | iconPath = qpedir + "/pics/"; |
408 | #endif | 414 | #endif |
409 | 415 | ||
410 | // create a zsafe configuration object | 416 | // create a zsafe configuration object |
411 | #ifdef DESKTOP | 417 | #ifdef DESKTOP |
412 | #ifndef WIN32 | 418 | #ifndef WIN32 |
413 | conf = new QSettings (); | 419 | conf = new QSettings (); |
414 | conf->insertSearchPath (QSettings::Unix, QDir::homeDirPath()); | 420 | conf->insertSearchPath (QSettings::Unix, QDir::homeDirPath()); |
415 | #else | 421 | #else |
416 | conf = new QSettings (cfgFile); | 422 | conf = new QSettings (cfgFile); |
417 | conf->insertSearchPath (QSettings::Unix, cfgFile); | 423 | conf->insertSearchPath (QSettings::Unix, cfgFile); |
418 | #endif | 424 | #endif |
419 | #else | 425 | #else |
420 | conf = new Config (cfgFile, Config::File); | 426 | conf = new Config (cfgFile, Config::File); |
421 | conf->setGroup ("zsafePrefs"); | 427 | conf->setGroup ("zsafePrefs"); |
422 | #endif | 428 | #endif |
423 | #ifdef DESKTOP | 429 | #ifdef DESKTOP |
424 | // #ifndef WIN32 | 430 | // #ifndef WIN32 |
425 | expandTree = conf->readBoolEntry(APP_KEY+"expandTree", false); | 431 | expandTree = conf->readBoolEntry(APP_KEY+"expandTree", false); |
426 | // #endif | 432 | // #endif |
427 | #else | 433 | #else |
428 | expandTree = conf->readNumEntry(APP_KEY+"expandTree", 0); | 434 | expandTree = conf->readNumEntry(APP_KEY+"expandTree", 0); |
429 | #endif | 435 | #endif |
430 | #ifndef DESKTOP | 436 | #ifndef DESKTOP |
431 | conf->setGroup ("zsafe"); | 437 | conf->setGroup ("zsafe"); |
432 | #endif | 438 | #endif |
@@ -480,73 +486,69 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl ) | |||
480 | resize( DeskW, DeskH-30 ); | 486 | resize( DeskW, DeskH-30 ); |
481 | #endif | 487 | #endif |
482 | 488 | ||
483 | #endif | 489 | #endif |
484 | // setCaption( tr( "ZSafe" ) ); | 490 | // setCaption( tr( "ZSafe" ) ); |
485 | 491 | ||
486 | filename = conf->readEntry(APP_KEY+"document"); | 492 | filename = conf->readEntry(APP_KEY+"document"); |
487 | if (filename.isEmpty() || filename.isNull()) | 493 | if (filename.isEmpty() || filename.isNull()) |
488 | { | 494 | { |
489 | 495 | ||
490 | // check if the directory application exists, if not | 496 | // check if the directory application exists, if not |
491 | // create it | 497 | // create it |
492 | // #ifndef WIN32 | 498 | // #ifndef WIN32 |
493 | // QString d1("Documents/application"); | 499 | // QString d1("Documents/application"); |
494 | // #else | 500 | // #else |
495 | QString d1(QDir::homeDirPath() + "/Documents/application"); | 501 | QString d1(QDir::homeDirPath() + "/Documents/application"); |
496 | // #endif | 502 | // #endif |
497 | QDir pd1(d1); | 503 | QDir pd1(d1); |
498 | if (!pd1.exists()) | 504 | if (!pd1.exists()) |
499 | { | 505 | { |
500 | QDir pd1("Documents"); | 506 | QDir pd1("Documents"); |
501 | if (!pd1.mkdir("application", FALSE)) | 507 | if (!pd1.mkdir("application", FALSE)) |
502 | { | 508 | { |
503 | QMessageBox::critical( 0, tr("ZSafe"), | 509 | QMessageBox::critical( 0, tr("ZSafe"), |
504 | #ifdef JPATCH_HDE | 510 | #ifdef JPATCH_HDE |
505 | tr("Can't create directory\n.../Documents/application\n\nZSafe will now exit.")); | 511 | tr("Can't create directory\n.../Documents/application\n\nZSafe will now exit.")); |
506 | #else | 512 | #else |
507 | tr("Can't create directory\n%1\n\nZSafe will now exit.").arg(d1)); | 513 | tr("Can't create directory\n%1\n\nZSafe will now exit.").arg(d1)); |
508 | #endif | 514 | #endif |
509 | exitZs (1); | 515 | exitZs (1); |
510 | } | 516 | } |
511 | } | 517 | } |
512 | // #ifndef WIN32 | 518 | QString d2(QDir::homeDirPath() + "/Documents/application/zsafe"); |
513 | // QString d2("Documents/application/zsafe"); | ||
514 | // #else | ||
515 | QString d2(QDir::homeDirPath() + "/Documents/application/zsafe"); | ||
516 | // #endif | ||
517 | QDir pd2(d2); | 519 | QDir pd2(d2); |
518 | if (!pd2.exists()) | 520 | if (!pd2.exists()) |
519 | { | 521 | { |
520 | QDir pd2("Documents/application"); | 522 | QDir pd2(QDir::homeDirPath() + "Documents/application"); |
521 | if (!pd2.mkdir("zsafe", FALSE)) | 523 | if (!pd2.mkdir("zsafe", FALSE)) |
522 | { | 524 | { |
523 | QMessageBox::critical( 0, tr("ZSafe"), | 525 | QMessageBox::critical( 0, tr("ZSafe"), |
524 | #ifdef JPATCH_HDE | 526 | #ifdef JPATCH_HDE |
525 | tr("Can't create directory\n...//Documents/application/zsafe\n\nZSafe will now exit.")); | 527 | tr("Can't create directory\n...//Documents/application/zsafe\n\nZSafe will now exit.")); |
526 | #else | 528 | #else |
527 | tr("Can't create directory\n%1\n\nZSafe will now exit.").arg(d2)); | 529 | tr("Can't create directory\n%1\n\nZSafe will now exit.").arg(d2)); |
528 | #endif | 530 | #endif |
529 | exitZs (1); | 531 | exitZs (1); |
530 | } | 532 | } |
531 | } | 533 | } |
532 | 534 | ||
533 | 535 | ||
534 | // set the default filename | 536 | // set the default filename |
535 | filename=d2 + "/passwords.zsf"; | 537 | filename=d2 + "/passwords.zsf"; |
536 | 538 | ||
537 | // save the current filename to the config file | 539 | // save the current filename to the config file |
538 | conf->writeEntry(APP_KEY+"document", filename); | 540 | conf->writeEntry(APP_KEY+"document", filename); |
539 | saveConf(); | 541 | saveConf(); |
540 | } | 542 | } |
541 | 543 | ||
542 | //if (filename == "INVALIDPWD") | 544 | //if (filename == "INVALIDPWD") |
543 | //filename = ""; | 545 | //filename = ""; |
544 | 546 | ||
545 | QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); | 547 | QString ti = filename.right (filename.length() - filename.findRev ('/') - 1); |
546 | #ifdef WIN32 | 548 | #ifdef WIN32 |
547 | this->setCaption("Qt ZSafe: " + ti); | 549 | this->setCaption("Qt ZSafe: " + ti); |
548 | #else | 550 | #else |
549 | this->setCaption("ZSafe: " + ti); | 551 | this->setCaption("ZSafe: " + ti); |
550 | #endif | 552 | #endif |
551 | 553 | ||
552 | selectedItem = NULL; | 554 | selectedItem = NULL; |
@@ -3618,71 +3620,73 @@ void ZSafe::setExpandFlag() | |||
3618 | file->setItemChecked('o', expandTree); | 3620 | file->setItemChecked('o', expandTree); |
3619 | #ifndef DESKTOP | 3621 | #ifndef DESKTOP |
3620 | conf->setGroup ("zsafePrefs"); | 3622 | conf->setGroup ("zsafePrefs"); |
3621 | #endif | 3623 | #endif |
3622 | // #ifndef WIN32 | 3624 | // #ifndef WIN32 |
3623 | conf->writeEntry (APP_KEY+"expandTree", expandTree); | 3625 | conf->writeEntry (APP_KEY+"expandTree", expandTree); |
3624 | // #endif | 3626 | // #endif |
3625 | saveConf(); | 3627 | saveConf(); |
3626 | 3628 | ||
3627 | } | 3629 | } |
3628 | 3630 | ||
3629 | void ZSafe::paintEvent( QPaintEvent * ) | 3631 | void ZSafe::paintEvent( QPaintEvent * ) |
3630 | { | 3632 | { |
3631 | if (raiseFlag) | 3633 | if (raiseFlag) |
3632 | { | 3634 | { |
3633 | raiseFlag = false; | 3635 | raiseFlag = false; |
3634 | raiseTimer.start (1, true); | 3636 | raiseTimer.start (1, true); |
3635 | if (infoForm->isVisible()) | 3637 | if (infoForm->isVisible()) |
3636 | infoForm->raise(); | 3638 | infoForm->raise(); |
3637 | } | 3639 | } |
3638 | } | 3640 | } |
3639 | 3641 | ||
3640 | void ZSafe::resizeEvent ( QResizeEvent * ) | 3642 | void ZSafe::resizeEvent ( QResizeEvent * ) |
3641 | { | 3643 | { |
3642 | // qWarning ("resizeEvent"); | 3644 | // qWarning ("resizeEvent"); |
3643 | #ifndef DESKTOP | 3645 | #ifndef DESKTOP |
3644 | DeskW = appl->desktop()->width(); | 3646 | DeskW = appl->desktop()->width(); |
3645 | DeskH = appl->desktop()->height(); | 3647 | DeskH = appl->desktop()->height(); |
3646 | #else | 3648 | #else |
3647 | DeskW = this->width(); | 3649 | DeskW = this->width(); |
3648 | DeskH = this->height(); | 3650 | DeskH = this->height(); |
3649 | #endif | 3651 | #endif |
3650 | qWarning( QString("Width : %1").arg(DeskW), 2000 ); | ||
3651 | qWarning( QString("Height: %1").arg(DeskH), 2000 ); | ||
3652 | 3652 | ||
3653 | New->setGeometry ( QRect( DeskW-84, 2, 20, 20 ) ); | 3653 | if (New) |
3654 | Edit->setGeometry ( QRect( DeskW-64, 2, 20, 20 ) ); | 3654 | New->setGeometry ( QRect( DeskW-84, 2, 20, 20 ) ); |
3655 | Delete->setGeometry( QRect( DeskW-44, 2, 20, 20 ) ); | 3655 | if (Edit) |
3656 | Find->setGeometry ( QRect( DeskW-24, 2, 20, 20 ) ); | 3656 | Edit->setGeometry ( QRect( DeskW-64, 2, 20, 20 ) ); |
3657 | if (Delete) | ||
3658 | Delete->setGeometry( QRect( DeskW-44, 2, 20, 20 ) ); | ||
3659 | if (Find) | ||
3660 | Find->setGeometry ( QRect( DeskW-24, 2, 20, 20 ) ); | ||
3657 | } | 3661 | } |
3658 | 3662 | ||
3659 | void ZSafe::slotRaiseTimer() | 3663 | void ZSafe::slotRaiseTimer() |
3660 | { | 3664 | { |
3661 | if (infoForm->isVisible()) | 3665 | if (infoForm->isVisible()) |
3662 | infoForm->raise(); | 3666 | infoForm->raise(); |
3663 | raiseFlag = true; | 3667 | raiseFlag = true; |
3664 | } | 3668 | } |
3665 | 3669 | ||
3666 | QPixmap * ZSafe::getPredefinedIcon(QString category) | 3670 | QPixmap * ZSafe::getPredefinedIcon(QString category) |
3667 | { | 3671 | { |
3668 | QPixmap *pm; | 3672 | QPixmap *pm; |
3669 | if (category == "Bank cards") | 3673 | if (category == "Bank cards") |
3670 | pm = new QPixmap((const char**)bank_cards_data); | 3674 | pm = new QPixmap((const char**)bank_cards_data); |
3671 | else if (category == "Passwords") | 3675 | else if (category == "Passwords") |
3672 | pm = new QPixmap((const char**)passwords_data); | 3676 | pm = new QPixmap((const char**)passwords_data); |
3673 | else if (category == "Software") | 3677 | else if (category == "Software") |
3674 | pm = new QPixmap((const char**)software_data); | 3678 | pm = new QPixmap((const char**)software_data); |
3675 | else if (category == "General") | 3679 | else if (category == "General") |
3676 | pm = new QPixmap((const char**)general_data); | 3680 | pm = new QPixmap((const char**)general_data); |
3677 | else | 3681 | else |
3678 | pm = new QPixmap((const char**)general_data); | 3682 | pm = new QPixmap((const char**)general_data); |
3679 | return pm; | 3683 | return pm; |
3680 | } | 3684 | } |
3681 | 3685 | ||
3682 | void ZSafe::setDocument(const QString& fileref) | 3686 | void ZSafe::setDocument(const QString& fileref) |
3683 | { | 3687 | { |
3684 | #ifndef DESKTOP | 3688 | #ifndef DESKTOP |
3685 | // stop the timer to prevent loading of the default document | 3689 | // stop the timer to prevent loading of the default document |
3686 | docuTimer.stop(); | 3690 | docuTimer.stop(); |
3687 | 3691 | ||
3688 | DocLnk link(fileref); | 3692 | DocLnk link(fileref); |