-rw-r--r-- | noncore/apps/zsafe/zsafe.cpp | 124 | ||||
-rw-r--r-- | noncore/apps/zsafe/zsafe.h | 4 |
2 files changed, 116 insertions, 12 deletions
diff --git a/noncore/apps/zsafe/zsafe.cpp b/noncore/apps/zsafe/zsafe.cpp index 189453e..5cad7cb 100644 --- a/noncore/apps/zsafe/zsafe.cpp +++ b/noncore/apps/zsafe/zsafe.cpp @@ -56,2 +56,3 @@ using namespace Opie::Ui; #include <qfiledialog.h> +#include <qdragobject.h> #ifndef WIN32 @@ -395,2 +396,3 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl ) modified = false; + showpwd = false; @@ -459,2 +461,3 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl ) QPixmap general( ( const char** ) general_data ); + QPixmap image0( ( const char** ) zsafe_xpm ); if ( !name ) @@ -494,11 +497,48 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl ) { - if ( !QDir( zsafeAppDirPath ).exists() ) + + // check if the directory application exists, if not + // create it +// #ifndef WIN32 + // QString d1("Documents/application"); +// #else + QString d1(QDir::homeDirPath() + "/Documents/application"); +// #endif + QDir pd1(d1); + if (!pd1.exists()) { - //FIXME: Pending someone to look into why QDir.mkdir does not work as expected - QString cmdline = QString().sprintf( "mkdir -p %s", (const char*) zsafeAppDirPath ); - ::system( cmdline ); + + QDir pd2(QDir::homeDirPath() + "/Documents"); + if (!pd2.exists()) { + QDir pd3(QDir::homeDirPath()); + if (!pd3.mkdir("Documents", FALSE)) { + } } - if ( !QDir( zsafeAppDirPath ).exists() ) + + if (!pd2.mkdir("application", FALSE)) { - QMessageBox::critical( 0, "ZSafe", tr("Can't create application data directory.\nZSafe will now exit.")); + QMessageBox::critical( 0, tr("ZSafe"), +#ifdef JPATCH_HDE + tr("<P>Can't create directory ..."+d1+"</P><P>ZSafe will now exit.</P>")); +#else + tr("<P>Can't create directory %1</P><P>ZSafe will now exit.</P>").arg(d1)); +#endif + exitZs (1); + } + } +// #ifndef WIN32 + // QString d2("Documents/application/zsafe"); +// #else + QString d2(QDir::homeDirPath() + "/Documents/application/zsafe"); +// #endif + QDir pd2(d2); + if (!pd2.exists()) + { + if (!pd1.mkdir("zsafe", FALSE)) + { + QMessageBox::critical( 0, tr("ZSafe"), +#ifdef JPATCH_HDE + tr("<P>Can't create directory ...//Documents/application/zsafe</P><P>ZSafe will now exit.</P")); +#else + tr("<P>Can't create directory %1</P><P>ZSafe will now exit.</P>").arg(d2)); +#endif exitZs (1); @@ -513,3 +553,3 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl ) saveConf(); - + } //if (filename == "INVALIDPWD") @@ -533,2 +573,3 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl ) categoryDialog = NULL; + infoForm->setIcon( image0); @@ -668,2 +709,9 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl ) +#ifndef DESKTOP + QPEApplication::setStylusOperation( ListView->viewport(),QPEApplication::RightOnHold); +#endif + connect( ListView, SIGNAL( mouseButtonPressed( int, QListViewItem *, const QPoint&, int)), + this,SLOT( ListPressed(int, QListViewItem *, const QPoint&, int)) ); + + this->setIcon( image0); } @@ -1518,3 +1566,3 @@ void ZSafe::readAllEntries() pix = new QPixmap (fullIconPath); - if (pix) + if (!pix->isNull()) { @@ -1733,3 +1781,3 @@ void ZSafe::readAllEntries() pix = new QPixmap (fullIconPath); - if (pix) + if (!pix->isNull()) { @@ -1762,2 +1810,4 @@ void ZSafe::resume(int) + if ( !showpwd ) + { infoForm->hide(); @@ -1789,2 +1839,3 @@ void ZSafe::resume(int) } +} @@ -1956,3 +2007,3 @@ bool ZSafe::openDocument(const char* _filename, const char* ) pix = new QPixmap (fullIconPath); - if (pix) + if (!pix->isNull()) { @@ -2304,2 +2355,5 @@ void ZSafe::getDocPassword(QString title) + QPixmap image0( ( const char** ) zsafe_xpm ); + dialog->setIcon( image0); + connect( dialog->PasswordField, SIGNAL( returnPressed() ), @@ -2694,3 +2748,3 @@ void ZSafe::addCategory() // pix->resize(14, 14); - if (pix) + if (!pix->isNull()) { @@ -3163,3 +3217,3 @@ void ZSafe::editCategory() pix = new QPixmap (fullIconPath); - if (pix) + if (!pix->isNull()) { @@ -3694,2 +3748,48 @@ void ZSafe::setDocument(const QString& fileref) +void ZSafe::ListPressed(int mouse, QListViewItem *item, const QPoint&, int column) { + if(item ==0) return; + switch (mouse) { + case 1: + { +#ifdef DESKTOP + QDragObject *d = new QTextDrag( item->text(column) , this ); + d->dragCopy(); +#endif + } + break; + case 2: + { + QClipboard *cb = QApplication::clipboard(); + + QIconSet copy_img((const char**) copy_xpm); + QIconSet edit_img((const char**) edit_xpm); + QPixmap folder_open_img((const char**) folder_open_xpm); + QPixmap editdelete_img((const char**) editdelete_xpm); + + QPopupMenu *m = new QPopupMenu(this); + int copyItem = m->insertItem( copy_img, tr( "Copy to Clipboard" )); + int editItem = m->insertItem(edit_img, tr( "Edit" )); + int showItem = m->insertItem(folder_open_img, tr( "Show Info" )); + int cancelItem = m->insertItem( editdelete_img, tr( "Cancel" )); + m->setFocus(); + int me=m->exec( QPoint( QCursor::pos().x(), QCursor::pos().y() ) ) ; + if(me == copyItem) { + copyClip( item->text(column) ) ; + } else if (me == cancelItem) { + cb->clear(); + } else if (me == editItem) { + editPwd(); + } else if (me == showItem) { + showInfo(item); + } + } + break; + }; +} + +void ZSafe::copyClip( const QString &text) { + QClipboard *cb = QApplication::clipboard(); + cb->setText( text); +} + diff --git a/noncore/apps/zsafe/zsafe.h b/noncore/apps/zsafe/zsafe.h index eef5cdc..ca041ff 100644 --- a/noncore/apps/zsafe/zsafe.h +++ b/noncore/apps/zsafe/zsafe.h @@ -83,2 +83,3 @@ public: bool modified; // true if database is modified + bool showpwd; // show PWD Dialog @@ -185,2 +186,5 @@ public slots: + virtual void ListPressed(int, QListViewItem *, const QPoint&, int); + virtual void copyClip( const QString &text); + private slots: |