Diffstat (limited to 'noncore/apps/zsafe/zsafe.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/zsafe/zsafe.cpp | 247 |
1 files changed, 76 insertions, 171 deletions
diff --git a/noncore/apps/zsafe/zsafe.cpp b/noncore/apps/zsafe/zsafe.cpp index 2b182f9..f70f863 100644 --- a/noncore/apps/zsafe/zsafe.cpp +++ b/noncore/apps/zsafe/zsafe.cpp | |||
@@ -21,2 +21,3 @@ | |||
21 | 21 | ||
22 | #include <opie2/oresource.h> | ||
22 | #include <opie2/ofiledialog.h> | 23 | #include <opie2/ofiledialog.h> |
@@ -40,8 +41,8 @@ using namespace Opie::Ui; | |||
40 | #include <qfile.h> | 41 | #include <qfile.h> |
41 | #include <qpe/fileselector.h> | 42 | #include <qpe/applnk.h> |
42 | #include <qpe/global.h> | 43 | #include <qpe/global.h> |
43 | #include <qpe/qpeapplication.h> | 44 | #include <qpe/qpeapplication.h> |
44 | #include <qpe/resource.h> | ||
45 | #include <qpe/config.h> | 45 | #include <qpe/config.h> |
46 | 46 | ||
47 | #include <qaction.h> | ||
47 | #include <qtimer.h> | 48 | #include <qtimer.h> |
@@ -53,3 +54,2 @@ using namespace Opie::Ui; | |||
53 | #include <qlistview.h> | 54 | #include <qlistview.h> |
54 | #include <qtoolbutton.h> | ||
55 | #include <qvariant.h> | 55 | #include <qvariant.h> |
@@ -66,2 +66,3 @@ using namespace Opie::Ui; | |||
66 | #include <qcombobox.h> | 66 | #include <qcombobox.h> |
67 | #include <qtoolbar.h> | ||
67 | 68 | ||
@@ -71,6 +72,2 @@ using namespace Opie::Ui; | |||
71 | 72 | ||
72 | int DeskW, DeskH; | ||
73 | QApplication *appl; | ||
74 | ZSafe *zs; | ||
75 | |||
76 | const QString APP_KEY = ""; | 73 | const QString APP_KEY = ""; |
@@ -78,14 +75,2 @@ const QString APP_KEY = ""; | |||
78 | // include xmp images | 75 | // include xmp images |
79 | #include "pics/zsafe/copy.xpm" | ||
80 | #include "pics/zsafe/cut.xpm" | ||
81 | #include "pics/zsafe/edit.xpm" | ||
82 | #include "pics/zsafe/editdelete.xpm" | ||
83 | #include "pics/zsafe/find.xpm" | ||
84 | #include "pics/zsafe/folder_open.xpm" | ||
85 | #include "pics/zsafe/help_icon.xpm" | ||
86 | #include "pics/zsafe/new.xpm" | ||
87 | #include "pics/zsafe/paste.xpm" | ||
88 | #include "pics/zsafe/quit_icon.xpm" | ||
89 | #include "pics/zsafe/save.xpm" | ||
90 | #include "pics/zsafe/trash.xpm" | ||
91 | #include "pics/zsafe/expand.xpm" | 76 | #include "pics/zsafe/expand.xpm" |
@@ -93,3 +78,2 @@ const QString APP_KEY = ""; | |||
93 | #include "pics/zsafe/import.xpm" | 78 | #include "pics/zsafe/import.xpm" |
94 | #include "pics/zsafe/zsafe.xpm" | ||
95 | 79 | ||
@@ -338,10 +322,5 @@ static const char* const general_data[] = { | |||
338 | ZSafe::ZSafe( QWidget* parent, const char* name, WFlags fl ) | 322 | ZSafe::ZSafe( QWidget* parent, const char* name, WFlags fl ) |
339 | : QWidget( parent, name, fl), | 323 | : QMainWindow( parent, name, fl), |
340 | Edit(0l), Delete(0l), Find(0l), New(0l), ListView(0l) | 324 | ListView(0l) |
341 | { | 325 | { |
342 | zs = this; | ||
343 | appl = qApp; | ||
344 | DeskW = qApp->desktop()->width(); | ||
345 | DeskH = qApp->desktop()->height(); | ||
346 | |||
347 | IsCut = false; | 326 | IsCut = false; |
@@ -364,14 +343,12 @@ ZSafe::ZSafe( QWidget* parent, const char* name, WFlags fl ) | |||
364 | 343 | ||
365 | QPixmap copy_img((const char**) copy_xpm); | 344 | QPixmap new_img = Opie::Core::OResource::loadPixmap( "new", Opie::Core::OResource::SmallIcon ); |
366 | QPixmap cut_img((const char**) cut_xpm); | 345 | QPixmap edit_img = Opie::Core::OResource::loadPixmap( "edit", Opie::Core::OResource::SmallIcon ); |
367 | QPixmap edit_img((const char**) edit_xpm); | 346 | QPixmap trash_img = Opie::Core::OResource::loadPixmap( "trash", Opie::Core::OResource::SmallIcon ); |
368 | QPixmap editdelete_img((const char**) editdelete_xpm); | 347 | QPixmap copy_img = Opie::Core::OResource::loadPixmap( "copy", Opie::Core::OResource::SmallIcon ); |
369 | QPixmap find_img((const char**) find_xpm); | 348 | QPixmap cut_img = Opie::Core::OResource::loadPixmap( "cut", Opie::Core::OResource::SmallIcon ); |
370 | QPixmap folder_open_img((const char**) folder_open_xpm); | 349 | QPixmap editdelete_img = Opie::Core::OResource::loadPixmap( "editdelete", Opie::Core::OResource::SmallIcon ); |
371 | QPixmap help_icon_img((const char**) help_icon_xpm); | 350 | QPixmap folder_open_img = Opie::Core::OResource::loadPixmap( "folder_open", Opie::Core::OResource::SmallIcon ); |
372 | QPixmap new_img((const char**) new_xpm); | 351 | QPixmap help_icon_img = Opie::Core::OResource::loadPixmap( "help_icon", Opie::Core::OResource::SmallIcon ); |
373 | QPixmap paste_img((const char**) paste_xpm); | 352 | QPixmap paste_img = Opie::Core::OResource::loadPixmap( "paste", Opie::Core::OResource::SmallIcon ); |
374 | QPixmap quit_icon_img((const char**) quit_icon_xpm); | 353 | QPixmap save_img = Opie::Core::OResource::loadPixmap( "save", Opie::Core::OResource::SmallIcon ); |
375 | QPixmap save_img((const char**) save_xpm); | ||
376 | QPixmap trash_img((const char**) trash_xpm); | ||
377 | QPixmap expand_img((const char**) expand_xpm); | 354 | QPixmap expand_img((const char**) expand_xpm); |
@@ -384,3 +361,3 @@ ZSafe::ZSafe( QWidget* parent, const char* name, WFlags fl ) | |||
384 | QPixmap general( ( const char** ) general_data ); | 361 | QPixmap general( ( const char** ) general_data ); |
385 | QPixmap image0( ( const char** ) zsafe_xpm ); | 362 | QPixmap image0 = Opie::Core::OResource::loadPixmap( "zsafe/zsafe", Opie::Core::OResource::SmallIcon ); |
386 | 363 | ||
@@ -450,4 +427,13 @@ ZSafe::ZSafe( QWidget* parent, const char* name, WFlags fl ) | |||
450 | 427 | ||
428 | // Create menu and tool bar dock | ||
429 | setToolBarsMovable( false ); | ||
430 | QToolBar *dock = new QToolBar( this ); | ||
431 | dock->setHorizontalStretchable( true ); | ||
432 | |||
451 | // add a menu bar | 433 | // add a menu bar |
452 | QMenuBar *menu = new QMenuBar( this ); | 434 | QMenuBar *menu = new QMenuBar( dock ); |
435 | menu->setMargin( 0 ); | ||
436 | |||
437 | // Add a toolbar | ||
438 | QToolBar *toolbar = new QToolBar( this ); | ||
453 | 439 | ||
@@ -457,79 +443,55 @@ ZSafe::ZSafe( QWidget* parent, const char* name, WFlags fl ) | |||
457 | 443 | ||
458 | file->insertItem( new_img, tr("&New document"), this, SLOT(newDocument()) ); | 444 | // File menu |
459 | file->insertItem( folder_open_img, tr("&Open document"), this, SLOT(loadDocument()) ); | 445 | file->insertItem( new_img, tr("New document"), this, SLOT(newDocument()) ); |
460 | file->insertItem( save_img, tr("&Save document as .."), this, SLOT(saveDocumentAs()) ); | 446 | file->insertItem( folder_open_img, tr("Open document"), this, SLOT(loadDocument()) ); |
447 | file->insertItem( save_img, tr("Save document as"), this, SLOT(saveDocumentAs()) ); | ||
461 | file->insertSeparator(); | 448 | file->insertSeparator(); |
462 | 449 | ||
463 | file->insertItem( save_img, tr("&Save document"), this, SLOT(saveDocumentWithoutPwd()) ); | 450 | file->insertItem( save_img, tr("Save document"), this, SLOT(saveDocumentWithoutPwd()) ); |
464 | file->insertItem( save_img, tr("S&ave document with new Password"), this, | 451 | file->insertItem( save_img, tr("Save document with new Password"), this, |
465 | SLOT(saveDocumentWithPwd()) ); | 452 | SLOT(saveDocumentWithPwd()) ); |
466 | file->insertSeparator(); | 453 | file->insertSeparator(); |
467 | file->insertItem( export_img, tr("&Export text file"), this, SLOT(writeAllEntries()) ); | 454 | file->insertItem( export_img, tr("Export text file"), this, SLOT(writeAllEntries()) ); |
468 | file->insertItem( import_img, tr("&Import text file"), this, SLOT(readAllEntries()) ); | 455 | file->insertItem( import_img, tr("Import text file"), this, SLOT(readAllEntries()) ); |
469 | file->insertItem( trash_img, tr("&Remove text file"), this, SLOT(removeAsciiFile()) ); | 456 | file->insertItem( trash_img, tr("Remove text file"), this, SLOT(removeAsciiFile()) ); |
470 | file->insertSeparator(); | 457 | file->insertSeparator(); |
471 | file->insertItem( expand_img, tr("&Open entries expanded"), this, | 458 | file->insertItem( expand_img, tr("Open entries expanded"), this, |
472 | SLOT(setExpandFlag()), 0, 'o'); | 459 | SLOT(setExpandFlag()), 0, 'o'); |
473 | file->setItemChecked('o', expandTree); | 460 | file->setItemChecked('o', expandTree); |
474 | file->insertSeparator(); | 461 | menu->insertItem( tr("File"), file ); |
475 | file->insertItem( quit_icon_img, tr("E&xit"), this, SLOT(quitMe()) ); | ||
476 | menu->insertItem( tr("&File"), file ); | ||
477 | 462 | ||
463 | // Category menu | ||
478 | QPopupMenu *cat = new QPopupMenu( this ); | 464 | QPopupMenu *cat = new QPopupMenu( this ); |
479 | cat->insertItem( new_img, tr("&New"), this, SLOT(addCategory()) ); | 465 | cat->insertItem( new_img, tr("New"), this, SLOT(addCategory()) ); |
480 | cat->insertItem( edit_img, tr("&Edit"), this, SLOT(editCategory()) ); | 466 | cat->insertItem( edit_img, tr("Edit"), this, SLOT(editCategory()) ); |
481 | cat->insertItem( trash_img, tr("&Delete"), this, SLOT(delCategory()) ); | 467 | cat->insertItem( trash_img, tr("Delete"), this, SLOT(delCategory()) ); |
482 | menu->insertItem( tr("&Category"), cat ); | 468 | menu->insertItem( tr("Category"), cat ); |
483 | 469 | ||
470 | // Entry menu | ||
484 | QPopupMenu *it = new QPopupMenu( this ); | 471 | QPopupMenu *it = new QPopupMenu( this ); |
485 | it->insertItem( cut_img, tr("&Cut"), this, SLOT(cutItem()) ); | 472 | it->insertItem( cut_img, tr("Cut"), this, SLOT(cutItem()) ); |
486 | it->insertItem( copy_img, tr("C&opy"), this, SLOT(copyItem()) ); | 473 | it->insertItem( copy_img, tr("Copy"), this, SLOT(copyItem()) ); |
487 | it->insertItem( paste_img, tr("&Paste"), this, SLOT(pasteItem()) ); | 474 | it->insertItem( paste_img, tr("Paste"), this, SLOT(pasteItem()) ); |
488 | it->insertSeparator(); | 475 | it->insertSeparator(); |
489 | it->insertItem( new_img, tr("&New"), this, SLOT(newPwd()) ); | ||
490 | it->insertItem( edit_img, tr("&Edit"), this, SLOT(editPwd()) ); | ||
491 | it->insertItem( trash_img, tr("&Delete"), this, SLOT(deletePwd()) ); | ||
492 | it->insertItem( find_img, tr("&Search"), this, SLOT(findPwd()) ); | ||
493 | menu->insertItem( tr("&Entry"), it ); | ||
494 | |||
495 | QPopupMenu *help = new QPopupMenu( this ); | ||
496 | help->insertItem( help_icon_img, tr("&About"), this, SLOT(about()) ); | ||
497 | menu->insertItem( tr("&Help"), help ); | ||
498 | |||
499 | // toolbar icons | ||
500 | |||
501 | New = new QToolButton( menu, "New" ); | ||
502 | New->setGeometry( QRect( DeskW-84, 2, 20, 20 ) ); | ||
503 | New->setMouseTracking( TRUE ); | ||
504 | New->setText( "" ); | ||
505 | New->setPixmap( new_img ); | ||
506 | QToolTip::add( New, tr( "New entry" ) ); | ||
507 | |||
508 | Edit = new QToolButton( menu, "Edit" ); | ||
509 | Edit->setGeometry( QRect( DeskW-64, 2, 20, 20 ) ); | ||
510 | Edit->setText( "" ); | ||
511 | Edit->setPixmap( edit_img ); | ||
512 | QToolTip::add( Edit, tr( "Edit category or entry" ) ); | ||
513 | |||
514 | Delete = new QToolButton( menu, "Delete" ); | ||
515 | Delete->setGeometry( QRect( DeskW-44, 2, 20, 20 ) ); | ||
516 | Delete->setText( "" ); | ||
517 | Delete->setPixmap( trash_img ); | ||
518 | QToolTip::add( Delete, tr( "Delete category or entry" ) ); | ||
519 | |||
520 | Find = new QToolButton( menu, "Find" ); | ||
521 | Find->setGeometry( QRect( DeskW-24, 2, 20, 20 ) ); | ||
522 | Find->setText( "" ); | ||
523 | Find->setPixmap( find_img ); | ||
524 | QToolTip::add( Find, tr( "Find entry" ) ); | ||
525 | |||
526 | /* | ||
527 | QBoxLayout * h = new QHBoxLayout( this ); | ||
528 | h->addWidget (menu); | ||
529 | h->addWidget (New); | ||
530 | h->addWidget (Edit); | ||
531 | h->addWidget (Delete); | ||
532 | h->addWidget (Find); | ||
533 | */ | ||
534 | 476 | ||
477 | QAction *a = new QAction( tr( "New" ), new_img, QString::null, 0, this, 0 ); | ||
478 | connect( a, SIGNAL(activated()), this, SLOT(newPwd()) ); | ||
479 | a->addTo( it ); | ||
480 | a->addTo( toolbar ); | ||
481 | a = new QAction( tr( "Edit" ), edit_img, QString::null, 0, this, 0 ); | ||
482 | connect( a, SIGNAL(activated()), this, SLOT(editPwd()) ); | ||
483 | a->addTo( it ); | ||
484 | a->addTo( toolbar ); | ||
485 | a = new QAction( tr( "Delete" ), trash_img, QString::null, 0, this, 0 ); | ||
486 | connect( a, SIGNAL(activated()), this, SLOT(deletePwd()) ); | ||
487 | a->addTo( it ); | ||
488 | a->addTo( toolbar ); | ||
489 | a = new QAction( tr( "Search" ), Opie::Core::OResource::loadPixmap( "find", Opie::Core::OResource::SmallIcon ), | ||
490 | QString::null, 0, this, 0 ); | ||
491 | connect( a, SIGNAL(activated()), this, SLOT(findPwd()) ); | ||
492 | a->addTo( it ); | ||
493 | a->addTo( toolbar ); | ||
494 | menu->insertItem( tr("Entry"), it ); | ||
495 | |||
496 | // Add main view | ||
535 | ListView = new ZListView( this, "ListView" ); | 497 | ListView = new ZListView( this, "ListView" ); |
@@ -544,6 +506,3 @@ ZSafe::ZSafe( QWidget* parent, const char* name, WFlags fl ) | |||
544 | ListView->setResizePolicy(QScrollView::AutoOneFit); | 506 | ListView->setResizePolicy(QScrollView::AutoOneFit); |
545 | // ListView->setGeometry( QRect( 0, 22, | 507 | setCentralWidget( ListView ); |
546 | // this->width(), this->height() - 30 ) ); | ||
547 | // ListView->setMaximumSize( QSize( 440, 290 ) ); | ||
548 | // ListView->setVScrollBarMode( QListView::Auto ); | ||
549 | 508 | ||
@@ -559,7 +518,2 @@ ZSafe::ZSafe( QWidget* parent, const char* name, WFlags fl ) | |||
559 | 518 | ||
560 | // signals and slots connections for QTollButton | ||
561 | connect( New, SIGNAL( clicked() ), this, SLOT( newPwd() ) ); | ||
562 | connect( Edit, SIGNAL( clicked() ), this, SLOT( editPwd() ) ); | ||
563 | connect( Delete, SIGNAL( clicked() ), this, SLOT( deletePwd() ) ); | ||
564 | connect( Find, SIGNAL( clicked() ), this, SLOT( findPwd() ) ); | ||
565 | // signals and slots connections for QListView | 519 | // signals and slots connections for QListView |
@@ -2112,4 +2066,4 @@ void ZSafe::getDocPassword(QString title) | |||
2112 | 2066 | ||
2113 | QPixmap image0( ( const char** ) zsafe_xpm ); | 2067 | // QPixmap image0 = Opie::Core::OResource::loadPixmap( "zsafe/zsafe", Opie::Core::OResource::SmallIcon ); |
2114 | dialog->setIcon( image0); | 2068 | // dialog->setIcon( image0); |
2115 | 2069 | ||
@@ -2409,6 +2363,3 @@ void ZSafe::addCategory() | |||
2409 | fileName = fileName.mid(0,fileName.length()-4); | 2363 | fileName = fileName.mid(0,fileName.length()-4); |
2410 | QPixmap imageOfFile(Resource::loadPixmap(fileName)); | 2364 | QPixmap imageOfFile(Opie::Core::OResource::loadPixmap(fileName,Opie::Core::OResource::SmallIcon)); |
2411 | QImage foo = imageOfFile.convertToImage(); | ||
2412 | foo = foo.smoothScale(16,16); | ||
2413 | imageOfFile.convertFromImage(foo); | ||
2414 | dialog->IconField->insertItem(imageOfFile,fileName); | 2365 | dialog->IconField->insertItem(imageOfFile,fileName); |
@@ -2763,6 +2714,3 @@ void ZSafe::editCategory() | |||
2763 | fileName = fileName.mid(0,fileName.length()-4); | 2714 | fileName = fileName.mid(0,fileName.length()-4); |
2764 | QPixmap imageOfFile(Resource::loadPixmap(fileName)); | 2715 | QPixmap imageOfFile(Opie::Core::OResource::loadPixmap(fileName,Opie::Core::OResource::SmallIcon)); |
2765 | QImage foo = imageOfFile.convertToImage(); | ||
2766 | foo = foo.smoothScale(16,16); | ||
2767 | imageOfFile.convertFromImage(foo); | ||
2768 | dialog->IconField->insertItem(imageOfFile,fileName); | 2716 | dialog->IconField->insertItem(imageOfFile,fileName); |
@@ -3115,29 +3063,2 @@ void ZSafe::saveDocumentWithPwd() | |||
3115 | 3063 | ||
3116 | void ZSafe::about() | ||
3117 | { | ||
3118 | QString info; | ||
3119 | info = tr("<html><body><div align=""center"">" | ||
3120 | "<b>" | ||
3121 | "Zaurus Password Manager<br>" | ||
3122 | "ZSafe version 2.1.2<br>" | ||
3123 | "</b>" | ||
3124 | "by Carsten Schneider<br>" | ||
3125 | "zcarsten@gmx.net<br>" | ||
3126 | "http://z-soft.z-portal.info/zsafe" | ||
3127 | "<br>" | ||
3128 | "Translations by Robert Ernst<br>" | ||
3129 | "robert.ernst@linux-solutions.at<br>" | ||
3130 | "<br></div>" | ||
3131 | "</body></html>"); | ||
3132 | |||
3133 | // QMessageBox::information( this, tr("ZSafe"), info, tr("&OK"), 0); | ||
3134 | |||
3135 | QMessageBox mb( this, tr("ZSafe")); | ||
3136 | mb.setText (info); | ||
3137 | mb.setButtonText (QMessageBox::Ok, tr ("&OK")); | ||
3138 | QPixmap zsafe_img((const char**) zsafe_xpm); | ||
3139 | mb.setIconPixmap (zsafe_img); | ||
3140 | mb.exec(); | ||
3141 | } | ||
3142 | |||
3143 | void ZSafe::setExpandFlag() | 3064 | void ZSafe::setExpandFlag() |
@@ -3165,18 +3086,2 @@ void ZSafe::paintEvent( QPaintEvent * ) | |||
3165 | 3086 | ||
3166 | void ZSafe::resizeEvent ( QResizeEvent * ) | ||
3167 | { | ||
3168 | // owarn << "resizeEvent" << oendl; | ||
3169 | DeskW = appl->desktop()->width(); | ||
3170 | DeskH = appl->desktop()->height(); | ||
3171 | |||
3172 | if (New) | ||
3173 | New->setGeometry ( QRect( DeskW-84, 2, 20, 20 ) ); | ||
3174 | if (Edit) | ||
3175 | Edit->setGeometry ( QRect( DeskW-64, 2, 20, 20 ) ); | ||
3176 | if (Delete) | ||
3177 | Delete->setGeometry( QRect( DeskW-44, 2, 20, 20 ) ); | ||
3178 | if (Find) | ||
3179 | Find->setGeometry ( QRect( DeskW-24, 2, 20, 20 ) ); | ||
3180 | } | ||
3181 | |||
3182 | void ZSafe::slotRaiseTimer() | 3087 | void ZSafe::slotRaiseTimer() |
@@ -3270,6 +3175,6 @@ void ZSafe::ListPressed(int mouse, QListViewItem *item, const QPoint&, int colum | |||
3270 | 3175 | ||
3271 | QIconSet copy_img((const char**) copy_xpm); | 3176 | QIconSet copy_img = Opie::Core::OResource::loadPixmap( "copy", Opie::Core::OResource::SmallIcon ); |
3272 | QIconSet edit_img((const char**) edit_xpm); | 3177 | QIconSet edit_img = Opie::Core::OResource::loadPixmap( "edit", Opie::Core::OResource::SmallIcon ); |
3273 | QPixmap folder_open_img((const char**) folder_open_xpm); | 3178 | QPixmap folder_open_img = Opie::Core::OResource::loadPixmap( "folder_open", Opie::Core::OResource::SmallIcon ); |
3274 | QPixmap editdelete_img((const char**) editdelete_xpm); | 3179 | QPixmap editdelete_img = Opie::Core::OResource::loadPixmap( "editdelete", Opie::Core::OResource::SmallIcon ); |
3275 | 3180 | ||