diff --git a/share/keepass/icons/bookmark.png b/share/keepass/icons/bookmark.png index 0cc8656..972f550 100644 Binary files a/share/keepass/icons/bookmark.png and b/share/keepass/icons/bookmark.png differ diff --git a/share/keepass/icons/bookmark_add.png b/share/keepass/icons/bookmark_add.png index 3521387..bbaa71a 100644 Binary files a/share/keepass/icons/bookmark_add.png and b/share/keepass/icons/bookmark_add.png differ diff --git a/share/keepass/icons/bookmark_del.png b/share/keepass/icons/bookmark_del.png new file mode 100755 index 0000000..231713f Binary files /dev/null and b/share/keepass/icons/bookmark_del.png differ diff --git a/share/keepass/icons/bookmark_edit.png b/share/keepass/icons/bookmark_edit.png index d2f72df..7e63526 100644 Binary files a/share/keepass/icons/bookmark_edit.png and b/share/keepass/icons/bookmark_edit.png differ diff --git a/share/keepass/icons/bookmark_this.png b/share/keepass/icons/bookmark_this.png new file mode 100755 index 0000000..758d9be Binary files /dev/null and b/share/keepass/icons/bookmark_this.png differ diff --git a/src/Database.h b/src/Database.h index a5c109d..d766a60 100644 --- a/src/Database.h +++ b/src/Database.h @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ - + #ifndef _DATABASE_H_ #define _DATABASE_H_ @@ -75,7 +75,7 @@ class KpxDateTime:public QDateTime{ }; //! Entry Data Structure -/*! This class holds the data of a normal database entry. It is used by some interface functions to process predefined entries and can be used for internal data handling.*/ +/*! This class holds the data of a normal database entry. It is used by some interface functions to process predefined entries and can be used for internal data handling.*/ class CEntry{ public: CEntry(); @@ -97,7 +97,7 @@ public: }; //! Group Data Structure -/*! This class holds the data of a normal database group. It is used by some interface functions to process predefined groups and can be used for internal data handling.*/ +/*! This class holds the data of a normal database group. It is used by some interface functions to process predefined groups and can be used for internal data handling.*/ class CGroup{ public: CGroup(); @@ -147,15 +147,16 @@ public: virtual KpxDateTime expire()=0; virtual QByteArray binary()=0; virtual quint32 binarySize()=0; - + virtual QString friendlySize()=0; + //! \return the index of the entry amongst the entries of its group. The index of the first entry is 0. virtual int visualIndex()const=0; - + /*! Sets the visual index of an entry. The indices of all other entries in the same group get automaticly readjusted by this function. \param index The new visual index. */ virtual void setVisualIndex(int index)=0; - + /*! Sets the visual index of an entry. The indices of all other entries in the same group need to be adjusted manually! This function is optimal to avoid readjustion overhead when sorting items. \param index The new visual index. @@ -170,7 +171,7 @@ public: }; //! Custom Icon Interface -/*! +/*! This class provides an interface for the management of custom icons. The implementation is optional and not necessarily needed. */ class ICustomIcons:public QObject{ @@ -180,12 +181,12 @@ class ICustomIcons:public QObject{ \param icon The pixmap which contains the new icon. This function makes a copy of the given pixmap. */ virtual void addIcon(const QPixmap& icon)=0; - + /*! Removes an icon. \param index The index of the icon which should be removed. Built-in icons cannot be removed so make sure that index is not the index of an Built-in icon before calling this function. - */ + */ virtual void removeIcon(int index)=0; - + /*! Replaces one icon with another one. \param index The index of the icon which should be replaced. Built-in icons cannot be replaced so make sure that index is not the index of an Built-in icon before calling this function. \param icon The pixmap which contains the new icon. @@ -196,43 +197,43 @@ class ICustomIcons:public QObject{ That means it is emitted after every call off addIcon(), removeIcon() and replaceIcon(). */ void iconsModified(); - + }; //! Handle class interface for accessing groups /*! -The IGroupHandle interface provides access to CGroup data structures without using direct references. Every entry handle class must implement this interface necessarily. +The IGroupHandle interface provides access to CGroup data structures without using direct references. Every entry handle class must implement this interface necessarily. */ class IGroupHandle{ public: virtual void setTitle(const QString& Title)=0; virtual void setImage(const quint32& ImageID)=0; - + virtual QString title()=0; virtual quint32 image()=0; - + //! \return a pointer to the handle of the parent group or NULL if the group has no parent. virtual IGroupHandle* parent()=0; - + //! \return a List of pointers to the handles of all childs of the group and an empty list if the group has no childs. The list is sorted and starts with the first child. virtual QList childs()=0; - + //! \return the index of the group amongst the childs of its parent. The index of the first child is 0. virtual int index()=0; - + /*! Sets the index of a group amongst the childs of its parent. This function can be used to sort the groups of the database in a specific order. \param index The new index of the group. The indices of the other groups which are affected by this operation will be automatically adjusted.*/ virtual void setIndex(int index)=0; - + /*! Tests the validity of the handle. \return TRUE if the handle is valid and FALSE if the handle is invalid e.g. because the associated group was deleted.*/ virtual bool isValid()=0; - + /*! \return the level of the group in the group tree. This level is tantamount to the number of parents that the group has. */ virtual int level()=0; - + virtual bool expanded()=0; virtual void setExpanded(bool)=0; @@ -240,7 +241,7 @@ public: //! Common Database Interface. /*! -This is the common base interface for databases. Every database class must implement this interface necessarily. +This is the common base interface for databases. Every database class must implement this interface necessarily. */ class IDatabase:public QObject{ public: @@ -254,9 +255,9 @@ public: virtual bool load(QString identifier)=0; //! Saves the current database. - /*! It is not allowed to call this function if no database is loaded. + /*! It is not allowed to call this function if no database is loaded. \return TRUE if saving was successfull, otherwise FALSE. - */ + */ virtual bool save()=0; //! Closes the current database. @@ -264,33 +265,33 @@ public: It is not allowed to call this function if no database is loaded. Please note: The database will be closed without saving it in before. * \return TRUE if closing was successfull, otherwise FALSE. - */ + */ virtual bool close()=0; //! Creates a new database. /*! It is not allowed to call this function if a database is already loaded. \return TRUE if saving was successfull, otherwise FALSE. - */ + */ virtual void create()=0; - - + + virtual bool changeFile(const QString& filename)=0; - + virtual QFile* file()=0; //! \return a list with the pointers to the handles of all entries of the database. The list contains only valid handles. The list is not sorted. virtual QList entries()=0; - + //! \param Group The group which contains the wanted entries. //! \return a list of pointers to the handles of all entries which belong to the given group. The list contains only valid handles and is sorted in an ascending order regarding to the entry indices. virtual QList entries(IGroupHandle* Group)=0; - + //! \return a list with the pointers to the handles of all expired entries of the database. The list contains only valid handles. The list is not sorted. virtual QList expiredEntries()=0; - + //! \return a list with the pointers to the handles of all entries of the database. The list contains only valid handles and is not sorted. virtual QList groups()=0; - + /*! This function might be slower than groups() - denpending on the implementation. \return a list with the pointers to the handles of all entries of the database. The list ist sorted and contains only valid handles.*/ @@ -298,7 +299,7 @@ public: /*! \return the last error message or an empty QString() object if no error occured.*/ - virtual QString getError()=0; + virtual QString getError()=0; /*! Creates a clone of a given entry. All attributes besides the UUID are copied, even the creation date. @@ -311,13 +312,13 @@ public: \param entry The handle of the entry which should be deleted. */ virtual void deleteEntry(IEntryHandle* entry)=0; - - + + /*! Deletes the last added entry. This function should only be called immediately after an addEntry() call, otherwise the behavior is undefined. Immediately means that there are no other add/move/delete operations between the two function calls.*/ virtual void deleteLastEntry()=0; - - + + /*! Deletes multiple given entries. Calling this function can be faster then calling deleteEntry(..) several times - depending on the implementation. Important: All entries must belong to the same group! @@ -328,7 +329,7 @@ public: /*! Creates a new blank entry. \param Group The group to which the entry should be added. \return the handle of the new entry. - */ + */ virtual IEntryHandle* newEntry(IGroupHandle* Group)=0; /*! Adds a Entry object to the database. @@ -337,7 +338,7 @@ public: \return a pointer to the handle of the added entry. */ virtual IEntryHandle* addEntry(const CEntry* NewEntry, IGroupHandle* Group)=0; - + /*! Moves an entry to another group. \param entry The entry which should be moved. \param group The new group of the entry.*/ @@ -348,25 +349,25 @@ public: Deletes the group, all it's entries and child groups and their entries as well. \param group The group which should be deleted.*/ virtual void deleteGroup(IGroupHandle* group)=0; - + /*! Adds a group to the database. \param Group A pointer to a CGroup object. Id and ParentId of the object are ignored. \param Parent A pointer to the handle of parent of the group. Can be NULL if the group is a top-level group. \return a pointer to the handle of the added group.*/ virtual IGroupHandle* addGroup(const CGroup* Group,IGroupHandle* Parent)=0; - + /*! Moves a group. \param Group The group which should be moved. \param NewParent The new parent of the group. \param Position The position of the group amongst it's new siblings. If Position is 0 the group will be prepended if it is -1 the group will be appended.*/ virtual void moveGroup(IGroupHandle* Group,IGroupHandle* NewParent,int Position)=0; - + /*! Checks two given groups if one is the parent of the other. \param Child The child group. \param Parent The parent group. \return TRUE if Parent is the parent of child, otherwise FALSE.*/ virtual bool isParent(IGroupHandle* parent, IGroupHandle* child)=0; - + /*! \param index Index of the requested icon. \return a reference to the pixmap of the requested icon. */ @@ -377,18 +378,18 @@ public: /*! Deletes all old invalid handles of the database. Make sure that there are no pointers to those handles which are still in use before calling this function.*/ virtual void cleanUpHandles()=0; - + /*! \return the number of groups in the database.*/ virtual int numGroups()=0; - + /*! \return the number of entires in the database.*/ - virtual int numEntries()=0; - + virtual int numEntries()=0; + /*! \return the number of built-in icons of the database. Each database must contain at least one built-in icon. */ virtual int builtinIcons()=0; - + /*! Searches in the database for a string or regular expression. - \param Group The group where the search should be performed in. If Group is NULL the search will be performed in the whole database. + \param Group The group where the search should be performed in. If Group is NULL the search will be performed in the whole database. \param SearchString The searched string or a regular expression. \param CaseSensitvie If this parameter is true the search will be case sensitive. \param RegExp The SearchString parameter will be handled as regular expression if this parameter is true. @@ -396,16 +397,16 @@ public: \param Fields A pointer to a six element bool array. It defines which fields are included into the search. The order is: title, username, url, password, comment, attachment description. The pointer can also be NULL, than the default pattern is used instead. \return the search results as a list of pointers to the entry handles.*/ virtual QList search(IGroupHandle* Group,const QString& SearchString, bool CaseSensitve, bool RegExp,bool Recursive,bool* Fields)=0; - + //! Moves an entry to the recycle bin. virtual void moveToTrash(IEntryHandle* entry)=0; - + //! \returns all entries of the recycle bin. virtual QList trashEntries()=0; - + //! Empty the recycle bin. virtual void emptyTrash()=0; - + }; @@ -430,7 +431,7 @@ class IKdbSettings{ virtual void setCryptAlgorithm(CryptAlgorithm algo)=0; virtual CryptAlgorithm cryptAlgorithm()=0; virtual unsigned int keyTransfRounds()=0; - virtual void setKeyTransfRounds(unsigned int rounds)=0; + virtual void setKeyTransfRounds(unsigned int rounds)=0; }; #endif diff --git a/src/Kdb3Database.cpp b/src/Kdb3Database.cpp index 2062af4..9cf254e 100644 --- a/src/Kdb3Database.cpp +++ b/src/Kdb3Database.cpp @@ -843,7 +843,7 @@ QList Kdb3Database::entries(IGroupHandle* group){ handles.append(&EntryHandles[i]); } qSort(handles.begin(),handles.end(),EntryHandleLessThan); - + return handles; } @@ -962,6 +962,43 @@ KpxDateTime Kdb3Database::EntryHandle::lastAccess(){return Entry->LastAccess;} KpxDateTime Kdb3Database::EntryHandle::expire(){return Entry->Expire;} QByteArray Kdb3Database::EntryHandle::binary(){return Entry->Binary;} quint32 Kdb3Database::EntryHandle::binarySize(){return Entry->Binary.size();} + +QString Kdb3Database::EntryHandle::friendlySize() +{ + quint32 binsize = binarySize(); + QString unit; + uint faktor; + int prec; + + if (binsize < 1024) + { + unit = tr("Bytes"); + faktor = 1; + prec = 0; + } + else + { + if (binsize < 1048576) + { + unit = tr("KiB"); + faktor = 1024; + } + else + if (binsize < 1073741824) + { + unit = tr("MiB"); + faktor = 1048576; + } + else + { + unit = tr("GiB"); + faktor = 1073741824; + } + prec = 1; + } + return (QString::number((float)binsize / (float)faktor, 'f', prec) + " " + unit); +} + int Kdb3Database::EntryHandle::visualIndex()const{return Entry->Index;} void Kdb3Database::EntryHandle::setVisualIndexDirectly(int i){Entry->Index=i;} bool Kdb3Database::EntryHandle::isValid()const{return valid;} @@ -1637,7 +1674,7 @@ bool Kdb3Database::createKeyFile(const QString& filename,int length, bool Hex){ void Kdb3Database::moveGroup(IGroupHandle* groupHandle,IGroupHandle* NewParent,int Pos){ - StdGroup* Parent; + StdGroup* Parent; StdGroup* Group=((GroupHandle*)groupHandle)->Group; if(NewParent) Parent=((GroupHandle*)NewParent)->Group; @@ -1686,7 +1723,7 @@ void Kdb3Database::moveToTrash(IEntryHandle* entry){ TrashEntries.append(trash); TrashHandles.append(EntryHandle(this)); TrashHandles.back().Entry=&TrashEntries.back(); - TrashEntries.back().Handle=&TrashHandles.back(); + TrashEntries.back().Handle=&TrashHandles.back(); } void Kdb3Database::emptyTrash(){ diff --git a/src/Kdb3Database.h b/src/Kdb3Database.h index f2154d9..8e3e29c 100644 --- a/src/Kdb3Database.h +++ b/src/Kdb3Database.h @@ -16,7 +16,7 @@ * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ - + #ifndef _STD_DATABASE_H_ #define _STD_DATABASE_H_ @@ -55,7 +55,7 @@ public: class StdGroup; class StdEntry; class EntryHandle:public IEntryHandle{ - + friend class Kdb3Database; public: EntryHandle(Kdb3Database* db); @@ -91,6 +91,7 @@ public: virtual KpxDateTime expire(); virtual QByteArray binary(); virtual quint32 binarySize(); + virtual QString friendlySize(); virtual bool isValid() const; private: void invalidate(){valid=false;} @@ -99,14 +100,14 @@ public: Kdb3Database* pDB; StdEntry* Entry; }; - + class GroupHandle:public IGroupHandle{ friend class Kdb3Database; GroupHandle(Kdb3Database* db); public: virtual void setTitle(const QString& Title); virtual void setImage(const quint32& ImageId); - void setOldImage(const quint32& ImageId); + void setOldImage(const quint32& ImageId); virtual QString title(); virtual quint32 image(); quint32 oldImage(); @@ -124,10 +125,10 @@ public: StdGroup* Group; Kdb3Database* pDB; }; - + friend class EntryHandle; friend class GroupHandle; - + class StdEntry:public CEntry{ public: quint32 OldImage; @@ -135,7 +136,7 @@ public: EntryHandle* Handle; StdGroup* Group; }; - + class StdGroup:public CGroup{ public: StdGroup():CGroup(){}; @@ -147,12 +148,12 @@ public: QList Childs; QList Entries; }; - + class TrashEntry: public StdEntry{ public: - QStringList GroupPath; + QStringList GroupPath; }; - + virtual ~Kdb3Database(){}; virtual bool load(QString identifier); virtual bool save(); @@ -179,12 +180,12 @@ public: virtual void setCryptAlgorithm(CryptAlgorithm algo){Algorithm=algo;} virtual CryptAlgorithm cryptAlgorithm(){return Algorithm;} virtual unsigned int keyTransfRounds(){return KeyTransfRounds;} - virtual void setKeyTransfRounds(unsigned int rounds){KeyTransfRounds=rounds;} - + virtual void setKeyTransfRounds(unsigned int rounds){KeyTransfRounds=rounds;} + virtual QList entries(); virtual QList entries(IGroupHandle* Group); virtual QList expiredEntries(); - + virtual IEntryHandle* cloneEntry(const IEntryHandle* entry); virtual void deleteEntry(IEntryHandle* entry); virtual void deleteEntries(QList entries); @@ -196,7 +197,7 @@ public: virtual QList trashEntries(); virtual void emptyTrash(); - + virtual QList groups(); virtual QList sortedGroups(); virtual void deleteGroup(IGroupHandle* group); @@ -204,9 +205,9 @@ public: virtual IGroupHandle* addGroup(const CGroup* Group,IGroupHandle* Parent); virtual bool isParent(IGroupHandle* parent, IGroupHandle* child); - - + + private: QDateTime dateFromPackedStruct5(const unsigned char* pBytes); void dateToPackedStruct5(const QDateTime& datetime, unsigned char* dst); @@ -239,7 +240,7 @@ private: StdEntry* getEntry(EntryHandle* handle); int getEntryListIndex(EntryHandle* handle); EntryHandle* getHandle(StdEntry* entry); - + StdGroup* getGroup(quint32 Id); void deleteGroup(StdGroup* group); diff --git a/src/dialogs/AboutDlg.cpp b/src/dialogs/AboutDlg.cpp index 95be523..9fbb016 100755 --- a/src/dialogs/AboutDlg.cpp +++ b/src/dialogs/AboutDlg.cpp @@ -18,20 +18,20 @@ ***************************************************************************/ #include -#include -#include -#include #include -#include "main.h" #include "AboutDlg.h" + AboutDialog::AboutDialog(QWidget* parent):QDialog(parent) { setupUi(this); - createBanner(&BannerPixmap,getPixmap("keepassx_large"),tr("KeePassX %1").arg(KEEPASS_VERSION),width()); + createBanner(&BannerPixmap,getPixmap("keepassx_large"),tr("%1 %2").arg(APP_DISPLAY_NAME, APP_VERSION),width()); loadLicFromFile(); + labelAppName->setText(tr(APP_DISPLAY_NAME)); + labelAppFunc->setText(tr(" - %1").arg(APP_LONG_FUNC)); + QString AboutTr=tr("Current Translation: None

","Please replace 'None' with the language of your translation"); if(TrActive){ AboutTr+=tr("Author: %1
").arg(tr("$TRANSLATION_AUTHOR")); @@ -51,9 +51,9 @@ AboutDialog::AboutDialog(QWidget* parent):QDialog(parent) str+="
"; str+=""+tr("Eugen Gorschenin")+"
"+tr("Web Designer")+"
"+tr("geugen@users.sf.de")+"
"; str+="
"; - str+=""+tr("Jota Jota")+"
"+tr("Developer")+"
"+tr("myxself@users.sf.de")+"
"; + str+=""+tr("Juan J González Cárdenas [Jota Jota]")+"
"+tr("Developer")+"
"+tr("myxelf@users.sf.net")+"
"; str+="
"; - str+=""+tr("Thanks To")+""; + str+=""+tr("Thanks To")+"
"; str+="
"; str+=""+tr("Matthias Miller")+"
"+tr("Patches for better MacOS X support")+"
"+tr("www.outofhanwell.com")+"
"; str+="
"; diff --git a/src/dialogs/AboutDlg.h b/src/dialogs/AboutDlg.h index bd96c1e..4ef153b 100755 --- a/src/dialogs/AboutDlg.h +++ b/src/dialogs/AboutDlg.h @@ -21,9 +21,9 @@ #define _ABOUTDIALOG_H_ #include -#include #include "ui_AboutDlg.h" #include "lib/UrlLabel.h" + #include "main.h" @@ -42,7 +42,7 @@ public slots: private: QPixmap BannerPixmap; inline void loadLicFromFile(); - virtual void paintEvent(QPaintEvent*); + virtual void paintEvent(QPaintEvent*); }; #endif diff --git a/src/dialogs/AddBookmarkDlg.cpp b/src/dialogs/AddBookmarkDlg.cpp index 3238e55..4bc797e 100644 --- a/src/dialogs/AddBookmarkDlg.cpp +++ b/src/dialogs/AddBookmarkDlg.cpp @@ -18,10 +18,13 @@ ***************************************************************************/ #include -#include "AddBookmarkDlg.h" +#include #include "lib/FileDialogs.h" #include "lib/bookmarks.h" +#include "AddBookmarkDlg.h" + + AddBookmarkDlg::AddBookmarkDlg(QWidget* parent, QString DefaultFilename, int _ItemID):QDialog(parent) { setupUi(this); @@ -30,18 +33,29 @@ AddBookmarkDlg::AddBookmarkDlg(QWidget* parent, QString DefaultFilename, int _It connect(buttonBox->button(QDialogButtonBox::Ok),SIGNAL(clicked()),this,SLOT(OnButtonOk())); connect(buttonBox->button(QDialogButtonBox::Cancel),SIGNAL(clicked()),this,SLOT(reject())); if(ItemID==-1){ + createBanner(&BannerPixmap,getPixmap("bookmark_add"),tr("Add Bookmark"),width()); + if(DefaultFilename==QString()) OnButtonBrowse(); else Edit_Filename->setText(DefaultFilename); } else { - Edit_Title->setText(KpxBookmarks::title(ItemID)); + createBanner(&BannerPixmap,getPixmap("bookmark_edit"),tr("Edit Bookmark"),width()); + + Edit_Title->setText(KpxBookmarks::title(ItemID)); Edit_Filename->setText(KpxBookmarks::path(ItemID)); setWindowTitle(tr("Edit Bookmark")); } } +void AddBookmarkDlg::paintEvent(QPaintEvent *event){ + QDialog::paintEvent(event); + QPainter painter(this); + painter.setClipRegion(event->region()); + painter.drawPixmap(QPoint(0,0),BannerPixmap); +} + void AddBookmarkDlg::OnButtonBrowse(){ QString path=KpxFileDialogs::openExistingFile(this,"AddBookmarkDlg", tr("Add Bookmark"), QStringList() << tr("KeePass Databases (*.kdb)") << tr("All Files (*)")); @@ -54,5 +68,5 @@ void AddBookmarkDlg::OnButtonOk(){ ItemID=KpxBookmarks::add(Edit_Title->text(),Edit_Filename->text()); else KpxBookmarks::edit(Edit_Title->text(),Edit_Filename->text(),ItemID); - accept(); + accept(); } \ No newline at end of file diff --git a/src/dialogs/AddBookmarkDlg.h b/src/dialogs/AddBookmarkDlg.h index 363ace2..d7f2541 100644 --- a/src/dialogs/AddBookmarkDlg.h +++ b/src/dialogs/AddBookmarkDlg.h @@ -21,8 +21,11 @@ #define _ADDBOOKMARKDLG_H_ #include +#include #include "ui_AddBookmarkDlg.h" +#include "main.h" + class AddBookmarkDlg : public QDialog, private Ui::AddBookmarkDlg { Q_OBJECT @@ -30,11 +33,15 @@ class AddBookmarkDlg : public QDialog, private Ui::AddBookmarkDlg public: AddBookmarkDlg (QWidget* parent=0, QString DefaultFilename=QString(), int ItemID=-1); int ItemID; - - private slots: + + private: + QPixmap BannerPixmap; + virtual void paintEvent(QPaintEvent*); + + private slots: void OnButtonOk(); void OnButtonBrowse(); - + }; #endif diff --git a/src/dialogs/CollectEntropyDlg.cpp b/src/dialogs/CollectEntropyDlg.cpp index f64aa3e..841f243 100644 --- a/src/dialogs/CollectEntropyDlg.cpp +++ b/src/dialogs/CollectEntropyDlg.cpp @@ -21,8 +21,9 @@ #include #include #include "crypto/yarrow.h" + #include "CollectEntropyDlg.h" -#include "main.h" + CollectEntropyDlg::CollectEntropyDlg(QWidget* parent):QDialog(parent){ setupUi(this); @@ -81,12 +82,12 @@ void CollectEntropyDlg::updateProgress(){ stackedWidget->setCurrentIndex(1); } else - progressBar->setValue(4*KeyCounter+4*MouseCounter); - + progressBar->setValue(4*KeyCounter+4*MouseCounter); + } void CollectEntropyDlg::showEvent(QShowEvent* event){ if(!event->spontaneous()){ - Animation->start(); - } + Animation->start(); + } } diff --git a/src/dialogs/CollectEntropyDlg.h b/src/dialogs/CollectEntropyDlg.h index c68b9cb..e2c5cbb 100644 --- a/src/dialogs/CollectEntropyDlg.h +++ b/src/dialogs/CollectEntropyDlg.h @@ -17,7 +17,7 @@ * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ - + #ifndef _COLLECT_ENTROPY_DLG_H_ #define _COLLECT_ENTROPY_DLG_H_ @@ -26,12 +26,15 @@ #include #include +#include "main.h" + + class CollectEntropyDlg: public QDialog, public Ui_CollectEntropyDlg{ Q_OBJECT public: CollectEntropyDlg(QWidget* parent); ~CollectEntropyDlg(); - + private: QPixmap BannerPixmap; virtual void paintEvent(QPaintEvent* event); diff --git a/src/dialogs/EditEntryDlg.cpp b/src/dialogs/EditEntryDlg.cpp index 75aefc3..61201ee 100755 --- a/src/dialogs/EditEntryDlg.cpp +++ b/src/dialogs/EditEntryDlg.cpp @@ -131,16 +131,9 @@ CEditEntryDlg::CEditEntryDlg(IDatabase* _db, IEntryHandle* _entry,QWidget* paren ButtonDeleteAttachment->setDisabled(true); Label_AttachmentSize->setText(""); } - else{ - QString unit; - int faktor; - int prec; - if(entry->binarySize()<1000){unit=" Byte";faktor=1;prec=0;} - else - if(entry->binarySize()<1000000){unit=" kB";faktor=1000;prec=1;} - else{unit=" MB";faktor=1000000;prec=1;} - Label_AttachmentSize->setText(QString::number((float)entry->binarySize()/(float)faktor,'f',prec)+unit); - } + else + Label_AttachmentSize->setText(entry->friendlySize()); + if(entry->expire()==Date_Never){ DateTime_Expire->setDisabled(true); CheckBox_ExpiresNever->setChecked(true); @@ -344,36 +337,7 @@ void CEditEntryDlg::OnNewAttachment() QFileInfo info(filename); entry->setBinaryDesc(info.fileName()); Edit_Attachment->setText(entry->binaryDesc()); - QString unit; - uint faktor; - int prec; - if (entry->binarySize() < 1024) - { - unit = tr("Bytes"); - faktor = 1; - prec = 0; - } - else - { - if (entry->binarySize() < pow(2,20)) - { - unit = tr("kiB"); - faktor = 1024; - } - else - if (entry->binarySize() < pow(2,30)) - { - unit = tr("MiB"); - faktor = pow(2,20); - } - else - { - unit = tr("GiB"); - faktor = pow(2,30); - } - prec = 1; - } - Label_AttachmentSize->setText(QString::number((float)entry->binarySize()/(float)faktor,'f',prec) + " " + unit); + Label_AttachmentSize->setText(entry->friendlySize()); ButtonOpenAttachment->setEnabled(true); ButtonSaveAttachment->setEnabled(true); ButtonDeleteAttachment->setEnabled(true); diff --git a/src/dialogs/ManageBookmarksDlg.cpp b/src/dialogs/ManageBookmarksDlg.cpp index c1045b0..d132371 100644 --- a/src/dialogs/ManageBookmarksDlg.cpp +++ b/src/dialogs/ManageBookmarksDlg.cpp @@ -18,7 +18,7 @@ ***************************************************************************/ #include -#include "main.h" +#include #include "ManageBookmarksDlg.h" #include "lib/bookmarks.h" #include "dialogs/AddBookmarkDlg.h" @@ -26,24 +26,65 @@ ManageBookmarksDlg::ManageBookmarksDlg(QWidget* parent):QDialog(parent) { setupUi(this); + createBanner(&BannerPixmap,getPixmap("bookmark"),tr("Manage Bookmarks"),width()); + for(int i=0;isetData(Qt::UserRole,i); - item->setText(KpxBookmarks::title(i)); + item->setText(KpxBookmarks::title(i)); } - connect(Button_Up,SIGNAL(clicked()),this,SLOT(OnButtonUp())); + connect(Button_Add,SIGNAL(clicked()),this,SLOT(OnButtonAdd())); + connect(Button_Edit,SIGNAL(clicked()),this,SLOT(OnButtonEdit())); + connect(Button_Delete,SIGNAL(clicked()),this,SLOT(OnButtonDelete())); + connect(Button_Up,SIGNAL(clicked()),this,SLOT(OnButtonUp())); connect(Button_Down,SIGNAL(clicked()),this,SLOT(OnButtonDown())); - connect(Button_Delete,SIGNAL(clicked()),this,SLOT(OnButtonDelete())); - connect(Button_Add,SIGNAL(clicked()),this,SLOT(OnButtonAdd())); - connect(Button_Edit,SIGNAL(clicked()),this,SLOT(OnButtonEdit())); connect(ListWidget,SIGNAL(itemDoubleClicked(QListWidgetItem*)),this,SLOT(edit(QListWidgetItem*))); connect(buttonBox->button(QDialogButtonBox::Close),SIGNAL(clicked()),this,SLOT(close())); - - Button_Up->setIcon(getIcon("up")); - Button_Down->setIcon(getIcon("down")); - Button_Delete->setIcon(getIcon("delete")); + + Button_Add->setIcon(getIcon("bookmark_add")); Button_Edit->setIcon(getIcon("bookmark_edit")); - Button_Add->setIcon(getIcon("bookmark_add")); + Button_Delete->setIcon(getIcon("bookmark_del")); + Button_Up->setIcon(getIcon("up")); + Button_Down->setIcon(getIcon("down")); +} + +void ManageBookmarksDlg::paintEvent(QPaintEvent *event){ + QDialog::paintEvent(event); + QPainter painter(this); + painter.setClipRegion(event->region()); + painter.drawPixmap(QPoint(0,0),BannerPixmap); +} + + + +void ManageBookmarksDlg::OnButtonAdd(){ + AddBookmarkDlg dlg(this); + if(dlg.exec()){ + int i=dlg.ItemID; + QListWidgetItem* item=new QListWidgetItem(ListWidget); + item->setData(Qt::UserRole,i); + item->setText(KpxBookmarks::title(i)); + } + return; +} + +void ManageBookmarksDlg::OnButtonEdit(){ + QListWidgetItem* item=ListWidget->currentItem(); + if(!item)return; + edit(item); +} + +void ManageBookmarksDlg::OnButtonDelete(){ + QListWidgetItem* item=ListWidget->currentItem(); + if(!item)return; + int index=item->data(Qt::UserRole).toInt(); + KpxBookmarks::remove(index); + delete item; + for(int i=0;icount();i++){ + int itemindex=ListWidget->item(i)->data(Qt::UserRole).toInt(); + if(itemindex>index) + ListWidget->item(i)->setData(Qt::UserRole,itemindex-1); + } } @@ -66,44 +107,17 @@ void ManageBookmarksDlg::OnButtonDown(){ ListWidget->insertItem(row,item); ListWidget->setCurrentRow(row); } - -void ManageBookmarksDlg::OnButtonDelete(){ - QListWidgetItem* item=ListWidget->currentItem(); - if(!item)return; - int index=item->data(Qt::UserRole).toInt(); - KpxBookmarks::remove(index); - delete item; - for(int i=0;icount();i++){ - int itemindex=ListWidget->item(i)->data(Qt::UserRole).toInt(); - if(itemindex>index) - ListWidget->item(i)->setData(Qt::UserRole,itemindex-1); - } -} -void ManageBookmarksDlg::OnButtonEdit(){ - QListWidgetItem* item=ListWidget->currentItem(); - if(!item)return; - edit(item); -} + void ManageBookmarksDlg::edit(QListWidgetItem* item){ int i=item->data(Qt::UserRole).toInt(); AddBookmarkDlg dlg(this,QString(),i); - dlg.exec(); - item->setText(KpxBookmarks::title(i)); + dlg.exec(); + item->setText(KpxBookmarks::title(i)); } -void ManageBookmarksDlg::OnButtonAdd(){ - AddBookmarkDlg dlg(this); - if(dlg.exec()){ - int i=dlg.ItemID; - QListWidgetItem* item=new QListWidgetItem(ListWidget); - item->setData(Qt::UserRole,i); - item->setText(KpxBookmarks::title(i)); - } - return; -} void ManageBookmarksDlg::closeEvent(QCloseEvent * event){ QList Order; @@ -112,6 +126,6 @@ void ManageBookmarksDlg::closeEvent(QCloseEvent * event){ for(int i=0;iitem(i)->data(Qt::UserRole).toInt(); } - KpxBookmarks::resort(Order); + KpxBookmarks::resort(Order); event->accept(); } \ No newline at end of file diff --git a/src/dialogs/ManageBookmarksDlg.h b/src/dialogs/ManageBookmarksDlg.h index 4501a5c..25ac7ce 100644 --- a/src/dialogs/ManageBookmarksDlg.h +++ b/src/dialogs/ManageBookmarksDlg.h @@ -22,21 +22,26 @@ #include #include +#include #include "ui_ManageBookmarksDlg.h" +#include "main.h" + class ManageBookmarksDlg : public QDialog, private Ui::ManageBookmarksDlg { Q_OBJECT public: ManageBookmarksDlg(QWidget* parent=0); private: + QPixmap BannerPixmap; + virtual void paintEvent(QPaintEvent*); virtual void closeEvent(QCloseEvent* event); private slots: - void OnButtonUp(); + void OnButtonAdd(); + void OnButtonEdit(); + void OnButtonDelete(); + void OnButtonUp(); void OnButtonDown(); - void OnButtonDelete(); - void OnButtonAdd(); - void OnButtonEdit(); void edit(QListWidgetItem*); }; diff --git a/src/forms/AboutDlg.ui b/src/forms/AboutDlg.ui index 2883a64..3bc6bf6 100644 --- a/src/forms/AboutDlg.ui +++ b/src/forms/AboutDlg.ui @@ -88,11 +88,49 @@ 9 - - - <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:Sans Serif; font-size:9pt; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:12pt; font-weight:600;">KeePassX</span> - Cross Platform Password Manager</p></body></html> - - + + + + + + 0 + 0 + + + + + 12 + 75 + true + + + + AppName + + + + + + + + 0 + 0 + + + + + 9 + + + + AppFunc + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + diff --git a/src/forms/AddBookmarkDlg.ui b/src/forms/AddBookmarkDlg.ui index e2897f6..7bc7594 100644 --- a/src/forms/AddBookmarkDlg.ui +++ b/src/forms/AddBookmarkDlg.ui @@ -1,18 +1,53 @@ + Tarek Saidi AddBookmarkDlg 0 0 - 497 - 148 + 500 + 180 + + + 0 + 0 + + + + + 500 + 180 + + + + + 500 + 180 + + Add Bookmark + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 50 + + + + @@ -44,6 +79,13 @@ + + + + Qt::Horizontal + + + @@ -53,6 +95,7 @@ + diff --git a/src/forms/MainWindow.ui b/src/forms/MainWindow.ui index 9871057..4b9c64c 100644 --- a/src/forms/MainWindow.ui +++ b/src/forms/MainWindow.ui @@ -285,7 +285,7 @@ - E&xit + Q&uit diff --git a/src/forms/ManageBookmarksDlg.ui b/src/forms/ManageBookmarksDlg.ui index fa81c67..1c45508 100644 --- a/src/forms/ManageBookmarksDlg.ui +++ b/src/forms/ManageBookmarksDlg.ui @@ -5,14 +5,36 @@ 0 0 - 452 + 280 360 + + + 280 + 300 + + Manage Bookmarks + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 50 + + + + @@ -21,19 +43,70 @@ - + + + + 16 + 16 + + + - + + + + 16 + 16 + + + - + + + + 16 + 16 + + + - + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 10 + + + - + + + + 16 + 16 + + + + + + + + + 16 + 16 + + + diff --git a/src/main.cpp b/src/main.cpp index 3be4dcd..ff2dd5c 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -93,9 +93,9 @@ void test_getAllWindowTitles(){ qDebug("%i %i: %s",i,p,XGetAtomName(pDisplay,atom[p])); } XFree(atom); - + } - #endif + #endif } int main(int argc, char **_argv) @@ -138,12 +138,12 @@ int main(int argc, char **_argv) qWarning("Could not load desktop integration plugin:"); qWarning(CSTR(PluginLoadError)); } - else{ + else{ QObject *plugininstance=plugin.instance(); IFileDialog* fdlg=qobject_cast(plugininstance); IconLoader=qobject_cast(plugininstance); if(IconLoader==NULL){ - qWarning("Error: Integration Plugin: Could not initialize IconTheme interface."); + qWarning("Error: Integration Plugin: Could not initialize IconTheme interface."); } KpxFileDialogs::setPlugin(fdlg); if(config->integrPlugin()==KpxConfig::KDE){ @@ -365,7 +365,7 @@ const QIcon& getIcon(const QString& name){ NewIcon=new QIcon(IconLoader->getIcon(name)); if(NewIcon->isNull()){ delete NewIcon; - NewIcon=NULL; + NewIcon=NULL; } else IconCache.insert(name,NewIcon); @@ -379,7 +379,7 @@ const QIcon& getIcon(const QString& name){ } NewIcon=new QIcon(AppDir+"/../share/keepass/icons/"+name+".png"); IconCache.insert(name,NewIcon); - } + } return *NewIcon; } @@ -423,7 +423,7 @@ int i=1; i++; } for(i; i Use specified file for loading/saving the configuration." << endl; @@ -485,7 +485,7 @@ QString makePathRelative(const QString& AbsDir,const QString& CurDir){ QString applicationDirPath(){ QString filepath=applicationFilePath(); - filepath.truncate(filepath.lastIndexOf("/")); + filepath.truncate(filepath.lastIndexOf("/")); return filepath; } diff --git a/src/main.h b/src/main.h index b66d943..8475a51 100644 --- a/src/main.h +++ b/src/main.h @@ -16,7 +16,7 @@ * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ - + #ifndef _MAIN_H_ #define _MAIN_H_ @@ -27,9 +27,14 @@ #include #include -#define APP_NAME "KeePassX" -#define APP_FUNC "Password Manager" -#define KEEPASS_VERSION "0.2.3" +#define APP_DISPLAY_NAME "KeePassX" +#define APP_CODE_NAME "keepassx" + +#define APP_SHORT_FUNC "Password Manager" +#define APP_LONG_FUNC "Cross Platform Password Manager" + +#define APP_VERSION "0.2.3" + #define BUILTIN_ICONS 65 typedef enum tKeyType {PASSWORD=0,KEYFILE=1,BOTH=2}; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 4e299e6..d94a3a6 100755 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -115,7 +115,7 @@ KeepassMainWindow::KeepassMainWindow(const QString& ArgFile,QWidget *parent, Qt: } HelpBrowser = new QAssistantClient(QString(),this); HelpBrowser->setArguments(QStringList()<< "-profile" << "/home/tarek/Documents/KeePassX/share/keepass/doc/keepassx.adp"); - + createBookmarkActions(); } @@ -240,9 +240,9 @@ void KeepassMainWindow::setupIcons(){ HelpHandbookAction->setIcon(getIcon("manual")); HelpAboutAction->setIcon(getIcon("help")); menuBookmarks->menuAction()->setIcon(getIcon("bookmark_folder")); - AddThisAsBookmarkAction->setIcon(getIcon("bookmark")); + AddThisAsBookmarkAction->setIcon(getIcon("bookmark_this")); AddBookmarkAction->setIcon(getIcon("bookmark_add")); - ManageBookmarksAction->setIcon(getIcon("bookmark_edit")); + ManageBookmarksAction->setIcon(getIcon("bookmark")); SysTray->setIcon(getIcon("keepassx_large")); if(config->showSysTrayIcon()) SysTray->show(); @@ -294,12 +294,12 @@ void KeepassMainWindow::setupMenus(){ case 28: ViewToolButtonSize28Action->setChecked(true); break; } - SysTrayMenu = new QMenu(tr("KeePassX"),this); + SysTrayMenu = new QMenu(tr(APP_DISPLAY_NAME),this); SysTrayMenu->addAction(FileUnLockWorkspaceAction); SysTrayMenu->addSeparator(); SysTrayMenu->addAction(FileExitAction); SysTray->setContextMenu(SysTrayMenu); - SysTray->setToolTip(tr("%1 %2").arg(APP_NAME, APP_FUNC) + " - " + tr((IsLocked) ? "Locked" : "Unlocked")); + SysTray->setToolTip(tr("%1 %2").arg(APP_DISPLAY_NAME, APP_SHORT_FUNC) + " - " + tr((IsLocked) ? "Locked" : "Unlocked")); #define _add_import(name){\ QAction* import=new QAction(this);\ @@ -323,7 +323,7 @@ void KeepassMainWindow::setupMenus(){ FileOpenAction->setShortcut(tr("Ctrl+O")); FileSaveAction->setShortcut(tr("Ctrl+S")); FileUnLockWorkspaceAction->setShortcut(tr("Ctrl+L")); - FileExitAction->setShortcut(tr("Ctrl+X")); + FileExitAction->setShortcut(tr("Ctrl+Q")); EditNewGroupAction->setShortcut(tr("Ctrl+G")); EditPasswordToClipboardAction->setShortcut(tr("Ctrl+C")); EditUsernameToClipboardAction->setShortcut(tr("Ctrl+B")); @@ -1011,7 +1011,7 @@ void KeepassMainWindow::OnUnLockWorkspace(){ setCentralWidget(NormalCentralWidget); NormalCentralWidget->setVisible(true); SysTray->setIcon(getIcon("keepassx_large")); - SysTray->setToolTip(tr("%1 %2").arg(APP_NAME, APP_FUNC) + " - " + tr("Unlocked")); + SysTray->setToolTip(tr("%1 %2").arg(APP_DISPLAY_NAME, APP_SHORT_FUNC) + " - " + tr("Unlocked")); FileUnLockWorkspaceAction->setText(tr("&Lock Workspace")); IsLocked=false; } else { @@ -1020,7 +1020,7 @@ void KeepassMainWindow::OnUnLockWorkspace(){ setCentralWidget(LockedCentralWidget); LockedCentralWidget->setVisible(true); SysTray->setIcon(getIcon("keepassx_locked")); - SysTray->setToolTip(tr("%1 %2").arg(APP_NAME, APP_FUNC) + " - " + tr("Locked")); + SysTray->setToolTip(tr("%1 %2").arg(APP_DISPLAY_NAME, APP_SHORT_FUNC) + " - " + tr("Locked")); FileUnLockWorkspaceAction->setText(tr("Un&lock Workspace")); IsLocked=true; } @@ -1030,38 +1030,38 @@ void KeepassMainWindow::OnBookmarkTriggered(QAction* action){ if(action==AddBookmarkAction){ AddBookmarkDlg dlg(this); if(dlg.exec()){ - int id=dlg.ItemID; + int id=dlg.ItemID; QAction* action=new QAction(this); action->setData(id); action->setText(KpxBookmarks::title(id)); action->setIcon(getIcon("document")); - menuBookmarks->addAction(action); + menuBookmarks->addAction(action); } return; } - + if(action==ManageBookmarksAction){ ManageBookmarksDlg dlg(this); dlg.exec(); menuBookmarks->clear(); createBookmarkActions(); - return; + return; } - + if(action==AddThisAsBookmarkAction){ AddBookmarkDlg dlg(this,db->file()->fileName()); if(dlg.exec()){ - int id=dlg.ItemID; + int id=dlg.ItemID; QAction* action=new QAction(this); action->setData(id); action->setText(KpxBookmarks::title(id)); action->setIcon(getIcon("document")); - menuBookmarks->addAction(action); - } + menuBookmarks->addAction(action); + } return; - } + } openDatabase(KpxBookmarks::path(action->data().toInt())); - + } void KeepassMainWindow::createBookmarkActions(){ @@ -1074,6 +1074,6 @@ void KeepassMainWindow::createBookmarkActions(){ action->setData(i); action->setText(KpxBookmarks::title(i)); action->setIcon(getIcon("document")); - menuBookmarks->addAction(action); - } + menuBookmarks->addAction(action); + } }