new config system

git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@133 b624d157-de02-0410-bad0-e51aec6abb33
master
tarek_saidi 17 years ago
parent 9b25cc235d
commit 9dc8f878b5
  1. 14
      src/Database.h
  2. 257
      src/Kdb3Database.cpp
  3. 19
      src/Kdb3Database.h
  4. 7
      src/dialogs/AboutDlg.cpp
  5. 1
      src/dialogs/CollectEntropyDlg.cpp
  6. 40
      src/dialogs/EditEntryDlg.cpp
  7. 2
      src/dialogs/EditEntryDlg.h
  8. 108
      src/dialogs/PasswordDlg.cpp
  9. 111
      src/dialogs/PasswordGenDlg.cpp
  10. 43
      src/dialogs/SearchDlg.cpp
  11. 188
      src/dialogs/SettingsDlg.cpp
  12. 8
      src/dialogs/SimplePasswordDlg.cpp
  13. 24
      src/forms/CollectEntropyDlg.ui
  14. 45
      src/forms/MainWindow.ui
  15. 620
      src/forms/SettingsDlg.ui
  16. 313
      src/lib/EntryView.cpp
  17. 19
      src/lib/EntryView.h
  18. 107
      src/lib/FileDialogs.cpp
  19. 16
      src/lib/FileDialogs.h
  20. 19
      src/lib/GroupView.cpp
  21. 2
      src/lib/GroupView.h
  22. 21
      src/lib/WaitAnimationWidget.cpp
  23. 164
      src/main.cpp
  24. 8
      src/main.h
  25. 219
      src/mainwindow.cpp
  26. 13
      src/mainwindow.h
  27. 8
      src/plugins/interfaces/IFileDialog.h
  28. 16
      src/src.pro

@ -298,9 +298,7 @@ public:
/*! \return the last error message or an empty QString() object if no error occured.*/ /*! \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. /*! Creates a clone of a given entry.
All attributes besides the UUID are copied, even the creation date. All attributes besides the UUID are copied, even the creation date.
@ -398,7 +396,15 @@ 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. \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.*/ \return the search results as a list of pointers to the entry handles.*/
virtual QList<IEntryHandle*> search(IGroupHandle* Group,const QString& SearchString, bool CaseSensitve, bool RegExp,bool Recursive,bool* Fields)=0; virtual QList<IEntryHandle*> 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<IEntryHandle*> trashEntries()=0;
//! Empty the recycle bin.
virtual void emptyTrash()=0;
}; };

@ -34,20 +34,21 @@
#include "crypto/yarrow.h" #include "crypto/yarrow.h"
#include "lib/random.h" #include "lib/random.h"
using namespace std; using namespace std;
#include "StandardDatabase.h" #include "Kdb3Database.h"
#include "main.h" #include "main.h"
#include "KpxConfig.h"
#define UNEXP_ERROR error=QString("Unexpected error in: %1, Line:%2").arg(__FILE__).arg(__LINE__); #define UNEXP_ERROR error=QString("Unexpected error in: %1, Line:%2").arg(__FILE__).arg(__LINE__);
const QDateTime Date_Never(QDate(2999,12,28),QTime(23,59,59)); const QDateTime Date_Never(QDate(2999,12,28),QTime(23,59,59));
bool EntryHandleLessThan(const IEntryHandle* This,const IEntryHandle* Other){ bool EntryHandleLessThan(const IEntryHandle* This,const IEntryHandle* Other){
if(!This->isValid() && Other->isValid())return true; if(!This->isValid() && Other->isValid())return true;
if(This->isValid() && !Other->isValid())return false; if(This->isValid() && !Other->isValid())return false;
if(!This->isValid() && !Other->isValid())return false; if(!This->isValid() && !Other->isValid())return false;
return This->visualIndex()<Other->visualIndex(); return This->visualIndex()<Other->visualIndex();
} }
bool StdEntryLessThan(const Kdb3Database::StdEntry& This,const Kdb3Database::StdEntry& Other){ bool StdEntryLessThan(const Kdb3Database::StdEntry& This,const Kdb3Database::StdEntry& Other){
@ -103,23 +104,23 @@ int Kdb3Database::numIcons(){
} }
bool Kdb3Database::parseMetaStream(const StdEntry& entry){ bool Kdb3Database::parseMetaStream(const StdEntry& entry){
qDebug("%s",entry.Comment.toUtf8().data()); qDebug("%s",entry.Comment.toUtf8().data());
if(entry.Comment=="KPX_GROUP_TREE_STATE"){ if(entry.Comment=="KPX_GROUP_TREE_STATE"){
parseGroupTreeStateMetaStream(entry.Binary); parseGroupTreeStateMetaStream(entry.Binary);
return true;} return true;}
if(entry.Comment=="KPX_CUSTOM_ICONS_3"){ if(entry.Comment=="KPX_CUSTOM_ICONS_3"){
parseCustomIconsMetaStream(entry.Binary); parseCustomIconsMetaStream(entry.Binary);
return true;} return true;}
if(entry.Comment=="KPX_CUSTOM_ICONS_2") if(entry.Comment=="KPX_CUSTOM_ICONS_2")
return parseCustomIconsMetaStreamV2(entry.Binary); return parseCustomIconsMetaStreamV2(entry.Binary);
if(entry.Comment=="KPX_CUSTOM_ICONS") if(entry.Comment=="KPX_CUSTOM_ICONS")
return parseCustomIconsMetaStreamV1(entry.Binary); return parseCustomIconsMetaStreamV1(entry.Binary);
return false; //unknown MetaStream return false; //unknown MetaStream
} }
@ -234,7 +235,7 @@ void Kdb3Database::createGroupTreeStateMetaStream(StdEntry* e){
if(Groups[i].IsExpanded) if(Groups[i].IsExpanded)
bin.data()[8+5*i]=1; bin.data()[8+5*i]=1;
else else
bin.data()[8+5*i]=0; bin.data()[8+5*i]=0;
} }
e->Binary=bin; e->Binary=bin;
} }
@ -380,10 +381,10 @@ bool Kdb3Database::createGroupTree(QList<quint32>& Levels){
Groups[i].Index=Groups[j].Childs.size(); Groups[i].Index=Groups[j].Childs.size();
Groups[i].Parent->Childs.append(&Groups[i]); Groups[i].Parent->Childs.append(&Groups[i]);
} }
QList<int> EntryIndexCounter; QList<int> EntryIndexCounter;
for(int i=0;i<Groups.size();i++)EntryIndexCounter << 0; for(int i=0;i<Groups.size();i++)EntryIndexCounter << 0;
for(int e=0;e<Entries.size();e++){ for(int e=0;e<Entries.size();e++){
for(int g=0;g<Groups.size();g++){ for(int g=0;g<Groups.size();g++){
if(Entries[e].GroupId==Groups[g].Id){ if(Entries[e].GroupId==Groups[g].Id){
@ -392,9 +393,9 @@ bool Kdb3Database::createGroupTree(QList<quint32>& Levels){
Entries[e].Index=EntryIndexCounter[g]; Entries[e].Index=EntryIndexCounter[g];
EntryIndexCounter[g]++; EntryIndexCounter[g]++;
} }
} }
} }
return true; return true;
} }
@ -408,21 +409,22 @@ void Kdb3Database::createHandles(){
EntryHandles.append(EntryHandle(this)); EntryHandles.append(EntryHandle(this));
Entries[i].Handle=&EntryHandles.back(); Entries[i].Handle=&EntryHandles.back();
EntryHandles.back().Entry=&Entries[i]; EntryHandles.back().Entry=&Entries[i];
} }
} }
void Kdb3Database::restoreGroupTreeState(){ void Kdb3Database::restoreGroupTreeState(){
if(settings->value("GroupTreeState","ExpandAll")=="ExpandAll"){ switch (config->groupTreeState()){
for(int i=0;i<Groups.size();i++){ case KpxConfig::RestoreLast:
Groups[i].IsExpanded=true;
}
}
else
if(settings->value("GroupTreeState","ExpandAll")=="Restore"){
for(int i=0;i<Groups.size();i++){ for(int i=0;i<Groups.size();i++){
if(TreeStateMetaStream.contains(Groups[i].Id)) if(TreeStateMetaStream.contains(Groups[i].Id))
Groups[i].IsExpanded=TreeStateMetaStream.value(Groups[i].Id); Groups[i].IsExpanded=TreeStateMetaStream.value(Groups[i].Id);
} }
break;
case KpxConfig::ExpandAll:
for(int i=0;i<Groups.size();i++)
Groups[i].IsExpanded=true;
break;
} }
} }
@ -484,7 +486,7 @@ sha.update(FinalRandomSeed,16);
sha.update(MasterKey,32); sha.update(MasterKey,32);
sha.finish(FinalKey); sha.finish(FinalKey);
if(Algorithm == Rijndael_Cipher) if(Algorithm == Rijndael_Cipher)
{ AESdecrypt aes; { AESdecrypt aes;
aes.key256(FinalKey); aes.key256(FinalKey);
aes.cbc_decrypt((unsigned char*)buffer+DB_HEADER_SIZE,(unsigned char*)buffer+DB_HEADER_SIZE,total_size-DB_HEADER_SIZE,(unsigned char*)EncryptionIV); aes.cbc_decrypt((unsigned char*)buffer+DB_HEADER_SIZE,(unsigned char*)buffer+DB_HEADER_SIZE,total_size-DB_HEADER_SIZE,(unsigned char*)EncryptionIV);
@ -566,7 +568,7 @@ StdEntry entry;
bRet = readEntryField(&entry,FieldType,FieldSize,(quint8*)pField); bRet = readEntryField(&entry,FieldType,FieldSize,(quint8*)pField);
if((FieldType == 0xFFFF) && (bRet == true)){ if((FieldType == 0xFFFF) && (bRet == true)){
Entries << entry; Entries << entry;
if(!entry.GroupId)qDebug("NULL: %i, '%s'",(int)CurEntry,(char*)entry.Title.toUtf8().data()); if(!entry.GroupId)qDebug("NULL: %i, '%s'",(int)CurEntry,(char*)entry.Title.toUtf8().data());
CurEntry++;} CurEntry++;}
@ -582,7 +584,7 @@ if(!createGroupTree(Levels)){
error=tr("Invalid group tree."); error=tr("Invalid group tree.");
return false; return false;
} }
unsigned long CurGID, g, e, z, num; unsigned long CurGID, g, e, z, num;
delete [] buffer; delete [] buffer;
@ -599,7 +601,7 @@ for(int i=0;i<Entries.size();i++){
int* EntryIndices=new int[Groups.size()]; int* EntryIndices=new int[Groups.size()];
for(int i=0;i<Groups.size();i++)EntryIndices[i]=0; for(int i=0;i<Groups.size();i++)EntryIndices[i]=0;
for(int g=0;g<Groups.size();g++){ for(int g=0;g<Groups.size();g++){
for(int e=0;e<Entries.size();e++){ for(int e=0;e<Entries.size();e++){
if(Entries[e].GroupId==Groups[g].Id){ if(Entries[e].GroupId==Groups[g].Id){
Entries[e].Index=EntryIndices[g]; Entries[e].Index=EntryIndices[g];
@ -643,8 +645,8 @@ bool Kdb3Database::transformKey(quint8* src,quint8* dst,quint8* KeySeed,int roun
aes.key256(KeySeed); aes.key256(KeySeed);
memcpy(tmp,src,32); memcpy(tmp,src,32);
for(int i=0;i<rounds;i++){ for(int i=0;i<rounds;i++){
aes.ecb_encrypt(tmp,tmp,32); aes.ecb_encrypt(tmp,tmp,32);
} }
SHA256::hashBuffer(tmp,dst,32); SHA256::hashBuffer(tmp,dst,32);
return true; return true;
} }
@ -658,13 +660,13 @@ int Kdb3Database::numEntries(){
return Entries.size(); return Entries.size();
} }
void Kdb3Database::deleteGroup(StdGroup* group){ void Kdb3Database::deleteGroup(StdGroup* group){
while(group->Childs.size()) while(group->Childs.size())
deleteGroup(group->Childs.front()); deleteGroup(group->Childs.front());
QList<IEntryHandle*> GroupEntries; QList<IEntryHandle*> GroupEntries;
GroupEntries=entries(group->Handle); GroupEntries=entries(group->Handle);
deleteEntries(GroupEntries); deleteEntries(GroupEntries);
@ -672,22 +674,22 @@ void Kdb3Database::deleteGroup(StdGroup* group){
Q_ASSERT(group==group->Parent->Childs[group->Index]); Q_ASSERT(group==group->Parent->Childs[group->Index]);
group->Parent->Childs.removeAt(group->Index); group->Parent->Childs.removeAt(group->Index);
for(int i=group->Index;i<group->Parent->Childs.size();i++){ for(int i=group->Index;i<group->Parent->Childs.size();i++){
group->Parent->Childs[i]->Index--; group->Parent->Childs[i]->Index--;
} }
group->Handle->invalidate(); group->Handle->invalidate();
for(int i=0;i<Groups.size();i++){ for(int i=0;i<Groups.size();i++){
if(&Groups[i]==group){ if(&Groups[i]==group){
Groups.removeAt(i); Groups.removeAt(i);
break; break;
} }
} }
} }
void Kdb3Database::deleteGroup(IGroupHandle* group){ void Kdb3Database::deleteGroup(IGroupHandle* group){
deleteGroup(((GroupHandle*)group)->Group); deleteGroup(((GroupHandle*)group)->Group);
} }
void Kdb3Database::GroupHandle::setIndex(int index){ void Kdb3Database::GroupHandle::setIndex(int index){
@ -707,14 +709,14 @@ void Kdb3Database::GroupHandle::setIndex(int index){
else{ else{
for(NewPos;NewPos<pDB->Groups.size();NewPos++){ for(NewPos;NewPos<pDB->Groups.size();NewPos++){
if(pDB->Groups[NewPos].ParentId==ParentId && pDB->Groups[NewPos].Index+1==index) if(pDB->Groups[NewPos].ParentId==ParentId && pDB->Groups[NewPos].Index+1==index)
break; break;
} }
//skip the childs of the found sibling //skip the childs of the found sibling
for(NewPos;NewPos<Groups.size();NewPos++){ for(NewPos;NewPos<Groups.size();NewPos++){
if(Groups[NewPos] if(Groups[NewPos]
pDB->Groups.move(Pos,NewPos); pDB->Groups.move(Pos,NewPos);
} }
} }
// adjust the indices // adjust the indices
int NewIndex=0; int NewIndex=0;
@ -722,7 +724,7 @@ void Kdb3Database::GroupHandle::setIndex(int index){
if(pDB->Groups[i].ParentId==ParentId){ if(pDB->Groups[i].ParentId==ParentId){
pDB->Groups[i].Index=NewIndex; pDB->Groups[i].Index=NewIndex;
NewIndex++; NewIndex++;
} }
} }
*/ */
} }
@ -747,7 +749,7 @@ void Kdb3Database::authByPwd(QString& Password){
return; return;
} }
SHA256::hashBuffer(Password.toUtf8().data(),RawMasterKey,Password.toUtf8().size()); SHA256::hashBuffer(Password.toUtf8().data(),RawMasterKey,Password.toUtf8().size());
return; return;
}*/ }*/
void Kdb3Database::authByPwd(QString& Password){ void Kdb3Database::authByPwd(QString& Password){
@ -761,7 +763,7 @@ void Kdb3Database::authByPwd(QString& Password){
lat=Password.toLatin1(); lat=Password.toLatin1();
char *Lat=lat.data(); char *Lat=lat.data();
char *Utf=utf.data(); char *Utf=utf.data();
return; return;
} }
bool Kdb3Database::authByFile(QString& filename){ bool Kdb3Database::authByFile(QString& filename){
@ -770,17 +772,17 @@ bool Kdb3Database::authByFile(QString& filename){
error=decodeFileError(file.error()); error=decodeFileError(file.error());
return false; return false;
} }
unsigned long FileSize=file.size(); unsigned long FileSize=file.size();
if(FileSize == 0){ if(FileSize == 0){
error=tr("Key file is empty."); error=tr("Key file is empty.");
return false; return false;
} }
if(FileSize == 32){ if(FileSize == 32){
if(file.read((char*)RawMasterKey,32) != 32){ if(file.read((char*)RawMasterKey,32) != 32){
error=decodeFileError(file.error()); error=decodeFileError(file.error());
return false;} return false;}
return true; return true;
} }
if(FileSize == 64){ if(FileSize == 64){
char hex[64]; char hex[64];
if(file.read(hex,64) != 64){ if(file.read(hex,64) != 64){
@ -798,7 +800,7 @@ bool Kdb3Database::authByFile(QString& filename){
if(read != 2048) break; if(read != 2048) break;
} }
sha.finish(RawMasterKey); sha.finish(RawMasterKey);
delete [] buffer; delete [] buffer;
return true; return true;
} }
@ -809,7 +811,7 @@ bool Kdb3Database::authByFileAndPwd(QString& Password, QString& filename){
memcpy(FileKey,RawMasterKey,32); memcpy(FileKey,RawMasterKey,32);
authByPwd(Password); authByPwd(Password);
memcpy(PasswordKey,RawMasterKey,32); memcpy(PasswordKey,RawMasterKey,32);
SHA256 sha; SHA256 sha;
sha.update(PasswordKey,32); sha.update(PasswordKey,32);
sha.update(FileKey,32); sha.update(FileKey,32);
@ -822,7 +824,7 @@ QList<IEntryHandle*> Kdb3Database::entries(){
for(int i=0; i<EntryHandles.size(); i++){ for(int i=0; i<EntryHandles.size(); i++){
if(EntryHandles[i].isValid())handles.append(&EntryHandles[i]); if(EntryHandles[i].isValid())handles.append(&EntryHandles[i]);
} }
return handles; return handles;
} }
QList<IEntryHandle*> Kdb3Database::expiredEntries(){ QList<IEntryHandle*> Kdb3Database::expiredEntries(){
@ -833,7 +835,7 @@ QList<IEntryHandle*> Kdb3Database::expiredEntries(){
(EntryHandles[i].expire()!=Date_Never)) (EntryHandles[i].expire()!=Date_Never))
handles.append(&EntryHandles[i]); handles.append(&EntryHandles[i]);
} }
return handles; return handles;
} }
QList<IEntryHandle*> Kdb3Database::entries(IGroupHandle* group){ QList<IEntryHandle*> Kdb3Database::entries(IGroupHandle* group){
@ -850,19 +852,19 @@ QList<IEntryHandle*> Kdb3Database::entries(IGroupHandle* group){
void Kdb3Database::deleteEntry(IEntryHandle* entry){ void Kdb3Database::deleteEntry(IEntryHandle* entry){
if(!entry)return; if(!entry)return;
StdGroup* Group=((EntryHandle*)entry)->Entry->Group; StdGroup* Group=((EntryHandle*)entry)->Entry->Group;
int j; int j;
for(j=0;j<Entries.size();j++){ for(j=0;j<Entries.size();j++){
if(&Entries[j]==((EntryHandle*)entry)->Entry) if(&Entries[j]==((EntryHandle*)entry)->Entry)
break; break;
} }
Entries[j].Handle->invalidate(); Entries[j].Handle->invalidate();
Entries.removeAt(j); Entries.removeAt(j);
} }
void Kdb3Database::moveEntry(IEntryHandle* entry, IGroupHandle* group){ void Kdb3Database::moveEntry(IEntryHandle* entry, IGroupHandle* group){
((EntryHandle*)entry)->Entry->GroupId=((GroupHandle*)group)->Group->Id; ((EntryHandle*)entry)->Entry->GroupId=((GroupHandle*)group)->Group->Id;
((EntryHandle*)entry)->Entry->Group=((GroupHandle*)group)->Group; ((EntryHandle*)entry)->Entry->Group=((GroupHandle*)group)->Group;
} }
@ -879,7 +881,7 @@ void Kdb3Database::deleteEntries(QList<IEntryHandle*> entries){
Entries[j].Handle->invalidate(); Entries[j].Handle->invalidate();
Entries.removeAt(j); Entries.removeAt(j);
} }
for(int i=0;i<Group->Childs.size();i++){ for(int i=0;i<Group->Childs.size();i++){
Group->Childs[i]->Index=i; Group->Childs[i]->Index=i;
} }
@ -890,7 +892,7 @@ QList<IGroupHandle*> Kdb3Database::groups(){
for(int i=0; i<GroupHandles.size(); i++){ for(int i=0; i<GroupHandles.size(); i++){
if(GroupHandles[i].isValid())handles.append(&GroupHandles[i]); if(GroupHandles[i].isValid())handles.append(&GroupHandles[i]);
} }
return handles; return handles;
} }
quint32 Kdb3Database::getNewGroupId(){ quint32 Kdb3Database::getNewGroupId(){
@ -904,7 +906,7 @@ quint32 Kdb3Database::getNewGroupId(){
if(Groups[j].Id==id)used=true;} if(Groups[j].Id==id)used=true;}
if(used==false)break; if(used==false)break;
} }
return id; return id;
} }
IGroupHandle* Kdb3Database::addGroup(const CGroup* group,IGroupHandle* ParentHandle){ IGroupHandle* Kdb3Database::addGroup(const CGroup* group,IGroupHandle* ParentHandle){
@ -921,7 +923,7 @@ IGroupHandle* Kdb3Database::addGroup(const CGroup* group,IGroupHandle* ParentHan
else{ else{
Groups.back().Parent=&RootGroup; Groups.back().Parent=&RootGroup;
Groups.back().Index=RootGroup.Childs.size(); Groups.back().Index=RootGroup.Childs.size();
Groups.back().Parent->Childs.append(&Groups.back()); Groups.back().Parent->Childs.append(&Groups.back());
} }
return &GroupHandles.back(); return &GroupHandles.back();
} }
@ -931,7 +933,7 @@ Kdb3Database::StdGroup::StdGroup(const CGroup& other){
Index=0; Index=0;
Id=other.Id; Id=other.Id;
Image=other.Image; Image=other.Image;
Title=other.Title; Title=other.Title;
} }
void Kdb3Database::EntryHandle::setTitle(const QString& Title){Entry->Title=Title; } void Kdb3Database::EntryHandle::setTitle(const QString& Title){Entry->Title=Title; }
@ -977,7 +979,6 @@ void Kdb3Database::EntryHandle::setVisualIndex(int index){
Kdb3Database::EntryHandle::EntryHandle(Kdb3Database* db){ Kdb3Database::EntryHandle::EntryHandle(Kdb3Database* db){
pDB=db; pDB=db;
ListIndex=0;
valid=true; valid=true;
} }
@ -995,10 +996,10 @@ void Kdb3Database::GroupHandle::setImage(const quint32& New)
{ {
if(Group->Image < pDB->builtinIcons() && New >= pDB->builtinIcons()) if(Group->Image < pDB->builtinIcons() && New >= pDB->builtinIcons())
Group->OldImage=Group->Image; Group->OldImage=Group->Image;
if(New < pDB->builtinIcons()) if(New < pDB->builtinIcons())
Group->OldImage=New; Group->OldImage=New;
Group->Image=New; Group->Image=New;
} }
@ -1018,7 +1019,7 @@ int Kdb3Database::GroupHandle::level(){
StdGroup* group=Group; StdGroup* group=Group;
while(group->Parent){ while(group->Parent){
group=group->Parent; group=group->Parent;
i++; i++;
} }
i--; i--;
return i; return i;
@ -1112,7 +1113,7 @@ bool Kdb3Database::save(){
/* ----------------------------------------------------------------------------------*/ /* ----------------------------------------------------------------------------------*/
unsigned int FileSize; unsigned int FileSize;
QList<StdEntry> MetaStreams; QList<StdEntry> MetaStreams;
MetaStreams << StdEntry(); MetaStreams << StdEntry();
createCustomIconsMetaStream(&MetaStreams.back()); createCustomIconsMetaStream(&MetaStreams.back());
@ -1134,7 +1135,7 @@ bool Kdb3Database::save(){
+Entries[i].Password.length()+1 +Entries[i].Password.length()+1
+Entries[i].Comment.toUtf8().length()+1 +Entries[i].Comment.toUtf8().length()+1
+Entries[i].BinaryDesc.toUtf8().length()+1 +Entries[i].BinaryDesc.toUtf8().length()+1
+Entries[i].Binary.length(); +Entries[i].Binary.length();
} }
for(int i=0; i < UnknownMetaStreams.size(); i++){ for(int i=0; i < UnknownMetaStreams.size(); i++){
@ -1143,14 +1144,14 @@ bool Kdb3Database::save(){
+UnknownMetaStreams[i].Comment.toUtf8().length()+1 +UnknownMetaStreams[i].Comment.toUtf8().length()+1
+UnknownMetaStreams[i].Binary.length(); +UnknownMetaStreams[i].Binary.length();
} }
for(int i=0; i < MetaStreams.size(); i++){ for(int i=0; i < MetaStreams.size(); i++){
FileSize FileSize
+=164 +=164
+MetaStreams[i].Comment.toUtf8().length()+1 +MetaStreams[i].Comment.toUtf8().length()+1
+MetaStreams[i].Binary.length(); +MetaStreams[i].Binary.length();
} }
// Round up filesize to 16-byte boundary for Rijndael/Twofish // Round up filesize to 16-byte boundary for Rijndael/Twofish
FileSize = (FileSize + 16) - (FileSize % 16); FileSize = (FileSize + 16) - (FileSize % 16);
@ -1164,7 +1165,7 @@ bool Kdb3Database::save(){
Version = PWM_DBVER_DW; Version = PWM_DBVER_DW;
NumGroups = Groups.size(); NumGroups = Groups.size();
NumEntries = Entries.size()+UnknownMetaStreams.size()+MetaStreams.size(); NumEntries = Entries.size()+UnknownMetaStreams.size()+MetaStreams.size();
qSort(Entries.begin(),Entries.end(),StdEntryLessThan); qSort(Entries.begin(),Entries.end(),StdEntryLessThan);
randomize(FinalRandomSeed,16); randomize(FinalRandomSeed,16);
@ -1172,7 +1173,7 @@ bool Kdb3Database::save(){
randomize(EncryptionIV,16); randomize(EncryptionIV,16);
unsigned int pos=DB_HEADER_SIZE; // Skip the header, it will be written later unsigned int pos=DB_HEADER_SIZE; // Skip the header, it will be written later
serializeGroups(Groups,buffer,pos); serializeGroups(Groups,buffer,pos);
serializeEntries(Entries,buffer,pos); serializeEntries(Entries,buffer,pos);
serializeEntries(UnknownMetaStreams,buffer,pos); serializeEntries(UnknownMetaStreams,buffer,pos);
@ -1191,7 +1192,7 @@ bool Kdb3Database::save(){
memcpyToLEnd32(buffer+120,&KeyTransfRounds); memcpyToLEnd32(buffer+120,&KeyTransfRounds);
transformKey(RawMasterKey,MasterKey,TransfRandomSeed,KeyTransfRounds); transformKey(RawMasterKey,MasterKey,TransfRandomSeed,KeyTransfRounds);
quint8 FinalKey[32]; quint8 FinalKey[32];
SHA256 sha; SHA256 sha;
sha.update(FinalRandomSeed,16); sha.update(FinalRandomSeed,16);
sha.update(MasterKey,32); sha.update(MasterKey,32);
@ -1203,7 +1204,7 @@ bool Kdb3Database::save(){
EncryptedPartSize=((pos-DB_HEADER_SIZE)/16+1)*16; EncryptedPartSize=((pos-DB_HEADER_SIZE)/16+1)*16;
quint8 PadLen=EncryptedPartSize-(pos-DB_HEADER_SIZE); quint8 PadLen=EncryptedPartSize-(pos-DB_HEADER_SIZE);
for(int i=0;i<PadLen;i++) for(int i=0;i<PadLen;i++)
((quint8*)buffer)[DB_HEADER_SIZE+EncryptedPartSize-1-i]=PadLen; ((quint8*)buffer)[DB_HEADER_SIZE+EncryptedPartSize-1-i]=PadLen;
AESencrypt aes; AESencrypt aes;
aes.key256(FinalKey); aes.key256(FinalKey);
aes.cbc_encrypt((unsigned char*)buffer+DB_HEADER_SIZE,(unsigned char*)buffer+DB_HEADER_SIZE,EncryptedPartSize,(unsigned char*)EncryptionIV); aes.cbc_encrypt((unsigned char*)buffer+DB_HEADER_SIZE,(unsigned char*)buffer+DB_HEADER_SIZE,EncryptedPartSize,(unsigned char*)EncryptionIV);
@ -1250,7 +1251,7 @@ void Kdb3Database::createCustomIconsMetaStream(StdEntry* e){
quint32 NumEntries=Entries.size(); quint32 NumEntries=Entries.size();
quint32 NumGroups=Groups.size(); quint32 NumGroups=Groups.size();
Size+=8*NumGroups+20*NumEntries; Size+=8*NumGroups+20*NumEntries;
Size+=CustomIcons.size()*1000; // 1KB Size+=CustomIcons.size()*1000; // 1KB
e->Binary.reserve(Size); e->Binary.reserve(Size);
e->Binary.resize(12); e->Binary.resize(12);
quint32 NumIcons=CustomIcons.size(); quint32 NumIcons=CustomIcons.size();
@ -1288,7 +1289,7 @@ void Kdb3Database::createCustomIconsMetaStream(StdEntry* e){
QList<IGroupHandle*> Kdb3Database::sortedGroups(){ QList<IGroupHandle*> Kdb3Database::sortedGroups(){
QList<IGroupHandle*> SortedGroups; QList<IGroupHandle*> SortedGroups;
appendChildsToGroupList(SortedGroups,RootGroup); appendChildsToGroupList(SortedGroups,RootGroup);
return SortedGroups; return SortedGroups;
} }
@ -1296,29 +1297,29 @@ QList<IGroupHandle*> Kdb3Database::sortedGroups(){
void Kdb3Database::appendChildsToGroupList(QList<IGroupHandle*>& list,StdGroup& group){ void Kdb3Database::appendChildsToGroupList(QList<IGroupHandle*>& list,StdGroup& group){
for(int i=0;i<group.Childs.size();i++){ for(int i=0;i<group.Childs.size();i++){
list << group.Childs[i]->Handle; list << group.Childs[i]->Handle;
appendChildsToGroupList(list,*group.Childs[i]); appendChildsToGroupList(list,*group.Childs[i]);
} }
} }
void Kdb3Database::appendChildsToGroupList(QList<StdGroup*>& list,StdGroup& group){ void Kdb3Database::appendChildsToGroupList(QList<StdGroup*>& list,StdGroup& group){
for(int i=0;i<group.Childs.size();i++){ for(int i=0;i<group.Childs.size();i++){
list << group.Childs[i]; list << group.Childs[i];
appendChildsToGroupList(list,*group.Childs[i]); appendChildsToGroupList(list,*group.Childs[i]);
} }
} }
void Kdb3Database::serializeGroups(QList<StdGroup>& GroupList,char* buffer,unsigned int& pos){ void Kdb3Database::serializeGroups(QList<StdGroup>& GroupList,char* buffer,unsigned int& pos){
quint16 FieldType; quint16 FieldType;
quint32 FieldSize; quint32 FieldSize;
quint32 Flags=0; //unused quint32 Flags=0; //unused
QList<StdGroup*>SortedGroups; QList<StdGroup*>SortedGroups;
appendChildsToGroupList(SortedGroups,RootGroup); appendChildsToGroupList(SortedGroups,RootGroup);
for(int i=0; i < SortedGroups.size(); i++){ for(int i=0; i < SortedGroups.size(); i++){
unsigned char Date[5]; unsigned char Date[5];
dateToPackedStruct5(Date_Never,Date); dateToPackedStruct5(Date_Never,Date);
quint16 Level=0; quint16 Level=0;
StdGroup* group=SortedGroups[i]; StdGroup* group=SortedGroups[i];
while(group->Parent){ while(group->Parent){
@ -1326,7 +1327,7 @@ void Kdb3Database::serializeGroups(QList<StdGroup>& GroupList,char* buffer,unsig
group=group->Parent; group=group->Parent;
} }
Level--; Level--;
FieldType = 0x0001; FieldSize = 4; FieldType = 0x0001; FieldSize = 4;
memcpyToLEnd16(buffer+pos, &FieldType); pos += 2; memcpyToLEnd16(buffer+pos, &FieldType); pos += 2;
memcpyToLEnd32(buffer+pos, &FieldSize); pos += 4; memcpyToLEnd32(buffer+pos, &FieldSize); pos += 4;
@ -1375,8 +1376,8 @@ void Kdb3Database::serializeGroups(QList<StdGroup>& GroupList,char* buffer,unsig
FieldType = 0xFFFF; FieldSize = 0; FieldType = 0xFFFF; FieldSize = 0;
memcpyToLEnd16(buffer+pos, &FieldType); pos += 2; memcpyToLEnd16(buffer+pos, &FieldType); pos += 2;
memcpyToLEnd32(buffer+pos, &FieldSize); pos += 4; memcpyToLEnd32(buffer+pos, &FieldSize); pos += 4;
} }
} }
@ -1469,11 +1470,11 @@ void Kdb3Database::serializeEntries(QList<StdEntry>& EntryList,char* buffer,unsi
FieldType = 0xFFFF; FieldSize = 0; FieldType = 0xFFFF; FieldSize = 0;
memcpyToLEnd16(buffer+pos, &FieldType); pos += 2; memcpyToLEnd16(buffer+pos, &FieldType); pos += 2;
memcpyToLEnd32(buffer+pos, &FieldSize); pos += 4; memcpyToLEnd32(buffer+pos, &FieldSize); pos += 4;
} }
} }
bool Kdb3Database::close(){ bool Kdb3Database::close(){
return true; return true;
} }
void Kdb3Database::create(){ void Kdb3Database::create(){
@ -1489,7 +1490,7 @@ void Kdb3Database::create(){
bool Kdb3Database::isKeyError(){ bool Kdb3Database::isKeyError(){
if(KeyError){ if(KeyError){
KeyError=false; KeyError=false;
return true; return true;
} }
else else
return false; return false;
@ -1502,7 +1503,7 @@ IEntryHandle* Kdb3Database::cloneEntry(const IEntryHandle* entry){
Entries.append(dolly); Entries.append(dolly);
EntryHandles.append(EntryHandle(this)); EntryHandles.append(EntryHandle(this));
EntryHandles.back().Entry=&Entries.back(); EntryHandles.back().Entry=&Entries.back();
Entries.back().Handle=&EntryHandles.back(); Entries.back().Handle=&EntryHandles.back();
return &EntryHandles.back(); return &EntryHandles.back();
} }
@ -1514,7 +1515,7 @@ IEntryHandle* Kdb3Database::newEntry(IGroupHandle* group){
Entries.append(Entry); Entries.append(Entry);
EntryHandles.append(EntryHandle(this)); EntryHandles.append(EntryHandle(this));
EntryHandles.back().Entry=&Entries.back(); EntryHandles.back().Entry=&Entries.back();
Entries.back().Handle=&EntryHandles.back(); Entries.back().Handle=&EntryHandles.back();
return &EntryHandles.back(); return &EntryHandles.back();
} }
@ -1526,7 +1527,7 @@ IEntryHandle* Kdb3Database::addEntry(const CEntry* NewEntry, IGroupHandle* Group
Entries.append(Entry); Entries.append(Entry);
EntryHandles.append(EntryHandle(this)); EntryHandles.append(EntryHandle(this));
EntryHandles.back().Entry=&Entries.back(); EntryHandles.back().Entry=&Entries.back();
Entries.back().Handle=&EntryHandles.back(); Entries.back().Handle=&EntryHandles.back();
return &EntryHandles.back(); return &EntryHandles.back();
} }
@ -1539,47 +1540,47 @@ bool Kdb3Database::isParent(IGroupHandle* parent, IGroupHandle* child){
StdGroup* group=((GroupHandle*)child)->Group; StdGroup* group=((GroupHandle*)child)->Group;
while(group->Parent!=&RootGroup){ while(group->Parent!=&RootGroup){
if(group->Parent==((GroupHandle*)parent)->Group)return true; if(group->Parent==((GroupHandle*)parent)->Group)return true;
group=group->Parent; group=group->Parent;
} }
return false; return false;
} }
void Kdb3Database::cleanUpHandles(){} void Kdb3Database::cleanUpHandles(){}
bool Kdb3Database::searchStringContains(const QString& search, const QString& string,bool Cs, bool RegExp){ bool Kdb3Database::searchStringContains(const QString& search, const QString& string,bool Cs, bool RegExp){
if(RegExp){ if(RegExp){
QRegExp exp(search,Cs ? Qt::CaseSensitive : Qt::CaseInsensitive); QRegExp exp(search,Cs ? Qt::CaseSensitive : Qt::CaseInsensitive);
if(string.contains(exp)==0)return false;} if(string.contains(exp)==0)return false;}
else else
if(string.contains(search,Cs ? Qt::CaseSensitive : Qt::CaseInsensitive)==0)return false; if(string.contains(search,Cs ? Qt::CaseSensitive : Qt::CaseInsensitive)==0)return false;
return true; return true;
} }
void Kdb3Database::getEntriesRecursive(IGroupHandle* Group, QList<IEntryHandle*>& EntryList){ void Kdb3Database::getEntriesRecursive(IGroupHandle* Group, QList<IEntryHandle*>& EntryList){
EntryList<<entries(Group); EntryList<<entries(Group);
for(int i=0;i<((GroupHandle*)Group)->Group->Childs.size(); i++){ for(int i=0;i<((GroupHandle*)Group)->Group->Childs.size(); i++){
getEntriesRecursive(((GroupHandle*)Group)->Group->Childs[i]->Handle,EntryList); getEntriesRecursive(((GroupHandle*)Group)->Group->Childs[i]->Handle,EntryList);
} }
} }
QList<IEntryHandle*> Kdb3Database::search(IGroupHandle* Group,const QString& search, bool CaseSensitive, bool RegExp, bool Recursive,bool* Fields){ QList<IEntryHandle*> Kdb3Database::search(IGroupHandle* Group,const QString& search, bool CaseSensitive, bool RegExp, bool Recursive,bool* Fields){
bool fields[6]={true,true,true,false,true,true}; bool fields[6]={true,true,true,false,true,true};
if(!Fields) if(!Fields)
Fields=fields; Fields=fields;
QList<IEntryHandle*> SearchEntries; QList<IEntryHandle*> SearchEntries;
if(search==QString())return Group ? entries(Group) : entries(); if(search==QString())return Group ? entries(Group) : entries();
if(Group){ if(Group){
if(Recursive) if(Recursive)
getEntriesRecursive(Group,SearchEntries); getEntriesRecursive(Group,SearchEntries);
else else
SearchEntries=entries(Group); SearchEntries=entries(Group);
} }
else else
SearchEntries=entries(); SearchEntries=entries();
for(int i=0;i<SearchEntries.size();i++){ for(int i=0;i<SearchEntries.size();i++){
bool match=false; bool match=false;
if(Fields[0])match=match||searchStringContains(search,SearchEntries[i]->title(),CaseSensitive,RegExp); if(Fields[0])match=match||searchStringContains(search,SearchEntries[i]->title(),CaseSensitive,RegExp);
@ -1595,14 +1596,14 @@ QList<IEntryHandle*> Kdb3Database::search(IGroupHandle* Group,const QString& sea
i--; i--;
} }
} }
return SearchEntries; return SearchEntries;
} }
void Kdb3Database::rebuildIndices(QList<StdGroup*>& list){ void Kdb3Database::rebuildIndices(QList<StdGroup*>& list){
for(int i=0;i<list.size();i++){ for(int i=0;i<list.size();i++){
list[i]->Index=i; list[i]->Index=i;
} }
} }
bool Kdb3Database::createKeyFile(const QString& filename,int length, bool Hex){ bool Kdb3Database::createKeyFile(const QString& filename,int length, bool Hex){
@ -1624,14 +1625,14 @@ bool Kdb3Database::createKeyFile(const QString& filename,int length, bool Hex){
else key[i]='0'+dig1; else key[i]='0'+dig1;
if(dig2>9)key[i+1]='A'+dig2-10; if(dig2>9)key[i+1]='A'+dig2-10;
else key[i+1]='0'+dig2; else key[i+1]='0'+dig2;
} }
} }
if(file.write((char*)key,length)==-1){ if(file.write((char*)key,length)==-1){
delete [] key; delete [] key;
error=decodeFileError(file.error()); error=decodeFileError(file.error());
file.close(); file.close();
return false; return false;
} }
file.close(); file.close();
delete [] key; delete [] key;
return true; return true;
@ -1639,7 +1640,7 @@ bool Kdb3Database::createKeyFile(const QString& filename,int length, bool Hex){
void Kdb3Database::moveGroup(IGroupHandle* groupHandle,IGroupHandle* NewParent,int Pos){ void Kdb3Database::moveGroup(IGroupHandle* groupHandle,IGroupHandle* NewParent,int Pos){
StdGroup* Parent; StdGroup* Parent;
StdGroup* Group=((GroupHandle*)groupHandle)->Group; StdGroup* Group=((GroupHandle*)groupHandle)->Group;
if(NewParent) if(NewParent)
Parent=((GroupHandle*)NewParent)->Group; Parent=((GroupHandle*)NewParent)->Group;
@ -1656,22 +1657,50 @@ void Kdb3Database::moveGroup(IGroupHandle* groupHandle,IGroupHandle* NewParent,i
Q_ASSERT(Parent->Childs.size()>=Pos); Q_ASSERT(Parent->Childs.size()>=Pos);
Parent->Childs.insert(Pos,Group); Parent->Childs.insert(Pos,Group);
} }
rebuildIndices(Parent->Childs); rebuildIndices(Parent->Childs);
} }
bool Kdb3Database::changeFile(const QString& filename){ bool Kdb3Database::changeFile(const QString& filename){
if(File) if(File)
delete File; delete File;
if(filename==QString()){ if(filename==QString()){
File=NULL; File=NULL;
return true; return true;
} }
File=new QFile(filename); File=new QFile(filename);
if(!File->open(QIODevice::ReadWrite)){ if(!File->open(QIODevice::ReadWrite)){
if(!File->open(QIODevice::ReadOnly)){ if(!File->open(QIODevice::ReadOnly)){
error=decodeFileError(File->error()); error=decodeFileError(File->error());
return false; return false;
} }
} }
return true; return true;
} }
void Kdb3Database::moveToTrash(IEntryHandle* entry){
TrashEntry trash=*((TrashEntry*)dynamic_cast<EntryHandle*>(entry)->Entry);
IGroupHandle* CurGroup=entry->group();
while(CurGroup){
trash.GroupPath << CurGroup->title();
CurGroup=CurGroup->parent();
}
deleteEntry(entry);
trash.Group=NULL;
TrashEntries.append(trash);
TrashHandles.append(EntryHandle(this));
TrashHandles.back().Entry=&TrashEntries.back();
TrashEntries.back().Handle=&TrashHandles.back();
}
void Kdb3Database::emptyTrash(){
TrashEntries.clear();
TrashHandles.clear();
}
QList<IEntryHandle*> Kdb3Database::trashEntries(){
QList<IEntryHandle*> handles;
for(int i=0; i<TrashHandles.size();i++)
if(TrashHandles[i].isValid())
handles << &TrashHandles[i];
return handles;
}

@ -55,6 +55,7 @@ public:
class StdGroup; class StdGroup;
class StdEntry; class StdEntry;
class EntryHandle:public IEntryHandle{ class EntryHandle:public IEntryHandle{
friend class Kdb3Database; friend class Kdb3Database;
public: public:
EntryHandle(Kdb3Database* db); EntryHandle(Kdb3Database* db);
@ -94,11 +95,11 @@ public:
private: private:
void invalidate(){valid=false;} void invalidate(){valid=false;}
bool valid; bool valid;
unsigned int ListIndex; //KpxUuid Uuid; ???
KpxUuid Uuid;
Kdb3Database* pDB; Kdb3Database* pDB;
StdEntry* Entry; StdEntry* Entry;
}; };
class GroupHandle:public IGroupHandle{ class GroupHandle:public IGroupHandle{
friend class Kdb3Database; friend class Kdb3Database;
GroupHandle(Kdb3Database* db); GroupHandle(Kdb3Database* db);
@ -123,8 +124,10 @@ public:
StdGroup* Group; StdGroup* Group;
Kdb3Database* pDB; Kdb3Database* pDB;
}; };
friend class EntryHandle; friend class EntryHandle;
friend class GroupHandle; friend class GroupHandle;
class StdEntry:public CEntry{ class StdEntry:public CEntry{
public: public:
quint32 OldImage; quint32 OldImage;
@ -132,6 +135,7 @@ public:
EntryHandle* Handle; EntryHandle* Handle;
StdGroup* Group; StdGroup* Group;
}; };
class StdGroup:public CGroup{ class StdGroup:public CGroup{
public: public:
StdGroup():CGroup(){}; StdGroup():CGroup(){};
@ -143,6 +147,12 @@ public:
QList<StdGroup*> Childs; QList<StdGroup*> Childs;
QList<StdEntry*> Entries; QList<StdEntry*> Entries;
}; };
class TrashEntry: public StdEntry{
public:
QStringList GroupPath;
};
virtual ~Kdb3Database(){}; virtual ~Kdb3Database(){};
virtual bool load(QString identifier); virtual bool load(QString identifier);
virtual bool save(); virtual bool save();
@ -182,6 +192,9 @@ public:
virtual IEntryHandle* addEntry(const CEntry* NewEntry, IGroupHandle* group); virtual IEntryHandle* addEntry(const CEntry* NewEntry, IGroupHandle* group);
virtual void moveEntry(IEntryHandle* entry, IGroupHandle* group); virtual void moveEntry(IEntryHandle* entry, IGroupHandle* group);
virtual void deleteLastEntry(); virtual void deleteLastEntry();
virtual void moveToTrash(IEntryHandle* entry);
virtual QList<IEntryHandle*> trashEntries();
virtual void emptyTrash();
virtual QList<IGroupHandle*> groups(); virtual QList<IGroupHandle*> groups();
@ -232,8 +245,10 @@ private:
QList<EntryHandle> EntryHandles; QList<EntryHandle> EntryHandles;
QList<GroupHandle> GroupHandles; QList<GroupHandle> GroupHandles;
QList<EntryHandle> TrashHandles;
QList<StdEntry> Entries; QList<StdEntry> Entries;
QList<StdGroup> Groups; QList<StdGroup> Groups;
QList<TrashEntry> TrashEntries;
StdGroup RootGroup; StdGroup RootGroup;
QList<QPixmap>CustomIcons; QList<QPixmap>CustomIcons;
QFile* File; QFile* File;

@ -32,7 +32,7 @@ AboutDialog::AboutDialog(QWidget* parent):QDialog(parent)
setupUi(this); setupUi(this);
createBanner(&BannerPixmap,getPixmap("keepassx_large"),tr("KeePassX %1").arg(KEEPASS_VERSION),width()); createBanner(&BannerPixmap,getPixmap("keepassx_large"),tr("KeePassX %1").arg(KEEPASS_VERSION),width());
loadLicFromFile(); loadLicFromFile();
QString AboutTr=tr("<b>Current Translation: None</b><br><br>","Please replace 'None' with the language of your translation"); QString AboutTr=tr("<b>Current Translation: None</b><br><br>","Please replace 'None' with the language of your translation");
if(TrActive){ if(TrActive){
AboutTr+=tr("<b>Author:</b> %1<br>").arg(tr("$TRANSLATION_AUTHOR")); AboutTr+=tr("<b>Author:</b> %1<br>").arg(tr("$TRANSLATION_AUTHOR"));
@ -58,6 +58,9 @@ AboutDialog::AboutDialog(QWidget* parent):QDialog(parent)
str+="<br>"; str+="<br>";
str+="</div><div style='margin-left:10px;'>"; str+="</div><div style='margin-left:10px;'>";
str+="<u>"+tr("James Nicholls")+"</u><br>"+tr("Main Application Icon")/*+"<br>"+tr("mailto:???")*/+"<br></div>"; str+="<u>"+tr("James Nicholls")+"</u><br>"+tr("Main Application Icon")/*+"<br>"+tr("mailto:???")*/+"<br></div>";
str+="<br>";
str+="</div><div style='margin-left:10px;'>";
str+="<u>"+tr("Constantin Makshin")+"</u><br>"+tr("Various fixes and improvements")+"<br>"+tr("dinosaur-rus@users.sourceforge.net")+"<br></div>";
Edit_Thanks->setHtml(str); Edit_Thanks->setHtml(str);
} }
@ -85,7 +88,7 @@ return;
if(!gpl.open(QIODevice::ReadOnly)){ if(!gpl.open(QIODevice::ReadOnly)){
QMessageBox::critical(this,tr("Error"),tr("Could not open file '%1'") QMessageBox::critical(this,tr("Error"),tr("Could not open file '%1'")
.arg("'license.txt'")+tr("The following error occured:\n%1").arg(gpl.errorString()) .arg("'license.txt'")+tr("The following error occured:\n%1").arg(gpl.errorString())
,tr("OK"),0,0,2,1); ,tr("OK"),0,0,2,1);
return; return;
} }

@ -26,6 +26,7 @@
CollectEntropyDlg::CollectEntropyDlg(QWidget* parent):QDialog(parent){ CollectEntropyDlg::CollectEntropyDlg(QWidget* parent):QDialog(parent){
setupUi(this); setupUi(this);
resize(layout()->closestAcceptableSize(this,QSize(0,0)));
setMinimumSize(size()); setMinimumSize(size());
setMaximumSize(size()); setMaximumSize(size());
createBanner(&BannerPixmap,getPixmap("dice"),tr("Entropy Collection"),width()); createBanner(&BannerPixmap,getPixmap("dice"),tr("Entropy Collection"),width());

@ -19,7 +19,7 @@
***************************************************************************/ ***************************************************************************/
#include "main.h" #include "main.h"
#include "PwmConfig.h" #include "KpxConfig.h"
#include <qpushbutton.h> #include <qpushbutton.h>
#include <qpalette.h> #include <qpalette.h>
#include <qfont.h> #include <qfont.h>
@ -69,7 +69,7 @@ CEditEntryDlg::CEditEntryDlg(IDatabase* _db, IEntryHandle* _entry,QWidget* paren
connect(Button_CustomIcons,SIGNAL(clicked()),this,SLOT(OnCustomIcons())); connect(Button_CustomIcons,SIGNAL(clicked()),this,SLOT(OnCustomIcons()));
connect(ExpirePresetsMenu,SIGNAL(triggered(QAction*)),this,SLOT(OnExpirePreset(QAction*))); connect(ExpirePresetsMenu,SIGNAL(triggered(QAction*)),this,SLOT(OnExpirePreset(QAction*)));
connect(ButtonExpirePresets,SIGNAL(triggered(QAction*)),this,SLOT(OnCalendar(QAction*))); connect(ButtonExpirePresets,SIGNAL(triggered(QAction*)),this,SLOT(OnCalendar(QAction*)));
// QAction::data() contains the time until expiration in days. // QAction::data() contains the time until expiration in days.
ExpirePresetsMenu->addAction(tr("Today"))->setData(0); ExpirePresetsMenu->addAction(tr("Today"))->setData(0);
ExpirePresetsMenu->addSeparator(); ExpirePresetsMenu->addSeparator();
@ -84,7 +84,7 @@ CEditEntryDlg::CEditEntryDlg(IDatabase* _db, IEntryHandle* _entry,QWidget* paren
ExpirePresetsMenu->addAction(tr("1 Year"))->setData(365); ExpirePresetsMenu->addAction(tr("1 Year"))->setData(365);
ButtonExpirePresets->setMenu(ExpirePresetsMenu); ButtonExpirePresets->setMenu(ExpirePresetsMenu);
ButtonExpirePresets->setDefaultAction(new QAction(tr("Calendar..."),ButtonExpirePresets)); ButtonExpirePresets->setDefaultAction(new QAction(tr("Calendar..."),ButtonExpirePresets));
ButtonOpenAttachment->setIcon(getIcon("fileopen")); ButtonOpenAttachment->setIcon(getIcon("fileopen"));
ButtonDeleteAttachment->setIcon(getIcon("filedelete")); ButtonDeleteAttachment->setIcon(getIcon("filedelete"));
ButtonSaveAttachment->setIcon(getIcon("filesave")); ButtonSaveAttachment->setIcon(getIcon("filesave"));
@ -101,7 +101,7 @@ CEditEntryDlg::CEditEntryDlg(IDatabase* _db, IEntryHandle* _entry,QWidget* paren
Edit_Password->setText(Password.string()); Edit_Password->setText(Password.string());
Edit_Password_w->setText(Password.string()); Edit_Password_w->setText(Password.string());
Password.lock(); Password.lock();
if(!config.ShowPasswords) if(!config->showPasswords())
ChangeEchoMode(); ChangeEchoMode();
OnPasswordwLostFocus(); OnPasswordwLostFocus();
int bits=(Password.length()*8); int bits=(Password.length()*8);
@ -118,15 +118,15 @@ CEditEntryDlg::CEditEntryDlg(IDatabase* _db, IEntryHandle* _entry,QWidget* paren
ButtonSaveAttachment->setDisabled(true); ButtonSaveAttachment->setDisabled(true);
ButtonDeleteAttachment->setDisabled(true); ButtonDeleteAttachment->setDisabled(true);
Label_AttachmentSize->setText(""); Label_AttachmentSize->setText("");
} }
else{ else{
QString unit; QString unit;
int faktor; int faktor;
int prec; int prec;
if(entry->binarySize()<1000){unit=" Byte";faktor=1;prec=0;} if(entry->binarySize()<1000){unit=" Byte";faktor=1;prec=0;}
else else
if(entry->binarySize()<1000000){unit=" kB";faktor=1000;prec=1;} if(entry->binarySize()<1000000){unit=" kB";faktor=1000;prec=1;}
else{unit=" MB";faktor=1000000;prec=1;} else{unit=" MB";faktor=1000000;prec=1;}
Label_AttachmentSize->setText(QString::number((float)entry->binarySize()/(float)faktor,'f',prec)+unit); Label_AttachmentSize->setText(QString::number((float)entry->binarySize()/(float)faktor,'f',prec)+unit);
} }
if(entry->expire()==Date_Never){ if(entry->expire()==Date_Never){
@ -135,7 +135,7 @@ CEditEntryDlg::CEditEntryDlg(IDatabase* _db, IEntryHandle* _entry,QWidget* paren
} }
else{ else{
DateTime_Expire->setDateTime(entry->expire()); DateTime_Expire->setDateTime(entry->expire());
} }
} }
CEditEntryDlg::~CEditEntryDlg() CEditEntryDlg::~CEditEntryDlg()
@ -183,9 +183,9 @@ void CEditEntryDlg::InitGroupComboBox(){
Combo_Group->insertItem(i,db->icon(groups[i]->image()),Space+groups[i]->title()); Combo_Group->insertItem(i,db->icon(groups[i]->image()),Space+groups[i]->title());
if(groups[i]==entry->group()){ if(groups[i]==entry->group()){
Combo_Group->setCurrentIndex(i); Combo_Group->setCurrentIndex(i);
GroupIndex=i; GroupIndex=i;
} }
} }
} }
void CEditEntryDlg::OnButtonOK() void CEditEntryDlg::OnButtonOK()
@ -219,7 +219,7 @@ void CEditEntryDlg::OnButtonOK()
password.fill('X'); password.fill('X');
if(entry->image()!=Combo_IconPicker->currentIndex()) if(entry->image()!=Combo_IconPicker->currentIndex())
ModFlag=true; ModFlag=true;
if(ModFlag){ if(ModFlag){
entry->setExpire(DateTime_Expire->dateTime()); entry->setExpire(DateTime_Expire->dateTime());
entry->setLastAccess(QDateTime::currentDateTime()); entry->setLastAccess(QDateTime::currentDateTime());
@ -238,11 +238,11 @@ void CEditEntryDlg::OnButtonOK()
EntryMoved=true; ModFlag=true; EntryMoved=true; ModFlag=true;
} }
entry->setImage(Combo_IconPicker->currentIndex()); entry->setImage(Combo_IconPicker->currentIndex());
if(ModFlag&&EntryMoved)done(2); if(ModFlag&&EntryMoved)done(2);
else if(ModFlag)done(1); else if(ModFlag)done(1);
else done(0); else done(0);
} }
void CEditEntryDlg::OnButtonCancel() void CEditEntryDlg::OnButtonCancel()
@ -268,7 +268,7 @@ Edit_Password_w->setEchoMode(QLineEdit::Normal);
void CEditEntryDlg::OnPasswordTextChanged(const QString& txt) void CEditEntryDlg::OnPasswordTextChanged(const QString& txt)
{ {
Edit_Password_w->setText(""); Edit_Password_w->setText(QString());
int bits=(Edit_Password->text().length()*8); int bits=(Edit_Password->text().length()*8);
Label_Bits->setText(QString::number(bits)+" Bit"); Label_Bits->setText(QString::number(bits)+" Bit");
if(bits>128)bits=128; if(bits>128)bits=128;
@ -307,7 +307,7 @@ else
} }
void CEditEntryDlg::OnNewAttachment() void CEditEntryDlg::OnNewAttachment()
{ {
QString filename=QFileDialog::getOpenFileName(this,tr("Add Attachment..."),QDir::homePath()); QString filename=QFileDialog::getOpenFileName(this,tr("Add Attachment..."),QDir::homePath());
if(filename=="")return; if(filename=="")return;
QFile file(filename); QFile file(filename);
@ -316,7 +316,7 @@ void CEditEntryDlg::OnNewAttachment()
QMessageBox::warning(NULL,tr("Error"),tr("Could not open file."),tr("OK")); QMessageBox::warning(NULL,tr("Error"),tr("Could not open file."),tr("OK"));
return; return;
} }
ModFlag=true; ModFlag=true;
entry->setBinary(file.readAll()); entry->setBinary(file.readAll());
file.close(); file.close();
QFileInfo info(filename); QFileInfo info(filename);
@ -341,7 +341,7 @@ void CEditEntryDlg::OnSaveAttachment(){
void CEditEntryDlg::saveAttachment(IEntryHandle* pEntry, QWidget* ParentWidget) void CEditEntryDlg::saveAttachment(IEntryHandle* pEntry, QWidget* ParentWidget)
{ {
if(!pEntry->binarySize()){ if(!pEntry->binarySize()){
QMessageBox::information(NULL,tr("Error"),tr("The chosen entry has no attachment or it is empty."),tr("OK")); QMessageBox::information(NULL,tr("Error"),tr("The chosen entry has no attachment or it is empty."),tr("OK"));
return; return;
} }
@ -390,8 +390,8 @@ void CEditEntryDlg::OnButtonGenPw()
{ {
CGenPwDialog dlg(this,false); CGenPwDialog dlg(this,false);
if(dlg.exec()){ if(dlg.exec()){
Edit_Password->setText(dlg.Edit_dest->text()); Edit_Password->setText(dlg.Edit_dest->text());
Edit_Password_w->setText(dlg.Edit_dest->text()); Edit_Password_w->setText(dlg.Edit_dest->text());
ModFlag=true; ModFlag=true;
} }
} }
@ -427,6 +427,6 @@ void CEditEntryDlg::OnCalendar(QAction* action){
CheckBox_ExpiresNever->setChecked(false); CheckBox_ExpiresNever->setChecked(false);
DateTime_Expire->setDate(dlg.calendarWidget->selectedDate()); DateTime_Expire->setDate(dlg.calendarWidget->selectedDate());
DateTime_Expire->setTime(QTime(0,0,0)); DateTime_Expire->setTime(QTime(0,0,0));
} }
} }

@ -24,7 +24,7 @@
#include <QPixmap> #include <QPixmap>
#include <QShowEvent> #include <QShowEvent>
#include "main.h" #include "main.h"
#include "StandardDatabase.h" #include "Kdb3Database.h"
class CEditEntryDlg : public QDialog, public Ui_EditEntryDialog class CEditEntryDlg : public QDialog, public Ui_EditEntryDialog
{ {

@ -29,7 +29,7 @@
#include <QStringList> #include <QStringList>
#include "main.h" #include "main.h"
#include "PwmConfig.h" #include "KpxConfig.h"
#include "PasswordDlg.h" #include "PasswordDlg.h"
#include "lib/FileDialogs.h" #include "lib/FileDialogs.h"
@ -40,31 +40,33 @@ CPasswordDialog::CPasswordDialog(QWidget* parent,IDatabase* DB,bool ShowExitButt
setupUi(this); setupUi(this);
createBanner(Banner,getPixmap("key"),tr("Database Key")); createBanner(Banner,getPixmap("key"),tr("Database Key"));
db=DB; db=DB;
QDir media(config.MountDir); QString mountDir=config->mountDir();
QDir media(mountDir);
if(media.exists()){ if(media.exists()){
QStringList Paths; QStringList Paths;
Paths=media.entryList(QStringList()<<"*",QDir::Dirs); Paths=media.entryList(QStringList()<<"*",QDir::Dirs);
Paths.erase(Paths.begin()); // delete "." Paths.erase(Paths.begin()); // delete "."
Paths.erase(Paths.begin()); // delete ".." Paths.erase(Paths.begin()); // delete ".."
for(int i=0;i<Paths.count();i++) for(int i=0;i<Paths.count();i++)
Combo_Dirs->addItem(config.MountDir+Paths[i]); Combo_Dirs->addItem(mountDir+Paths[i]);
} }
Combo_Dirs->setEditText(QString()); Combo_Dirs->setEditText(QString());
if(settings->value("RememberLastKey",true).toBool() && !ChangeKeyMode){ if(config->rememberLastKey() && !ChangeKeyMode){
QString LastKeyType=settings->value("LastKeyType","").toString(); switch(config->lastKeyType()){
if(LastKeyType=="KeyFile"){ case KEYFILE:
setStateKeyFileOnly(); setStateKeyFileOnly();
Combo_Dirs->setEditText(QDir::cleanPath(QDir::current().absoluteFilePath(settings->value("LastKeyFile","").toString()))); Combo_Dirs->setEditText(QDir::cleanPath(QDir::current().absoluteFilePath(config->lastKeyLocation())));
} break;
else if(LastKeyType=="Composite"){
setStateBoth(); case BOTH:
CheckBox_Both->setChecked(true); setStateBoth();
Combo_Dirs->setEditText(QDir::cleanPath(QDir::current().absoluteFilePath(settings->value("LastKeyFile","").toString()))); CheckBox_Both->setChecked(true);
Combo_Dirs->setEditText(QDir::cleanPath(QDir::current().absoluteFilePath(config->lastKeyLocation())));
} }
// if(LastKeyType==Password){... is not required because it is already the default state. // if(LastKeyType==Password){... is not required because it is already the default state.
} }
connect( Combo_Dirs, SIGNAL( editTextChanged(const QString&) ),this, SLOT( OnComboTextChanged(const QString&))); connect( Combo_Dirs, SIGNAL( editTextChanged(const QString&) ),this, SLOT( OnComboTextChanged(const QString&)));
connect( ButtonCancel, SIGNAL( clicked() ), this, SLOT( OnCancel() ) ); connect( ButtonCancel, SIGNAL( clicked() ), this, SLOT( OnCancel() ) );
connect( Edit_Password, SIGNAL( textChanged(const QString&) ), this, SLOT( OnPasswordChanged(const QString&) ) ); connect( Edit_Password, SIGNAL( textChanged(const QString&) ), this, SLOT( OnPasswordChanged(const QString&) ) );
@ -73,7 +75,7 @@ CPasswordDialog::CPasswordDialog(QWidget* parent,IDatabase* DB,bool ShowExitButt
connect( Edit_Password, SIGNAL( returnPressed() ), this, SLOT( OnOK() ) ); connect( Edit_Password, SIGNAL( returnPressed() ), this, SLOT( OnOK() ) );
connect( Edit_PasswordRep, SIGNAL( returnPressed() ), this, SLOT( OnOK() ) ); connect( Edit_PasswordRep, SIGNAL( returnPressed() ), this, SLOT( OnOK() ) );
connect( ButtonExit, SIGNAL( clicked()),this,SLOT(OnButtonExit())); connect( ButtonExit, SIGNAL( clicked()),this,SLOT(OnButtonExit()));
ButtonExit->setVisible(ShowExitButton); ButtonExit->setVisible(ShowExitButton);
Mode_Set=ChangeKeyMode; Mode_Set=ChangeKeyMode;
if(!ChangeKeyMode){ if(!ChangeKeyMode){
@ -85,8 +87,8 @@ CPasswordDialog::CPasswordDialog(QWidget* parent,IDatabase* DB,bool ShowExitButt
connect( ButtonOK, SIGNAL( clicked() ), this, SLOT( OnOK_Set() ) ); connect( ButtonOK, SIGNAL( clicked() ), this, SLOT( OnOK_Set() ) );
connect( ButtonBrowse, SIGNAL( clicked() ), this, SLOT( OnButtonBrowse_Set() ) ); connect( ButtonBrowse, SIGNAL( clicked() ), this, SLOT( OnButtonBrowse_Set() ) );
} }
if(!config.ShowPasswordsPasswordDlg)ChangeEchoModeDatabaseKey(); if(!config->showPasswordsPasswordDlg())ChangeEchoModeDatabaseKey();
} }
@ -159,16 +161,16 @@ void CPasswordDialog::OnOK(){
password=Edit_Password->text(); password=Edit_Password->text();
keyfile=Combo_Dirs->currentText(); keyfile=Combo_Dirs->currentText();
if(password=="" && keyfile==""){ if(password.isEmpty() && keyfile.isEmpty()){
QMessageBox::warning(this,tr("Error"),tr("Please enter a Password or select a key file."),tr("OK"),"","",0,0); QMessageBox::warning(this,tr("Error"),tr("Please enter a Password or select a key file."),tr("OK"),"","",0,0);
return; return;
} }
if(KeyType==BOTH){ if(KeyType==BOTH){
if(password==""){ if(password.isEmpty()){
QMessageBox::warning(this,tr("Error"),tr("Please enter a Password."),tr("OK"),"","",0,0); QMessageBox::warning(this,tr("Error"),tr("Please enter a Password."),tr("OK"),"","",0,0);
return;} return;}
if(keyfile==""){ if(keyfile.isEmpty()){
QMessageBox::warning(this,tr("Error"),tr("Please choose a key file."),tr("OK"),"","",0,0); QMessageBox::warning(this,tr("Error"),tr("Please choose a key file."),tr("OK"),"","",0,0);
return;} return;}
} }
@ -186,7 +188,7 @@ void CPasswordDialog::OnOK(){
if(fileinfo.isDir()){ if(fileinfo.isDir()){
if(keyfile.right(1)!="/")keyfile+="/"; if(keyfile.right(1)!="/")keyfile+="/";
QFile file(keyfile+"pwsafe.key"); QFile file(keyfile+"pwsafe.key");
if(!file.exists()){ if(!file.exists()){
QDir dir(keyfile); QDir dir(keyfile);
QStringList files; QStringList files;
files=dir.entryList(QStringList()<<"*.key",QDir::Files); files=dir.entryList(QStringList()<<"*.key",QDir::Files);
@ -200,13 +202,13 @@ void CPasswordDialog::OnOK(){
Q_ASSERT(file.exists()); Q_ASSERT(file.exists());
if(!QFileInfo(file).isReadable()){ if(!QFileInfo(file).isReadable()){
QMessageBox::warning(this,tr("Error"),tr("The key file found in the given directory is not readable.\nPlease check your permissions."),tr("OK"),"","",0,0); QMessageBox::warning(this,tr("Error"),tr("The key file found in the given directory is not readable.\nPlease check your permissions."),tr("OK"),"","",0,0);
return;} return;}
keyfile+=files[0]; keyfile+=files[0];
} }
else{ /* pwsafe.key exists */ else{ /* pwsafe.key exists */
if(!QFileInfo(file).isReadable()){ if(!QFileInfo(file).isReadable()){
QMessageBox::warning(this,tr("Error"),tr("The key file found in the given directory is not readable.\nPlease check your permissions."),tr("OK"),"","",0,0); QMessageBox::warning(this,tr("Error"),tr("The key file found in the given directory is not readable.\nPlease check your permissions."),tr("OK"),"","",0,0);
return;} return;}
keyfile+="pwsafe.key"; keyfile+="pwsafe.key";
} }
} }
@ -231,15 +233,15 @@ void CPasswordDialog::OnOK_Set(){
return; return;
} }
keyfile=Combo_Dirs->currentText(); keyfile=Combo_Dirs->currentText();
if(password=="" && keyfile==""){ if(password.isEmpty() && keyfile.isEmpty()){
QMessageBox::warning(this,tr("Error"),tr("Please enter a password or select a key file."),tr("OK"),"","",0,0); QMessageBox::warning(this,tr("Error"),tr("Please enter a password or select a key file."),tr("OK"),"","",0,0);
return; return;
} }
if(keyfile!=QString()){ if(!keyfile.isEmpty()){
QFile file(keyfile); QFile file(keyfile);
if(QFileInfo(file).isDir()){ if(QFileInfo(file).isDir()){
if(keyfile.right(1)!="/")keyfile+="/"; if(keyfile.right(1)!="/")keyfile+="/";
keyfile+="pwsafe.key"; keyfile+="pwsafe.key";
} }
if(file.exists()){ if(file.exists()){
@ -252,60 +254,55 @@ void CPasswordDialog::OnOK_Set(){
OverwriteKeyFile=true; OverwriteKeyFile=true;
break; break;
case 2: case 2:
return; return;
} }
} }
IFilePasswordAuth* DbAuth=dynamic_cast<IFilePasswordAuth*>(db); IFilePasswordAuth* DbAuth=dynamic_cast<IFilePasswordAuth*>(db);
if(OverwriteKeyFile){ if(OverwriteKeyFile){
if(!DbAuth->createKeyFile(keyfile,32,true)){ if(!DbAuth->createKeyFile(keyfile,32,true)){
QMessageBox::warning(this,tr("Error"),tr("Key file could not be created.\n%1").arg(db->getError()),tr("OK"),"","",0,0); QMessageBox::warning(this,tr("Error"),tr("Key file could not be created.\n%1").arg(db->getError()),tr("OK"),"","",0,0);
return; return;
} }
} }
} }
if(doAuth())done(1); if(doAuth())done(1);
} }
bool CPasswordDialog::doAuth(){ bool CPasswordDialog::doAuth(){
IFilePasswordAuth* DbAuth=dynamic_cast<IFilePasswordAuth*>(db); IFilePasswordAuth* DbAuth=dynamic_cast<IFilePasswordAuth*>(db);
if(password!=QString() && keyfile==QString()){ if(!password.isEmpty() && keyfile.isEmpty()){
DbAuth->authByPwd(password); DbAuth->authByPwd(password);
} }
if(password==QString() && keyfile!=QString()){ if(password.isEmpty() && !keyfile.isEmpty()){
if(!DbAuth->authByFile(keyfile))return false; if(!DbAuth->authByFile(keyfile))return false;
} }
if(password!=QString() && keyfile!=QString()){ if(!password.isEmpty() && !keyfile.isEmpty()){
if(!DbAuth->authByFile(keyfile))return false; if(!DbAuth->authByFile(keyfile))return false;
} }
if(settings->value("RememberLastKey",true).toBool()){ if(config->rememberLastKey()){
QString KeyLocation=keyfile; QString KeyLocation=keyfile;
if(settings->value("SaveRelativePaths",true).toBool()){ if(config->saveRelativePaths()){
KeyLocation=KeyLocation.left(KeyLocation.lastIndexOf("/")); KeyLocation=KeyLocation.left(KeyLocation.lastIndexOf("/"));
KeyLocation=makePathRelative(KeyLocation,QDir::currentPath())+keyfile.right(keyfile.length()-keyfile.lastIndexOf("/")-1); KeyLocation=makePathRelative(KeyLocation,QDir::currentPath())+keyfile.right(keyfile.length()-keyfile.lastIndexOf("/")-1);
} }
settings->setValue("LastKeyFile",KeyLocation); config->setLastKeyLocation(KeyLocation);
if(KeyType==PASSWORD) config->setLastKeyType(KeyType);
settings->setValue("LastKeyType","Password");
if(KeyType==KEYFILE)
settings->setValue("LastKeyType","KeyFile");
if(KeyType==BOTH)
settings->setValue("LastKeyType","Composite");
} }
return true; return true;
} }
void CPasswordDialog::OnPasswordChanged(const QString &txt){ void CPasswordDialog::OnPasswordChanged(const QString &txt){
Edit_PasswordRep->setText(""); Edit_PasswordRep->setText(QString());
if(CheckBox_Both->isChecked() || txt==QString()) if(CheckBox_Both->isChecked() || txt.isEmpty())
setStateBoth(); setStateBoth();
else else
setStatePasswordOnly(); setStatePasswordOnly();
} }
void CPasswordDialog::OnComboTextChanged(const QString& txt){ void CPasswordDialog::OnComboTextChanged(const QString& txt){
if(CheckBox_Both->isChecked() || txt==QString()) if(CheckBox_Both->isChecked() || txt.isEmpty())
setStateBoth(); setStateBoth();
else else
setStateKeyFileOnly(); setStateKeyFileOnly();
@ -317,17 +314,16 @@ void CPasswordDialog::OnCheckBox_BothChanged(int state){
if(state==Qt::Checked) if(state==Qt::Checked)
setStateBoth(); setStateBoth();
if(state==Qt::Unchecked){ if(state==Qt::Unchecked){
if(Edit_Password->text()!=QString() && Combo_Dirs->currentText()!=QString()){ if(!Edit_Password->text().isEmpty() && !Combo_Dirs->currentText().isEmpty()){
Combo_Dirs->setEditText(QString()); Combo_Dirs->setEditText(QString());
setStatePasswordOnly(); setStatePasswordOnly();
} }
else{ else{
if(Edit_Password->text()==QString()) if(Edit_Password->text().isEmpty())
setStateKeyFileOnly(); setStateKeyFileOnly();
else else
setStatePasswordOnly(); setStatePasswordOnly();
} }
} }
} }

@ -29,17 +29,17 @@
#include "PasswordGenDlg.h" #include "PasswordGenDlg.h"
#include "CollectEntropyDlg.h" #include "CollectEntropyDlg.h"
#include "crypto/yarrow.h" #include "crypto/yarrow.h"
#include "PwmConfig.h" #include "KpxConfig.h"
bool CGenPwDialog::EntropyCollected=false; bool CGenPwDialog::EntropyCollected=false;
CGenPwDialog::CGenPwDialog(QWidget* parent, bool StandAloneMode,Qt::WFlags fl) CGenPwDialog::CGenPwDialog(QWidget* parent, bool StandAloneMode,Qt::WFlags fl)
: QDialog(parent,fl) : QDialog(parent,fl)
{ {
setupUi(this); setupUi(this);
setMinimumSize(size()); setMinimumSize(size());
setMaximumSize(size()); setMaximumSize(size());
createBanner(&BannerPixmap,getPixmap("dice"),tr("Password Generator"),width()); createBanner(&BannerPixmap,getPixmap("dice"),tr("Password Generator"),width());
connect(ButtonGenerate,SIGNAL(clicked()),this,SLOT(OnGeneratePw())); connect(ButtonGenerate,SIGNAL(clicked()),this,SLOT(OnGeneratePw()));
connect(Radio_1,SIGNAL(toggled(bool)),this,SLOT(OnRadio1StateChanged(bool))); connect(Radio_1,SIGNAL(toggled(bool)),this,SLOT(OnRadio1StateChanged(bool)));
connect(Radio_2,SIGNAL(toggled(bool)),this,SLOT(OnRadio2StateChanged(bool))); connect(Radio_2,SIGNAL(toggled(bool)),this,SLOT(OnRadio2StateChanged(bool)));
@ -56,43 +56,46 @@ CGenPwDialog::CGenPwDialog(QWidget* parent, bool StandAloneMode,Qt::WFlags fl)
connect(Check_CollectEntropy,SIGNAL(stateChanged(int)),this,SLOT(OnCollectEntropyChanged(int))); connect(Check_CollectEntropy,SIGNAL(stateChanged(int)),this,SLOT(OnCollectEntropyChanged(int)));
connect(Edit_chars,SIGNAL(textChanged(const QString&)),this,SLOT(estimateQuality())); connect(Edit_chars,SIGNAL(textChanged(const QString&)),this,SLOT(estimateQuality()));
connect(Edit_chars,SIGNAL(textEdited(const QString&)),this,SLOT(OnCharsChanged(const QString&))); connect(Edit_chars,SIGNAL(textEdited(const QString&)),this,SLOT(OnCharsChanged(const QString&)));
if(!StandAloneMode){ if(!StandAloneMode){
AcceptButton=DialogButtons->addButton(tr("Accept"),QDialogButtonBox::AcceptRole); AcceptButton=DialogButtons->addButton(tr("Accept"),QDialogButtonBox::AcceptRole);
AcceptButton->setDisabled(true); AcceptButton->setDisabled(true);
DialogButtons->addButton(QDialogButtonBox::Cancel); DialogButtons->addButton(QDialogButtonBox::Cancel);
} }
else{ else{
DialogButtons->addButton(tr("OK"),QDialogButtonBox::AcceptRole); DialogButtons->addButton(tr("OK"),QDialogButtonBox::AcceptRole);
AcceptButton=NULL; AcceptButton=NULL;
} }
Radio_1->setChecked(config.PwGenOptions[0]); QBitArray pwGenOptions=config->pwGenOptions();
Radio_2->setChecked(!config.PwGenOptions[0]); Radio_1->setChecked(pwGenOptions.at(0));
checkBox1->setChecked(config.PwGenOptions[1]); Radio_2->setChecked(!pwGenOptions.at(0));
checkBox2->setChecked(config.PwGenOptions[2]); checkBox1->setChecked(pwGenOptions.at(1));
checkBox3->setChecked(config.PwGenOptions[3]); checkBox2->setChecked(pwGenOptions.at(2));
checkBox4->setChecked(config.PwGenOptions[4]); checkBox3->setChecked(pwGenOptions.at(3));
checkBox5->setChecked(config.PwGenOptions[5]); checkBox4->setChecked(pwGenOptions.at(4));
checkBox6->setChecked(config.PwGenOptions[6]); checkBox5->setChecked(pwGenOptions.at(5));
checkBox7->setChecked(config.PwGenOptions[7]); checkBox6->setChecked(pwGenOptions.at(6));
Check_CollectEntropy->setChecked(config.PwGenOptions[8]); checkBox7->setChecked(pwGenOptions.at(7));
Check_CollectOncePerSession->setChecked(config.PwGenOptions[9]); Check_CollectEntropy->setChecked(pwGenOptions.at(8));
OnRadio1StateChanged(config.PwGenOptions[0]); Check_CollectOncePerSession->setChecked(pwGenOptions.at(9));
OnRadio2StateChanged(!config.PwGenOptions[0]); OnRadio1StateChanged(pwGenOptions.at(0));
OnRadio2StateChanged(!pwGenOptions.at(0));
} }
CGenPwDialog::~CGenPwDialog(){ CGenPwDialog::~CGenPwDialog(){
config.PwGenOptions[0]=Radio_1->isChecked(); QBitArray pwGenOptions(10);
config.PwGenOptions[1]=checkBox1->isChecked(); pwGenOptions.setBit(0,Radio_1->isChecked());
config.PwGenOptions[2]=checkBox2->isChecked(); pwGenOptions.setBit(1,checkBox1->isChecked());
config.PwGenOptions[3]=checkBox3->isChecked(); pwGenOptions.setBit(2,checkBox2->isChecked());
config.PwGenOptions[4]=checkBox4->isChecked(); pwGenOptions.setBit(3,checkBox3->isChecked());
config.PwGenOptions[5]=checkBox5->isChecked(); pwGenOptions.setBit(4,checkBox4->isChecked());
config.PwGenOptions[6]=checkBox6->isChecked(); pwGenOptions.setBit(5,checkBox5->isChecked());
config.PwGenOptions[7]=checkBox7->isChecked(); pwGenOptions.setBit(6,checkBox6->isChecked());
config.PwGenOptions[8]=Check_CollectEntropy->isChecked(); pwGenOptions.setBit(7,checkBox7->isChecked());
config.PwGenOptions[9]=Check_CollectOncePerSession->isChecked(); pwGenOptions.setBit(8,Check_CollectEntropy->isChecked());
pwGenOptions.setBit(9,Check_CollectOncePerSession->isChecked());
config->setPwGenOptions(pwGenOptions);
} }
void CGenPwDialog::paintEvent(QPaintEvent *event){ void CGenPwDialog::paintEvent(QPaintEvent *event){
@ -129,7 +132,7 @@ void CGenPwDialog::OnRadio2StateChanged(bool state){
Edit_chars->setEnabled(true); Edit_chars->setEnabled(true);
else else
Edit_chars->setDisabled(true); Edit_chars->setDisabled(true);
estimateQuality(); estimateQuality();
} }
@ -141,22 +144,22 @@ void CGenPwDialog::OnGeneratePw()
"A...Z" 65...90 "A...Z" 65...90
"a...z" 97...122 "a...z" 97...122
"0...9" 48...57 "0...9" 48...57
Special Charakters 33...47; 58...64; 91...96; 123...126 Special Characters 33...47; 58...64; 91...96; 123...126
"-" 45 "-" 45
"_" 95 "_" 95
------------------------------------------------------- -------------------------------------------------------
*/ */
int num=0; int num=0;
char assoctable[255]; char assoctable[255];
if(Radio_1->isChecked()){ if(Radio_1->isChecked()){
if(checkBox1->isChecked()) if(checkBox1->isChecked())
num+=AddToAssoctable(assoctable,65,90,num); num+=AddToAssoctable(assoctable,65,90,num);
if(checkBox2->isChecked()) if(checkBox2->isChecked())
num+=AddToAssoctable(assoctable,97,122,num); num+=AddToAssoctable(assoctable,97,122,num);
if(checkBox3->isChecked()) if(checkBox3->isChecked())
num+=AddToAssoctable(assoctable,48,57,num); num+=AddToAssoctable(assoctable,48,57,num);
if(checkBox4->isChecked()){ if(checkBox4->isChecked()){
num+=AddToAssoctable(assoctable,33,47,num); num+=AddToAssoctable(assoctable,33,47,num);
num+=AddToAssoctable(assoctable,58,64,num); num+=AddToAssoctable(assoctable,58,64,num);
@ -173,7 +176,7 @@ void CGenPwDialog::OnGeneratePw()
QString str=Edit_chars->text(); QString str=Edit_chars->text();
for(int i=0;i<str.length();i++){ for(int i=0;i<str.length();i++){
assoctable[i]=str[i].toAscii(); assoctable[i]=str[i].toAscii();
num++; num++;
} }
} }
if(num==0){ if(num==0){
@ -186,7 +189,7 @@ void CGenPwDialog::OnGeneratePw()
int length=Spin_Num->value(); int length=Spin_Num->value();
char* buffer=new char[length+1]; char* buffer=new char[length+1];
buffer[length]=0; buffer[length]=0;
if(Check_CollectEntropy->isChecked()){ if(Check_CollectEntropy->isChecked()){
if((Check_CollectOncePerSession->isChecked() && !EntropyCollected) || !Check_CollectOncePerSession->isChecked()){ if((Check_CollectOncePerSession->isChecked() && !EntropyCollected) || !Check_CollectOncePerSession->isChecked()){
CollectEntropyDlg dlg(this); CollectEntropyDlg dlg(this);
@ -194,21 +197,21 @@ void CGenPwDialog::OnGeneratePw()
EntropyCollected=true; EntropyCollected=true;
} }
} }
unsigned char tmp; unsigned char tmp;
for(int i=0;i<length;i++){ for(int i=0;i<length;i++){
do randomize(&tmp,1); do randomize(&tmp,1);
while(!trim(tmp,num)); while(!trim(tmp,num));
buffer[i]=assoctable[tmp]; buffer[i]=assoctable[tmp];
} }
Edit_dest->setText(buffer); Edit_dest->setText(buffer);
delete [] buffer; delete [] buffer;
if(AcceptButton)AcceptButton->setEnabled(true); if(AcceptButton)AcceptButton->setEnabled(true);
} }
int CGenPwDialog::AddToAssoctable(char* table,int start,int end,int pos){ int CGenPwDialog::AddToAssoctable(char* table,int start,int end,int pos){
for(int i=start;i<=end;i++){ for(int i=start;i<=end;i++){
table[pos]=i; table[pos]=i;
@ -231,11 +234,11 @@ void CGenPwDialog::estimateQuality(){
int num=0; int num=0;
if(Radio_1->isChecked()){ if(Radio_1->isChecked()){
if(checkBox1->isChecked()) if(checkBox1->isChecked())
num+=26; num+=26;
if(checkBox2->isChecked()) if(checkBox2->isChecked())
num+=26; num+=26;
if(checkBox3->isChecked()) if(checkBox3->isChecked())
num+=10; num+=10;
if(checkBox4->isChecked()) if(checkBox4->isChecked())
num+=32; num+=32;
if(checkBox5->isChecked()) if(checkBox5->isChecked())
@ -247,7 +250,7 @@ void CGenPwDialog::estimateQuality(){
} }
else else
num=Edit_chars->text().length(); num=Edit_chars->text().length();
float bits=0; float bits=0;
if(num)bits=log(num)/log(2); if(num)bits=log(num)/log(2);
bits=bits*((float)Spin_Num->value()); bits=bits*((float)Spin_Num->value());
@ -267,18 +270,18 @@ void CGenPwDialog::OnCharsChanged(const QString& str){
else {count++;} else {count++;}
} }
} }
if(multiple)break; if(multiple)break;
} }
if(!multiple)return; if(!multiple)return;
QString newstr; QString newstr;
for(int i=0;i<str.size();i++){ for(int i=0;i<str.size();i++){
if(!newstr.count(str[i])){ if(!newstr.count(str[i])){
newstr+=str[i]; newstr+=str[i];
} }
} }
Edit_chars->setText(newstr); Edit_chars->setText(newstr);
} }
void CGenPwDialog::OnAccept() void CGenPwDialog::OnAccept()

@ -25,7 +25,7 @@
#include <QMessageBox> #include <QMessageBox>
#include <QPainter> #include <QPainter>
#include "main.h" #include "main.h"
#include "PwmConfig.h" #include "KpxConfig.h"
#include "SearchDlg.h" #include "SearchDlg.h"
@ -37,16 +37,17 @@ SearchDialog::SearchDialog(IDatabase* database,IGroupHandle* Group,QWidget* pare
db=database; db=database;
group=Group; group=Group;
createBanner(&BannerPixmap,getPixmap("search"),tr("Search"),width()); createBanner(&BannerPixmap,getPixmap("search"),tr("Search"),width());
checkBox_Cs->setChecked(config.SearchOptions[0]); QBitArray searchOptions=config->searchOptions();
checkBox_regExp->setChecked(config.SearchOptions[1]); checkBox_Cs->setChecked(searchOptions.at(0));
checkBox_Title->setChecked(config.SearchOptions[2]); checkBox_regExp->setChecked(searchOptions.at(1));
checkBox_Username->setChecked(config.SearchOptions[3]); checkBox_Title->setChecked(searchOptions.at(2));
checkBox_Password->setChecked(config.SearchOptions[4]); checkBox_Username->setChecked(searchOptions.at(3));
checkBox_Comment->setChecked(config.SearchOptions[5]); checkBox_Password->setChecked(searchOptions.at(4));
checkBox_URL->setChecked(config.SearchOptions[6]); checkBox_Comment->setChecked(searchOptions.at(5));
checkBox_Attachment->setChecked(config.SearchOptions[7]); checkBox_URL->setChecked(searchOptions.at(6));
checkBox_Attachment->setChecked(searchOptions.at(7));
if(group) if(group)
checkBox_Recursive->setChecked(config.SearchOptions[8]); checkBox_Recursive->setChecked(searchOptions.at(8));
else{ else{
checkBox_Recursive->setChecked(false); checkBox_Recursive->setChecked(false);
checkBox_Recursive->setEnabled(false); checkBox_Recursive->setEnabled(false);
@ -55,15 +56,17 @@ SearchDialog::SearchDialog(IDatabase* database,IGroupHandle* Group,QWidget* pare
SearchDialog::~SearchDialog() SearchDialog::~SearchDialog()
{ {
config.SearchOptions[0]=checkBox_Cs->isChecked(); QBitArray searchOptions(9);
config.SearchOptions[1]=checkBox_regExp->isChecked(); searchOptions.setBit(0,checkBox_Cs->isChecked());
config.SearchOptions[2]=checkBox_Title->isChecked(); searchOptions.setBit(1,checkBox_regExp->isChecked());
config.SearchOptions[3]=checkBox_Username->isChecked(); searchOptions.setBit(2,checkBox_Title->isChecked());
config.SearchOptions[4]=checkBox_Password->isChecked(); searchOptions.setBit(3,checkBox_Username->isChecked());
config.SearchOptions[5]=checkBox_Comment->isChecked(); searchOptions.setBit(4,checkBox_Password->isChecked());
config.SearchOptions[6]=checkBox_URL->isChecked(); searchOptions.setBit(5,checkBox_Comment->isChecked());
config.SearchOptions[7]=checkBox_Attachment->isChecked(); searchOptions.setBit(6,checkBox_URL->isChecked());
if(group) config.SearchOptions[8]=checkBox_Recursive->isChecked(); searchOptions.setBit(7,checkBox_Attachment->isChecked());
if(group) searchOptions.setBit(8,checkBox_Recursive->isChecked());
config->setSearchOptions(searchOptions);
} }
void SearchDialog::OnClose() void SearchDialog::OnClose()
@ -79,7 +82,7 @@ void SearchDialog::OnSearch()
Fields[2]=checkBox_URL->isChecked(); Fields[2]=checkBox_URL->isChecked();
Fields[3]=checkBox_Password->isChecked(); Fields[3]=checkBox_Password->isChecked();
Fields[4]=checkBox_Comment->isChecked(); Fields[4]=checkBox_Comment->isChecked();
Fields[5]=checkBox_Attachment->isChecked(); Fields[5]=checkBox_Attachment->isChecked();
Result=db->search(group,Edit_Search->text(),checkBox_Cs->isChecked(),checkBox_regExp->isChecked(),checkBox_Recursive->isChecked(),Fields); Result=db->search(group,Edit_Search->text(),checkBox_Cs->isChecked(),checkBox_regExp->isChecked(),checkBox_Recursive->isChecked(),Fields);
done(1); done(1);
} }

@ -17,9 +17,9 @@
* Free Software Foundation, Inc., * * Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/ ***************************************************************************/
#include "main.h" #include "main.h"
#include "PwmConfig.h" #include "KpxConfig.h"
#include <qpixmap.h> #include <qpixmap.h>
#include <qcheckbox.h> #include <qcheckbox.h>
#include <qspinbox.h> #include <qspinbox.h>
@ -40,92 +40,94 @@ CSettingsDlg::CSettingsDlg(QWidget* parent):QDialog(parent,Qt::Dialog)
connect(DialogButtons, SIGNAL( accepted() ), this, SLOT( OnOK() ) ); connect(DialogButtons, SIGNAL( accepted() ), this, SLOT( OnOK() ) );
connect(DialogButtons, SIGNAL( rejected() ), this, SLOT( OnCancel() ) ); connect(DialogButtons, SIGNAL( rejected() ), this, SLOT( OnCancel() ) );
connect(DialogButtons, SIGNAL( clicked(QAbstractButton*)), this, SLOT(OnOtherButton(QAbstractButton*))); connect(DialogButtons, SIGNAL( clicked(QAbstractButton*)), this, SLOT(OnOtherButton(QAbstractButton*)));
connect(ButtonColor1, SIGNAL( clicked() ), this, SLOT( OnColor1() ) ); connect(ButtonColor1, SIGNAL( clicked() ), this, SLOT( OnColor1() ) );
connect(ButtonColor2, SIGNAL( clicked() ), this, SLOT( OnColor2() ) ); connect(ButtonColor2, SIGNAL( clicked() ), this, SLOT( OnColor2() ) );
connect(ButtonTextColor, SIGNAL( clicked() ), this, SLOT( OnTextColor() ) ); connect(ButtonTextColor, SIGNAL( clicked() ), this, SLOT( OnTextColor() ) );
connect(CheckBox_OpenLast,SIGNAL(stateChanged(int)),this,SLOT(OnCheckBoxOpenLastChanged(int))); connect(CheckBox_OpenLast,SIGNAL(stateChanged(int)),this,SLOT(OnCheckBoxOpenLastChanged(int)));
connect(Button_MountDirBrowse,SIGNAL(clicked()),this,SLOT(OnMountDirBrowse())); connect(Button_MountDirBrowse,SIGNAL(clicked()),this,SLOT(OnMountDirBrowse()));
connect(Radio_IntPlugin_None,SIGNAL(toggled(bool)),this,SLOT(OnIntPluginNone(bool))); connect(Radio_IntPlugin_None,SIGNAL(toggled(bool)),this,SLOT(OnIntPluginNone(bool)));
connect(Radio_IntPlugin_Gnome,SIGNAL(toggled(bool)),this,SLOT(OnIntPluginGnome(bool))); connect(Radio_IntPlugin_Gnome,SIGNAL(toggled(bool)),this,SLOT(OnIntPluginGnome(bool)));
connect(Radio_IntPlugin_Kde,SIGNAL(toggled(bool)),this,SLOT(OnIntPluginKde(bool))); connect(Radio_IntPlugin_Kde,SIGNAL(toggled(bool)),this,SLOT(OnIntPluginKde(bool)));
connect(CheckBox_BrowserDefault,SIGNAL(stateChanged(int)),this,SLOT(OnCheckBoxBrowserDefaultChanged(int))); connect(CheckBox_BrowserDefault,SIGNAL(stateChanged(int)),this,SLOT(OnCheckBoxBrowserDefaultChanged(int)));
connect(Button_CustomizeEntryDetails,SIGNAL(clicked()),this,SLOT(OnCustomizeEntryDetails())); connect(Button_CustomizeEntryDetails,SIGNAL(clicked()),this,SLOT(OnCustomizeEntryDetails()));
createBanner(&BannerPixmap,getPixmap("appsettings"),tr("Settings"),width()); createBanner(&BannerPixmap,getPixmap("appsettings"),tr("Settings"),width());
//General //General
CheckBox_OpenLast->setChecked(settings->value("OpenLastFile",true).toBool()); CheckBox_OpenLast->setChecked(config->openLastFile());
CheckBox_RememberLastKey->setChecked(settings->value("RememberLastKey",true).toBool()); CheckBox_RememberLastKey->setChecked(config->rememberLastKey());
checkBox_ShowSysTrayIcon->setChecked(config.ShowSysTrayIcon); checkBox_ShowSysTrayIcon->setChecked(config->showSysTrayIcon());
checkBox_MinimizeToTray->setChecked(config.MinimizeToTray); checkBox_MinimizeToTray->setChecked(config->minimizeToTray());
checkBox_SaveFileDlgHistory->setChecked(config.SaveFileDlgHistory); checkBox_SaveFileDlgHistory->setChecked(config->saveFileDlgHistory());
checkBox_AskBeforeDelete->setChecked(config->askBeforeDelete());
switch(config.GroupTreeRestore){
case 1: switch(config->groupTreeState()){
case KpxConfig::RestoreLast:
Radio_GroupTreeRestore->setChecked(true); Radio_GroupTreeRestore->setChecked(true);
break; break;
case 2: case KpxConfig::ExpandAll:
Radio_GroupTreeExpand->setChecked(true); Radio_GroupTreeExpand->setChecked(true);
break; break;
case 3: default:
Radio_GroupTreeDoNothing->setChecked(true); Radio_GroupTreeDoNothing->setChecked(true);
} }
if(settings->value("GroupTreeState","ExpandAll")=="ExpandAll")Radio_GroupTreeExpand->setChecked(true);
if(settings->value("GroupTreeState","ExpandAll")=="Restore")Radio_GroupTreeRestore->setChecked(true); //Appearance
if(settings->value("GroupTreeState","ExpandAll")=="ExpandNone")Radio_GroupTreeDoNothing->setChecked(true);
//Appearance
QPixmap *pxt=new QPixmap(pixmTextColor->width(),pixmTextColor->height()); QPixmap *pxt=new QPixmap(pixmTextColor->width(),pixmTextColor->height());
pxt->fill(config.BannerTextColor); pxt->fill(config->bannerTextColor());
pixmTextColor->clear(); pixmTextColor->clear();
pixmTextColor->setPixmap(*pxt); pixmTextColor->setPixmap(*pxt);
QPixmap *px1=new QPixmap(pixmColor1->width(),pixmColor1->height()); QPixmap *px1=new QPixmap(pixmColor1->width(),pixmColor1->height());
px1->fill(config.BannerColor1); px1->fill(config->bannerColor1());
pixmColor1->clear(); pixmColor1->clear();
pixmColor1->setPixmap(*px1); pixmColor1->setPixmap(*px1);
QPixmap *px2=new QPixmap(pixmColor2->width(),pixmColor2->height()); QPixmap *px2=new QPixmap(pixmColor2->width(),pixmColor2->height());
px2->fill(config.BannerColor2); px2->fill(config->bannerColor2());
pixmColor2->clear(); pixmColor2->clear();
pixmColor2->setPixmap(*px2); pixmColor2->setPixmap(*px2);
color1=config.BannerColor1; color1=config->bannerColor1();
color2=config.BannerColor2; color2=config->bannerColor2();
textcolor=config.BannerTextColor; textcolor=config->bannerTextColor();
CheckBox_AlternatingRowColors->setChecked(config.AlternatingRowColors); CheckBox_AlternatingRowColors->setChecked(config->alternatingRowColors());
//Security //Security
SpinBox_ClipboardTime->setValue(config.ClipboardTimeOut); SpinBox_ClipboardTime->setValue(config->clipboardTimeOut());
CheckBox_ShowPasswords->setChecked(config.ShowPasswords); CheckBox_ShowPasswords->setChecked(config->showPasswords());
CheckBox_ShowPasswords_PasswordDlg->setChecked(config.ShowPasswordsPasswordDlg); CheckBox_ShowPasswords_PasswordDlg->setChecked(config->showPasswordsPasswordDlg());
//Desktop Integration //Desktop Integration
if(PluginLoadError==QString()) if(PluginLoadError==QString())
Label_IntPlugin_Error->hide(); Label_IntPlugin_Error->hide();
else else
Label_IntPlugin_Error->setText(QString("<html><p style='font-weight:600; color:#8b0000;'>%1</p></body></html>") Label_IntPlugin_Error->setText(QString("<html><p style='font-weight:600; color:#8b0000;'>%1</p></body></html>")
.arg(tr("Error: %1")).arg(PluginLoadError)); .arg(tr("Error: %1")).arg(PluginLoadError));
switch(config.IntegrPlugin){ switch(config->integrPlugin()){
case CConfig::NONE: Radio_IntPlugin_None->setChecked(true); break; case KpxConfig::KDE:
case CConfig::GNOME: Radio_IntPlugin_Gnome->setChecked(true); break; Radio_IntPlugin_Kde->setChecked(true);
case CConfig::KDE: Radio_IntPlugin_Kde->setChecked(true); break; break;
case KpxConfig::Gnome:
Radio_IntPlugin_Gnome->setChecked(true);
break;
default:
Radio_IntPlugin_None->setChecked(true);
} }
if(!PluginsModified) if(!PluginsModified)
Label_IntPlugin_Info->hide(); Label_IntPlugin_Info->hide();
//Advanced //Advanced
QString BrowserCmd=settings->value("BrowserCmd","<<default>>").toString(); QString BrowserCmd=config->urlCmd();
if(BrowserCmd=="<<default>>"){ if(BrowserCmd.isEmpty()){
CheckBox_BrowserDefault->setChecked(true); CheckBox_BrowserDefault->setChecked(true);
Edit_BrowserCmd->setDisabled(true); Edit_BrowserCmd->setDisabled(true);
} }
@ -133,10 +135,10 @@ CSettingsDlg::CSettingsDlg(QWidget* parent):QDialog(parent,Qt::Dialog)
Edit_BrowserCmd->setText(BrowserCmd); Edit_BrowserCmd->setText(BrowserCmd);
CheckBox_BrowserDefault->setChecked(false); CheckBox_BrowserDefault->setChecked(false);
} }
Edit_MountDir->setText(config.MountDir); Edit_MountDir->setText(config->mountDir());
CheckBox_SaveRelativePaths->setChecked(settings->value("SaveRelativePaths",true).toBool()); CheckBox_SaveRelativePaths->setChecked(config->saveRelativePaths());
} }
CSettingsDlg::~CSettingsDlg() CSettingsDlg::~CSettingsDlg()
@ -153,7 +155,7 @@ void CSettingsDlg::paintEvent(QPaintEvent *event){
void CSettingsDlg::OnCheckBoxBrowserDefaultChanged(int state){ void CSettingsDlg::OnCheckBoxBrowserDefaultChanged(int state){
if(state==Qt::Checked){ if(state==Qt::Checked){
Edit_BrowserCmd->setDisabled(true); Edit_BrowserCmd->setDisabled(true);
Edit_BrowserCmd->setText(""); Edit_BrowserCmd->setText(QString());
} }
else{ else{
Edit_BrowserCmd->setDisabled(false); Edit_BrowserCmd->setDisabled(false);
@ -172,51 +174,49 @@ void CSettingsDlg::OnCancel()
} }
void CSettingsDlg::OnOtherButton(QAbstractButton* button){ void CSettingsDlg::OnOtherButton(QAbstractButton* button){
if(DialogButtons->buttonRole(button)==QDialogButtonBox::ApplyRole) if(DialogButtons->buttonRole(button)==QDialogButtonBox::ApplyRole)
apply(); apply();
} }
void CSettingsDlg::apply(){ void CSettingsDlg::apply(){
//General //General
config.ShowSysTrayIcon=checkBox_ShowSysTrayIcon->isChecked(); config->setShowSysTrayIcon(checkBox_ShowSysTrayIcon->isChecked());
config.MinimizeToTray=checkBox_MinimizeToTray->isChecked(); config->setMinimizeToTray(checkBox_MinimizeToTray->isChecked());
config.SaveFileDlgHistory=checkBox_SaveFileDlgHistory->isChecked(); config->setSaveFileDlgHistory(checkBox_SaveFileDlgHistory->isChecked());
config.EnableBookmarkMenu=checkBox_EnableBookmarkMenu->isChecked(); config->setEnableBookmarkMenu(checkBox_EnableBookmarkMenu->isChecked());
if(Radio_GroupTreeRestore->isChecked())config.GroupTreeRestore=0; if(Radio_GroupTreeRestore->isChecked())config->setGroupTreeState(KpxConfig::RestoreLast);
if(Radio_GroupTreeExpand->isChecked())config.GroupTreeRestore=1; else if(Radio_GroupTreeExpand->isChecked())config->setGroupTreeState(KpxConfig::ExpandAll);
if(Radio_GroupTreeDoNothing->isChecked())config.GroupTreeRestore=2; else config->setGroupTreeState(KpxConfig::DoNothing);
settings->setValue("OpenLastFile",CheckBox_OpenLast->isChecked()); config->setOpenLastFile(CheckBox_OpenLast->isChecked());
settings->setValue("RememberLastKey",CheckBox_RememberLastKey->isChecked()); config->setRememberLastKey(CheckBox_RememberLastKey->isChecked());
if(Radio_GroupTreeExpand->isChecked())settings->setValue("GroupTreeState","ExpandAll"); config->setAskBeforeDelete(checkBox_AskBeforeDelete->isChecked());
if(Radio_GroupTreeDoNothing->isChecked())settings->setValue("GroupTreeState","ExpandNone");
if(Radio_GroupTreeRestore->isChecked())settings->setValue("GroupTreeState","Restore");
//Appearence //Appearence
config.BannerColor1=color1; config->setBannerColor1(color1);
config.BannerColor2=color2; config->setBannerColor2(color2);
config.BannerTextColor=textcolor; config->setBannerTextColor(textcolor);
config.AlternatingRowColors=CheckBox_AlternatingRowColors->isChecked(); config->setAlternatingRowColors(CheckBox_AlternatingRowColors->isChecked());
//Security //Security
config.ClipboardTimeOut=SpinBox_ClipboardTime->value(); config->setClipboardTimeOut(SpinBox_ClipboardTime->value());
config.ShowPasswords=CheckBox_ShowPasswords->isChecked(); config->setShowPasswords(CheckBox_ShowPasswords->isChecked());
config.ShowPasswordsPasswordDlg=CheckBox_ShowPasswords_PasswordDlg->isChecked(); config->setShowPasswordsPasswordDlg(CheckBox_ShowPasswords_PasswordDlg->isChecked());
//Desktop Integration //Desktop Integration
PluginsModified=Label_IntPlugin_Info->isVisible(); PluginsModified=Label_IntPlugin_Info->isVisible();
if(Radio_IntPlugin_None->isChecked())config.IntegrPlugin=CConfig::NONE; if(Radio_IntPlugin_Kde->isChecked())config->setIntegrPlugin(KpxConfig::KDE);
if(Radio_IntPlugin_Gnome->isChecked())config.IntegrPlugin=CConfig::GNOME; else if(Radio_IntPlugin_Gnome->isChecked())config->setIntegrPlugin(KpxConfig::Gnome);
if(Radio_IntPlugin_Kde->isChecked())config.IntegrPlugin=CConfig::KDE; else config->setIntegrPlugin(KpxConfig::NoIntegr);
//Advanced //Advanced
config.OpenUrlCommand=Edit_BrowserCmd->text(); config->setUrlCmd(Edit_BrowserCmd->text());
config.MountDir=Edit_MountDir->text(); config->setMountDir(Edit_MountDir->text());
if(config.MountDir!="" && config.MountDir.right(1)!="/") if(!config->mountDir().isEmpty() && config->mountDir().right(1)!="/")
config.MountDir+="/"; config->setMountDir(config->mountDir()+"/");
if(CheckBox_BrowserDefault->isChecked())settings->setValue("BrowserCmd","<<default>>"); if(CheckBox_BrowserDefault->isChecked())config->setUrlCmd(QString());
else settings->setValue("BrowserCmd",Edit_BrowserCmd->text()); else config->setUrlCmd(Edit_BrowserCmd->text());
settings->setValue("SaveRelativePaths",CheckBox_SaveRelativePaths->isChecked()); config->setSaveRelativePaths(CheckBox_SaveRelativePaths->isChecked());
} }
@ -230,7 +230,7 @@ void CSettingsDlg::OnTextColor()
pixmTextColor->clear(); pixmTextColor->clear();
pixmTextColor->setPixmap(*px); pixmTextColor->setPixmap(*px);
createBanner(&BannerPixmap,getPixmap("appsettings"),tr("Settings"),width(),color1,color2,textcolor); createBanner(&BannerPixmap,getPixmap("appsettings"),tr("Settings"),width(),color1,color2,textcolor);
} }
} }
@ -292,5 +292,5 @@ void CSettingsDlg::OnIntPluginKde(bool toggled){
void CSettingsDlg::OnCustomizeEntryDetails(){ void CSettingsDlg::OnCustomizeEntryDetails(){
CustomizeDetailViewDialog dlg(this); CustomizeDetailViewDialog dlg(this);
dlg.exec(); dlg.exec();
} }

@ -21,14 +21,14 @@
#include <QLineEdit> #include <QLineEdit>
#include <QPushButton> #include <QPushButton>
#include "main.h" #include "main.h"
#include "PwmConfig.h" #include "KpxConfig.h"
#include "SimplePasswordDlg.h" #include "SimplePasswordDlg.h"
SimplePasswordDialog::SimplePasswordDialog(QWidget* parent, bool modal, Qt::WFlags fl) SimplePasswordDialog::SimplePasswordDialog(QWidget* parent, bool modal, Qt::WFlags fl)
: QDialog(parent,fl) : QDialog(parent,fl)
{ {
setupUi(this); setupUi(this);
if(!config.ShowPasswords)Button_HidePassword->toggle(); if(!config->showPasswords())Button_HidePassword->toggle();
connect(buttonBox->button(QDialogButtonBox::Ok),SIGNAL(clicked()),this,SLOT(OnOK())); connect(buttonBox->button(QDialogButtonBox::Ok),SIGNAL(clicked()),this,SLOT(OnOK()));
connect(buttonBox->button(QDialogButtonBox::Cancel),SIGNAL(clicked()),this,SLOT(OnCancel())); connect(buttonBox->button(QDialogButtonBox::Cancel),SIGNAL(clicked()),this,SLOT(OnCancel()));
connect(Button_HidePassword,SIGNAL(toggled(bool)),this,SLOT(OnHidePasswordToggled(bool))); connect(Button_HidePassword,SIGNAL(toggled(bool)),this,SLOT(OnHidePasswordToggled(bool)));
@ -42,9 +42,9 @@ SimplePasswordDialog::~SimplePasswordDialog()
void SimplePasswordDialog::OnTextChanged(const QString& txt){ void SimplePasswordDialog::OnTextChanged(const QString& txt){
if(txt==QString()) if(txt==QString())
buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false); buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
else else
buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true); buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
} }
void SimplePasswordDialog::OnCancel() void SimplePasswordDialog::OnCancel()

@ -6,13 +6,13 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>432</width> <width>432</width>
<height>230</height> <height>316</height>
</rect> </rect>
</property> </property>
<property name="sizePolicy" > <property name="sizePolicy" >
<sizepolicy> <sizepolicy>
<hsizetype>5</hsizetype> <hsizetype>4</hsizetype>
<vsizetype>5</vsizetype> <vsizetype>4</vsizetype>
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
@ -51,6 +51,14 @@
</item> </item>
<item> <item>
<widget class="QLabel" name="label" > <widget class="QLabel" name="label" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>5</hsizetype>
<vsizetype>4</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text" > <property name="text" >
<string>Collecting entropy... <string>Collecting entropy...
Please move the mouse and/or press some keys until enought entropy for a reseed of the random number generator is collected.</string> Please move the mouse and/or press some keys until enought entropy for a reseed of the random number generator is collected.</string>
@ -81,7 +89,7 @@ Please move the mouse and/or press some keys until enought entropy for a reseed
<property name="sizePolicy" > <property name="sizePolicy" >
<sizepolicy> <sizepolicy>
<hsizetype>5</hsizetype> <hsizetype>5</hsizetype>
<vsizetype>1</vsizetype> <vsizetype>0</vsizetype>
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
@ -89,7 +97,13 @@ Please move the mouse and/or press some keys until enought entropy for a reseed
<property name="minimumSize" > <property name="minimumSize" >
<size> <size>
<width>16</width> <width>16</width>
<height>45</height> <height>46</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>16777215</width>
<height>46</height>
</size> </size>
</property> </property>
<property name="currentIndex" > <property name="currentIndex" >

@ -18,12 +18,21 @@
</property> </property>
<widget class="QWidget" name="centralWidget" > <widget class="QWidget" name="centralWidget" >
<layout class="QVBoxLayout" > <layout class="QVBoxLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<property name="leftMargin" >
<number>9</number>
</property>
<property name="topMargin" >
<number>9</number>
</property>
<property name="rightMargin" >
<number>9</number>
</property>
<property name="bottomMargin" >
<number>9</number>
</property>
<item> <item>
<widget class="QSplitter" name="HSplitter" > <widget class="QSplitter" name="HSplitter" >
<property name="orientation" > <property name="orientation" >
@ -31,9 +40,7 @@
</property> </property>
<widget class="QSplitter" name="VSplitter" > <widget class="QSplitter" name="VSplitter" >
<property name="sizePolicy" > <property name="sizePolicy" >
<sizepolicy> <sizepolicy vsizetype="Expanding" hsizetype="Expanding" >
<hsizetype>7</hsizetype>
<vsizetype>7</vsizetype>
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>60</verstretch> <verstretch>60</verstretch>
</sizepolicy> </sizepolicy>
@ -46,9 +53,7 @@
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="sizePolicy" > <property name="sizePolicy" >
<sizepolicy> <sizepolicy vsizetype="Expanding" hsizetype="Expanding" >
<hsizetype>7</hsizetype>
<vsizetype>7</vsizetype>
<horstretch>30</horstretch> <horstretch>30</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
@ -68,9 +73,7 @@
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="sizePolicy" > <property name="sizePolicy" >
<sizepolicy> <sizepolicy vsizetype="Expanding" hsizetype="Expanding" >
<hsizetype>7</hsizetype>
<vsizetype>7</vsizetype>
<horstretch>70</horstretch> <horstretch>70</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
@ -83,14 +86,12 @@
</property> </property>
</widget> </widget>
</widget> </widget>
<widget class="QTextEdit" name="DetailView" > <widget class="QTextBrowser" name="DetailView" >
<property name="enabled" > <property name="enabled" >
<bool>false</bool> <bool>false</bool>
</property> </property>
<property name="sizePolicy" > <property name="sizePolicy" >
<sizepolicy> <sizepolicy vsizetype="Expanding" hsizetype="Expanding" >
<hsizetype>7</hsizetype>
<vsizetype>7</vsizetype>
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>10</verstretch> <verstretch>10</verstretch>
</sizepolicy> </sizepolicy>
@ -104,6 +105,9 @@
<property name="readOnly" > <property name="readOnly" >
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="openLinks" >
<bool>false</bool>
</property>
</widget> </widget>
</widget> </widget>
</item> </item>
@ -221,8 +225,10 @@
<string>E&amp;xtras</string> <string>E&amp;xtras</string>
</property> </property>
<addaction name="ExtrasSettingsAction" /> <addaction name="ExtrasSettingsAction" />
<addaction name="ExtrasShowExpiredEntriesAction" />
<addaction name="ExtrasPasswordGenAction" /> <addaction name="ExtrasPasswordGenAction" />
<addaction name="separator" />
<addaction name="ExtrasShowExpiredEntriesAction" />
<addaction name="ExtrasTrashCanAction" />
</widget> </widget>
<addaction name="menuDatei" /> <addaction name="menuDatei" />
<addaction name="menuBearbeiten" /> <addaction name="menuBearbeiten" />
@ -533,6 +539,11 @@
<string>Show Expired Entries</string> <string>Show Expired Entries</string>
</property> </property>
</action> </action>
<action name="ExtrasTrashCanAction" >
<property name="text" >
<string>Recycle Bin...</string>
</property>
</action>
</widget> </widget>
<customwidgets> <customwidgets>
<customwidget> <customwidget>

@ -28,12 +28,21 @@
<bool>true</bool> <bool>true</bool>
</property> </property>
<layout class="QVBoxLayout" > <layout class="QVBoxLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<property name="leftMargin" >
<number>9</number>
</property>
<property name="topMargin" >
<number>9</number>
</property>
<property name="rightMargin" >
<number>9</number>
</property>
<property name="bottomMargin" >
<number>9</number>
</property>
<item> <item>
<spacer> <spacer>
<property name="orientation" > <property name="orientation" >
@ -69,12 +78,6 @@
<string>General</string> <string>General</string>
</attribute> </attribute>
<layout class="QVBoxLayout" > <layout class="QVBoxLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item> <item>
<widget class="QCheckBox" name="checkBox_ShowSysTrayIcon" > <widget class="QCheckBox" name="checkBox_ShowSysTrayIcon" >
<property name="text" > <property name="text" >
@ -91,12 +94,21 @@
</item> </item>
<item> <item>
<layout class="QHBoxLayout" > <layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<property name="leftMargin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>0</number>
</property>
<item> <item>
<widget class="QCheckBox" name="CheckBox_OpenLast" > <widget class="QCheckBox" name="CheckBox_OpenLast" >
<property name="text" > <property name="text" >
@ -147,12 +159,21 @@
</item> </item>
<item> <item>
<layout class="QHBoxLayout" > <layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<property name="leftMargin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>0</number>
</property>
<item> <item>
<widget class="QCheckBox" name="checkBox_SaveFileDlgHistory" > <widget class="QCheckBox" name="checkBox_SaveFileDlgHistory" >
<property name="text" > <property name="text" >
@ -179,7 +200,7 @@
<item> <item>
<widget class="QPushButton" name="Button_ClearFileDlgHistory" > <widget class="QPushButton" name="Button_ClearFileDlgHistory" >
<property name="text" > <property name="text" >
<string>Clear</string> <string>Clear History Now</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -199,73 +220,71 @@
</layout> </layout>
</item> </item>
<item> <item>
<widget class="QCheckBox" name="checkBox_EnableBookmarkMenu" > <widget class="QCheckBox" name="checkBox_AskBeforeDelete" >
<property name="text" > <property name="text" >
<string>Enable bookmark menu</string> <string>Always ask before deleting entries or groups</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<layout class="QHBoxLayout" > <layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<property name="leftMargin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>0</number>
</property>
<item> <item>
<layout class="QVBoxLayout" > <layout class="QGridLayout" >
<property name="margin" > <property name="leftMargin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number> <number>0</number>
</property> </property>
<property name="spacing" > <property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>0</number>
</property>
<property name="horizontalSpacing" >
<number>6</number>
</property>
<property name="verticalSpacing" >
<number>6</number> <number>6</number>
</property> </property>
<item> <item row="0" column="0" >
<widget class="QLabel" name="label_3" > <widget class="QLabel" name="label_3" >
<property name="text" > <property name="text" >
<string>Group tree at start-up:</string> <string>Group tree at start-up:</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item row="0" column="1" >
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>0</number>
</property>
<item>
<widget class="QRadioButton" name="Radio_GroupTreeRestore" > <widget class="QRadioButton" name="Radio_GroupTreeRestore" >
<property name="text" > <property name="text" >
<string>Restore last state</string> <string>Restore last state</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item row="1" column="1" >
<widget class="QRadioButton" name="Radio_GroupTreeExpand" > <widget class="QRadioButton" name="Radio_GroupTreeExpand" >
<property name="text" > <property name="text" >
<string>Expand all items</string> <string>Expand all items</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item row="2" column="1" >
<widget class="QRadioButton" name="Radio_GroupTreeDoNothing" > <widget class="QRadioButton" name="Radio_GroupTreeDoNothing" >
<property name="text" > <property name="text" >
<string>Do not expand any item</string> <string>Do not expand any item</string>
@ -296,8 +315,8 @@
</property> </property>
<property name="sizeHint" > <property name="sizeHint" >
<size> <size>
<width>20</width> <width>531</width>
<height>40</height> <height>16</height>
</size> </size>
</property> </property>
</spacer> </spacer>
@ -309,30 +328,60 @@
<string>Appea&amp;rance</string> <string>Appea&amp;rance</string>
</attribute> </attribute>
<layout class="QVBoxLayout" > <layout class="QVBoxLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<property name="leftMargin" >
<number>9</number>
</property>
<property name="topMargin" >
<number>9</number>
</property>
<property name="rightMargin" >
<number>9</number>
</property>
<property name="bottomMargin" >
<number>9</number>
</property>
<item> <item>
<widget class="QGroupBox" name="groupBox1" > <widget class="QGroupBox" name="groupBox1" >
<property name="title" > <property name="title" >
<string>Banner Color</string> <string>Banner Color</string>
</property> </property>
<layout class="QVBoxLayout" > <layout class="QVBoxLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<property name="leftMargin" >
<number>9</number>
</property>
<property name="topMargin" >
<number>9</number>
</property>
<property name="rightMargin" >
<number>9</number>
</property>
<property name="bottomMargin" >
<number>9</number>
</property>
<item> <item>
<layout class="QGridLayout" > <layout class="QGridLayout" >
<property name="margin" > <property name="leftMargin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number> <number>0</number>
</property> </property>
<property name="spacing" > <property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>0</number>
</property>
<property name="horizontalSpacing" >
<number>6</number>
</property>
<property name="verticalSpacing" >
<number>6</number> <number>6</number>
</property> </property>
<item row="1" column="0" > <item row="1" column="0" >
@ -361,9 +410,7 @@
<item row="1" column="2" > <item row="1" column="2" >
<widget class="QPushButton" name="ButtonTextColor" > <widget class="QPushButton" name="ButtonTextColor" >
<property name="sizePolicy" > <property name="sizePolicy" >
<sizepolicy> <sizepolicy vsizetype="Fixed" hsizetype="Maximum" >
<hsizetype>4</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
@ -391,9 +438,7 @@
<item row="0" column="4" > <item row="0" column="4" >
<widget class="QLabel" name="textLabel3" > <widget class="QLabel" name="textLabel3" >
<property name="sizePolicy" > <property name="sizePolicy" >
<sizepolicy> <sizepolicy vsizetype="Preferred" hsizetype="Maximum" >
<hsizetype>4</hsizetype>
<vsizetype>5</vsizetype>
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
@ -406,9 +451,7 @@
<item row="0" column="1" > <item row="0" column="1" >
<widget class="QLabel" name="pixmColor1" > <widget class="QLabel" name="pixmColor1" >
<property name="sizePolicy" > <property name="sizePolicy" >
<sizepolicy> <sizepolicy vsizetype="Fixed" hsizetype="Maximum" >
<hsizetype>4</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
@ -433,9 +476,7 @@
<item row="1" column="1" > <item row="1" column="1" >
<widget class="QLabel" name="pixmTextColor" > <widget class="QLabel" name="pixmTextColor" >
<property name="sizePolicy" > <property name="sizePolicy" >
<sizepolicy> <sizepolicy vsizetype="Fixed" hsizetype="Maximum" >
<hsizetype>4</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
@ -463,9 +504,7 @@
<item row="0" column="6" > <item row="0" column="6" >
<widget class="QPushButton" name="ButtonColor2" > <widget class="QPushButton" name="ButtonColor2" >
<property name="sizePolicy" > <property name="sizePolicy" >
<sizepolicy> <sizepolicy vsizetype="Fixed" hsizetype="Maximum" >
<hsizetype>4</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
@ -493,9 +532,7 @@
<item row="0" column="5" > <item row="0" column="5" >
<widget class="QLabel" name="pixmColor2" > <widget class="QLabel" name="pixmColor2" >
<property name="sizePolicy" > <property name="sizePolicy" >
<sizepolicy> <sizepolicy vsizetype="Fixed" hsizetype="Maximum" >
<hsizetype>4</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
@ -523,9 +560,7 @@
<item row="0" column="2" > <item row="0" column="2" >
<widget class="QPushButton" name="ButtonColor1" > <widget class="QPushButton" name="ButtonColor1" >
<property name="sizePolicy" > <property name="sizePolicy" >
<sizepolicy> <sizepolicy vsizetype="Fixed" hsizetype="Maximum" >
<hsizetype>4</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
@ -553,9 +588,7 @@
<item row="0" column="0" > <item row="0" column="0" >
<widget class="QLabel" name="textLabel1_3" > <widget class="QLabel" name="textLabel1_3" >
<property name="sizePolicy" > <property name="sizePolicy" >
<sizepolicy> <sizepolicy vsizetype="Preferred" hsizetype="Maximum" >
<hsizetype>4</hsizetype>
<vsizetype>5</vsizetype>
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
@ -602,12 +635,21 @@
</item> </item>
<item> <item>
<layout class="QHBoxLayout" > <layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<property name="leftMargin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>0</number>
</property>
<item> <item>
<widget class="QPushButton" name="Button_CustomizeEntryDetails" > <widget class="QPushButton" name="Button_CustomizeEntryDetails" >
<property name="text" > <property name="text" >
@ -650,26 +692,89 @@
<string>Security</string> <string>Security</string>
</attribute> </attribute>
<layout class="QVBoxLayout" > <layout class="QVBoxLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<property name="leftMargin" >
<number>9</number>
</property>
<property name="topMargin" >
<number>9</number>
</property>
<property name="rightMargin" >
<number>9</number>
</property>
<property name="bottomMargin" >
<number>9</number>
</property>
<item> <item>
<layout class="QHBoxLayout" > <widget class="QGroupBox" name="groupBox_2" >
<property name="margin" > <property name="sizePolicy" >
<number>0</number> <sizepolicy vsizetype="Minimum" hsizetype="Preferred" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property> </property>
<property name="title" >
<string>Show passwords in plain text in:</string>
</property>
<layout class="QVBoxLayout" >
<property name="spacing" >
<number>0</number>
</property>
<property name="leftMargin" >
<number>9</number>
</property>
<property name="topMargin" >
<number>9</number>
</property>
<property name="rightMargin" >
<number>9</number>
</property>
<property name="bottomMargin" >
<number>9</number>
</property>
<item>
<widget class="QCheckBox" name="CheckBox_ShowPasswords" >
<property name="text" >
<string>Edit Entry Dialog</string>
</property>
<property name="shortcut" >
<string>Alt+O</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="CheckBox_ShowPasswords_PasswordDlg" >
<property name="text" >
<string>Key Dialogs</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" >
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<property name="leftMargin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>0</number>
</property>
<item> <item>
<widget class="QLabel" name="textLabel1" > <widget class="QLabel" name="textLabel1" >
<property name="sizePolicy" > <property name="sizePolicy" >
<sizepolicy> <sizepolicy vsizetype="Preferred" hsizetype="Maximum" >
<hsizetype>4</hsizetype>
<vsizetype>5</vsizetype>
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
@ -682,9 +787,7 @@
<item> <item>
<widget class="QSpinBox" name="SpinBox_ClipboardTime" > <widget class="QSpinBox" name="SpinBox_ClipboardTime" >
<property name="sizePolicy" > <property name="sizePolicy" >
<sizepolicy> <sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
<hsizetype>5</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
@ -713,43 +816,40 @@
</layout> </layout>
</item> </item>
<item> <item>
<widget class="QGroupBox" name="groupBox_2" > <spacer>
<property name="sizePolicy" > <property name="orientation" >
<sizepolicy> <enum>Qt::Vertical</enum>
<hsizetype>5</hsizetype>
<vsizetype>1</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property> </property>
<property name="title" > <property name="sizeHint" >
<string>Show passwords in plain text in:</string> <size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="Seite" >
<attribute name="title" >
<string>Features</string>
</attribute>
<layout class="QVBoxLayout" >
<item>
<widget class="QLabel" name="label_6" >
<property name="text" >
<string>You can disable several features of KeePassX here according to your needs in order to keep the user interface slim.</string>
</property>
<property name="wordWrap" >
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_EnableBookmarkMenu" >
<property name="text" >
<string>Bookmarks</string>
</property> </property>
<layout class="QVBoxLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>0</number>
</property>
<item>
<widget class="QCheckBox" name="CheckBox_ShowPasswords" >
<property name="text" >
<string>Edit Entry Dialog</string>
</property>
<property name="shortcut" >
<string>Alt+O</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="CheckBox_ShowPasswords_PasswordDlg" >
<property name="text" >
<string>Key Dialogs</string>
</property>
</widget>
</item>
</layout>
</widget> </widget>
</item> </item>
<item> <item>
@ -760,7 +860,7 @@
<property name="sizeHint" > <property name="sizeHint" >
<size> <size>
<width>20</width> <width>20</width>
<height>40</height> <height>131</height>
</size> </size>
</property> </property>
</spacer> </spacer>
@ -772,18 +872,25 @@
<string>Desktop Integration</string> <string>Desktop Integration</string>
</attribute> </attribute>
<layout class="QVBoxLayout" > <layout class="QVBoxLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<property name="leftMargin" >
<number>9</number>
</property>
<property name="topMargin" >
<number>9</number>
</property>
<property name="rightMargin" >
<number>9</number>
</property>
<property name="bottomMargin" >
<number>9</number>
</property>
<item> <item>
<widget class="QLabel" name="Label_IntPlugin_Error" > <widget class="QLabel" name="Label_IntPlugin_Error" >
<property name="sizePolicy" > <property name="sizePolicy" >
<sizepolicy> <sizepolicy vsizetype="Maximum" hsizetype="Preferred" >
<hsizetype>5</hsizetype>
<vsizetype>4</vsizetype>
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
@ -799,9 +906,7 @@
<item> <item>
<widget class="QGroupBox" name="groupBox" > <widget class="QGroupBox" name="groupBox" >
<property name="sizePolicy" > <property name="sizePolicy" >
<sizepolicy> <sizepolicy vsizetype="Minimum" hsizetype="Preferred" >
<hsizetype>5</hsizetype>
<vsizetype>1</vsizetype>
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
@ -810,12 +915,21 @@
<string>Plug-Ins</string> <string>Plug-Ins</string>
</property> </property>
<layout class="QVBoxLayout" > <layout class="QVBoxLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<property name="leftMargin" >
<number>9</number>
</property>
<property name="topMargin" >
<number>9</number>
</property>
<property name="rightMargin" >
<number>9</number>
</property>
<property name="bottomMargin" >
<number>9</number>
</property>
<item> <item>
<widget class="QRadioButton" name="Radio_IntPlugin_None" > <widget class="QRadioButton" name="Radio_IntPlugin_None" >
<property name="text" > <property name="text" >
@ -842,12 +956,21 @@
</item> </item>
<item> <item>
<layout class="QHBoxLayout" > <layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<property name="leftMargin" >
<number>0</number>
</property>
<property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>0</number>
</property>
<item> <item>
<widget class="QLabel" name="Label_IntPlugin_Info" > <widget class="QLabel" name="Label_IntPlugin_Info" >
<property name="text" > <property name="text" >
@ -897,18 +1020,125 @@
<string>Advanced</string> <string>Advanced</string>
</attribute> </attribute>
<layout class="QVBoxLayout" > <layout class="QVBoxLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<property name="leftMargin" >
<number>9</number>
</property>
<property name="topMargin" >
<number>9</number>
</property>
<property name="rightMargin" >
<number>9</number>
</property>
<property name="bottomMargin" >
<number>9</number>
</property>
<item>
<widget class="QGroupBox" name="groupBox_3" >
<property name="title" >
<string>Auto-Type Fine Tuning</string>
</property>
<layout class="QGridLayout" >
<property name="leftMargin" >
<number>9</number>
</property>
<property name="topMargin" >
<number>9</number>
</property>
<property name="rightMargin" >
<number>9</number>
</property>
<property name="bottomMargin" >
<number>9</number>
</property>
<property name="horizontalSpacing" >
<number>6</number>
</property>
<property name="verticalSpacing" >
<number>6</number>
</property>
<item row="0" column="1" >
<widget class="QSpinBox" name="spinBox_PreGap" >
<property name="whatsThis" >
<string>Time between the activation of an auto-type action by the user and the first simulated key stroke.</string>
</property>
<property name="suffix" >
<string>ms</string>
</property>
<property name="maximum" >
<number>10000</number>
</property>
</widget>
</item>
<item row="0" column="0" >
<widget class="QLabel" name="label_4" >
<property name="text" >
<string>Pre-Gap:</string>
</property>
<property name="alignment" >
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="2" >
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0" >
<widget class="QLabel" name="label_5" >
<property name="text" >
<string>Key Stroke Delay:</string>
</property>
<property name="alignment" >
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="1" >
<widget class="QSpinBox" name="spinBox_KeyStrokeDelay" >
<property name="whatsThis" >
<string>Delay between two simulated key strokes. Increase this if Auto-Type is randomly skipping characters.</string>
</property>
<property name="suffix" >
<string>ms</string>
</property>
<property name="maximum" >
<number>10000</number>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item> <item>
<layout class="QGridLayout" > <layout class="QGridLayout" >
<property name="margin" > <property name="leftMargin" >
<number>0</number> <number>0</number>
</property> </property>
<property name="spacing" > <property name="topMargin" >
<number>0</number>
</property>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>0</number>
</property>
<property name="horizontalSpacing" >
<number>6</number>
</property>
<property name="verticalSpacing" >
<number>6</number> <number>6</number>
</property> </property>
<item row="1" column="2" > <item row="1" column="2" >
@ -979,9 +1209,7 @@
<item row="0" column="2" colspan="2" > <item row="0" column="2" colspan="2" >
<widget class="QCheckBox" name="CheckBox_BrowserDefault" > <widget class="QCheckBox" name="CheckBox_BrowserDefault" >
<property name="sizePolicy" > <property name="sizePolicy" >
<sizepolicy> <sizepolicy vsizetype="Fixed" hsizetype="Maximum" >
<hsizetype>4</hsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch> <horstretch>0</horstretch>
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
@ -993,80 +1221,6 @@
</item> </item>
</layout> </layout>
</item> </item>
<item>
<widget class="QGroupBox" name="groupBox_3" >
<property name="title" >
<string>Auto-Type Fine Tuning</string>
</property>
<layout class="QGridLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item row="0" column="1" >
<widget class="QSpinBox" name="spinBox_PreGap" >
<property name="whatsThis" >
<string>Time between the activation of an auto-type action by the user and the first simulated key stroke.</string>
</property>
<property name="suffix" >
<string>ms</string>
</property>
<property name="maximum" >
<number>10000</number>
</property>
</widget>
</item>
<item row="0" column="0" >
<widget class="QLabel" name="label_4" >
<property name="text" >
<string>Pre-Gap:</string>
</property>
<property name="alignment" >
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="0" column="2" >
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="0" >
<widget class="QLabel" name="label_5" >
<property name="text" >
<string>Key Stroke Delay:</string>
</property>
<property name="alignment" >
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="1" column="1" >
<widget class="QSpinBox" name="spinBox_KeyStrokeDelay" >
<property name="whatsThis" >
<string>Delay between two simulated key strokes. Increase this if Auto-Type is randomly skipping characters.</string>
</property>
<property name="suffix" >
<string>ms</string>
</property>
<property name="maximum" >
<number>10000</number>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item> <item>
<widget class="QCheckBox" name="CheckBox_SaveRelativePaths" > <widget class="QCheckBox" name="CheckBox_SaveRelativePaths" >
<property name="whatsThis" > <property name="whatsThis" >

@ -29,46 +29,29 @@
#include <QApplication> #include <QApplication>
#include <QPainter> #include <QPainter>
#include <QPair> #include <QPair>
#include <QMessageBox>
#include "main.h" #include "main.h"
#include "PwmConfig.h" #include "KpxConfig.h"
#include "EntryView.h" #include "EntryView.h"
#include "dialogs/EditEntryDlg.h" #include "dialogs/EditEntryDlg.h"
#include "lib/AutoType.h" #include "lib/AutoType.h"
// just for the lessThan funtion // just for the lessThan funtion
QList<EntryViewItem*>* pItems; QList<EntryViewItem*>* pItems;
KeepassEntryView* pEntryView; KeepassEntryView* pEntryView;
KeepassEntryView::KeepassEntryView(QWidget* parent):QTreeWidget(parent){ KeepassEntryView::KeepassEntryView(QWidget* parent):QTreeWidget(parent){
AutoResizeColumns=true; AutoResizeColumns=true;
header()->setResizeMode(QHeaderView::Interactive); header()->setResizeMode(QHeaderView::Interactive);
header()->setStretchLastSection(false); header()->setStretchLastSection(false);
header()->setClickable(true); header()->setClickable(true);
header()->setCascadingSectionResizes(true); header()->setCascadingSectionResizes(true);
ColumnSizes.resize(NUM_COLUMNS); ColumnSizes=config->columnSizes();
QStringList ColumnSizeConfig=settings->value("Ui/ColumnSizes",QStringList()<<"1"<<"1"<<"1"<<"1"<<"1"<<"1"<<"1"<<"1"<<"1"<<"1"<<"1").toStringList(); Columns=config->columns();
for(int i=0;i<NUM_COLUMNS;i++) ColumnOrder=config->columnOrder();
ColumnSizes[i]=(float)ColumnSizeConfig[i].toInt();
QStringList DefaultColumnConfig=QStringList()<<"1"<<"1"<<"1"<<"1"<<"1"<<"0"<<"0"<<"0"<<"0"<<"0"<<"1";
QStringList ColumnConfig=settings->value("Ui/ShowColumns",DefaultColumnConfig).toStringList();
Columns.resize(NUM_COLUMNS);
if(ColumnConfig.size()<NUM_COLUMNS)ColumnConfig=DefaultColumnConfig;
for(int i=0;i<ColumnConfig.size();i++){
Columns[i]=(bool)ColumnConfig[i].toInt();
}
ColumnOrder.resize(NUM_COLUMNS);
QStringList ColumnOrderConfig=settings->value("Ui/ColumnOrder",QStringList()<<"100"<<"100"<<"100"<<"100"<<"100"<<"100"<<"100"<<"100"<<"100"<<"100"<<"100").toStringList();
for(int i=0;i<NUM_COLUMNS;i++){
if(i<ColumnOrderConfig.size()){
ColumnOrder[i]=ColumnOrderConfig[i].toInt();
}
else
ColumnOrder[i]=100;
}
updateColumns(); updateColumns();
connect(header(),SIGNAL(sectionResized(int,int,int)),this,SLOT(OnColumnResized(int,int,int))); connect(header(),SIGNAL(sectionResized(int,int,int)),this,SLOT(OnColumnResized(int,int,int)));
connect(this,SIGNAL(itemSelectionChanged()),this,SLOT(OnItemsChanged())); connect(this,SIGNAL(itemSelectionChanged()),this,SLOT(OnItemsChanged()));
connect(&ClipboardTimer, SIGNAL(timeout()), this, SLOT(OnClipboardTimeOut())); connect(&ClipboardTimer, SIGNAL(timeout()), this, SLOT(OnClipboardTimeOut()));
@ -76,31 +59,16 @@ KeepassEntryView::KeepassEntryView(QWidget* parent):QTreeWidget(parent){
connect(header(),SIGNAL(sectionMoved(int,int,int)),this,SLOT(OnColumnMoved(int,int,int))); connect(header(),SIGNAL(sectionMoved(int,int,int)),this,SLOT(OnColumnMoved(int,int,int)));
Clipboard=QApplication::clipboard(); Clipboard=QApplication::clipboard();
ContextMenu=new QMenu(this); ContextMenu=new QMenu(this);
setAlternatingRowColors(config.AlternatingRowColors); setAlternatingRowColors(config->alternatingRowColors());
pItems=&Items; pItems=&Items;
pEntryView=this; pEntryView=this;
} }
KeepassEntryView::~KeepassEntryView(){ KeepassEntryView::~KeepassEntryView(){
QStringList ColumnSizesConfig; config->setColumnSizes(ColumnSizes);
for(int i=0;i<ColumnSizes.size();i++){ config->setColumns(Columns);
ColumnSizesConfig<<QString::number((int)(ColumnSizes[i])); config->setColumnOrder(ColumnOrder);
}
settings->setValue("Ui/ColumnSizes",ColumnSizesConfig);
QStringList ColumnConfig;
for(int i=0;i<Columns.size();i++){
if(Columns[i])
ColumnConfig<<"1";
else
ColumnConfig<<"0";
}
settings->setValue("Ui/ShowColumns",ColumnConfig);
QStringList ColumnOrderConfig;
for(int i=0;i<NUM_COLUMNS;i++){
ColumnOrderConfig << QString::number(ColumnOrder[i]);
}
settings->setValue("Ui/ColumnOrder",ColumnOrderConfig);
} }
void KeepassEntryView::OnGroupChanged(IGroupHandle* group){ void KeepassEntryView::OnGroupChanged(IGroupHandle* group){
@ -110,7 +78,7 @@ void KeepassEntryView::OnGroupChanged(IGroupHandle* group){
void KeepassEntryView::OnShowSearchResults(){ void KeepassEntryView::OnShowSearchResults(){
CurrentGroup=NULL; CurrentGroup=NULL;
showSearchResults(); showSearchResults();
} }
@ -119,7 +87,7 @@ void KeepassEntryView::OnItemsChanged(){
case 0: emit selectionChanged(NONE); case 0: emit selectionChanged(NONE);
break; break;
case 1: emit selectionChanged(SINGLE); case 1: emit selectionChanged(SINGLE);
break; break;
default:emit selectionChanged(MULTIPLE); default:emit selectionChanged(MULTIPLE);
} }
} }
@ -128,10 +96,10 @@ bool sortSearchResultsLessThan(const IEntryHandle* a, const IEntryHandle* b){
int indexA=0; int indexA=0;
int indexB=0; int indexB=0;
for(indexA;indexA<pItems->size();indexA++){ for(indexA;indexA<pItems->size();indexA++){
if((*pItems)[indexA]->EntryHandle==a)break; if((*pItems)[indexA]->EntryHandle==a)break;
} }
for(indexB;indexB<pItems->size();indexB++){ for(indexB;indexB<pItems->size();indexB++){
if((*pItems)[indexB]->EntryHandle==b)break; if((*pItems)[indexB]->EntryHandle==b)break;
} }
return pEntryView->indexOfTopLevelItem((*pItems)[indexA])<pEntryView->indexOfTopLevelItem((*pItems)[indexB]); return pEntryView->indexOfTopLevelItem((*pItems)[indexA])<pEntryView->indexOfTopLevelItem((*pItems)[indexB]);
} }
@ -145,12 +113,12 @@ void KeepassEntryView::OnHeaderSectionClicked(int index){
else{ else{
header()->setSortIndicator(index,Qt::AscendingOrder); header()->setSortIndicator(index,Qt::AscendingOrder);
header()->setSortIndicatorShown(true); header()->setSortIndicatorShown(true);
sortItems(index,Qt::AscendingOrder); sortItems(index,Qt::AscendingOrder);
} }
if(ViewMode==Normal){ if(ViewMode==Normal){
for(int i=0;i<Items.size();i++){ for(int i=0;i<Items.size();i++){
Items[i]->EntryHandle->setVisualIndexDirectly(indexOfTopLevelItem(Items[i])); Items[i]->EntryHandle->setVisualIndexDirectly(indexOfTopLevelItem(Items[i]));
} }
} }
else if(ViewMode==ShowSearchResults){ else if(ViewMode==ShowSearchResults){
@ -158,16 +126,16 @@ void KeepassEntryView::OnHeaderSectionClicked(int index){
qSort(SearchResults.begin(),SearchResults.end(),sortSearchResultsLessThan); qSort(SearchResults.begin(),SearchResults.end(),sortSearchResultsLessThan);
else else
qSort(SearchResults.end(),SearchResults.begin(),sortSearchResultsLessThan); qSort(SearchResults.end(),SearchResults.begin(),sortSearchResultsLessThan);
} }
} }
void KeepassEntryView::OnSaveAttachment(){ void KeepassEntryView::OnSaveAttachment(){
Q_ASSERT(selectedItems().size()==1); Q_ASSERT(selectedItems().size()==1);
CEditEntryDlg::saveAttachment(((EntryViewItem*)selectedItems()[0])->EntryHandle,this); CEditEntryDlg::saveAttachment(((EntryViewItem*)selectedItems().first())->EntryHandle,this);
} }
void KeepassEntryView::OnCloneEntry(){ void KeepassEntryView::OnCloneEntry(){
QList<QTreeWidgetItem*> entries=selectedItems(); QList<QTreeWidgetItem*> entries=selectedItems();
for(int i=0; i<entries.size();i++){ for(int i=0; i<entries.size();i++){
Items.append(new EntryViewItem(this)); Items.append(new EntryViewItem(this));
@ -180,6 +148,17 @@ void KeepassEntryView::OnCloneEntry(){
void KeepassEntryView::OnDeleteEntry(){ void KeepassEntryView::OnDeleteEntry(){
QList<QTreeWidgetItem*> entries=selectedItems(); QList<QTreeWidgetItem*> entries=selectedItems();
if(config->askBeforeDelete()){
QString text;
if(entries.size()==1)
text=tr("Are you sure you want delete this entry?");
else
text=tr("Are you sure you want delete these %1 entries?").arg(entries.size());
if(QMessageBox::question(this,tr("Delete?"),text,QMessageBox::Yes | QMessageBox::No,QMessageBox::No)==QMessageBox::No)
return;
}
for(int i=0; i<entries.size();i++){ for(int i=0; i<entries.size();i++){
db->deleteEntry(((EntryViewItem*)entries[i])->EntryHandle); db->deleteEntry(((EntryViewItem*)entries[i])->EntryHandle);
Items.removeAt(Items.indexOf((EntryViewItem*)entries[i])); Items.removeAt(Items.indexOf((EntryViewItem*)entries[i]));
@ -193,18 +172,18 @@ void KeepassEntryView::OnDeleteEntry(){
void KeepassEntryView::updateEntry(EntryViewItem* item){ void KeepassEntryView::updateEntry(EntryViewItem* item){
IEntryHandle* entry = item->EntryHandle; IEntryHandle* entry = item->EntryHandle;
int j=0; int j=0;
if(Columns[0]){ if(Columns.at(0)){
item->setText(j++,entry->title()); item->setText(j++,entry->title());
item->setIcon(0,db->icon(entry->image())); item->setIcon(0,db->icon(entry->image()));
} }
if(Columns[1]){ if (Columns.at(1)){
if(config.ListView_HideUsernames) if(config->hideUsernames())
item->setText(j++,"******"); item->setText(j++,"******");
else else
item->setText(j++,entry->username());} item->setText(j++,entry->username());}
if(Columns[2]){item->setText(j++,entry->url());} if (Columns.at(2)){item->setText(j++,entry->url());}
if(Columns[3]){ if (Columns.at(3)){
if(config.ListView_HidePasswords) if(config->hidePasswords())
item->setText(j++,"******"); item->setText(j++,"******");
else{ else{
SecString password=entry->password(); SecString password=entry->password();
@ -212,21 +191,21 @@ void KeepassEntryView::updateEntry(EntryViewItem* item){
item->setText(j++,password.string()); item->setText(j++,password.string());
} }
} }
if(Columns[4]){ if (Columns.at(4)){
item->setText(j++,entry->comment().section('\n',0,0));} item->setText(j++,entry->comment().section('\n',0,0));}
if(Columns[5]){ if (Columns.at(5)){
item->setText(j++,entry->expire().dateToString(Qt::LocalDate));} item->setText(j++,entry->expire().dateToString(Qt::LocalDate));}
if(Columns[6]){ if (Columns.at(6)){
item->setText(j++,entry->creation().dateToString(Qt::LocalDate));} item->setText(j++,entry->creation().dateToString(Qt::LocalDate));}
if(Columns[7]){ if (Columns.at(7)){
item->setText(j++,entry->lastMod().dateToString(Qt::LocalDate));} item->setText(j++,entry->lastMod().dateToString(Qt::LocalDate));}
if(Columns[8]){ if (Columns.at(8)){
item->setText(j++,entry->lastAccess().dateToString(Qt::LocalDate));} item->setText(j++,entry->lastAccess().dateToString(Qt::LocalDate));}
if(Columns[9]){ if (Columns.at(9)){
item->setText(j++,entry->binaryDesc());} item->setText(j++,entry->binaryDesc());}
if(Columns[10] && ViewMode==ShowSearchResults){ if(Columns.at(10) && ViewMode==ShowSearchResults){
item->setText(j,entry->group()->title()); item->setText(j,entry->group()->title());
item->setIcon(j++,db->icon(entry->group()->image()));} item->setIcon(j++,db->icon(entry->group()->image()));}
} }
void KeepassEntryView::editEntry(EntryViewItem* item){ void KeepassEntryView::editEntry(EntryViewItem* item){
@ -238,13 +217,13 @@ void KeepassEntryView::editEntry(EntryViewItem* item){
updateEntry(item); updateEntry(item);
emit fileModified(); emit fileModified();
break; break;
case 2: //entry moved to another group case 2: //entry moved to another group
delete item; delete item;
Items.removeAt(Items.indexOf(item)); Items.removeAt(Items.indexOf(item));
emit fileModified(); emit fileModified();
break; break;
} }
} }
@ -260,7 +239,7 @@ void KeepassEntryView::OnNewEntry(){
updateEntry(Items.back()); updateEntry(Items.back());
emit fileModified(); emit fileModified();
} }
} }
void KeepassEntryView::OnEntryActivated(QTreeWidgetItem* item,int Column){ void KeepassEntryView::OnEntryActivated(QTreeWidgetItem* item,int Column){
@ -274,49 +253,58 @@ void KeepassEntryView::OnEntryActivated(QTreeWidgetItem* item,int Column){
case 3: OnPasswordToClipboard(); case 3: OnPasswordToClipboard();
break; break;
} }
} }
void KeepassEntryView::OnEditEntry(){ void KeepassEntryView::OnEditEntry(){
Q_ASSERT(selectedItems().size()==1); Q_ASSERT(selectedItems().size()==1);
editEntry((EntryViewItem*)selectedItems()[0]); editEntry((EntryViewItem*)selectedItems().first());
} }
void KeepassEntryView::OnEditOpenUrl(){ void KeepassEntryView::OnEditOpenUrl(){
Q_ASSERT(selectedItems().size()==1); Q_ASSERT(selectedItems().size()==1);
openBrowser(((EntryViewItem*)selectedItems()[0])->text(logicalColIndex(2))); openBrowser(((EntryViewItem*)selectedItems().first())->text(logicalColIndex(2)));
} }
void KeepassEntryView::OnUsernameToClipboard(){ void KeepassEntryView::OnUsernameToClipboard(){
Clipboard->setText(((EntryViewItem*)selectedItems()[0])->EntryHandle->username(), QClipboard::Clipboard); Clipboard->setText(((EntryViewItem*)selectedItems().first())->EntryHandle->username(), QClipboard::Clipboard);
if(Clipboard->supportsSelection()){
Clipboard->setText(((EntryViewItem*)selectedItems().first())->EntryHandle->username(),QClipboard::Selection);
}
ClipboardTimer.setSingleShot(true); ClipboardTimer.setSingleShot(true);
ClipboardTimer.start(config.ClipboardTimeOut*1000); ClipboardTimer.start(config->clipboardTimeOut()*1000);
} }
void KeepassEntryView::OnPasswordToClipboard(){ void KeepassEntryView::OnPasswordToClipboard(){
SecString password; SecString password;
password=((EntryViewItem*)selectedItems()[0])->EntryHandle->password(); password=((EntryViewItem*)selectedItems().first())->EntryHandle->password();
password.unlock(); password.unlock();
Clipboard->setText(password.string(),QClipboard::Clipboard); Clipboard->setText(password.string(),QClipboard::Clipboard);
if(Clipboard->supportsSelection()){
Clipboard->setText(password.string(),QClipboard::Selection);
}
ClipboardTimer.setSingleShot(true); ClipboardTimer.setSingleShot(true);
ClipboardTimer.start(config.ClipboardTimeOut*1000); ClipboardTimer.start(config->clipboardTimeOut()*1000);
} }
void KeepassEntryView::OnClipboardTimeOut(){ void KeepassEntryView::OnClipboardTimeOut(){
Clipboard->clear(QClipboard::Clipboard); Clipboard->clear(QClipboard::Clipboard);
if(Clipboard->supportsSelection()){
Clipboard->clear(QClipboard::Selection);
}
} }
void KeepassEntryView::contextMenuEvent(QContextMenuEvent* e){ void KeepassEntryView::contextMenuEvent(QContextMenuEvent* e){
if(itemAt(e->pos())){ if(itemAt(e->pos())){
EntryViewItem* item=(EntryViewItem*)itemAt(e->pos()); EntryViewItem* item=(EntryViewItem*)itemAt(e->pos());
if(selectedItems().size()==0){ if(!selectedItems().size()){
setItemSelected(item,true); setItemSelected(item,true);
} }
else{ else{
if(!isItemSelected(item)){ if(!isItemSelected(item)){
while(selectedItems().size()){ while(selectedItems().size()){
setItemSelected(selectedItems()[0],false); setItemSelected(selectedItems().first(),false);
} }
setItemSelected(item,true); setItemSelected(item,true);
} }
@ -324,7 +312,7 @@ void KeepassEntryView::contextMenuEvent(QContextMenuEvent* e){
} }
else else
{while(selectedItems().size()){ {while(selectedItems().size()){
setItemSelected(selectedItems()[0],false);} setItemSelected(selectedItems().first(),false);}
} }
e->accept(); e->accept();
ContextMenu->popup(e->globalPos()); ContextMenu->popup(e->globalPos());
@ -339,7 +327,7 @@ void KeepassEntryView::resizeEvent(QResizeEvent* e){
void KeepassEntryView::showSearchResults(){ void KeepassEntryView::showSearchResults(){
if(ViewMode==Normal){ if(ViewMode==Normal){
ViewMode=ShowSearchResults; ViewMode=ShowSearchResults;
if(Columns[10])ColumnOrder[10]--; if(Columns.at(10))ColumnOrder[10]--;
updateColumns(); updateColumns();
} }
clear(); clear();
@ -357,7 +345,7 @@ void KeepassEntryView::showGroup(IGroupHandle* group){
Items.clear(); Items.clear();
if(group==NULL)return; if(group==NULL)return;
QList<IEntryHandle*>entries=db->entries(group); QList<IEntryHandle*>entries=db->entries(group);
createItems(entries); createItems(entries);
} }
void KeepassEntryView::createItems(QList<IEntryHandle*>& entries){ void KeepassEntryView::createItems(QList<IEntryHandle*>& entries){
@ -368,17 +356,17 @@ void KeepassEntryView::createItems(QList<IEntryHandle*>& entries){
Items.push_back(item); Items.push_back(item);
Items.back()->EntryHandle=entries[i]; Items.back()->EntryHandle=entries[i];
int j=0; int j=0;
if(Columns[0]){ if (Columns.at(0)){
item->setText(j++,entries[i]->title()); item->setText(j++,entries[i]->title());
item->setIcon(0,db->icon(entries[i]->image()));} item->setIcon(0,db->icon(entries[i]->image()));}
if(Columns[1]){ if (Columns.at(1)){
if(config.ListView_HideUsernames) if(config->hideUsernames())
item->setText(j++,"******"); item->setText(j++,"******");
else else
item->setText(j++,entries[i]->username());} item->setText(j++,entries[i]->username());}
if(Columns[2]){item->setText(j++,entries[i]->url());} if (Columns.at(2)){item->setText(j++,entries[i]->url());}
if(Columns[3]){ if (Columns.at(3)){
if(config.ListView_HidePasswords) if(config->hidePasswords())
item->setText(j++,"******"); item->setText(j++,"******");
else{ else{
SecString password=entries[i]->password(); SecString password=entries[i]->password();
@ -386,19 +374,19 @@ void KeepassEntryView::createItems(QList<IEntryHandle*>& entries){
item->setText(j++,password.string()); item->setText(j++,password.string());
} }
} }
if(Columns[4]){ if (Columns.at(4)){
item->setText(j++,entries[i]->comment().section('\n',0,0));} item->setText(j++,entries[i]->comment().section('\n',0,0));}
if(Columns[5]){ if (Columns.at(5)){
item->setText(j++,entries[i]->expire().dateToString(Qt::LocalDate));} item->setText(j++,entries[i]->expire().dateToString(Qt::LocalDate));}
if(Columns[6]){ if (Columns.at(6)){
item->setText(j++,entries[i]->creation().dateToString(Qt::LocalDate));} item->setText(j++,entries[i]->creation().dateToString(Qt::LocalDate));}
if(Columns[7]){ if (Columns.at(7)){
item->setText(j++,entries[i]->lastMod().dateToString(Qt::LocalDate));} item->setText(j++,entries[i]->lastMod().dateToString(Qt::LocalDate));}
if(Columns[8]){ if (Columns.at(8)){
item->setText(j++,entries[i]->lastAccess().dateToString(Qt::LocalDate));} item->setText(j++,entries[i]->lastAccess().dateToString(Qt::LocalDate));}
if(Columns[9]){ if (Columns.at(9)){
item->setText(j++,entries[i]->binaryDesc());} item->setText(j++,entries[i]->binaryDesc());}
if(Columns[10] && ViewMode==ShowSearchResults){ if(Columns.at(10) && ViewMode==ShowSearchResults){
item->setText(j,entries[i]->group()->title()); item->setText(j,entries[i]->group()->title());
item->setIcon(j++,db->icon(entries[i]->group()->image()));} item->setIcon(j++,db->icon(entries[i]->group()->image()));}
} }
@ -406,8 +394,8 @@ void KeepassEntryView::createItems(QList<IEntryHandle*>& entries){
void KeepassEntryView::updateIcons(){ void KeepassEntryView::updateIcons(){
for(int i=0;i<Items.size();i++){ for(int i=0;i<Items.size();i++){
Items[i]->setIcon(0,db->icon(Items[i]->EntryHandle->image())); Items[i]->setIcon(0,db->icon(Items[i]->EntryHandle->image()));
} }
} }
@ -418,44 +406,45 @@ void KeepassEntryView::setEntry(IEntryHandle* entry){
void KeepassEntryView::updateColumns(){ void KeepassEntryView::updateColumns(){
setColumnCount(0); setColumnCount(0);
QStringList cols; QStringList cols;
if(Columns[0]){ if (Columns.at(0)){
cols << tr("Title");} cols << tr("Title");}
if(Columns[1]){ if (Columns.at(1)){
cols << tr("Username");} cols << tr("Username");}
if(Columns[2]){ if (Columns.at(2)){
cols << tr("URL");} cols << tr("URL");}
if(Columns[3]){ if (Columns.at(3)){
cols << tr("Password");} cols << tr("Password");}
if(Columns[4]){ if (Columns.at(4)){
cols << tr("Comments");} cols << tr("Comments");}
if(Columns[5]){ if (Columns.at(5)){
cols << tr("Expires");} cols << tr("Expires");}
if(Columns[6]){ if (Columns.at(6)){
cols << tr("Creation");} cols << tr("Creation");}
if(Columns[7]){ if (Columns.at(7)){
cols << tr("Last Change");} cols << tr("Last Change");}
if(Columns[8]){ if (Columns.at(8)){
cols << tr("Last Access");} cols << tr("Last Access");}
if(Columns[9]){ if (Columns.at(9)){
cols << tr("Attachment");} cols << tr("Attachment");}
if(Columns[10] && ViewMode==ShowSearchResults){ if(Columns.at(10) && ViewMode==ShowSearchResults){
cols << tr("Group");} cols << tr("Group");}
setHeaderLabels(cols); setHeaderLabels(cols);
for(int i=0;i<NUM_COLUMNS;i++){ for(int i=0;i<NUM_COLUMNS;i++){
if(!Columns[i])ColumnOrder[i]=100; if(!Columns.at(i))
ColumnOrder[i]=100;
} }
QMap<int,int> Order; QMap<int,int> Order;
for(int i=NUM_COLUMNS-1;i>=0;i--) for(int i=NUM_COLUMNS-1;i>=0;i--)
Order.insertMulti(ColumnOrder[i],i); Order.insertMulti(ColumnOrder.at(i),i);
QMapIterator<int, int> i(Order); QMapIterator<int, int> i(Order);
while (i.hasNext()) { while (i.hasNext()) {
i.next(); i.next();
int index=i.value(); int index=i.value();
if(!Columns[index])continue; if(!Columns.at(index))continue;
header()->moveSection(header()->visualIndex(logicalColIndex(index)),header()->count()-1); header()->moveSection(header()->visualIndex(logicalColIndex(index)),header()->count()-1);
} }
resizeColumns(); resizeColumns();
@ -469,61 +458,63 @@ void KeepassEntryView::refreshItems(){
void KeepassEntryView::OnColumnMoved(int LogIndex,int OldVisIndex,int NewVisIndex){ void KeepassEntryView::OnColumnMoved(int LogIndex,int OldVisIndex,int NewVisIndex){
for(int i=0;i<header()->count();i++){ for(int i=0;i<header()->count();i++){
ColumnOrder[columnListIndex(header()->logicalIndex(i))]=i; ColumnOrder[columnListIndex(header()->logicalIndex(i))]=i;
} }
} }
int KeepassEntryView::logicalColIndex(int LstIndex){ int KeepassEntryView::logicalColIndex(int LstIndex){
qDebug("%i",LstIndex); qDebug("%i",LstIndex);
int c=-1; int c=-1;
for(int i=0;i<NUM_COLUMNS;i++){ for(int i=0;i<NUM_COLUMNS;i++){
if(Columns[i])c++; if(Columns.at(i))c++;
if(i==10 && Columns[10] && ViewMode!=ShowSearchResults)c--; if(i==10 && Columns.at(10) && ViewMode!=ShowSearchResults)c--;
if(i==LstIndex)return c; if(i==LstIndex)return c;
} }
Q_ASSERT(false); Q_ASSERT(false);
} }
void KeepassEntryView::resizeColumns(){ void KeepassEntryView::resizeColumns(){
AutoResizeColumns=false; AutoResizeColumns=false;
int w=viewport()->width(); int w=viewport()->width();
int sum=0; int sum=0;
for(int i=0;i<NUM_COLUMNS;i++){ for(int i=0;i<NUM_COLUMNS;i++){
// if(i==10) continue; //skip "Group" column // if(i==10) continue; //skip "Group" column
if(!Columns[i])ColumnSizes[i]=0; if(!Columns.at(i))
if(Columns[i] && ColumnSizes[i]==0)ColumnSizes[i]=0.1f*(float)w; ColumnSizes[i]=0;
if(Columns.at(i) && !ColumnSizes.at(i))
ColumnSizes[i]=w/10;
} }
for(int i=0;i<header()->count();i++){ for(int i=0;i<header()->count();i++){
sum+=ColumnSizes[columnListIndex(i)]; sum+=ColumnSizes.at(columnListIndex(i));
} }
float stretch=((float)w)/((float)sum); float stretch=((float)w)/((float)sum);
sum=0; sum=0;
for(int i=0;i<header()->count();i++){ for(int i=0;i<header()->count();i++){
int lstIndex=columnListIndex(header()->logicalIndex(i)); int lstIndex=columnListIndex(header()->logicalIndex(i));
int NewSize=qRound(stretch*(float)ColumnSizes[lstIndex]); int NewSize=qRound(stretch*(float)ColumnSizes.at(lstIndex));
sum+=NewSize; sum+=NewSize;
if(i==header()->count()-1){ if(i==header()->count()-1){
NewSize+=(w-sum); // add rounding difference to the last column NewSize+=(w-sum); // add rounding difference to the last column
} }
header()->resizeSection(header()->logicalIndex(i),NewSize); header()->resizeSection(header()->logicalIndex(i),NewSize);
ColumnSizes[lstIndex]=NewSize; ColumnSizes[lstIndex]=NewSize;
} }
AutoResizeColumns=true; AutoResizeColumns=true;
} }
int KeepassEntryView::columnListIndex(int LogicalIndex){ int KeepassEntryView::columnListIndex(int LogicalIndex){
int c=-1; int i=0; int c=-1; int i=0;
for(i;i<NUM_COLUMNS;i++){ for(i;i<NUM_COLUMNS;i++){
if(Columns[i])c++; if(Columns.at(i))c++;
if(i==10 && Columns[10] && ViewMode!=ShowSearchResults)c--; if(i==10 && Columns.at(10) && ViewMode!=ShowSearchResults)c--;
if(c==LogicalIndex)break; if(c==LogicalIndex)break;
} }
return i; return i;
} }
void KeepassEntryView::OnColumnResized(int lindex,int Old, int New){ void KeepassEntryView::OnColumnResized(int lindex,int Old, int New){
if(!AutoResizeColumns)return; if(!AutoResizeColumns)return;
for(int i=0;i<header()->count();i++){ for(int i=0;i<header()->count();i++){
ColumnSizes[columnListIndex(i)]=header()->sectionSize(i); ColumnSizes[columnListIndex(i)]=header()->sectionSize(i);
@ -534,7 +525,7 @@ void KeepassEntryView::OnColumnResized(int lindex,int Old, int New){
void KeepassEntryView::mousePressEvent(QMouseEvent *event){ void KeepassEntryView::mousePressEvent(QMouseEvent *event){
//save event position - maybe this is the start of a drag //save event position - maybe this is the start of a drag
if (event->button() == Qt::LeftButton) if (event->button() == Qt::LeftButton)
DragStartPos = event->pos(); DragStartPos = event->pos();
QTreeWidget::mousePressEvent(event); QTreeWidget::mousePressEvent(event);
} }
@ -543,15 +534,15 @@ void KeepassEntryView::mouseMoveEvent(QMouseEvent *event){
return; return;
if ((event->pos() - DragStartPos).manhattanLength() < QApplication::startDragDistance()) if ((event->pos() - DragStartPos).manhattanLength() < QApplication::startDragDistance())
return; return;
DragItems.clear(); DragItems.clear();
EntryViewItem* DragStartItem=(EntryViewItem*)itemAt(DragStartPos); EntryViewItem* DragStartItem=(EntryViewItem*)itemAt(DragStartPos);
if(!DragStartItem){ if(!DragStartItem){
while(selectedItems().size()){ while(selectedItems().size()){
setItemSelected(selectedItems()[0],false);} setItemSelected(selectedItems().first(),false);}
return; return;
} }
if(selectedItems().size()==0){ if(selectedItems().isEmpty()){
setItemSelected(DragStartItem,true);} setItemSelected(DragStartItem,true);}
else{ else{
bool AlreadySelected=false; bool AlreadySelected=false;
@ -560,17 +551,17 @@ void KeepassEntryView::mouseMoveEvent(QMouseEvent *event){
} }
if(!AlreadySelected){ if(!AlreadySelected){
while(selectedItems().size()){ while(selectedItems().size()){
setItemSelected(selectedItems()[0],false); setItemSelected(selectedItems().first(),false);
} }
setItemSelected(DragStartItem,true); setItemSelected(DragStartItem,true);
} }
} }
DragItems=selectedItems(); DragItems=selectedItems();
QDrag *drag = new QDrag(this); QDrag *drag = new QDrag(this);
QMimeData *mimeData = new QMimeData; QMimeData *mimeData = new QMimeData;
void* pDragItems=&DragItems; void* pDragItems=&DragItems;
mimeData->setData("text/plain;charset=UTF-8",DragItems[0]->text(0).toUtf8()); mimeData->setData("text/plain;charset=UTF-8",DragItems.first()->text(0).toUtf8());
mimeData->setData("application/x-keepassx-entry",QByteArray((char*)&pDragItems,sizeof(void*))); mimeData->setData("application/x-keepassx-entry",QByteArray((char*)&pDragItems,sizeof(void*)));
drag->setMimeData(mimeData); drag->setMimeData(mimeData);
drag->setPixmap(DragPixmap); drag->setPixmap(DragPixmap);
@ -584,16 +575,16 @@ void KeepassEntryView::removeDragItems(){
if(Items[j]==DragItems[i]){ if(Items[j]==DragItems[i]){
Items.removeAt(j); Items.removeAt(j);
j--; j--;
delete DragItems[i]; delete DragItems[i];
} }
} }
} }
} }
void KeepassEntryView::OnAutoType(){ void KeepassEntryView::OnAutoType(){
Q_ASSERT(selectedItems().size()==1); Q_ASSERT(selectedItems().size()==1);
QString error; QString error;
AutoType::perform(((EntryViewItem*)selectedItems()[0])->EntryHandle,error); AutoType::perform(((EntryViewItem*)selectedItems().first())->EntryHandle,error);
} }
void KeepassEntryView::paintEvent(QPaintEvent * event){ void KeepassEntryView::paintEvent(QPaintEvent * event){
@ -624,13 +615,13 @@ bool EntryViewItem::operator<(const QTreeWidgetItem& other)const{
if(ListIndex < 5 || ListIndex==9 || ListIndex==10){ //columns with string values (Title, Username, Password, URL, Comment, Group) if(ListIndex < 5 || ListIndex==9 || ListIndex==10){ //columns with string values (Title, Username, Password, URL, Comment, Group)
if(QString::localeAwareCompare(text(SortCol),other.text(SortCol)) < 0) if(QString::localeAwareCompare(text(SortCol),other.text(SortCol)) < 0)
return true; return true;
else else
return false; return false;
} }
KpxDateTime DateThis; KpxDateTime DateThis;
KpxDateTime DateOther; KpxDateTime DateOther;
switch(SortCol){ switch(SortCol){
case 5: DateThis=EntryHandle->expire(); case 5: DateThis=EntryHandle->expire();
DateOther=((EntryViewItem&)other).EntryHandle->expire(); DateOther=((EntryViewItem&)other).EntryHandle->expire();
@ -654,7 +645,7 @@ void KeepassEntryView::setCurrentEntry(IEntryHandle* entry){
bool found=false; bool found=false;
int i=0; int i=0;
for(i;i<Items.size();i++) for(i;i<Items.size();i++)
if(Items[i]->EntryHandle==entry){found=true; break;} if(Items.at(i)->EntryHandle==entry){found=true; break;}
if(!found)return; if(!found)return;
setCurrentItem(Items[i]); setCurrentItem(Items.at(i));
} }

@ -27,8 +27,9 @@
#include <QHeaderView> #include <QHeaderView>
#include <QTimer> #include <QTimer>
#include <QClipboard> #include <QClipboard>
#include <QVarLengthArray> #include <QBitArray>
#include "../StandardDatabase.h" #include <QList>
#include "../Kdb3Database.h"
#define NUM_COLUMNS 11 #define NUM_COLUMNS 11
@ -49,17 +50,17 @@ class KeepassEntryView:public QTreeWidget{
QList<EntryViewItem*>Items; QList<EntryViewItem*>Items;
QList<IEntryHandle*> SearchResults; QList<IEntryHandle*> SearchResults;
QMenu *ContextMenu; QMenu *ContextMenu;
QVarLengthArray<bool>Columns; QBitArray Columns;
void setCurrentEntry(IEntryHandle* entry); void setCurrentEntry(IEntryHandle* entry);
private: private:
void setEntry(IEntryHandle* entry); void setEntry(IEntryHandle* entry);
void updateEntry(EntryViewItem*); void updateEntry(EntryViewItem*);
void editEntry(EntryViewItem*); void editEntry(EntryViewItem*);
void createItems(QList<IEntryHandle*>& entries); void createItems(QList<IEntryHandle*>& entries);
int logicalColIndex(int ListIndex); int logicalColIndex(int ListIndex);
QClipboard* Clipboard; QClipboard* Clipboard;
QTimer ClipboardTimer; QTimer ClipboardTimer;
void resizeColumns(); void resizeColumns();
bool AutoResizeColumns; bool AutoResizeColumns;
QPoint DragStartPos; QPoint DragStartPos;
@ -68,10 +69,10 @@ class KeepassEntryView:public QTreeWidget{
IGroupHandle* CurrentGroup; IGroupHandle* CurrentGroup;
enum EntryViewMode {Normal, ShowSearchResults}; enum EntryViewMode {Normal, ShowSearchResults};
EntryViewMode ViewMode; EntryViewMode ViewMode;
QVarLengthArray<float>ColumnSizes; QList<int> ColumnSizes;
QVarLengthArray<int>ColumnOrder; QList<int> ColumnOrder;
float GroupColumnSize; float GroupColumnSize;
virtual void contextMenuEvent(QContextMenuEvent *event); virtual void contextMenuEvent(QContextMenuEvent *event);
virtual void paintEvent(QPaintEvent* event); virtual void paintEvent(QPaintEvent* event);
virtual void resizeEvent(QResizeEvent* event); virtual void resizeEvent(QResizeEvent* event);

@ -19,8 +19,8 @@
***************************************************************************/ ***************************************************************************/
#include <QDir> #include <QDir>
#include <QSettings>
#include "main.h" #include "main.h"
#include "KpxConfig.h"
#include "FileDialogs.h" #include "FileDialogs.h"
@ -29,55 +29,65 @@ QtStandardFileDialogs DefaultQtDlgs;
FileDlgHistory fileDlgHistory; FileDlgHistory fileDlgHistory;
void KpxFileDialogs::setPlugin(IFileDialog* plugin){ void KpxFileDialogs::setPlugin(IFileDialog* plugin){
iFileDialog=plugin; iFileDialog=plugin;
} }
QString KpxFileDialogs::openExistingFile(QWidget* Parent, const QString& Name, const QString& Title,const QStringList& Filters,const QString& Dir) QString KpxFileDialogs::openExistingFile(QWidget* Parent, const QString& Name, const QString& Title,const QStringList& Filters,QString Dir,int SelectedFilter)
{ {
QString dir; if(!iFileDialog)iFileDialog=dynamic_cast<IFileDialog*>(&DefaultQtDlgs);
if(iFileDialog==NULL)iFileDialog=dynamic_cast<IFileDialog*>(&DefaultQtDlgs); if(Dir==QString())
if(Dir==QString()) dir=fileDlgHistory.getDir(Name); Dir=fileDlgHistory.getDir(Name);
else dir=Dir; if(SelectedFilter==-1)
QString result = iFileDialog->openExistingFileDialog(Parent,Title,dir,Filters); SelectedFilter=fileDlgHistory.getFilter(Name);
if(result!=QString()){ QString result = iFileDialog->openExistingFileDialog(Parent,Title,Dir,Filters,SelectedFilter);
fileDlgHistory.set(Name,result.left(result.lastIndexOf("/")+1),iFileDialog->getLastFilter()); if(!result.isEmpty()){
fileDlgHistory.set(Name,result.left(result.lastIndexOf("/")+1),iFileDialog->getLastFilter());
} }
return result; return result;
} }
QStringList KpxFileDialogs::openExistingFiles(QWidget* Parent, const QString& Name, const QString& Title,const QStringList& Filters,const QString& Dir) QStringList KpxFileDialogs::openExistingFiles(QWidget* Parent, const QString& Name, const QString& Title,const QStringList& Filters,QString Dir,int SelectedFilter)
{ {
if(iFileDialog==NULL)iFileDialog=dynamic_cast<IFileDialog*>(&DefaultQtDlgs); if(!iFileDialog)iFileDialog=dynamic_cast<IFileDialog*>(&DefaultQtDlgs);
//Load History here! if(Dir==QString())
QStringList results=iFileDialog->openExistingFilesDialog(Parent,Title,QString(),Filters); Dir=fileDlgHistory.getDir(Name);
if(results.size()){ if(SelectedFilter==-1)
fileDlgHistory.set(Name,results[0].left(results[0].lastIndexOf("/")+1),iFileDialog->getLastFilter()); SelectedFilter=fileDlgHistory.getFilter(Name);
QStringList results=iFileDialog->openExistingFilesDialog(Parent,Title,QString(),Filters,SelectedFilter);
if(!results.isEmpty()){
fileDlgHistory.set(Name,results[0].left(results[0].lastIndexOf("/")+1),iFileDialog->getLastFilter());
} }
return results; return results;
} }
QString KpxFileDialogs::saveFile(QWidget* Parent, const QString& Name, const QString& Title,const QStringList& Filters,bool OverWriteWarn, const QString& Dir) QString KpxFileDialogs::saveFile(QWidget* Parent, const QString& Name, const QString& Title,const QStringList& Filters,bool OverWriteWarn,QString Dir,int SelectedFilter)
{ {
if(iFileDialog==NULL)iFileDialog=dynamic_cast<IFileDialog*>(&DefaultQtDlgs); if(!iFileDialog)iFileDialog=dynamic_cast<IFileDialog*>(&DefaultQtDlgs);
//Load History here! if(Dir==QString())
QString result = iFileDialog->saveFileDialog(Parent,Title,QString(),Filters,OverWriteWarn); Dir=fileDlgHistory.getDir(Name);
if(result!=QString()){ if(SelectedFilter==-1)
fileDlgHistory.set(Name,result.left(result.lastIndexOf("/")+1),iFileDialog->getLastFilter()); SelectedFilter=fileDlgHistory.getFilter(Name);
QString result = iFileDialog->saveFileDialog(Parent,Title,QString(),Filters,SelectedFilter,OverWriteWarn);
if(!result.isEmpty()){
fileDlgHistory.set(Name,result.left(result.lastIndexOf("/")+1),iFileDialog->getLastFilter());
} }
return result; return result;
} }
QString QtStandardFileDialogs::openExistingFileDialog(QWidget* parent,QString title,QString dir,QStringList Filters){ QString QtStandardFileDialogs::openExistingFileDialog(QWidget* parent,QString title,QString dir,QStringList Filters,int SelectedFilter){
if(SelectedFilter >= Filters.size())
SelectedFilter=0;
QFileDialog FileDlg(parent,title,dir); QFileDialog FileDlg(parent,title,dir);
FileDlg.setFilters(Filters); FileDlg.setFilters(Filters);
FileDlg.setFileMode(QFileDialog::ExistingFile); FileDlg.setFileMode(QFileDialog::ExistingFile);
FileDlg.selectFilter(Filters[SelectedFilter]);
if(!FileDlg.exec())return QString(); if(!FileDlg.exec())return QString();
if(!FileDlg.selectedFiles().size())return QString(); if(!FileDlg.selectedFiles().size())return QString();
LastFilter=FileDlg.filters().indexOf(FileDlg.selectedFilter()); LastFilter=FileDlg.filters().indexOf(FileDlg.selectedFilter());
return FileDlg.selectedFiles()[0]; return FileDlg.selectedFiles()[0];
} }
QStringList QtStandardFileDialogs::openExistingFilesDialog(QWidget* parent,QString title,QString dir,QStringList Filters){ QStringList QtStandardFileDialogs::openExistingFilesDialog(QWidget* parent,QString title,QString dir,QStringList Filters,int SelectedFilter){
QFileDialog FileDlg(parent,title,dir); QFileDialog FileDlg(parent,title,dir);
FileDlg.setFilters(Filters); FileDlg.setFilters(Filters);
FileDlg.setFileMode(QFileDialog::ExistingFiles); FileDlg.setFileMode(QFileDialog::ExistingFiles);
@ -86,7 +96,7 @@ QStringList QtStandardFileDialogs::openExistingFilesDialog(QWidget* parent,QStri
return FileDlg.selectedFiles(); return FileDlg.selectedFiles();
} }
QString QtStandardFileDialogs::saveFileDialog(QWidget* parent,QString title,QString dir,QStringList Filters,bool ShowOverwriteWarning){ QString QtStandardFileDialogs::saveFileDialog(QWidget* parent,QString title,QString dir,QStringList Filters,int SelectedFilter, bool ShowOverwriteWarning){
QFileDialog FileDlg(parent,title,dir); QFileDialog FileDlg(parent,title,dir);
FileDlg.setFilters(Filters); FileDlg.setFilters(Filters);
FileDlg.setFileMode(QFileDialog::AnyFile); FileDlg.setFileMode(QFileDialog::AnyFile);
@ -94,11 +104,11 @@ QString QtStandardFileDialogs::saveFileDialog(QWidget* parent,QString title,QStr
FileDlg.setConfirmOverwrite(ShowOverwriteWarning); FileDlg.setConfirmOverwrite(ShowOverwriteWarning);
if(!FileDlg.exec())return QString(); if(!FileDlg.exec())return QString();
LastFilter=FileDlg.filters().indexOf(FileDlg.selectedFilter()); LastFilter=FileDlg.filters().indexOf(FileDlg.selectedFilter());
return FileDlg.selectedFiles()[0]; return FileDlg.selectedFiles().first();
} }
int QtStandardFileDialogs::getLastFilter(){ int QtStandardFileDialogs::getLastFilter(){
return LastFilter; return LastFilter;
} }
@ -121,37 +131,40 @@ int FileDlgHistory::getFilter(const QString& name){
void FileDlgHistory::set(const QString& name,const QString& dir, int filter){ void FileDlgHistory::set(const QString& name,const QString& dir, int filter){
History[name]=Entry(); History[name]=Entry();
History[name].Dir=dir; History[name].Dir=dir;
History[name].Filter=filter; History[name].Filter=filter;
} }
void FileDlgHistory::save(){ void FileDlgHistory::save(){
if(settings->value("General/SaveFileDlgHistory",QVariant(true)).toBool()){ if(config->saveFileDlgHistory()){
settings->beginGroup("FileDlgHistory"); //settings->beginGroup("FileDlgHistory");
for(int i=0;i<History.size();i++){ for(unsigned i=0;i<static_cast<unsigned>(History.size());i++){
QStringList entry; QStringList entry;
entry << History.keys()[i] entry << History.keys().at(i)
<< History.values()[i].Dir << History.values().at(i).Dir
<< QString::number(History.values()[i].Filter); << QString::number(History.values().at(i).Filter);
settings->setValue(QString("ENTRY%1").arg(i),QVariant(entry)); //settings->setValue(QString("ENTRY%1").arg(i),QVariant(entry));
config->setFileDlgHistory(i,entry);
} }
settings->endGroup(); //settings->endGroup();
} }
} }
void FileDlgHistory::load(){ void FileDlgHistory::load(){
if(settings->value("General/SaveFileDlgHistory",QVariant(true)).toBool()){ if(config->saveFileDlgHistory()){
settings->beginGroup("FileDlgHistory"); //settings->beginGroup("FileDlgHistory");
QStringList keys=settings->childKeys(); //QStringList keys=settings->childKeys();
for(int i=0;i<keys.size();i++){ unsigned count=config->fileDlgHistorySize();
for(unsigned i=0;i</*keys.size()*/count;i++){
Entry entry; Entry entry;
QStringList value=settings->value(QString("ENTRY%1").arg(i)).toStringList(); QStringList value=config->fileDlgHistory(i);//settings->value(QString("ENTRY%1").arg(i)).toStringList();
entry.Dir=value[1]; entry.Dir=value[1];
entry.Filter=value[2].toInt(); entry.Filter=value[2].toInt();
History[value[0]]=entry; History[value[0]]=entry;
} }
settings->endGroup(); //settings->endGroup();
} }
else{ else{
settings->remove("FileDlgHistory"); config->clearFileDlgHistory();
//settings->remove("FileDlgHistory");
} }
} }

@ -55,17 +55,19 @@ class KpxFileDialogs{
static QString openExistingFile(QWidget* parent, const QString& Name, static QString openExistingFile(QWidget* parent, const QString& Name,
const QString& Title, const QString& Title,
const QStringList& Filters, const QStringList& Filters,
const QString& Dir=QString()); QString Dir=QString(),
int SelectedFilter=-1);
static QStringList openExistingFiles(QWidget* parent, const QString& Name, static QStringList openExistingFiles(QWidget* parent, const QString& Name,
const QString& Title, const QString& Title,
const QStringList& Filters, const QStringList& Filters,
const QString& Dir=QString()); const QString Dir=QString(),
int SelectedFilter=-1);
static QString saveFile(QWidget* parent, const QString& Name, static QString saveFile(QWidget* parent, const QString& Name,
const QString& Title, const QString& Title,
const QStringList& Filters, const QStringList& Filters,
bool ShowOverwriteWarning=true, bool ShowOverwriteWarning=true,
const QString& Dir=QString() QString Dir=QString(),
); int SelectedFilter=-1);
private: private:
static IFileDialog* iFileDialog; static IFileDialog* iFileDialog;
@ -77,9 +79,9 @@ class KpxFileDialogs{
class QtStandardFileDialogs:public QObject,public IFileDialog{ class QtStandardFileDialogs:public QObject,public IFileDialog{
Q_OBJECT Q_OBJECT
public: public:
QString openExistingFileDialog(QWidget* parent,QString title,QString dir,QStringList Filters); QString openExistingFileDialog(QWidget* parent,QString title,QString dir,QStringList Filters,int SelectedFilter);
QStringList openExistingFilesDialog(QWidget* parent,QString title,QString dir,QStringList Filters); QStringList openExistingFilesDialog(QWidget* parent,QString title,QString dir,QStringList Filters,int SelectedFilter);
QString saveFileDialog(QWidget* parent,QString title,QString dir,QStringList Filters,bool ShowOverwriteWarning); QString saveFileDialog(QWidget* parent,QString title,QString dir,QStringList Filters,int SelectedFilter,bool ShowOverwriteWarning);
int getLastFilter(); int getLastFilter();
private: private:
int LastFilter; int LastFilter;

@ -33,6 +33,8 @@
#include <QPen> #include <QPen>
#include <QBrush> #include <QBrush>
#include <QMenu> #include <QMenu>
#include <QMessageBox>
#include "KpxConfig.h"
#include "main.h" #include "main.h"
#include "EntryView.h" #include "EntryView.h"
#include "GroupView.h" #include "GroupView.h"
@ -99,6 +101,12 @@ void KeepassGroupView::addChilds(GroupViewItem* item){
} }
void KeepassGroupView::OnDeleteGroup(){ void KeepassGroupView::OnDeleteGroup(){
if(config->askBeforeDelete()){
if(QMessageBox::question(this,tr("Delete?"),
tr("Are you sure you want to delete this group, all it's child groups and all their entries?"),
QMessageBox::Yes | QMessageBox::No,QMessageBox::No) == QMessageBox::No)
return;
}
GroupViewItem* item=(GroupViewItem*)currentItem(); GroupViewItem* item=(GroupViewItem*)currentItem();
if(item){ if(item){
db->deleteGroup(item->GroupHandle); db->deleteGroup(item->GroupHandle);
@ -204,6 +212,7 @@ void KeepassGroupView::dragEnterEvent ( QDragEnterEvent * event ){
void KeepassGroupView::dragLeaveEvent ( QDragLeaveEvent * event ){ void KeepassGroupView::dragLeaveEvent ( QDragLeaveEvent * event ){
if(LastHoverItem){ if(LastHoverItem){
LastHoverItem->setBackgroundColor(0,QApplication::palette().color(QPalette::Base)); LastHoverItem->setBackgroundColor(0,QApplication::palette().color(QPalette::Base));
LastHoverItem->setForeground(0,QBrush(QApplication::palette().color(QPalette::Text)));
} }
if(InsLinePos!=-1){ if(InsLinePos!=-1){
int RemoveLine=InsLinePos; int RemoveLine=InsLinePos;
@ -345,6 +354,15 @@ void KeepassGroupView::entryDragMoveEvent( QDragMoveEvent * event ){
event->ignore(); event->ignore();
return; return;
} }
if(Item==SearchResultItem){
if(LastHoverItem){
LastHoverItem->setBackgroundColor(0,QApplication::palette().color(QPalette::Base));
LastHoverItem->setForeground(0,QBrush(QApplication::palette().color(QPalette::Text)));
LastHoverItem=NULL;
}
event->ignore();
return;
}
if(LastHoverItem != Item){ if(LastHoverItem != Item){
if(LastHoverItem){ if(LastHoverItem){
LastHoverItem->setBackgroundColor(0,QApplication::palette().color(QPalette::Base)); LastHoverItem->setBackgroundColor(0,QApplication::palette().color(QPalette::Base));
@ -354,7 +372,6 @@ void KeepassGroupView::entryDragMoveEvent( QDragMoveEvent * event ){
Item->setForeground(0,QBrush(QApplication::palette().color(QPalette::HighlightedText))); Item->setForeground(0,QBrush(QApplication::palette().color(QPalette::HighlightedText)));
LastHoverItem=Item; LastHoverItem=Item;
} }
event->accept(); event->accept();
return; return;

@ -23,7 +23,7 @@
#include <QTreeWidget> #include <QTreeWidget>
#include <QLine> #include <QLine>
#include <QContextMenuEvent> #include <QContextMenuEvent>
#include "../StandardDatabase.h" #include "../Kdb3Database.h"
class GroupViewItem; class GroupViewItem;

@ -21,7 +21,6 @@
#include <math.h> #include <math.h>
#include <QPainter> #include <QPainter>
#include <QRectF> #include <QRectF>
#include "PwmConfig.h"
#include "main.h" #include "main.h"
#include "WaitAnimationWidget.h" #include "WaitAnimationWidget.h"
@ -36,17 +35,17 @@ WaitAnimationWidget::WaitAnimationWidget(QWidget* parent):QWidget(parent){
diff=1.0f-diff; diff=1.0f-diff;
if(diff<-0.5f) if(diff<-0.5f)
diff=1.0f+diff; diff=1.0f+diff;
CircSizes[i]=1.0+exp(-14.0f*diff*diff); CircSizes[i]=1.0+exp(-14.0f*diff*diff);
} }
connect(&timer,SIGNAL(timeout()),this,SLOT(refreshAnimation())); connect(&timer,SIGNAL(timeout()),this,SLOT(refreshAnimation()));
} }
WaitAnimationWidget::~WaitAnimationWidget(){ WaitAnimationWidget::~WaitAnimationWidget(){
timer.stop(); timer.stop();
} }
void WaitAnimationWidget::start(){ void WaitAnimationWidget::start(){
timer.start(); timer.start();
} }
void WaitAnimationWidget::stop(){ void WaitAnimationWidget::stop(){
@ -68,22 +67,22 @@ void WaitAnimationWidget::refreshAnimation(){
diff=1.0f-diff; diff=1.0f-diff;
if(diff<-0.5f) if(diff<-0.5f)
diff=1.0f+diff; diff=1.0f+diff;
CircSizes[i]=1.0+exp(-14.0f*diff*diff); CircSizes[i]=1.0+exp(-14.0f*diff*diff);
} }
repaint(); repaint();
} }
void WaitAnimationWidget::paintEvent(QPaintEvent* event){ void WaitAnimationWidget::paintEvent(QPaintEvent* event){
if(timer.isActive()){ if(timer.isActive()){
QPainter painter(this); QPainter painter(this);
painter.setRenderHints(QPainter::Antialiasing,true); painter.setRenderHints(QPainter::Antialiasing,true);
painter.setBrush(Qt::black); painter.setBrush(Qt::black);
painter.setPen(Qt::black); painter.setPen(Qt::black);
for(int i=0;i<6;i++){ for(int i=0;i<6;i++){
float d=CircSizes[i]*5.0; float d=CircSizes[i]*5.0;
QRectF rect(CircPositions[i].x()-d/2,CircPositions[i].y()-d/2,d,d); QRectF rect(CircPositions[i].x()-d/2,CircPositions[i].y()-d/2,d,d);
painter.drawEllipse(rect); painter.drawEllipse(rect);
} }
} }
} }
@ -95,7 +94,7 @@ void WaitAnimationWidget::resizeEvent(QResizeEvent* event){
r=width()/2; r=width()/2;
for(int i=0;i<6;i++){ for(int i=0;i<6;i++){
CircPositions[i].setX((r-10)*cos(-2.0*3.14159265*(0.16666667*i))+r); CircPositions[i].setX((r-10)*cos(-2.0*3.14159265*(0.16666667*i))+r);
CircPositions[i].setY((r-10)*sin(-2.0*3.14159265*(0.16666667*i))+r); CircPositions[i].setY((r-10)*sin(-2.0*3.14159265*(0.16666667*i))+r);
} }
} }

@ -41,8 +41,8 @@
#include "main.h" #include "main.h"
#include "lib/FileDialogs.h" #include "lib/FileDialogs.h"
#include "PwmConfig.h" #include "KpxConfig.h"
#include "StandardDatabase.h" #include "Kdb3Database.h"
#include "mainwindow.h" #include "mainwindow.h"
#include "crypto/yarrow.h" #include "crypto/yarrow.h"
using namespace std; using namespace std;
@ -50,19 +50,18 @@ using namespace std;
#ifdef Q_WS_X11 #ifdef Q_WS_X11
#include <X11/extensions/XTest.h> #include <X11/extensions/XTest.h>
#define XK_LATIN1 #define XK_LATIN1
#define XK_MISCELLANY #define XK_MISCELLANY
#define XK_XKB_KEYS #define XK_XKB_KEYS
#include <X11/keysymdef.h> #include <X11/keysymdef.h>
#include <X11/Xlib.h> #include <X11/Xlib.h>
#endif #endif
#define CSTR(x)(x.toUtf8().data()) #define CSTR(x)(x.toUtf8().data())
QHash<QString,QPixmap*>PixmapCache; QHash<QString,QPixmap*>PixmapCache;
QHash<QString,QIcon*>IconCache; QHash<QString,QIcon*>IconCache;
CConfig config; KpxConfig *config;
QSettings* settings;
QString AppDir; QString AppDir;
QString PluginLoadError; QString PluginLoadError;
bool TrActive; bool TrActive;
@ -74,38 +73,58 @@ inline void loadImages();
inline void parseCmdLineArgs(int argc, char** argv,QString &ArgFile,QString& ArgCfg,QString& ArgLang); inline void parseCmdLineArgs(int argc, char** argv,QString &ArgFile,QString& ArgCfg,QString& ArgLang);
bool loadTranslation(QTranslator* tr,const QString& prefix,const QString& LocaleCode,const QStringList& SearchPaths); bool loadTranslation(QTranslator* tr,const QString& prefix,const QString& LocaleCode,const QStringList& SearchPaths);
void test_getAllWindowTitles(){
#ifdef Q_WS_X11
Display* pDisplay = XOpenDisplay( NULL );
Window r,p;
Window* c;
unsigned int num_ch=0;
XQueryTree(pDisplay,DefaultRootWindow(pDisplay),&r,&p,&c,&num_ch);
qDebug("%u",num_ch);
for(int i=0;i<num_ch;i++){
int num_prop=0;
Atom* atom=XListProperties(pDisplay,c[i],&num_prop);
for(int p=0;p<num_prop;p++){
qDebug("%i %i: %s",i,p,XGetAtomName(pDisplay,atom[p]));
}
XFree(atom);
}
#endif
}
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
//test_getAllWindowTitles();
//exit(0);
QString ArgFile,ArgCfg,ArgLang,IniFilename; QString ArgFile,ArgCfg,ArgLang,IniFilename;
QApplication* app=NULL; QApplication* app=NULL;
AppDir=QString(argv[0]); AppDir=QString(argv[0]);
AppDir.truncate(AppDir.lastIndexOf("/")); AppDir.truncate(AppDir.lastIndexOf("/"));
parseCmdLineArgs(argc,argv,ArgFile,ArgCfg,ArgLang);
//Load Config //Load Config
if(ArgCfg==QString()){ if(ArgCfg.isEmpty()){
if(!QDir(QDir::homePath()+"/.keepass").exists()){ if(!QDir(QDir::homePath()+"/.keepassx").exists()){
QDir conf(QDir::homePath()); QDir conf(QDir::homePath());
if(!conf.mkdir(".keepass")){ if(!conf.mkdir(".keepassx")){
cout << "Warning: Could not create directory '~/.keepass'." << endl;} cout << "Warning: Could not create directory '~/.keepassx'." << endl;}
} }
IniFilename=QDir::homePath()+"/.keepass/config"; IniFilename=QDir::homePath()+"/.keepassx/config";
config.loadFromIni(IniFilename);
} }
else{ else
IniFilename=ArgCfg; IniFilename=ArgCfg;
config.loadFromIni(IniFilename);}
config = new KpxConfig(IniFilename);
settings = new QSettings(QDir::homePath()+"/.keepassx/config",QSettings::IniFormat);
fileDlgHistory.load(); fileDlgHistory.load();
//Plugins //Plugins
if(config.IntegrPlugin!=CConfig::NONE){ if(config->integrPlugin()!=KpxConfig::NoIntegr){
QString LibName="libkeepassx-"; QString LibName="libkeepassx-";
if(config.IntegrPlugin==CConfig::KDE) if(config->integrPlugin()==KpxConfig::KDE)
LibName+="kde.so"; LibName+="kde.so";
else if(config.IntegrPlugin==CConfig::GNOME) else if(config->integrPlugin()==KpxConfig::Gnome)
LibName+="gnome.so"; LibName+="gnome.so";
QString filename=findPlugin(LibName); QString filename=findPlugin(LibName);
if(filename!=QString()){ if(filename!=QString()){
@ -118,44 +137,43 @@ int main(int argc, char **argv)
else{ else{
IFileDialog* fdlg=qobject_cast<IFileDialog*>(plugin.instance()); IFileDialog* fdlg=qobject_cast<IFileDialog*>(plugin.instance());
KpxFileDialogs::setPlugin(fdlg); KpxFileDialogs::setPlugin(fdlg);
if(config.IntegrPlugin==CConfig::KDE){ if(config->integrPlugin()==KpxConfig::KDE){
IKdeInit* kdeinit=qobject_cast<IKdeInit*>(plugin.instance()); IKdeInit* kdeinit=qobject_cast<IKdeInit*>(plugin.instance());
app=kdeinit->getMainAppObject(argc,argv); app=kdeinit->getMainAppObject(argc,argv);
if(!app)PluginLoadError=QObject::tr("Initialization failed."); if(!app)PluginLoadError=QObject::tr("Initialization failed.");
} }
if(config.IntegrPlugin==CConfig::GNOME){ if(config->integrPlugin()==KpxConfig::Gnome){
IGnomeInit* ginit=qobject_cast<IGnomeInit*>(plugin.instance()); IGnomeInit* ginit=qobject_cast<IGnomeInit*>(plugin.instance());
if(!ginit->init(argc,argv)){ if(!ginit->init(argc,argv)){
KpxFileDialogs::setPlugin(NULL); KpxFileDialogs::setPlugin(NULL);
qWarning("GtkIntegrPlugin: Gtk init failed."); qWarning("GtkIntegrPlugin: Gtk init failed.");
PluginLoadError=QObject::tr("Initialization failed."); PluginLoadError=QObject::tr("Initialization failed.");
} }
} }
} }
} }
else{ else{
qWarning(CSTR(QString("Could not load desktop integration plugin: File '%1' not found.").arg(LibName))); qWarning(CSTR(QString("Could not load desktop integration plugin: File '%1' not found.").arg(LibName)));
PluginLoadError=QObject::tr("Could not locate library file."); PluginLoadError=QObject::tr("Could not locate library file.");
} }
} }
if(!app) QApplication* app=new QApplication(argc,argv); if(!app) QApplication* app=new QApplication(argc,argv);
parseCmdLineArgs(argc,argv,ArgFile,ArgCfg,ArgLang);
//Internationalization //Internationalization
QLocale loc; QLocale loc;
if(!ArgLang.size()) if(!ArgLang.size())
loc=QLocale::system(); loc=QLocale::system();
else else
loc=QLocale(ArgLang); loc=QLocale(ArgLang);
QTranslator* translator = NULL; QTranslator* translator = NULL;
QTranslator* qtTranslator=NULL; QTranslator* qtTranslator=NULL;
translator=new QTranslator; translator=new QTranslator;
qtTranslator=new QTranslator; qtTranslator=new QTranslator;
if(loadTranslation(translator,"keepass-",loc.name(),QStringList() if(loadTranslation(translator,"keepass-",loc.name(),QStringList()
<< app->applicationDirPath()+"/../share/keepass/i18n/" << app->applicationDirPath()+"/../share/keepass/i18n/"
<< QDir::homePath()+"/.keepassx/" )) << QDir::homePath()+"/.keepassx/" ))
{app->installTranslator(translator); {app->installTranslator(translator);
TrActive=true;} TrActive=true;}
@ -167,10 +185,10 @@ int main(int argc, char **argv)
delete translator; delete translator;
TrActive=false; TrActive=false;
} }
if(loadTranslation(qtTranslator,"qt_",loc.name(),QStringList() if(loadTranslation(qtTranslator,"qt_",loc.name(),QStringList()
<< QLibraryInfo::location(QLibraryInfo::TranslationsPath) << QLibraryInfo::location(QLibraryInfo::TranslationsPath)
<< app->applicationDirPath()+"/../share/keepass/i18n/" << app->applicationDirPath()+"/../share/keepass/i18n/"
<< QDir::homePath()+"/.keepass/" )) << QDir::homePath()+"/.keepass/" ))
app->installTranslator(qtTranslator); app->installTranslator(qtTranslator);
else{ else{
@ -180,19 +198,19 @@ int main(int argc, char **argv)
.arg(QLocale::countryToString(loc.country())).toAscii()); .arg(QLocale::countryToString(loc.country())).toAscii());
delete qtTranslator; delete qtTranslator;
} }
QFile templ(QDir::homePath()+"/.keepassx/detailview-template.html"); ///FIXME ArgCfg QFile templ(QDir::homePath()+"/.keepassx/detailview-template.html"); ///FIXME ArgCfg
if(templ.open(QIODevice::ReadOnly)){ if(templ.open(QIODevice::ReadOnly)){
DetailViewTemplate=QString::fromUtf8(templ.readAll()); DetailViewTemplate=QString::fromUtf8(templ.readAll());
templ.close(); templ.close();
} }
else loadDefaultDetailViewTemplate(); else loadDefaultDetailViewTemplate();
loadImages(); loadImages();
initYarrow(); //init random number generator initYarrow(); //init random number generator
SecString::generateSessionKey(); SecString::generateSessionKey();
int r=0; int r=0;
KeepassMainWindow *mainWin = new KeepassMainWindow(ArgFile); KeepassMainWindow *mainWin = new KeepassMainWindow(ArgFile);
if(mainWin->Start){ if(mainWin->Start){
@ -200,23 +218,19 @@ int main(int argc, char **argv)
r=app->exec(); r=app->exec();
} }
delete mainWin; delete mainWin;
if(!config.saveToIni(IniFilename))
QMessageBox::warning(NULL,QObject::tr("Warning"),
QObject::tr("Could not save configuration file.\nMake sure you have write access to '~/.keepass'."),
QObject::tr("OK"),"","",0.0);
if(templ.open(QIODevice::WriteOnly)){ if(templ.open(QIODevice::WriteOnly)){
templ.write(DetailViewTemplate.toUtf8()); templ.write(DetailViewTemplate.toUtf8());
templ.close(); templ.close();
} }
else{ else{
qWarning("Failed to save detail view template: %s",decodeFileError(templ.error()).toUtf8().data()); qWarning("Failed to save detail view template: %s",decodeFileError(templ.error()).toUtf8().data());
} }
fileDlgHistory.save(); fileDlgHistory.save();
delete app; delete app;
delete settings; delete config;
return r; return r;
} }
@ -224,7 +238,7 @@ int main(int argc, char **argv)
void loadDefaultDetailViewTemplate(){ void loadDefaultDetailViewTemplate(){
QFile templ(":/default-detailview.html"); QFile templ(":/default-detailview.html");
templ.open(QIODevice::ReadOnly); templ.open(QIODevice::ReadOnly);
DetailViewTemplate=QString::fromUtf8(templ.readAll()); DetailViewTemplate=QString::fromUtf8(templ.readAll());
templ.close(); templ.close();
DetailViewTemplate.replace("Group",QCoreApplication::translate("DetailViewTemplate","Group")); DetailViewTemplate.replace("Group",QCoreApplication::translate("DetailViewTemplate","Group"));
DetailViewTemplate.replace("Title",QCoreApplication::translate("DetailViewTemplate","Title")); DetailViewTemplate.replace("Title",QCoreApplication::translate("DetailViewTemplate","Title"));
@ -235,7 +249,7 @@ void loadDefaultDetailViewTemplate(){
DetailViewTemplate.replace("Last Access",QCoreApplication::translate("DetailViewTemplate","Last Access")); DetailViewTemplate.replace("Last Access",QCoreApplication::translate("DetailViewTemplate","Last Access"));
DetailViewTemplate.replace("Last Modification",QCoreApplication::translate("DetailViewTemplate","Last Modification")); DetailViewTemplate.replace("Last Modification",QCoreApplication::translate("DetailViewTemplate","Last Modification"));
DetailViewTemplate.replace("Expiration",QCoreApplication::translate("DetailViewTemplate","Expiration")); DetailViewTemplate.replace("Expiration",QCoreApplication::translate("DetailViewTemplate","Expiration"));
DetailViewTemplate.replace("Comment",QCoreApplication::translate("DetailViewTemplate","Comment")); DetailViewTemplate.replace("Comment",QCoreApplication::translate("DetailViewTemplate","Comment"));
} }
//obsolete //obsolete
@ -243,14 +257,14 @@ void createBanner(QLabel *Banner,const QPixmap* symbol,QString text){
QPixmap Pixmap; QPixmap Pixmap;
createBanner(&Pixmap,symbol,text createBanner(&Pixmap,symbol,text
,Banner->width() ,Banner->width()
,config.BannerColor1 ,config->bannerColor1()
,config.BannerColor2 ,config->bannerColor2()
,config.BannerTextColor); ,config->bannerTextColor());
Banner->setPixmap(Pixmap); Banner->setPixmap(Pixmap);
} }
void createBanner(QPixmap* Pixmap,const QPixmap* IconAlpha,const QString& Text,int Width){ void createBanner(QPixmap* Pixmap,const QPixmap* IconAlpha,const QString& Text,int Width){
createBanner(Pixmap,IconAlpha,Text,Width,config.BannerColor1,config.BannerColor2,config.BannerTextColor); createBanner(Pixmap,IconAlpha,Text,Width,config->bannerColor1(),config->bannerColor2(),config->bannerTextColor());
} }
void createBanner(QPixmap* Pixmap,const QPixmap* IconAlpha,const QString& Text,int Width, QColor Color1, QColor Color2, QColor TextColor){ void createBanner(QPixmap* Pixmap,const QPixmap* IconAlpha,const QString& Text,int Width, QColor Color1, QColor Color2, QColor TextColor){
@ -262,26 +276,26 @@ void createBanner(QPixmap* Pixmap,const QPixmap* IconAlpha,const QString& Text,i
painter.setPen(Qt::NoPen); painter.setPen(Qt::NoPen);
painter.setBrush(grad); painter.setBrush(grad);
painter.drawRect(0,0,Width,50); painter.drawRect(0,0,Width,50);
QPixmap Icon(32,32); QPixmap Icon(32,32);
if(IconAlpha){ if(IconAlpha){
Icon.fill(TextColor); Icon.fill(TextColor);
Icon.setAlphaChannel(*IconAlpha); Icon.setAlphaChannel(*IconAlpha);
painter.drawPixmap(10,10,Icon); painter.drawPixmap(10,10,Icon);
} }
painter.setPen(QPen(TextColor)); painter.setPen(QPen(TextColor));
painter.setFont(QFont(QApplication::font().family(),16)); painter.setFont(QFont(QApplication::font().family(),16));
painter.drawText(50,35,Text); painter.drawText(50,35,Text);
} }
QString decodeFileError(QFile::FileError Code){ QString decodeFileError(QFile::FileError Code){
switch(Code){ switch(Code){
case QFile::NoError: return QApplication::translate("FileErrors","No error occurred."); case QFile::NoError: return QApplication::translate("FileErrors","No error occurred.");
case QFile::ReadError: return QApplication::translate("FileErrors","An error occurred while reading from the file."); case QFile::ReadError: return QApplication::translate("FileErrors","An error occurred while reading from the file.");
case QFile::WriteError: return QApplication::translate("FileErrors","An error occurred while writing to the file."); case QFile::WriteError: return QApplication::translate("FileErrors","An error occurred while writing to the file.");
case QFile::FatalError: return QApplication::translate("FileErrors","A fatal error occurred."); case QFile::FatalError: return QApplication::translate("FileErrors","A fatal error occurred.");
case QFile::ResourceError: return QApplication::translate("FileErrors","An resource error occurred."); case QFile::ResourceError: return QApplication::translate("FileErrors","An resource error occurred.");
case QFile::OpenError: return QApplication::translate("FileErrors","The file could not be opened."); case QFile::OpenError: return QApplication::translate("FileErrors","The file could not be opened.");
case QFile::AbortError: return QApplication::translate("FileErrors","The operation was aborted."); case QFile::AbortError: return QApplication::translate("FileErrors","The operation was aborted.");
case QFile::TimeOutError: return QApplication::translate("FileErrors","A timeout occurred."); case QFile::TimeOutError: return QApplication::translate("FileErrors","A timeout occurred.");
@ -291,7 +305,7 @@ QString decodeFileError(QFile::FileError Code){
case QFile::PositionError: return QApplication::translate("FileErrors","The position in the file could not be changed."); case QFile::PositionError: return QApplication::translate("FileErrors","The position in the file could not be changed.");
case QFile::ResizeError: return QApplication::translate("FileErrors","The file could not be resized."); case QFile::ResizeError: return QApplication::translate("FileErrors","The file could not be resized.");
case QFile::PermissionsError: return QApplication::translate("FileErrors","The file could not be accessed."); case QFile::PermissionsError: return QApplication::translate("FileErrors","The file could not be accessed.");
case QFile::CopyError: return QApplication::translate("FileErrors","The file could not be copied."); case QFile::CopyError: return QApplication::translate("FileErrors","The file could not be copied.");
} }
} }
@ -299,11 +313,11 @@ void openBrowser(QString UrlString){
QUrl url(UrlString); QUrl url(UrlString);
if(url.scheme().isEmpty()) if(url.scheme().isEmpty())
url=QUrl("http://"+UrlString); url=QUrl("http://"+UrlString);
if(settings->value("BrowserCmd","<<default>>").toString() == "<<default>>"){ if(config->urlCmd().isEmpty()){
QDesktopServices::openUrl(url); QDesktopServices::openUrl(url);
} }
else{ else{
QStringList args=settings->value("BrowserCmd","<<default>>").toString().arg(url.toString()).split(' '); QStringList args=config->urlCmd().arg(url.toString()).split(' ');
QString cmd=args.takeFirst(); QString cmd=args.takeFirst();
QProcess::startDetached(cmd,args); QProcess::startDetached(cmd,args);
} }
@ -338,7 +352,7 @@ const QIcon& getIcon(const QString& name){
return *CachedIcon; return *CachedIcon;
QFileInfo IconFile(AppDir+"/../share/keepass/icons/"+name+".png"); QFileInfo IconFile(AppDir+"/../share/keepass/icons/"+name+".png");
if(!IconFile.isFile() || !IconFile.exists() || !IconFile.isReadable()){ if(!IconFile.isFile() || !IconFile.exists() || !IconFile.isReadable()){
//ERROR ///TODO 0.2.3 error handling
qWarning("%s",CSTR(name)); qWarning("%s",CSTR(name));
} }
QIcon* NewIcon=new QIcon(AppDir+"/../share/keepass/icons/"+name+".png"); QIcon* NewIcon=new QIcon(AppDir+"/../share/keepass/icons/"+name+".png");
@ -352,7 +366,7 @@ const QPixmap* getPixmap(const QString& name){
return CachedPixmap; return CachedPixmap;
QImage img; QImage img;
if(!img.load(AppDir+"/../share/keepass/icons/"+name+".png")){ if(!img.load(AppDir+"/../share/keepass/icons/"+name+".png")){
//ERROR ///TODO 0.2.3 error handling
qWarning("%s",CSTR(name)); qWarning("%s",CSTR(name));
} }
QPixmap* NewPixmap=new QPixmap(QPixmap::fromImage(img)); QPixmap* NewPixmap=new QPixmap(QPixmap::fromImage(img));
@ -421,11 +435,11 @@ QMessageBox::critical(parent,QObject::tr("Error"),msg,QObject::tr("OK"));
QString findPlugin(const QString& filename){ QString findPlugin(const QString& filename){
QFileInfo info; QFileInfo info;
info.setFile(AppDir+"/../lib/keepassx/"+filename); info.setFile(AppDir+"/../lib/keepassx/"+filename);
if(info.exists() && info.isFile()) if(info.exists() && info.isFile())
return AppDir+"/../lib/keepassx/"+filename; return AppDir+"/../lib/keepassx/"+filename;
return QString(); return QString();
} }
@ -436,11 +450,11 @@ QString makePathRelative(const QString& AbsDir,const QString& CurDir){
QString rel="./"; QString rel="./";
int common=0; int common=0;
for(common; common < abs.size() && common < cur.size(); common++){ for(common; common < abs.size() && common < cur.size(); common++){
if(abs[common]!=cur[common])break; if(abs[common]!=cur[common])break;
} }
for(int i=0;i<cur.size()-common;i++) for(int i=0;i<cur.size()-common;i++)
rel.append("../"); rel.append("../");
for(int i=common;i<abs.size();i++) for(int i=common;i<abs.size();i++)
rel.append(abs[i]+"/"); rel.append(abs[i]+"/");
return rel; return rel;
} }

@ -26,13 +26,12 @@
#include <QColor> #include <QColor>
#include <QIcon> #include <QIcon>
#include <QFile> #include <QFile>
#include <QSettings>
#define KEEPASS_VERSION "0.2.3" #define KEEPASS_VERSION "0.2.3"
#define BUILTIN_ICONS 62 #define BUILTIN_ICONS 62
typedef enum tKeyType {PASSWORD=0,KEYFILE=1,BOTH=2}; typedef enum tKeyType {PASSWORD=0,KEYFILE=1,BOTH=2};
class CConfig; class KpxConfig;
void createBanner(QLabel *Banner,const QPixmap* symbol,QString text); void createBanner(QLabel *Banner,const QPixmap* symbol,QString text);
void createBanner(QPixmap* Pixmap, const QPixmap* IconAlpha,const QString& Text,int Width); void createBanner(QPixmap* Pixmap, const QPixmap* IconAlpha,const QString& Text,int Width);
@ -47,9 +46,8 @@ QString makePathRelative(const QString& Abs,const QString& Cur);
void loadDefaultDetailViewTemplate(); void loadDefaultDetailViewTemplate();
extern QString PluginLoadError; extern QString PluginLoadError;
extern CConfig config; extern KpxConfig *config;
extern QSettings *settings; extern QString AppDir;
extern QString AppDir;
extern bool TrActive; extern bool TrActive;
extern QString DetailViewTemplate; extern QString DetailViewTemplate;
extern QPixmap *EntryIcons; extern QPixmap *EntryIcons;

@ -40,7 +40,6 @@
#include "KpxFirefox.h" #include "KpxFirefox.h"
#include "lib/random.h" #include "lib/random.h"
#include "lib/IniReader.h"
#include "lib/AutoType.h" #include "lib/AutoType.h"
#include "lib/FileDialogs.h" #include "lib/FileDialogs.h"
#include "import/Import_PwManager.h" #include "import/Import_PwManager.h"
@ -59,6 +58,7 @@
#include "dialogs/CollectEntropyDlg.h" #include "dialogs/CollectEntropyDlg.h"
#include "dialogs/CustomizeDetailViewDlg.h" #include "dialogs/CustomizeDetailViewDlg.h"
#include "dialogs/ExpiredEntriesDlg.h" #include "dialogs/ExpiredEntriesDlg.h"
#include "dialogs/TrashCanDlg.h"
//#include <QtDBus/QtDBus> //#include <QtDBus/QtDBus>
#include <iostream> #include <iostream>
@ -77,11 +77,13 @@ KeepassMainWindow::KeepassMainWindow(const QString& ArgFile,QWidget *parent, Qt:
Start=true; Start=true;
ShutingDown=false; ShutingDown=false;
setupUi(this); setupUi(this);
#ifdef QT_WS_MAC
setUnifiedTitleAndToolBarOnMac(true); setUnifiedTitleAndToolBarOnMac(true);
#endif
AutoType::MainWin=this; AutoType::MainWin=this;
setGeometry(settings->value("Ui/MainWindowGeometry",QVariant(geometry())).toRect()); setGeometry(config->mainWindowGeometry(geometry()));
VSplitter->restoreState(settings->value("Ui/VSplitterPos").toByteArray()); VSplitter->restoreState(config->vSplitterPos());
HSplitter->restoreState(settings->value("Ui/HSplitterPos").toByteArray()); HSplitter->restoreState(config->hSplitterPos());
SysTray=new QSystemTrayIcon(this); SysTray=new QSystemTrayIcon(this);
setupToolbar(); setupToolbar();
setupIcons(); setupIcons();
@ -91,34 +93,34 @@ KeepassMainWindow::KeepassMainWindow(const QString& ArgFile,QWidget *parent, Qt:
StatusBarSelection=new QLabel(statusBar()); StatusBarSelection=new QLabel(statusBar());
statusBar()->addWidget(StatusBarGeneral,15); statusBar()->addWidget(StatusBarGeneral,15);
statusBar()->addWidget(StatusBarSelection,85); statusBar()->addWidget(StatusBarSelection,85);
statusBar()->setVisible(config.ShowStatusbar); statusBar()->setVisible(config->showStatusbar());
setupConnections(); setupConnections();
FileOpen=false; FileOpen=false;
if(ArgFile!=QString()) if(!ArgFile.isEmpty())
openDatabase(QDir::cleanPath(QDir::current().absoluteFilePath(ArgFile)),false); openDatabase(QDir::cleanPath(QDir::current().absoluteFilePath(ArgFile)),false);
else if(settings->value("OpenLastFile",true).toBool() && (settings->value("LastFile","").toString()!=QString())){ else if(config->openLastFile() && !config->lastFile().isEmpty()){
QFileInfo file(settings->value("LastFile","").toString()); QFileInfo file(config->lastFile());
if(file.exists()) if(file.exists())
openDatabase(QDir::cleanPath(QDir::current().absoluteFilePath(settings->value("LastFile","").toString())),true); openDatabase(QDir::cleanPath(QDir::current().absoluteFilePath(config->lastFile())),true);
else else
settings->setValue("LastFile",""); config->setLastFile(QString());
} }
// DBus Server of Qt 4.2 does not work - 4.3 snapshot seems to work fine // DBus Server of Qt 4.2 does not work - 4.3 snapshot seems to work fine
/* /*
//dbusServer=new QDBusServer("unix:path=/tmp/KpxBus",this); //dbusServer=new QDBusServer("unix:path=/tmp/KpxBus",this);
//qDebug("DBUS: %s",dbusServer->lastError().message().toAscii().data()); //qDebug("DBUS: %s",dbusServer->lastError().message().toAscii().data());
//QDBusConnection::connectToBus("unix:path=/tmp/KpxBus","MyKpxConnection"); //QDBusConnection::connectToBus("unix:path=/tmp/KpxBus","MyKpxConnection");
//qDebug("DBUS: %s",dbusCon->lastError().message().toAscii().data()); //qDebug("DBUS: %s",dbusCon->lastError().message().toAscii().data());
KpxFirefox* fox=new KpxFirefox(NULL); KpxFirefox* fox=new KpxFirefox(NULL);
new KpxFirefoxAdaptor(fox); new KpxFirefoxAdaptor(fox);
QDBusConnection::sessionBus().registerService("org.keepassx.firefoxservice"); QDBusConnection::sessionBus().registerService("org.keepassx.firefoxservice");
QDBusConnection::sessionBus().registerObject("/KpxFirefox",fox); QDBusConnection::sessionBus().registerObject("/KpxFirefox",fox);
qDebug("DBUS: %s",QDBusConnection::sessionBus().lastError().message().toAscii().data()); qDebug("DBUS: %s",QDBusConnection::sessionBus().lastError().message().toAscii().data());
*/ */
} }
void KeepassMainWindow::setupConnections(){ void KeepassMainWindow::setupConnections(){
@ -132,7 +134,7 @@ void KeepassMainWindow::setupConnections(){
connect(FileExitAction, SIGNAL(triggered()), this, SLOT(OnFileExit())); connect(FileExitAction, SIGNAL(triggered()), this, SLOT(OnFileExit()));
connect(menuImport,SIGNAL(triggered(QAction*)),this,SLOT(OnImport(QAction*))); connect(menuImport,SIGNAL(triggered(QAction*)),this,SLOT(OnImport(QAction*)));
connect(menuExport,SIGNAL(triggered(QAction*)),this,SLOT(OnExport(QAction*))); connect(menuExport,SIGNAL(triggered(QAction*)),this,SLOT(OnExport(QAction*)));
connect(EditNewGroupAction, SIGNAL(triggered()), GroupView, SLOT(OnNewGroup())); connect(EditNewGroupAction, SIGNAL(triggered()), GroupView, SLOT(OnNewGroup()));
connect(EditEditGroupAction, SIGNAL(triggered()), GroupView, SLOT(OnEditGroup())); connect(EditEditGroupAction, SIGNAL(triggered()), GroupView, SLOT(OnEditGroup()));
connect(EditDeleteGroupAction, SIGNAL(triggered()), GroupView, SLOT(OnDeleteGroup())); connect(EditDeleteGroupAction, SIGNAL(triggered()), GroupView, SLOT(OnDeleteGroup()));
@ -162,6 +164,7 @@ void KeepassMainWindow::setupConnections(){
connect(ExtrasSettingsAction,SIGNAL(triggered(bool)),this,SLOT(OnExtrasSettings())); connect(ExtrasSettingsAction,SIGNAL(triggered(bool)),this,SLOT(OnExtrasSettings()));
connect(ExtrasPasswordGenAction,SIGNAL(triggered(bool)),this,SLOT(OnExtrasPasswordGen())); connect(ExtrasPasswordGenAction,SIGNAL(triggered(bool)),this,SLOT(OnExtrasPasswordGen()));
connect(ExtrasShowExpiredEntriesAction,SIGNAL(triggered(bool)),this,SLOT(OnExtrasShowExpiredEntries())); connect(ExtrasShowExpiredEntriesAction,SIGNAL(triggered(bool)),this,SLOT(OnExtrasShowExpiredEntries()));
connect(ExtrasTrashCanAction,SIGNAL(triggered(bool)),this,SLOT(OnExtrasTrashCan()));
connect(HelpHandbookAction,SIGNAL(triggered()),this,SLOT(OnHelpHandbook())); connect(HelpHandbookAction,SIGNAL(triggered()),this,SLOT(OnHelpHandbook()));
connect(HelpAboutAction,SIGNAL(triggered()),this,SLOT(OnHelpAbout())); connect(HelpAboutAction,SIGNAL(triggered()),this,SLOT(OnHelpAbout()));
@ -177,15 +180,15 @@ void KeepassMainWindow::setupConnections(){
connect(GroupView,SIGNAL(searchResultsSelected()),this,SLOT(OnShowSearchResults())); connect(GroupView,SIGNAL(searchResultsSelected()),this,SLOT(OnShowSearchResults()));
connect(GroupView,SIGNAL(entriesDropped()),EntryView,SLOT(removeDragItems())); connect(GroupView,SIGNAL(entriesDropped()),EntryView,SLOT(removeDragItems()));
connect(HideSearchResultsAction,SIGNAL(triggered()),GroupView,SLOT(OnHideSearchResults())); connect(HideSearchResultsAction,SIGNAL(triggered()),GroupView,SLOT(OnHideSearchResults()));
connect(SysTray,SIGNAL(activated(QSystemTrayIcon::ActivationReason)),this,SLOT(OnSysTrayActivated(QSystemTrayIcon::ActivationReason)));
connect(SysTray,SIGNAL(activated(QSystemTrayIcon::ActivationReason)),this,SLOT(OnSysTrayActivated(QSystemTrayIcon::ActivationReason)));
connect(DetailView,SIGNAL(anchorClicked(const QUrl&)),this,SLOT(OnDetailViewUrlClicked(const QUrl&)));
} }
void KeepassMainWindow::setupToolbar(){ void KeepassMainWindow::setupToolbar(){
toolBar=new QToolBar(this); toolBar=new QToolBar(this);
addToolBar(toolBar); addToolBar(toolBar);
toolBar->setIconSize(QSize(config.ToolbarIconSize,config.ToolbarIconSize)); toolBar->setIconSize(QSize(config->toolbarIconSize(),config->toolbarIconSize()));
ViewShowToolbarAction=toolBar->toggleViewAction(); ViewShowToolbarAction=toolBar->toggleViewAction();
toolBar->addAction(FileNewAction); toolBar->addAction(FileNewAction);
toolBar->addAction(FileOpenAction); toolBar->addAction(FileOpenAction);
@ -228,12 +231,13 @@ void KeepassMainWindow::setupIcons(){
ExtrasSettingsAction->setIcon(getIcon("appsettings")); ExtrasSettingsAction->setIcon(getIcon("appsettings"));
ExtrasShowExpiredEntriesAction->setIcon(getIcon("expired")); ExtrasShowExpiredEntriesAction->setIcon(getIcon("expired"));
ExtrasPasswordGenAction->setIcon(getIcon("generator")); ExtrasPasswordGenAction->setIcon(getIcon("generator"));
ExtrasTrashCanAction->setIcon(getIcon("trashcan"));
EditAutoTypeAction->setIcon(getIcon("autotype")); EditAutoTypeAction->setIcon(getIcon("autotype"));
HelpHandbookAction->setIcon(getIcon("manual")); HelpHandbookAction->setIcon(getIcon("manual"));
HelpAboutAction->setIcon(getIcon("help")); HelpAboutAction->setIcon(getIcon("help"));
SysTray->setIcon(getIcon("keepassx_large")); SysTray->setIcon(getIcon("keepassx_large"));
if(config.ShowSysTrayIcon) if(config->showSysTrayIcon())
SysTray->show(); SysTray->show();
} }
void KeepassMainWindow::setupMenus(){ void KeepassMainWindow::setupMenus(){
@ -245,7 +249,7 @@ void KeepassMainWindow::setupMenus(){
GroupView->ContextMenu->addSeparator(); GroupView->ContextMenu->addSeparator();
GroupView->ContextMenu->addAction(EditGroupSearchAction); GroupView->ContextMenu->addAction(EditGroupSearchAction);
GroupView->ContextMenuSearchGroup->addAction(HideSearchResultsAction); GroupView->ContextMenuSearchGroup->addAction(HideSearchResultsAction);
EntryView->ContextMenu->addAction(EditPasswordToClipboardAction); EntryView->ContextMenu->addAction(EditPasswordToClipboardAction);
EntryView->ContextMenu->addAction(EditUsernameToClipboardAction); EntryView->ContextMenu->addAction(EditUsernameToClipboardAction);
EntryView->ContextMenu->addAction(EditOpenUrlAction); EntryView->ContextMenu->addAction(EditOpenUrlAction);
@ -256,13 +260,13 @@ void KeepassMainWindow::setupMenus(){
EntryView->ContextMenu->addAction(EditEditEntryAction); EntryView->ContextMenu->addAction(EditEditEntryAction);
EntryView->ContextMenu->addAction(EditCloneEntryAction); EntryView->ContextMenu->addAction(EditCloneEntryAction);
EntryView->ContextMenu->addAction(EditDeleteEntryAction); EntryView->ContextMenu->addAction(EditDeleteEntryAction);
ViewShowToolbarAction->setText(tr("Show Toolbar")); ViewShowToolbarAction->setText(tr("Show Toolbar"));
ViewMenu->insertAction(ViewShowEntryDetailsAction,ViewShowToolbarAction); ViewMenu->insertAction(ViewShowEntryDetailsAction,ViewShowToolbarAction);
ViewShowToolbarAction->setChecked(config.Toolbar); ViewShowToolbarAction->setChecked(config->showToolbar());
ViewShowEntryDetailsAction->setChecked(config.EntryDetails); ViewShowEntryDetailsAction->setChecked(config->showEntryDetails());
ViewHidePasswordsAction->setChecked(config.ListView_HidePasswords); ViewHidePasswordsAction->setChecked(config->hidePasswords());
ViewHideUsernamesAction->setChecked(config.ListView_HideUsernames); ViewHideUsernamesAction->setChecked(config->hideUsernames());
ViewColumnsTitleAction->setChecked(EntryView->Columns[0]); ViewColumnsTitleAction->setChecked(EntryView->Columns[0]);
ViewColumnsUsernameAction->setChecked(EntryView->Columns[1]); ViewColumnsUsernameAction->setChecked(EntryView->Columns[1]);
ViewColumnsUrlAction->setChecked(EntryView->Columns[2]); ViewColumnsUrlAction->setChecked(EntryView->Columns[2]);
@ -274,36 +278,36 @@ void KeepassMainWindow::setupMenus(){
ViewColumnsLastAccessAction->setChecked(EntryView->Columns[8]); ViewColumnsLastAccessAction->setChecked(EntryView->Columns[8]);
ViewColumnsAttachmentAction->setChecked(EntryView->Columns[9]); ViewColumnsAttachmentAction->setChecked(EntryView->Columns[9]);
ViewColumnsGroupAction->setChecked(EntryView->Columns[10]); ViewColumnsGroupAction->setChecked(EntryView->Columns[10]);
ViewShowStatusbarAction->setChecked(config.ShowStatusbar); ViewShowStatusbarAction->setChecked(config->showStatusbar());
switch(config.ToolbarIconSize){ switch(config->toolbarIconSize()){
case 16: ViewToolButtonSize16Action->setChecked(true); break; case 16: ViewToolButtonSize16Action->setChecked(true); break;
case 22: ViewToolButtonSize22Action->setChecked(true); break; case 22: ViewToolButtonSize22Action->setChecked(true); break;
case 28: ViewToolButtonSize28Action->setChecked(true); break; case 28: ViewToolButtonSize28Action->setChecked(true); break;
} }
SysTrayMenu = new QMenu(tr("KeePassX"),this); SysTrayMenu = new QMenu(tr("KeePassX"),this);
SysTrayMenu->addAction(FileExitAction); SysTrayMenu->addAction(FileExitAction);
SysTray->setContextMenu(SysTrayMenu); SysTray->setContextMenu(SysTrayMenu);
#define _add_import(name){\ #define _add_import(name){\
QAction* import=new QAction(this);\ QAction* import=new QAction(this);\
import->setData(qVariantFromValue(dynamic_cast<QObject*>(&name)));\ import->setData(qVariantFromValue(dynamic_cast<QObject*>(&name)));\
import->setText(name.title());\ import->setText(name.title());\
menuImport->addAction(import);} menuImport->addAction(import);}
#define _add_export(name){\ #define _add_export(name){\
QAction* Export=new QAction(this);\ QAction* Export=new QAction(this);\
Export->setData(qVariantFromValue(dynamic_cast<QObject*>(&name)));\ Export->setData(qVariantFromValue(dynamic_cast<QObject*>(&name)));\
Export->setText(name.title());\ Export->setText(name.title());\
menuExport->addAction(Export);} menuExport->addAction(Export);}
_add_import(import_KeePassX_Xml) _add_import(import_KeePassX_Xml)
_add_import(import_PwManager) _add_import(import_PwManager)
_add_import(import_KWalletXml) _add_import(import_KWalletXml)
_add_export(export_Txt); _add_export(export_Txt);
_add_export(export_KeePassX_Xml); _add_export(export_KeePassX_Xml);
//FileNewMenu->setShortcut(tr("Ctrl+N")); //FileNewMenu->setShortcut(tr("Ctrl+N"));
FileOpenAction->setShortcut(tr("Ctrl+O")); FileOpenAction->setShortcut(tr("Ctrl+O"));
FileSaveAction->setShortcut(tr("Ctrl+S")); FileSaveAction->setShortcut(tr("Ctrl+S"));
@ -322,6 +326,8 @@ void KeepassMainWindow::setupMenus(){
FileSaveAsAction->setShortcut(tr("Shift+Ctrl+S")); FileSaveAsAction->setShortcut(tr("Shift+Ctrl+S"));
EditGroupSearchAction->setShortcut(tr("Shift+Ctrl+F")); EditGroupSearchAction->setShortcut(tr("Shift+Ctrl+F"));
#endif #endif
ExtrasTrashCanAction->setVisible(false); //For KP 2.x only
} }
void KeepassMainWindow::setupDatabaseConnections(IDatabase* DB){ void KeepassMainWindow::setupDatabaseConnections(IDatabase* DB){
@ -336,8 +342,8 @@ void KeepassMainWindow::setupDatabaseConnections(IDatabase* DB){
void KeepassMainWindow::openDatabase(QString filename,bool IsAuto){ void KeepassMainWindow::openDatabase(QString filename,bool IsAuto){
if(!IsAuto){ if(!IsAuto){
config.LastKeyLocation=QString(); config->setLastKeyLocation(QString());
config.LastKeyType=PASSWORD;} config->setLastKeyType(PASSWORD);}
db=dynamic_cast<IDatabase*>(new Kdb3Database()); db=dynamic_cast<IDatabase*>(new Kdb3Database());
CPasswordDialog PasswordDlg(this,db,IsAuto,false); CPasswordDialog PasswordDlg(this,db,IsAuto,false);
PasswordDlg.setWindowTitle(filename); PasswordDlg.setWindowTitle(filename);
@ -409,10 +415,10 @@ void KeepassMainWindow::OnFileNewKdb(){
if(dlg.exec()==1){ if(dlg.exec()==1){
if(FileOpen) if(FileOpen)
if(!closeDatabase())return; if(!closeDatabase())return;
db=dynamic_cast<IDatabase*>(db_new); db=dynamic_cast<IDatabase*>(db_new);
setWindowTitle(tr("%1 - KeePassX").arg(tr("[new]"))); setWindowTitle(tr("%1 - KeePassX").arg(tr("[new]")));
GroupView->db=db; GroupView->db=db;
EntryView->db=db; EntryView->db=db;
GroupView->createItems(); GroupView->createItems();
EntryView->showGroup(NULL); EntryView->showGroup(NULL);
setStateFileOpen(true); setStateFileOpen(true);
@ -423,15 +429,15 @@ void KeepassMainWindow::OnFileNewKdb(){
setStateEntrySelected(NONE); setStateEntrySelected(NONE);
} }
else{ else{
delete db_new; delete db_new;
} }
} }
void KeepassMainWindow::OnFileNewKxdb(){ void KeepassMainWindow::OnFileNewKxdb(){
} }
@ -526,7 +532,7 @@ void KeepassMainWindow::setStateGroupSelected(SelectionState s){
EditDeleteGroupAction->setEnabled(false); EditDeleteGroupAction->setEnabled(false);
EditGroupSearchAction->setEnabled(false); EditGroupSearchAction->setEnabled(false);
EditNewEntryAction->setEnabled(false); EditNewEntryAction->setEnabled(false);
break; break;
default: Q_ASSERT(false); default: Q_ASSERT(false);
} }
} }
@ -536,15 +542,15 @@ void KeepassMainWindow::updateDetailView(){
DetailView->setPlainText(""); DetailView->setPlainText("");
return; return;
} }
QString templ=DetailViewTemplate; QString templ=DetailViewTemplate;
IEntryHandle* entry=((EntryViewItem*)(EntryView->selectedItems()[0]))->EntryHandle; IEntryHandle* entry=((EntryViewItem*)(EntryView->selectedItems()[0]))->EntryHandle;
templ.replace("%group%",entry->group()->title()); templ.replace("%group%",entry->group()->title());
templ.replace("%title%",entry->title()); templ.replace("%title%",entry->title());
if(config.ListView_HideUsernames)templ.replace("%username%","****"); if(config->hideUsernames())templ.replace("%username%","****");
else templ.replace("%username%",entry->username()); else templ.replace("%username%",entry->username());
if(!config.ListView_HidePasswords){ if(!config->hidePasswords()){
SecString password=entry->password(); SecString password=entry->password();
password.unlock(); password.unlock();
templ.replace("%password%",password.string()); templ.replace("%password%",password.string());
@ -557,11 +563,11 @@ void KeepassMainWindow::updateDetailView(){
templ.replace("%expire%",entry->expire().toString(Qt::LocalDate)); templ.replace("%expire%",entry->expire().toString(Qt::LocalDate));
templ.replace("%comment%",entry->comment()); templ.replace("%comment%",entry->comment());
templ.replace("%attachment%",entry->binaryDesc()); templ.replace("%attachment%",entry->binaryDesc());
if(entry->expire()!=Date_Never){ if(entry->expire()!=Date_Never){
int secs=QDateTime::currentDateTime().secsTo(entry->expire()); int secs=QDateTime::currentDateTime().secsTo(entry->expire());
if(secs < 0) if(secs < 0)
templ.replace("%expire-timeleft%",tr("expired")); templ.replace("%expire-timeleft%",tr("expired"));
else{ else{
int years=0; int years=0;
int months=0; int months=0;
@ -571,21 +577,21 @@ void KeepassMainWindow::updateDetailView(){
months=secs/(86400*30); months=secs/(86400*30);
secs-=months*(86400*30); secs-=months*(86400*30);
days=secs/86400; days=secs/86400;
QString out; QString out;
if(months==1) if(months==1)
out=tr("1 Month"); out=tr("1 Month");
if(months>1) if(months>1)
out=tr("%1 Months").arg(months); out=tr("%1 Months").arg(months);
if(years){ if(years){
if(out!=QString()) if(out!=QString())
out.prepend(tr(", ")); out.prepend(tr(", "));
if(years==1) if(years==1)
out.prepend(tr("1 Year")); out.prepend(tr("1 Year"));
if(years>1) if(years>1)
out.prepend(tr("%1 Years").arg(years)); out.prepend(tr("%1 Years").arg(years));
} }
else if(days){ else if(days){
if(out!=QString()) if(out!=QString())
@ -593,18 +599,18 @@ void KeepassMainWindow::updateDetailView(){
if(days==1) if(days==1)
out.append(tr("1 Day")); out.append(tr("1 Day"));
if(days>1) if(days>1)
out.append(tr("%1 Days").arg(days)); out.append(tr("%1 Days").arg(days));
} }
if(!days && !years && !months) if(!days && !years && !months)
out=tr("less than 1 day"); out=tr("less than 1 day");
templ.replace("%expire-timeleft%",out); templ.replace("%expire-timeleft%",out);
} }
} }
else else
templ.replace("%expire-timeleft%","-"); templ.replace("%expire-timeleft%","-");
DetailView->setHtml(templ); DetailView->setHtml(templ);
} }
@ -703,7 +709,7 @@ if(db->save())
setStateFileModified(false); setStateFileModified(false);
else{ else{
showErrMsg(tr("File could not be saved.\n%1").arg(db->getError())); showErrMsg(tr("File could not be saved.\n%1").arg(db->getError()));
return false; return false;
} }
return true; return true;
} }
@ -716,7 +722,7 @@ bool KeepassMainWindow::OnFileSaveAs(){
showErrMsg(tr("File could not be saved.\n%1").arg(db->getError())); showErrMsg(tr("File could not be saved.\n%1").arg(db->getError()));
db->changeFile(QString()); db->changeFile(QString());
setWindowTitle(tr("KeePassX - [unsaved]").arg(filename)); setWindowTitle(tr("KeePassX - [unsaved]").arg(filename));
return false; return false;
} }
setWindowTitle(tr("%1 - KeePassX").arg(filename)); setWindowTitle(tr("%1 - KeePassX").arg(filename));
return OnFileSave(); return OnFileSave();
@ -740,7 +746,7 @@ void KeepassMainWindow::OnFileExit(){
void KeepassMainWindow::OnExport(QAction* action){ void KeepassMainWindow::OnExport(QAction* action){
dynamic_cast<IExport*>(action->data().value<QObject*>())->exportDatabase(this,db); dynamic_cast<IExport*>(action->data().value<QObject*>())->exportDatabase(this,db);
} }
void KeepassMainWindow::OnImport(QAction* action){ void KeepassMainWindow::OnImport(QAction* action){
@ -767,7 +773,7 @@ void KeepassMainWindow::OnImport(QAction* action){
} }
else else
delete tmpdb; delete tmpdb;
} }
@ -802,7 +808,7 @@ void KeepassMainWindow::OnGroupSearch(){
void KeepassMainWindow::OnQuickSearch(){ void KeepassMainWindow::OnQuickSearch(){
EntryView->SearchResults=db->search(NULL,QuickSearchEdit->text(),false,false,false,NULL); EntryView->SearchResults=db->search(NULL,QuickSearchEdit->text(),false,false,false,NULL);
GroupView->showSearchResults(); GroupView->showSearchResults();
} }
void KeepassMainWindow::OnColumnVisibilityChanged(QAction* action){ void KeepassMainWindow::OnColumnVisibilityChanged(QAction* action){
@ -818,12 +824,12 @@ void KeepassMainWindow::OnColumnVisibilityChanged(QAction* action){
EntryView->Columns[9]=ViewColumnsAttachmentAction->isChecked(); EntryView->Columns[9]=ViewColumnsAttachmentAction->isChecked();
EntryView->Columns[10]=ViewColumnsGroupAction->isChecked(); EntryView->Columns[10]=ViewColumnsGroupAction->isChecked();
EntryView->updateColumns(); EntryView->updateColumns();
//if(FileOpen) EntryView->updateItems(); if(FileOpen) EntryView->refreshItems();
} }
void KeepassMainWindow::OnUsernPasswVisibilityChanged(bool value){ void KeepassMainWindow::OnUsernPasswVisibilityChanged(bool value){
config.ListView_HidePasswords=ViewHidePasswordsAction->isChecked(); config->setHidePasswords(ViewHidePasswordsAction->isChecked());
config.ListView_HideUsernames=ViewHideUsernamesAction->isChecked(); config->setHideUsernames(ViewHideUsernamesAction->isChecked());
EntryView->refreshItems(); EntryView->refreshItems();
} }
@ -832,19 +838,19 @@ setStateFileModified(true);
} }
void KeepassMainWindow::closeEvent(QCloseEvent* e){ void KeepassMainWindow::closeEvent(QCloseEvent* e){
if(!ShutingDown && config.MinimizeToTray){ if(!ShutingDown && config->minimizeToTray()){
e->ignore(); e->ignore();
hide(); hide();
return; return;
} }
settings->setValue("Ui/MainWindowGeometry",QVariant(geometry())); config->setMainWindowGeometry(geometry());
settings->setValue("Ui/VSplitterPos",VSplitter->saveState()); config->setVSplitterPos(VSplitter->saveState());
settings->setValue("Ui/HSplitterPos",HSplitter->saveState()); config->setHSplitterPos(HSplitter->saveState());
config.ShowStatusbar=statusBar()->isVisible(); config->setShowStatusbar(statusBar()->isVisible());
if(FileOpen){ if(FileOpen){
if(!closeDatabase()){ if(!closeDatabase()){
ShutingDown=false; ShutingDown=false;
e->ignore(); e->ignore();
return;} return;}
@ -860,8 +866,8 @@ void KeepassMainWindow::closeEvent(QCloseEvent* e){
void KeepassMainWindow::OnExtrasSettings(){ void KeepassMainWindow::OnExtrasSettings(){
CSettingsDlg dlg(this); CSettingsDlg dlg(this);
if(dlg.exec()==QDialog::Accepted){ if(dlg.exec()==QDialog::Accepted){
EntryView->setAlternatingRowColors(config.AlternatingRowColors); EntryView->setAlternatingRowColors(config->alternatingRowColors());
SysTray->setVisible(config.ShowSysTrayIcon); SysTray->setVisible(config->showSysTrayIcon());
} }
} }
@ -875,13 +881,13 @@ openBrowser(AppDir+"/../share/doc/keepass/index.html");
} }
void KeepassMainWindow::OnViewShowToolbar(bool show){ void KeepassMainWindow::OnViewShowToolbar(bool show){
config.Toolbar=show; config->setShowToolbar(show);
toolBar->setVisible(config.Toolbar); toolBar->setVisible(show);
} }
void KeepassMainWindow::OnViewShowEntryDetails(bool show){ void KeepassMainWindow::OnViewShowEntryDetails(bool show){
config.EntryDetails=show; config->setShowEntryDetails(show);
DetailView->setVisible(config.EntryDetails); DetailView->setVisible(show);
} }
void KeepassMainWindow::OnItemExpanded(QTreeWidgetItem* item){ void KeepassMainWindow::OnItemExpanded(QTreeWidgetItem* item){
@ -896,7 +902,7 @@ void KeepassMainWindow::OnGroupSelectionChanged(IGroupHandle* group){
if(group) if(group)
setStateGroupSelected(SINGLE); setStateGroupSelected(SINGLE);
else else
setStateGroupSelected(NONE); setStateGroupSelected(NONE);
} }
void KeepassMainWindow::OnEntryChanged(SelectionState Selection){ void KeepassMainWindow::OnEntryChanged(SelectionState Selection){
@ -905,7 +911,7 @@ void KeepassMainWindow::OnEntryChanged(SelectionState Selection){
} }
void KeepassMainWindow::OnShowSearchResults(){ void KeepassMainWindow::OnShowSearchResults(){
setStateGroupSelected(SEARCHGROUP); setStateGroupSelected(SEARCHGROUP);
} }
@ -913,24 +919,24 @@ void KeepassMainWindow::OnViewToolbarIconSize16(bool state){
if(!state)return; if(!state)return;
ViewToolButtonSize22Action->setChecked(false); ViewToolButtonSize22Action->setChecked(false);
ViewToolButtonSize28Action->setChecked(false); ViewToolButtonSize28Action->setChecked(false);
config.ToolbarIconSize=16; config->setToolbarIconSize(16);
toolBar->setIconSize(QSize(config.ToolbarIconSize,config.ToolbarIconSize)); toolBar->setIconSize(QSize(16,16));
} }
void KeepassMainWindow::OnViewToolbarIconSize22(bool state){ void KeepassMainWindow::OnViewToolbarIconSize22(bool state){
if(!state)return; if(!state)return;
ViewToolButtonSize16Action->setChecked(false); ViewToolButtonSize16Action->setChecked(false);
ViewToolButtonSize28Action->setChecked(false); ViewToolButtonSize28Action->setChecked(false);
config.ToolbarIconSize=22; config->setToolbarIconSize(22);
toolBar->setIconSize(QSize(config.ToolbarIconSize,config.ToolbarIconSize)); toolBar->setIconSize(QSize(22,22));
} }
void KeepassMainWindow::OnViewToolbarIconSize28(bool state){ void KeepassMainWindow::OnViewToolbarIconSize28(bool state){
if(!state)return; if(!state)return;
ViewToolButtonSize16Action->setChecked(false); ViewToolButtonSize16Action->setChecked(false);
ViewToolButtonSize22Action->setChecked(false); ViewToolButtonSize22Action->setChecked(false);
config.ToolbarIconSize=28; config->setToolbarIconSize(28);
toolBar->setIconSize(QSize(config.ToolbarIconSize,config.ToolbarIconSize)); toolBar->setIconSize(QSize(28,28));
} }
void KeepassMainWindow::OnSysTrayActivated(QSystemTrayIcon::ActivationReason reason){ void KeepassMainWindow::OnSysTrayActivated(QSystemTrayIcon::ActivationReason reason){
@ -940,21 +946,21 @@ void KeepassMainWindow::OnSysTrayActivated(QSystemTrayIcon::ActivationReason rea
void KeepassMainWindow::OnExtrasPasswordGen(){ void KeepassMainWindow::OnExtrasPasswordGen(){
CGenPwDialog dlg(this,true); CGenPwDialog dlg(this,true);
dlg.exec(); dlg.exec();
} }
void KeepassMainWindow::saveLastFilename(const QString& filename){ void KeepassMainWindow::saveLastFilename(const QString& filename){
if(settings->value("OpenLastFile",true).toBool()){ if(config->openLastFile()){
if(settings->value("SaveRelativePath",true).toBool()){ if(config->saveRelativePaths()){
QString Path=filename.left(filename.lastIndexOf("/")); QString Path=filename.left(filename.lastIndexOf("/"));
Path=makePathRelative(Path,QDir::currentPath()); Path=makePathRelative(Path,QDir::currentPath());
settings->setValue("LastFile",Path+filename.right(filename.length()-filename.lastIndexOf("/")-1)); config->setLastFile(Path+filename.right(filename.length()-filename.lastIndexOf("/")-1));
} }
else else
settings->setValue("LastFile",filename); config->setLastFile(filename);
} }
} }
void KeepassMainWindow::OnExtrasShowExpiredEntries(){ void KeepassMainWindow::OnExtrasShowExpiredEntries(){
@ -963,5 +969,18 @@ void KeepassMainWindow::OnExtrasShowExpiredEntries(){
GroupView->setCurrentGroup(dlg.SelectedEntry->group()); GroupView->setCurrentGroup(dlg.SelectedEntry->group());
EntryView->setCurrentEntry(dlg.SelectedEntry); EntryView->setCurrentEntry(dlg.SelectedEntry);
} }
}
void KeepassMainWindow::OnExtrasTrashCan(){
TrashCanDialog dlg(this,db,db->expiredEntries());
if(dlg.exec()==QDialog::Accepted){
}
} }
void KeepassMainWindow::OnDetailViewUrlClicked(const QUrl& url){
openBrowser(url.toString());
}

@ -38,9 +38,10 @@
#include <QTimer> #include <QTimer>
#include <QToolButton> #include <QToolButton>
#include <QSystemTrayIcon> #include <QSystemTrayIcon>
#include <QUrl>
#include "StandardDatabase.h" #include "Kdb3Database.h"
#include "PwmConfig.h" #include "KpxConfig.h"
#include "lib/EntryView.h" #include "lib/EntryView.h"
#include "lib/GroupView.h" #include "lib/GroupView.h"
#include "export/Export.h" #include "export/Export.h"
@ -53,10 +54,10 @@ class KeepassMainWindow : public QMainWindow, public Ui_MainWindow{
KeepassMainWindow (const QString& ArgFile,QWidget *parent=0, Qt::WFlags flags=0); KeepassMainWindow (const QString& ArgFile,QWidget *parent=0, Qt::WFlags flags=0);
IDatabase* db; IDatabase* db;
bool Start; bool Start;
signals: signals:
void entryChanged(); void entryChanged();
private slots: private slots:
void OnFileNewKdb(); void OnFileNewKdb();
void OnFileNewKxdb(); void OnFileNewKxdb();
@ -82,6 +83,7 @@ class KeepassMainWindow : public QMainWindow, public Ui_MainWindow{
void OnExtrasSettings(); void OnExtrasSettings();
void OnExtrasPasswordGen(); void OnExtrasPasswordGen();
void OnExtrasShowExpiredEntries(); void OnExtrasShowExpiredEntries();
void OnExtrasTrashCan();
void OnHelpAbout(); void OnHelpAbout();
void OnHelpHandbook(); void OnHelpHandbook();
void OnItemExpanded(QTreeWidgetItem*); void OnItemExpanded(QTreeWidgetItem*);
@ -91,7 +93,8 @@ class KeepassMainWindow : public QMainWindow, public Ui_MainWindow{
void OnSysTrayActivated(QSystemTrayIcon::ActivationReason); void OnSysTrayActivated(QSystemTrayIcon::ActivationReason);
void OnImport(QAction*); void OnImport(QAction*);
void OnExport(QAction*); void OnExport(QAction*);
void OnDetailViewUrlClicked(const QUrl& url);
private: private:
void closeEvent(QCloseEvent* event); void closeEvent(QCloseEvent* event);
SelectionState GroupSelection, EntrySelection; SelectionState GroupSelection, EntrySelection;

@ -1,5 +1,5 @@
/*************************************************************************** /***************************************************************************
* Copyright (C) 2005-2006 by Tarek Saidi * * Copyright (C) 2005-2007 by Tarek Saidi *
* tarek.saidi@arcor.de * * tarek.saidi@arcor.de *
* * * *
* This program is free software; you can redistribute it and/or modify * * This program is free software; you can redistribute it and/or modify *
@ -27,12 +27,12 @@ class IFileDialog{
public: public:
virtual ~IFileDialog(){} virtual ~IFileDialog(){}
virtual QString openExistingFileDialog(QWidget* parent,QString title,QString dir, virtual QString openExistingFileDialog(QWidget* parent,QString title,QString dir,
QStringList Filters)=0; QStringList Filters,int SelectedFilter)=0;
virtual QStringList openExistingFilesDialog(QWidget* parent,QString title,QString dir, virtual QStringList openExistingFilesDialog(QWidget* parent,QString title,QString dir,
QStringList Filters)=0; QStringList Filters,int SelectedFilter)=0;
virtual QString saveFileDialog(QWidget* parent,QString title,QString dir, virtual QString saveFileDialog(QWidget* parent,QString title,QString dir,
QStringList Filters,bool ShowOverwriteWarning=true)=0; QStringList Filters,int SelectedFilter, bool ShowOverwriteWarning=true)=0;
virtual int getLastFilter()=0; virtual int getLastFilter()=0;
}; };

@ -11,7 +11,7 @@ DEPENDPATH += "crypto \
translations \ translations \
res" res"
INSTALLS += target data INSTALLS += target data
data.files += ../share/keepass/* data.files += ../share/keepass/*
TARGET = ../bin/keepassx TARGET = ../bin/keepassx
unix: !macx{ unix: !macx{
@ -51,6 +51,7 @@ FORMS += forms/EditGroupDlg.ui \
forms/CollectEntropyDlg.ui \ forms/CollectEntropyDlg.ui \
forms/CustomizeDetailViewDlg.ui \ forms/CustomizeDetailViewDlg.ui \
forms/CalendarDlg.ui \ forms/CalendarDlg.ui \
forms/TrashCanDlg.ui \
forms/ExpiredEntriesDlg.ui forms/ExpiredEntriesDlg.ui
TRANSLATIONS += translations/keepass-de_DE.ts \ TRANSLATIONS += translations/keepass-de_DE.ts \
translations/keepass-ru_RU.ts \ translations/keepass-ru_RU.ts \
@ -61,7 +62,7 @@ TRANSLATIONS += translations/keepass-de_DE.ts \
HEADERS += lib/IniReader.h \ HEADERS += lib/IniReader.h \
lib/UrlLabel.h \ lib/UrlLabel.h \
mainwindow.h \ mainwindow.h \
StandardDatabase.h \ Kdb3Database.h \
lib/SecString.h \ lib/SecString.h \
crypto/twoclass.h \ crypto/twoclass.h \
crypto/twofish.h \ crypto/twofish.h \
@ -72,7 +73,6 @@ HEADERS += lib/IniReader.h \
export/Export_KeePassX_Xml.h \ export/Export_KeePassX_Xml.h \
export/Export.h \ export/Export.h \
import/Import_KWalletXml.h \ import/Import_KWalletXml.h \
PwmConfig.h \
dialogs/AboutDlg.h \ dialogs/AboutDlg.h \
dialogs/EditGroupDlg.h \ dialogs/EditGroupDlg.h \
dialogs/SearchDlg.h \ dialogs/SearchDlg.h \
@ -87,6 +87,7 @@ HEADERS += lib/IniReader.h \
dialogs/CustomizeDetailViewDlg.h \ dialogs/CustomizeDetailViewDlg.h \
dialogs/CalendarDlg.h \ dialogs/CalendarDlg.h \
dialogs/ExpiredEntriesDlg.h \ dialogs/ExpiredEntriesDlg.h \
dialogs/TrashCanDlg.h \
lib/random.h \ lib/random.h \
Database.h \ Database.h \
lib/KdePlugin.h \ lib/KdePlugin.h \
@ -112,12 +113,12 @@ HEADERS += lib/IniReader.h \
plugins/interfaces/IFileDialog.h \ plugins/interfaces/IFileDialog.h \
plugins/interfaces/IKdeInit.h \ plugins/interfaces/IKdeInit.h \
plugins/interfaces/IGnomeInit.h \ plugins/interfaces/IGnomeInit.h \
KpxConfig.h \
KpxFirefox.h KpxFirefox.h
SOURCES += lib/IniReader.cpp \ SOURCES += lib/UrlLabel.cpp \
lib/UrlLabel.cpp \
main.cpp \ main.cpp \
mainwindow.cpp \ mainwindow.cpp \
StandardDatabase.cpp \ Kdb3Database.cpp \
lib/SecString.cpp \ lib/SecString.cpp \
crypto/twoclass.cpp \ crypto/twoclass.cpp \
crypto/twofish.cpp \ crypto/twofish.cpp \
@ -130,7 +131,6 @@ SOURCES += lib/IniReader.cpp \
export/Export_KeePassX_Xml.cpp \ export/Export_KeePassX_Xml.cpp \
export/Export.cpp \ export/Export.cpp \
import/Import_KWalletXml.cpp \ import/Import_KWalletXml.cpp \
PwmConfig.cpp \
dialogs/AboutDlg.cpp \ dialogs/AboutDlg.cpp \
dialogs/EditGroupDlg.cpp \ dialogs/EditGroupDlg.cpp \
dialogs/SearchDlg.cpp \ dialogs/SearchDlg.cpp \
@ -145,6 +145,7 @@ SOURCES += lib/IniReader.cpp \
dialogs/CustomizeDetailViewDlg.cpp \ dialogs/CustomizeDetailViewDlg.cpp \
dialogs/CalendarDlg.cpp \ dialogs/CalendarDlg.cpp \
dialogs/ExpiredEntriesDlg.cpp \ dialogs/ExpiredEntriesDlg.cpp \
dialogs/TrashCanDlg.cpp \
lib/random.cpp \ lib/random.cpp \
Database.cpp \ Database.cpp \
lib/KdePlugin.cpp \ lib/KdePlugin.cpp \
@ -160,6 +161,7 @@ SOURCES += lib/IniReader.cpp \
crypto/sha256.cpp \ crypto/sha256.cpp \
crypto/yarrow.cpp \ crypto/yarrow.cpp \
lib/WaitAnimationWidget.cpp \ lib/WaitAnimationWidget.cpp \
KpxConfig.cpp \
KpxFirefox.cpp KpxFirefox.cpp
RESOURCES += res/resources.qrc RESOURCES += res/resources.qrc
MOC_DIR = ../build/moc MOC_DIR = ../build/moc