summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2004-07-10 01:04:49 (UTC)
committer llornkcor <llornkcor>2004-07-10 01:04:49 (UTC)
commitf16bf63fc655c1e85fed6ce96c464553b260f796 (patch) (side-by-side diff)
tree798963e12adcddf320802101982001afa8ee639e
parent944adb8bf2741a16cf627d19e08f51c08920ad89 (diff)
downloadopie-f16bf63fc655c1e85fed6ce96c464553b260f796.zip
opie-f16bf63fc655c1e85fed6ce96c464553b260f796.tar.gz
opie-f16bf63fc655c1e85fed6ce96c464553b260f796.tar.bz2
add right click menu, and drag and drop for desktop version. show icons
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/zsafe/zsafe.cpp132
-rw-r--r--noncore/apps/zsafe/zsafe.h8
2 files changed, 122 insertions, 18 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
@@ -53,8 +53,9 @@ using namespace Opie::Ui;
#include <qpopupmenu.h>
#ifdef DESKTOP
#include <qfiledialog.h>
+#include <qdragobject.h>
#ifndef WIN32
#include <qsettings.h>
#else
#include "qsettings.h"
@@ -392,8 +393,9 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl )
{
IsCut = false;
IsCopy = false;
modified = false;
+ showpwd = false;
// set the config file
cfgFile=QDir::homeDirPath();
cfgFile += "/.zsafe.cfg";
@@ -456,9 +458,10 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl )
QPixmap bank_cards( ( const char** ) bank_cards_data );
QPixmap passwords( ( const char** ) passwords_data );
QPixmap software( ( const char** ) software_data );
QPixmap general( ( const char** ) general_data );
- if ( !name )
+ QPixmap image0( ( const char** ) zsafe_xpm );
+ if ( !name )
setName( "ZSafe" );
#ifdef DESKTOP
#ifdef WIN32
@@ -491,28 +494,65 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl )
QString zsafeAppDirPath = QDir::homeDirPath() + "/Documents/application/zsafe";
QString filename = conf->readEntry(APP_KEY+"document");
if (filename.isEmpty() || filename.isNull())
{
- 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())
+ {
+
+ QDir pd2(QDir::homeDirPath() + "/Documents");
+ if (!pd2.exists()) {
+ QDir pd3(QDir::homeDirPath());
+ if (!pd3.mkdir("Documents", FALSE)) {
+ }
+ }
+
+ if (!pd2.mkdir("application", FALSE))
{
- //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 );
+ 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);
}
- if ( !QDir( zsafeAppDirPath ).exists() )
+ }
+// #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, "ZSafe", tr("Can't create application data directory.\nZSafe will now exit."));
- exitZs (1);
+ 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);
}
- }
-
+ }
+
// set the default filename
filename = zsafeAppDirPath + "/passwords.zsf";
// save the current filename to the config file
conf->writeEntry(APP_KEY+"document", filename);
saveConf();
-
+ }
//if (filename == "INVALIDPWD")
//filename = "";
QString ti = filename.right (filename.length() - filename.findRev ('/') - 1);
@@ -530,8 +570,9 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl )
lastSearchedComment = "";
infoForm = new InfoForm();
categoryDialog = NULL;
+ infoForm->setIcon( image0);
// add a menu bar
QMenuBar *menu = new QMenuBar( this );
@@ -665,8 +706,15 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl )
this, SLOT( showInfo(QListViewItem*) ) );
connect( ListView, SIGNAL( returnPressed(QListViewItem*) ),
this, SLOT( showInfo(QListViewItem*) ) );
+#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);
}
const QColor *ZSafe::evenRowColor = &Qt::white;
// const QColor *ZSafe::oddRowColor = &Qt::lightGray;
@@ -1515,9 +1563,9 @@ void ZSafe::readAllEntries()
{
// build the full path
fullIconPath = iconPath + icon;
pix = new QPixmap (fullIconPath);
- if (pix)
+ if (!pix->isNull())
{
QImage img = pix->convertToImage();
pix->convertFromImage(img.smoothScale(14,14));
c1->setIconName (icon);
@@ -1730,9 +1778,9 @@ void ZSafe::readAllEntries()
{
// build the full path
fullIconPath = iconPath + icon;
pix = new QPixmap (fullIconPath);
- if (pix)
+ if (!pix->isNull())
{
QImage img = pix->convertToImage();
pix->convertFromImage(img.smoothScale(14,14));
c1->setIconName (icon);
@@ -1759,8 +1807,10 @@ void ZSafe::resume(int)
{
owarn << "Resume" << oendl;
// hide the main window
+ if ( !showpwd )
+ {
infoForm->hide();
// open zsafe again
m_password = "";
selectedItem = NULL;
@@ -1785,8 +1835,9 @@ void ZSafe::resume(int)
}
// ask for password and read again
openDocument(filename);
+ }
}
//---------------------------------------------
@@ -1953,9 +2004,9 @@ bool ZSafe::openDocument(const char* _filename, const char* )
{
// build the full path
fullIconPath = iconPath + icon;
pix = new QPixmap (fullIconPath);
- if (pix)
+ if (!pix->isNull())
{
QImage img = pix->convertToImage();
pix->convertFromImage(img.smoothScale(14,14));
c1->setIconName (icon);
@@ -2301,8 +2352,11 @@ void ZSafe::getDocPassword(QString title)
PasswordForm *dialog = new PasswordForm(this, title, TRUE);
newPwdDialog = dialog;
newPwdDialogResult = false;
+ QPixmap image0( ( const char** ) zsafe_xpm );
+ dialog->setIcon( image0);
+
connect( dialog->PasswordField, SIGNAL( returnPressed() ),
this, SLOT( setPasswordDialogDone() ) );
// CS: !!!
@@ -2691,9 +2745,9 @@ void ZSafe::addCategory()
// build the full path
fullIconPath = iconPath + icon;
pix = new QPixmap (fullIconPath);
// pix->resize(14, 14);
- if (pix)
+ if (!pix->isNull())
{
// save the full pixmap name into the config file
// #ifndef WIN32
conf->writeEntry(APP_KEY+category, icon);
@@ -3160,9 +3214,9 @@ void ZSafe::editCategory()
{
// build the full path
fullIconPath = iconPath + icon;
pix = new QPixmap (fullIconPath);
- if (pix)
+ if (!pix->isNull())
{
// save the full pixmap name into the config file
// #ifndef WIN32
conf->writeEntry(APP_KEY+category, icon);
@@ -3691,5 +3745,51 @@ void ZSafe::setDocument(const QString& fileref)
#endif
}
+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
@@ -60,10 +60,10 @@ protected:
public:
ZSafe( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = WDestructiveClose );
~ZSafe();
- static const QColor *evenRowColor;
- static const QColor *oddRowColor;
+ static const QColor *evenRowColor;
+ static const QColor *oddRowColor;
QToolButton* Edit;
QToolButton* Delete;
QToolButton* Find;
@@ -80,8 +80,9 @@ public:
QListViewItem *copiedItem; // copied item
bool IsCopy;
bool IsCut;
bool modified; // true if database is modified
+ bool showpwd; // show PWD Dialog
QListViewItem *lastSearchedCategory;
QListViewItem *lastSearchedItem;
QString lastSearchedName;
@@ -182,8 +183,11 @@ public slots:
virtual void setExpandFlag();
virtual void categoryFieldActivated( const QString& str);
+ virtual void ListPressed(int, QListViewItem *, const QPoint&, int);
+ virtual void copyClip( const QString &text);
+
private slots:
void setDocument(const QString& fileref);
void slotLoadDocu();
void slotRaiseTimer();