summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/zsafe/zsafe.cpp30
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
@@ -342,107 +342,113 @@ static const char* const general_data[] = {
"QtQt#a.X#b#c.5.6#d#e#f#g#h#i",
"QtQtQt#j.7#k.6#d#l#m#n#o#p#q",
"QtQtQtQt.k#r#s#m#t.H#u#v#w#x",
"QtQtQtQtQtQt.k#y#z.v#A#B#C#x",
"QtQtQtQtQtQtQtQt.k#D.w#s#E.k",
"QtQtQtQtQtQtQtQtQtQtQt#x#FQt"};
// exit ZSafe and clear the clipboard for security reasons
void ZSafe::exitZs (int ec)
{
QClipboard *cb = QApplication::clipboard();
cb->clear();
exit (ec);
}
// save the configuration into the file
void ZSafe::saveConf ()
{
if (conf)
{
delete conf;
#ifdef DESKTOP
#ifndef WIN32
conf = new QSettings ();
conf->insertSearchPath (QSettings::Unix, QDir::homeDirPath());
#else
conf = new QSettings (cfgFile);
conf->insertSearchPath (QSettings::Unix, cfgFile);
#endif
#else
conf = new Config (cfgFile, Config::File);
conf->setGroup ("zsafe");
#endif
}
}
/*
* Constructs a ZSafe which is a child of 'parent', with the
* name 'name' and widget flags set to 'f'
*
* The dialog will by default be modeless, unless you set 'modal' to
* TRUE to construct a modal dialog.
*/
ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl )
- : QDialog( parent, name, modal, fl )
+ : QDialog( parent, name, modal, fl ),
+ Edit(0l), Delete(0l), Find(0l), New(0l), ListView(0l)
{
IsCut = false;
IsCopy = false;
modified = false;
// set the config file
cfgFile=QDir::homeDirPath();
cfgFile += "/.zsafe.cfg";
// set the icon path
+#ifdef NO_OPIE
QString qpedir ((const char *)getenv("QPEDIR"));
+#else
+ QString qpedir ((const char *)getenv("OPIEDIR"));
+#endif
+
#ifdef DESKTOP
iconPath = QDir::homeDirPath() + "/pics/";
#else
if (qpedir.isEmpty())
iconPath = "/home/QtPalmtop/pics/";
else
iconPath = qpedir + "/pics/";
#endif
// create a zsafe configuration object
#ifdef DESKTOP
#ifndef WIN32
conf = new QSettings ();
conf->insertSearchPath (QSettings::Unix, QDir::homeDirPath());
#else
conf = new QSettings (cfgFile);
conf->insertSearchPath (QSettings::Unix, cfgFile);
#endif
#else
conf = new Config (cfgFile, Config::File);
conf->setGroup ("zsafePrefs");
#endif
#ifdef DESKTOP
// #ifndef WIN32
expandTree = conf->readBoolEntry(APP_KEY+"expandTree", false);
// #endif
#else
expandTree = conf->readNumEntry(APP_KEY+"expandTree", 0);
#endif
#ifndef DESKTOP
conf->setGroup ("zsafe");
#endif
QPixmap copy_img((const char**) copy_xpm);
QPixmap cut_img((const char**) cut_xpm);
QPixmap edit_img((const char**) edit_xpm);
QPixmap editdelete_img((const char**) editdelete_xpm);
QPixmap find_img((const char**) find_xpm);
QPixmap folder_open_img((const char**) folder_open_xpm);
QPixmap help_icon_img((const char**) help_icon_xpm);
QPixmap new_img((const char**) new_xpm);
QPixmap paste_img((const char**) paste_xpm);
QPixmap quit_icon_img((const char**) quit_icon_xpm);
QPixmap save_img((const char**) save_xpm);
QPixmap trash_img((const char**) trash_xpm);
QPixmap expand_img((const char**) expand_xpm);
QPixmap export_img((const char**) export_xpm);
QPixmap import_img((const char**) import_xpm);
@@ -464,105 +470,101 @@ ZSafe::ZSafe( QWidget* parent, const char* name, bool modal, WFlags fl )
#else
#ifdef JPATCH_HDE
int DeskS;
if(DeskW > DeskH)
{
DeskS = DeskW;
}
else
{
DeskS = DeskH;
}
resize( DeskW, DeskH );
setMinimumSize( QSize( DeskS, DeskS ) );
setMaximumSize( QSize( DeskS, DeskS ) );
#else
resize( DeskW, DeskH-30 );
#endif
#endif
// setCaption( tr( "ZSafe" ) );
filename = conf->readEntry(APP_KEY+"document");
if (filename.isEmpty() || filename.isNull())
{
// 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 pd1("Documents");
if (!pd1.mkdir("application", FALSE))
{
QMessageBox::critical( 0, tr("ZSafe"),
#ifdef JPATCH_HDE
tr("Can't create directory\n.../Documents/application\n\nZSafe will now exit."));
#else
tr("Can't create directory\n%1\n\nZSafe will now exit.").arg(d1));
#endif
exitZs (1);
}
}
-// #ifndef WIN32
- // QString d2("Documents/application/zsafe");
-// #else
- QString d2(QDir::homeDirPath() + "/Documents/application/zsafe");
-// #endif
+ QString d2(QDir::homeDirPath() + "/Documents/application/zsafe");
QDir pd2(d2);
if (!pd2.exists())
{
- QDir pd2("Documents/application");
+ QDir pd2(QDir::homeDirPath() + "Documents/application");
if (!pd2.mkdir("zsafe", FALSE))
{
QMessageBox::critical( 0, tr("ZSafe"),
#ifdef JPATCH_HDE
tr("Can't create directory\n...//Documents/application/zsafe\n\nZSafe will now exit."));
#else
tr("Can't create directory\n%1\n\nZSafe will now exit.").arg(d2));
#endif
exitZs (1);
}
}
// set the default filename
filename=d2 + "/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);
#ifdef WIN32
this->setCaption("Qt ZSafe: " + ti);
#else
this->setCaption("ZSafe: " + ti);
#endif
selectedItem = NULL;
lastSearchedCategory = NULL;
lastSearchedItem = NULL;
lastSearchedName = "";
lastSearchedUsername = "";
lastSearchedComment = "";
infoForm = new InfoForm();
categoryDialog = NULL;
// add a menu bar
QMenuBar *menu = new QMenuBar( this );
// add file menu
// QPopupMenu *file = new QPopupMenu( this );
file = new QPopupMenu( this );
@@ -3602,103 +3604,105 @@ void ZSafe::about()
info += "</body></html>";
#endif
// QMessageBox::information( this, tr("ZSafe"), info, tr("&OK"), 0);
QMessageBox mb( this, tr("ZSafe"));
mb.setText (info);
mb.setButtonText (QMessageBox::Ok, tr ("&OK"));
QPixmap zsafe_img((const char**) zsafe_xpm);
mb.setIconPixmap (zsafe_img);
mb.exec();
}
void ZSafe::setExpandFlag()
{
expandTree = !expandTree;
file->setItemChecked('o', expandTree);
#ifndef DESKTOP
conf->setGroup ("zsafePrefs");
#endif
// #ifndef WIN32
conf->writeEntry (APP_KEY+"expandTree", expandTree);
// #endif
saveConf();
}
void ZSafe::paintEvent( QPaintEvent * )
{
if (raiseFlag)
{
raiseFlag = false;
raiseTimer.start (1, true);
if (infoForm->isVisible())
infoForm->raise();
}
}
void ZSafe::resizeEvent ( QResizeEvent * )
{
// qWarning ("resizeEvent");
#ifndef DESKTOP
DeskW = appl->desktop()->width();
DeskH = appl->desktop()->height();
#else
DeskW = this->width();
DeskH = this->height();
#endif
- qWarning( QString("Width : %1").arg(DeskW), 2000 );
- qWarning( QString("Height: %1").arg(DeskH), 2000 );
- New->setGeometry ( QRect( DeskW-84, 2, 20, 20 ) );
- Edit->setGeometry ( QRect( DeskW-64, 2, 20, 20 ) );
- Delete->setGeometry( QRect( DeskW-44, 2, 20, 20 ) );
- Find->setGeometry ( QRect( DeskW-24, 2, 20, 20 ) );
+ if (New)
+ New->setGeometry ( QRect( DeskW-84, 2, 20, 20 ) );
+ if (Edit)
+ Edit->setGeometry ( QRect( DeskW-64, 2, 20, 20 ) );
+ if (Delete)
+ Delete->setGeometry( QRect( DeskW-44, 2, 20, 20 ) );
+ if (Find)
+ Find->setGeometry ( QRect( DeskW-24, 2, 20, 20 ) );
}
void ZSafe::slotRaiseTimer()
{
if (infoForm->isVisible())
infoForm->raise();
raiseFlag = true;
}
QPixmap * ZSafe::getPredefinedIcon(QString category)
{
QPixmap *pm;
if (category == "Bank cards")
pm = new QPixmap((const char**)bank_cards_data);
else if (category == "Passwords")
pm = new QPixmap((const char**)passwords_data);
else if (category == "Software")
pm = new QPixmap((const char**)software_data);
else if (category == "General")
pm = new QPixmap((const char**)general_data);
else
pm = new QPixmap((const char**)general_data);
return pm;
}
void ZSafe::setDocument(const QString& fileref)
{
#ifndef DESKTOP
// stop the timer to prevent loading of the default document
docuTimer.stop();
DocLnk link(fileref);
if ( link.isValid() )
{
// if (filename != link.file())
// saveDocument(filename, FALSE);
filename = link.file();
}
else
{
// if (filename != fileref)
// saveDocument(filename, FALSE);
filename = fileref;
}
// save the current filename to the config file
conf->writeEntry(APP_KEY+"document", filename);
saveConf();
QString ti = filename.right (filename.length() - filename.findRev ('/') - 1);