new config system

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

@ -300,8 +300,6 @@ public:
/*! \return the last error message or an empty QString() object if no error occured.*/
virtual QString getError()=0;
/*! Creates a clone of a given entry.
All attributes besides the UUID are copied, even the creation date.
\param entry The handle of the entry which should be cloned.
@ -399,6 +397,14 @@ public:
\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;
//! 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,8 +34,9 @@
#include "crypto/yarrow.h"
#include "lib/random.h"
using namespace std;
#include "StandardDatabase.h"
#include "Kdb3Database.h"
#include "main.h"
#include "KpxConfig.h"
#define UNEXP_ERROR error=QString("Unexpected error in: %1, Line:%2").arg(__FILE__).arg(__LINE__);
@ -412,17 +413,18 @@ void Kdb3Database::createHandles(){
}
void Kdb3Database::restoreGroupTreeState(){
if(settings->value("GroupTreeState","ExpandAll")=="ExpandAll"){
for(int i=0;i<Groups.size();i++){
Groups[i].IsExpanded=true;
}
}
else
if(settings->value("GroupTreeState","ExpandAll")=="Restore"){
switch (config->groupTreeState()){
case KpxConfig::RestoreLast:
for(int i=0;i<Groups.size();i++){
if(TreeStateMetaStream.contains(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;
}
}
@ -977,7 +979,6 @@ void Kdb3Database::EntryHandle::setVisualIndex(int index){
Kdb3Database::EntryHandle::EntryHandle(Kdb3Database* db){
pDB=db;
ListIndex=0;
valid=true;
}
@ -1675,3 +1676,31 @@ bool Kdb3Database::changeFile(const QString& filename){
}
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 StdEntry;
class EntryHandle:public IEntryHandle{
friend class Kdb3Database;
public:
EntryHandle(Kdb3Database* db);
@ -94,11 +95,11 @@ public:
private:
void invalidate(){valid=false;}
bool valid;
unsigned int ListIndex;
KpxUuid Uuid;
//KpxUuid Uuid; ???
Kdb3Database* pDB;
StdEntry* Entry;
};
class GroupHandle:public IGroupHandle{
friend class Kdb3Database;
GroupHandle(Kdb3Database* db);
@ -123,8 +124,10 @@ public:
StdGroup* Group;
Kdb3Database* pDB;
};
friend class EntryHandle;
friend class GroupHandle;
class StdEntry:public CEntry{
public:
quint32 OldImage;
@ -132,6 +135,7 @@ public:
EntryHandle* Handle;
StdGroup* Group;
};
class StdGroup:public CGroup{
public:
StdGroup():CGroup(){};
@ -143,6 +147,12 @@ public:
QList<StdGroup*> Childs;
QList<StdEntry*> Entries;
};
class TrashEntry: public StdEntry{
public:
QStringList GroupPath;
};
virtual ~Kdb3Database(){};
virtual bool load(QString identifier);
virtual bool save();
@ -182,6 +192,9 @@ public:
virtual IEntryHandle* addEntry(const CEntry* NewEntry, IGroupHandle* group);
virtual void moveEntry(IEntryHandle* entry, IGroupHandle* group);
virtual void deleteLastEntry();
virtual void moveToTrash(IEntryHandle* entry);
virtual QList<IEntryHandle*> trashEntries();
virtual void emptyTrash();
virtual QList<IGroupHandle*> groups();
@ -232,8 +245,10 @@ private:
QList<EntryHandle> EntryHandles;
QList<GroupHandle> GroupHandles;
QList<EntryHandle> TrashHandles;
QList<StdEntry> Entries;
QList<StdGroup> Groups;
QList<TrashEntry> TrashEntries;
StdGroup RootGroup;
QList<QPixmap>CustomIcons;
QFile* File;

@ -58,6 +58,9 @@ AboutDialog::AboutDialog(QWidget* parent):QDialog(parent)
str+="<br>";
str+="</div><div style='margin-left:10px;'>";
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);
}

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

@ -19,7 +19,7 @@
***************************************************************************/
#include "main.h"
#include "PwmConfig.h"
#include "KpxConfig.h"
#include <qpushbutton.h>
#include <qpalette.h>
#include <qfont.h>
@ -101,7 +101,7 @@ CEditEntryDlg::CEditEntryDlg(IDatabase* _db, IEntryHandle* _entry,QWidget* paren
Edit_Password->setText(Password.string());
Edit_Password_w->setText(Password.string());
Password.lock();
if(!config.ShowPasswords)
if(!config->showPasswords())
ChangeEchoMode();
OnPasswordwLostFocus();
int bits=(Password.length()*8);
@ -268,7 +268,7 @@ Edit_Password_w->setEchoMode(QLineEdit::Normal);
void CEditEntryDlg::OnPasswordTextChanged(const QString& txt)
{
Edit_Password_w->setText("");
Edit_Password_w->setText(QString());
int bits=(Edit_Password->text().length()*8);
Label_Bits->setText(QString::number(bits)+" Bit");
if(bits>128)bits=128;

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

@ -29,7 +29,7 @@
#include <QStringList>
#include "main.h"
#include "PwmConfig.h"
#include "KpxConfig.h"
#include "PasswordDlg.h"
#include "lib/FileDialogs.h"
@ -40,27 +40,29 @@ CPasswordDialog::CPasswordDialog(QWidget* parent,IDatabase* DB,bool ShowExitButt
setupUi(this);
createBanner(Banner,getPixmap("key"),tr("Database Key"));
db=DB;
QDir media(config.MountDir);
QString mountDir=config->mountDir();
QDir media(mountDir);
if(media.exists()){
QStringList Paths;
Paths=media.entryList(QStringList()<<"*",QDir::Dirs);
Paths.erase(Paths.begin()); // delete "."
Paths.erase(Paths.begin()); // delete ".."
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());
if(settings->value("RememberLastKey",true).toBool() && !ChangeKeyMode){
QString LastKeyType=settings->value("LastKeyType","").toString();
if(LastKeyType=="KeyFile"){
if(config->rememberLastKey() && !ChangeKeyMode){
switch(config->lastKeyType()){
case KEYFILE:
setStateKeyFileOnly();
Combo_Dirs->setEditText(QDir::cleanPath(QDir::current().absoluteFilePath(settings->value("LastKeyFile","").toString())));
}
else if(LastKeyType=="Composite"){
Combo_Dirs->setEditText(QDir::cleanPath(QDir::current().absoluteFilePath(config->lastKeyLocation())));
break;
case BOTH:
setStateBoth();
CheckBox_Both->setChecked(true);
Combo_Dirs->setEditText(QDir::cleanPath(QDir::current().absoluteFilePath(settings->value("LastKeyFile","").toString())));
Combo_Dirs->setEditText(QDir::cleanPath(QDir::current().absoluteFilePath(config->lastKeyLocation())));
}
// if(LastKeyType==Password){... is not required because it is already the default state.
}
@ -86,7 +88,7 @@ CPasswordDialog::CPasswordDialog(QWidget* parent,IDatabase* DB,bool ShowExitButt
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();
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);
return;
}
if(KeyType==BOTH){
if(password==""){
if(password.isEmpty()){
QMessageBox::warning(this,tr("Error"),tr("Please enter a Password."),tr("OK"),"","",0,0);
return;}
if(keyfile==""){
if(keyfile.isEmpty()){
QMessageBox::warning(this,tr("Error"),tr("Please choose a key file."),tr("OK"),"","",0,0);
return;}
}
@ -231,12 +233,12 @@ void CPasswordDialog::OnOK_Set(){
return;
}
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);
return;
}
if(keyfile!=QString()){
if(!keyfile.isEmpty()){
QFile file(keyfile);
if(QFileInfo(file).isDir()){
if(keyfile.right(1)!="/")keyfile+="/";
@ -268,44 +270,39 @@ void CPasswordDialog::OnOK_Set(){
bool CPasswordDialog::doAuth(){
IFilePasswordAuth* DbAuth=dynamic_cast<IFilePasswordAuth*>(db);
if(password!=QString() && keyfile==QString()){
if(!password.isEmpty() && keyfile.isEmpty()){
DbAuth->authByPwd(password);
}
if(password==QString() && keyfile!=QString()){
if(password.isEmpty() && !keyfile.isEmpty()){
if(!DbAuth->authByFile(keyfile))return false;
}
if(password!=QString() && keyfile!=QString()){
if(!password.isEmpty() && !keyfile.isEmpty()){
if(!DbAuth->authByFile(keyfile))return false;
}
if(settings->value("RememberLastKey",true).toBool()){
if(config->rememberLastKey()){
QString KeyLocation=keyfile;
if(settings->value("SaveRelativePaths",true).toBool()){
if(config->saveRelativePaths()){
KeyLocation=KeyLocation.left(KeyLocation.lastIndexOf("/"));
KeyLocation=makePathRelative(KeyLocation,QDir::currentPath())+keyfile.right(keyfile.length()-keyfile.lastIndexOf("/")-1);
}
settings->setValue("LastKeyFile",KeyLocation);
if(KeyType==PASSWORD)
settings->setValue("LastKeyType","Password");
if(KeyType==KEYFILE)
settings->setValue("LastKeyType","KeyFile");
if(KeyType==BOTH)
settings->setValue("LastKeyType","Composite");
config->setLastKeyLocation(KeyLocation);
config->setLastKeyType(KeyType);
}
return true;
}
void CPasswordDialog::OnPasswordChanged(const QString &txt){
Edit_PasswordRep->setText("");
if(CheckBox_Both->isChecked() || txt==QString())
Edit_PasswordRep->setText(QString());
if(CheckBox_Both->isChecked() || txt.isEmpty())
setStateBoth();
else
setStatePasswordOnly();
}
void CPasswordDialog::OnComboTextChanged(const QString& txt){
if(CheckBox_Both->isChecked() || txt==QString())
if(CheckBox_Both->isChecked() || txt.isEmpty())
setStateBoth();
else
setStateKeyFileOnly();
@ -317,17 +314,16 @@ void CPasswordDialog::OnCheckBox_BothChanged(int state){
if(state==Qt::Checked)
setStateBoth();
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());
setStatePasswordOnly();
}
else{
if(Edit_Password->text()==QString())
if(Edit_Password->text().isEmpty())
setStateKeyFileOnly();
else
setStatePasswordOnly();
}
}
}

@ -29,7 +29,7 @@
#include "PasswordGenDlg.h"
#include "CollectEntropyDlg.h"
#include "crypto/yarrow.h"
#include "PwmConfig.h"
#include "KpxConfig.h"
bool CGenPwDialog::EntropyCollected=false;
@ -67,32 +67,35 @@ CGenPwDialog::CGenPwDialog(QWidget* parent, bool StandAloneMode,Qt::WFlags fl)
AcceptButton=NULL;
}
Radio_1->setChecked(config.PwGenOptions[0]);
Radio_2->setChecked(!config.PwGenOptions[0]);
checkBox1->setChecked(config.PwGenOptions[1]);
checkBox2->setChecked(config.PwGenOptions[2]);
checkBox3->setChecked(config.PwGenOptions[3]);
checkBox4->setChecked(config.PwGenOptions[4]);
checkBox5->setChecked(config.PwGenOptions[5]);
checkBox6->setChecked(config.PwGenOptions[6]);
checkBox7->setChecked(config.PwGenOptions[7]);
Check_CollectEntropy->setChecked(config.PwGenOptions[8]);
Check_CollectOncePerSession->setChecked(config.PwGenOptions[9]);
OnRadio1StateChanged(config.PwGenOptions[0]);
OnRadio2StateChanged(!config.PwGenOptions[0]);
QBitArray pwGenOptions=config->pwGenOptions();
Radio_1->setChecked(pwGenOptions.at(0));
Radio_2->setChecked(!pwGenOptions.at(0));
checkBox1->setChecked(pwGenOptions.at(1));
checkBox2->setChecked(pwGenOptions.at(2));
checkBox3->setChecked(pwGenOptions.at(3));
checkBox4->setChecked(pwGenOptions.at(4));
checkBox5->setChecked(pwGenOptions.at(5));
checkBox6->setChecked(pwGenOptions.at(6));
checkBox7->setChecked(pwGenOptions.at(7));
Check_CollectEntropy->setChecked(pwGenOptions.at(8));
Check_CollectOncePerSession->setChecked(pwGenOptions.at(9));
OnRadio1StateChanged(pwGenOptions.at(0));
OnRadio2StateChanged(!pwGenOptions.at(0));
}
CGenPwDialog::~CGenPwDialog(){
config.PwGenOptions[0]=Radio_1->isChecked();
config.PwGenOptions[1]=checkBox1->isChecked();
config.PwGenOptions[2]=checkBox2->isChecked();
config.PwGenOptions[3]=checkBox3->isChecked();
config.PwGenOptions[4]=checkBox4->isChecked();
config.PwGenOptions[5]=checkBox5->isChecked();
config.PwGenOptions[6]=checkBox6->isChecked();
config.PwGenOptions[7]=checkBox7->isChecked();
config.PwGenOptions[8]=Check_CollectEntropy->isChecked();
config.PwGenOptions[9]=Check_CollectOncePerSession->isChecked();
QBitArray pwGenOptions(10);
pwGenOptions.setBit(0,Radio_1->isChecked());
pwGenOptions.setBit(1,checkBox1->isChecked());
pwGenOptions.setBit(2,checkBox2->isChecked());
pwGenOptions.setBit(3,checkBox3->isChecked());
pwGenOptions.setBit(4,checkBox4->isChecked());
pwGenOptions.setBit(5,checkBox5->isChecked());
pwGenOptions.setBit(6,checkBox6->isChecked());
pwGenOptions.setBit(7,checkBox7->isChecked());
pwGenOptions.setBit(8,Check_CollectEntropy->isChecked());
pwGenOptions.setBit(9,Check_CollectOncePerSession->isChecked());
config->setPwGenOptions(pwGenOptions);
}
void CGenPwDialog::paintEvent(QPaintEvent *event){
@ -141,7 +144,7 @@ void CGenPwDialog::OnGeneratePw()
"A...Z" 65...90
"a...z" 97...122
"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
"_" 95
-------------------------------------------------------

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

@ -19,7 +19,7 @@
***************************************************************************/
#include "main.h"
#include "PwmConfig.h"
#include "KpxConfig.h"
#include <qpixmap.h>
#include <qcheckbox.h>
#include <qspinbox.h>
@ -58,53 +58,50 @@ CSettingsDlg::CSettingsDlg(QWidget* parent):QDialog(parent,Qt::Dialog)
createBanner(&BannerPixmap,getPixmap("appsettings"),tr("Settings"),width());
//General
CheckBox_OpenLast->setChecked(settings->value("OpenLastFile",true).toBool());
CheckBox_RememberLastKey->setChecked(settings->value("RememberLastKey",true).toBool());
checkBox_ShowSysTrayIcon->setChecked(config.ShowSysTrayIcon);
checkBox_MinimizeToTray->setChecked(config.MinimizeToTray);
checkBox_SaveFileDlgHistory->setChecked(config.SaveFileDlgHistory);
switch(config.GroupTreeRestore){
case 1:
CheckBox_OpenLast->setChecked(config->openLastFile());
CheckBox_RememberLastKey->setChecked(config->rememberLastKey());
checkBox_ShowSysTrayIcon->setChecked(config->showSysTrayIcon());
checkBox_MinimizeToTray->setChecked(config->minimizeToTray());
checkBox_SaveFileDlgHistory->setChecked(config->saveFileDlgHistory());
checkBox_AskBeforeDelete->setChecked(config->askBeforeDelete());
switch(config->groupTreeState()){
case KpxConfig::RestoreLast:
Radio_GroupTreeRestore->setChecked(true);
break;
case 2:
case KpxConfig::ExpandAll:
Radio_GroupTreeExpand->setChecked(true);
break;
case 3:
default:
Radio_GroupTreeDoNothing->setChecked(true);
}
if(settings->value("GroupTreeState","ExpandAll")=="ExpandAll")Radio_GroupTreeExpand->setChecked(true);
if(settings->value("GroupTreeState","ExpandAll")=="Restore")Radio_GroupTreeRestore->setChecked(true);
if(settings->value("GroupTreeState","ExpandAll")=="ExpandNone")Radio_GroupTreeDoNothing->setChecked(true);
//Appearance
QPixmap *pxt=new QPixmap(pixmTextColor->width(),pixmTextColor->height());
pxt->fill(config.BannerTextColor);
pxt->fill(config->bannerTextColor());
pixmTextColor->clear();
pixmTextColor->setPixmap(*pxt);
QPixmap *px1=new QPixmap(pixmColor1->width(),pixmColor1->height());
px1->fill(config.BannerColor1);
px1->fill(config->bannerColor1());
pixmColor1->clear();
pixmColor1->setPixmap(*px1);
QPixmap *px2=new QPixmap(pixmColor2->width(),pixmColor2->height());
px2->fill(config.BannerColor2);
px2->fill(config->bannerColor2());
pixmColor2->clear();
pixmColor2->setPixmap(*px2);
color1=config.BannerColor1;
color2=config.BannerColor2;
textcolor=config.BannerTextColor;
CheckBox_AlternatingRowColors->setChecked(config.AlternatingRowColors);
color1=config->bannerColor1();
color2=config->bannerColor2();
textcolor=config->bannerTextColor();
CheckBox_AlternatingRowColors->setChecked(config->alternatingRowColors());
//Security
SpinBox_ClipboardTime->setValue(config.ClipboardTimeOut);
CheckBox_ShowPasswords->setChecked(config.ShowPasswords);
CheckBox_ShowPasswords_PasswordDlg->setChecked(config.ShowPasswordsPasswordDlg);
SpinBox_ClipboardTime->setValue(config->clipboardTimeOut());
CheckBox_ShowPasswords->setChecked(config->showPasswords());
CheckBox_ShowPasswords_PasswordDlg->setChecked(config->showPasswordsPasswordDlg());
//Desktop Integration
@ -114,18 +111,23 @@ CSettingsDlg::CSettingsDlg(QWidget* parent):QDialog(parent,Qt::Dialog)
Label_IntPlugin_Error->setText(QString("<html><p style='font-weight:600; color:#8b0000;'>%1</p></body></html>")
.arg(tr("Error: %1")).arg(PluginLoadError));
switch(config.IntegrPlugin){
case CConfig::NONE: Radio_IntPlugin_None->setChecked(true); break;
case CConfig::GNOME: Radio_IntPlugin_Gnome->setChecked(true); break;
case CConfig::KDE: Radio_IntPlugin_Kde->setChecked(true); break;
switch(config->integrPlugin()){
case KpxConfig::KDE:
Radio_IntPlugin_Kde->setChecked(true);
break;
case KpxConfig::Gnome:
Radio_IntPlugin_Gnome->setChecked(true);
break;
default:
Radio_IntPlugin_None->setChecked(true);
}
if(!PluginsModified)
Label_IntPlugin_Info->hide();
//Advanced
QString BrowserCmd=settings->value("BrowserCmd","<<default>>").toString();
if(BrowserCmd=="<<default>>"){
QString BrowserCmd=config->urlCmd();
if(BrowserCmd.isEmpty()){
CheckBox_BrowserDefault->setChecked(true);
Edit_BrowserCmd->setDisabled(true);
}
@ -134,8 +136,8 @@ CSettingsDlg::CSettingsDlg(QWidget* parent):QDialog(parent,Qt::Dialog)
CheckBox_BrowserDefault->setChecked(false);
}
Edit_MountDir->setText(config.MountDir);
CheckBox_SaveRelativePaths->setChecked(settings->value("SaveRelativePaths",true).toBool());
Edit_MountDir->setText(config->mountDir());
CheckBox_SaveRelativePaths->setChecked(config->saveRelativePaths());
}
@ -153,7 +155,7 @@ void CSettingsDlg::paintEvent(QPaintEvent *event){
void CSettingsDlg::OnCheckBoxBrowserDefaultChanged(int state){
if(state==Qt::Checked){
Edit_BrowserCmd->setDisabled(true);
Edit_BrowserCmd->setText("");
Edit_BrowserCmd->setText(QString());
}
else{
Edit_BrowserCmd->setDisabled(false);
@ -179,44 +181,42 @@ void CSettingsDlg::OnOtherButton(QAbstractButton* button){
void CSettingsDlg::apply(){
//General
config.ShowSysTrayIcon=checkBox_ShowSysTrayIcon->isChecked();
config.MinimizeToTray=checkBox_MinimizeToTray->isChecked();
config.SaveFileDlgHistory=checkBox_SaveFileDlgHistory->isChecked();
config.EnableBookmarkMenu=checkBox_EnableBookmarkMenu->isChecked();
if(Radio_GroupTreeRestore->isChecked())config.GroupTreeRestore=0;
if(Radio_GroupTreeExpand->isChecked())config.GroupTreeRestore=1;
if(Radio_GroupTreeDoNothing->isChecked())config.GroupTreeRestore=2;
settings->setValue("OpenLastFile",CheckBox_OpenLast->isChecked());
settings->setValue("RememberLastKey",CheckBox_RememberLastKey->isChecked());
if(Radio_GroupTreeExpand->isChecked())settings->setValue("GroupTreeState","ExpandAll");
if(Radio_GroupTreeDoNothing->isChecked())settings->setValue("GroupTreeState","ExpandNone");
if(Radio_GroupTreeRestore->isChecked())settings->setValue("GroupTreeState","Restore");
config->setShowSysTrayIcon(checkBox_ShowSysTrayIcon->isChecked());
config->setMinimizeToTray(checkBox_MinimizeToTray->isChecked());
config->setSaveFileDlgHistory(checkBox_SaveFileDlgHistory->isChecked());
config->setEnableBookmarkMenu(checkBox_EnableBookmarkMenu->isChecked());
if(Radio_GroupTreeRestore->isChecked())config->setGroupTreeState(KpxConfig::RestoreLast);
else if(Radio_GroupTreeExpand->isChecked())config->setGroupTreeState(KpxConfig::ExpandAll);
else config->setGroupTreeState(KpxConfig::DoNothing);
config->setOpenLastFile(CheckBox_OpenLast->isChecked());
config->setRememberLastKey(CheckBox_RememberLastKey->isChecked());
config->setAskBeforeDelete(checkBox_AskBeforeDelete->isChecked());
//Appearence
config.BannerColor1=color1;
config.BannerColor2=color2;
config.BannerTextColor=textcolor;
config.AlternatingRowColors=CheckBox_AlternatingRowColors->isChecked();
config->setBannerColor1(color1);
config->setBannerColor2(color2);
config->setBannerTextColor(textcolor);
config->setAlternatingRowColors(CheckBox_AlternatingRowColors->isChecked());
//Security
config.ClipboardTimeOut=SpinBox_ClipboardTime->value();
config.ShowPasswords=CheckBox_ShowPasswords->isChecked();
config.ShowPasswordsPasswordDlg=CheckBox_ShowPasswords_PasswordDlg->isChecked();
config->setClipboardTimeOut(SpinBox_ClipboardTime->value());
config->setShowPasswords(CheckBox_ShowPasswords->isChecked());
config->setShowPasswordsPasswordDlg(CheckBox_ShowPasswords_PasswordDlg->isChecked());
//Desktop Integration
PluginsModified=Label_IntPlugin_Info->isVisible();
if(Radio_IntPlugin_None->isChecked())config.IntegrPlugin=CConfig::NONE;
if(Radio_IntPlugin_Gnome->isChecked())config.IntegrPlugin=CConfig::GNOME;
if(Radio_IntPlugin_Kde->isChecked())config.IntegrPlugin=CConfig::KDE;
if(Radio_IntPlugin_Kde->isChecked())config->setIntegrPlugin(KpxConfig::KDE);
else if(Radio_IntPlugin_Gnome->isChecked())config->setIntegrPlugin(KpxConfig::Gnome);
else config->setIntegrPlugin(KpxConfig::NoIntegr);
//Advanced
config.OpenUrlCommand=Edit_BrowserCmd->text();
config.MountDir=Edit_MountDir->text();
if(config.MountDir!="" && config.MountDir.right(1)!="/")
config.MountDir+="/";
if(CheckBox_BrowserDefault->isChecked())settings->setValue("BrowserCmd","<<default>>");
else settings->setValue("BrowserCmd",Edit_BrowserCmd->text());
settings->setValue("SaveRelativePaths",CheckBox_SaveRelativePaths->isChecked());
config->setUrlCmd(Edit_BrowserCmd->text());
config->setMountDir(Edit_MountDir->text());
if(!config->mountDir().isEmpty() && config->mountDir().right(1)!="/")
config->setMountDir(config->mountDir()+"/");
if(CheckBox_BrowserDefault->isChecked())config->setUrlCmd(QString());
else config->setUrlCmd(Edit_BrowserCmd->text());
config->setSaveRelativePaths(CheckBox_SaveRelativePaths->isChecked());
}

@ -21,14 +21,14 @@
#include <QLineEdit>
#include <QPushButton>
#include "main.h"
#include "PwmConfig.h"
#include "KpxConfig.h"
#include "SimplePasswordDlg.h"
SimplePasswordDialog::SimplePasswordDialog(QWidget* parent, bool modal, Qt::WFlags fl)
: QDialog(parent,fl)
{
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::Cancel),SIGNAL(clicked()),this,SLOT(OnCancel()));
connect(Button_HidePassword,SIGNAL(toggled(bool)),this,SLOT(OnHidePasswordToggled(bool)));

@ -6,13 +6,13 @@
<x>0</x>
<y>0</y>
<width>432</width>
<height>230</height>
<height>316</height>
</rect>
</property>
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>5</hsizetype>
<vsizetype>5</vsizetype>
<hsizetype>4</hsizetype>
<vsizetype>4</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -51,6 +51,14 @@
</item>
<item>
<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" >
<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>
@ -81,7 +89,7 @@ Please move the mouse and/or press some keys until enought entropy for a reseed
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>5</hsizetype>
<vsizetype>1</vsizetype>
<vsizetype>0</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -89,7 +97,13 @@ Please move the mouse and/or press some keys until enought entropy for a reseed
<property name="minimumSize" >
<size>
<width>16</width>
<height>45</height>
<height>46</height>
</size>
</property>
<property name="maximumSize" >
<size>
<width>16777215</width>
<height>46</height>
</size>
</property>
<property name="currentIndex" >

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

@ -28,12 +28,21 @@
<bool>true</bool>
</property>
<layout class="QVBoxLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</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>
<spacer>
<property name="orientation" >
@ -69,12 +78,6 @@
<string>General</string>
</attribute>
<layout class="QVBoxLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QCheckBox" name="checkBox_ShowSysTrayIcon" >
<property name="text" >
@ -91,12 +94,21 @@
</item>
<item>
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</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>
<widget class="QCheckBox" name="CheckBox_OpenLast" >
<property name="text" >
@ -147,12 +159,21 @@
</item>
<item>
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</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>
<widget class="QCheckBox" name="checkBox_SaveFileDlgHistory" >
<property name="text" >
@ -179,7 +200,7 @@
<item>
<widget class="QPushButton" name="Button_ClearFileDlgHistory" >
<property name="text" >
<string>Clear</string>
<string>Clear History Now</string>
</property>
</widget>
</item>
@ -199,73 +220,71 @@
</layout>
</item>
<item>
<widget class="QCheckBox" name="checkBox_EnableBookmarkMenu" >
<widget class="QCheckBox" name="checkBox_AskBeforeDelete" >
<property name="text" >
<string>Enable bookmark menu</string>
<string>Always ask before deleting entries or groups</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<layout class="QVBoxLayout" >
<property name="margin" >
<property name="leftMargin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
<property name="topMargin" >
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label_3" >
<property name="text" >
<string>Group tree at start-up:</string>
<property name="rightMargin" >
<number>0</number>
</property>
<property name="bottomMargin" >
<number>0</number>
</property>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
<layout class="QGridLayout" >
<property name="leftMargin" >
<number>0</number>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>40</height>
</size>
<property name="topMargin" >
<number>0</number>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QVBoxLayout" >
<property name="margin" >
<property name="rightMargin" >
<number>0</number>
</property>
<property name="spacing" >
<property name="bottomMargin" >
<number>0</number>
</property>
<item>
<property name="horizontalSpacing" >
<number>6</number>
</property>
<property name="verticalSpacing" >
<number>6</number>
</property>
<item row="0" column="0" >
<widget class="QLabel" name="label_3" >
<property name="text" >
<string>Group tree at start-up:</string>
</property>
</widget>
</item>
<item row="0" column="1" >
<widget class="QRadioButton" name="Radio_GroupTreeRestore" >
<property name="text" >
<string>Restore last state</string>
</property>
</widget>
</item>
<item>
<item row="1" column="1" >
<widget class="QRadioButton" name="Radio_GroupTreeExpand" >
<property name="text" >
<string>Expand all items</string>
</property>
</widget>
</item>
<item>
<item row="2" column="1" >
<widget class="QRadioButton" name="Radio_GroupTreeDoNothing" >
<property name="text" >
<string>Do not expand any item</string>
@ -296,8 +315,8 @@
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>40</height>
<width>531</width>
<height>16</height>
</size>
</property>
</spacer>
@ -309,30 +328,60 @@
<string>Appea&amp;rance</string>
</attribute>
<layout class="QVBoxLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</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="QGroupBox" name="groupBox1" >
<property name="title" >
<string>Banner Color</string>
</property>
<layout class="QVBoxLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</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>
<layout class="QGridLayout" >
<property name="margin" >
<property name="leftMargin" >
<number>0</number>
</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>
</property>
<item row="1" column="0" >
@ -361,9 +410,7 @@
<item row="1" column="2" >
<widget class="QPushButton" name="ButtonTextColor" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>4</hsizetype>
<vsizetype>0</vsizetype>
<sizepolicy vsizetype="Fixed" hsizetype="Maximum" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -391,9 +438,7 @@
<item row="0" column="4" >
<widget class="QLabel" name="textLabel3" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>4</hsizetype>
<vsizetype>5</vsizetype>
<sizepolicy vsizetype="Preferred" hsizetype="Maximum" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -406,9 +451,7 @@
<item row="0" column="1" >
<widget class="QLabel" name="pixmColor1" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>4</hsizetype>
<vsizetype>0</vsizetype>
<sizepolicy vsizetype="Fixed" hsizetype="Maximum" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -433,9 +476,7 @@
<item row="1" column="1" >
<widget class="QLabel" name="pixmTextColor" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>4</hsizetype>
<vsizetype>0</vsizetype>
<sizepolicy vsizetype="Fixed" hsizetype="Maximum" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -463,9 +504,7 @@
<item row="0" column="6" >
<widget class="QPushButton" name="ButtonColor2" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>4</hsizetype>
<vsizetype>0</vsizetype>
<sizepolicy vsizetype="Fixed" hsizetype="Maximum" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -493,9 +532,7 @@
<item row="0" column="5" >
<widget class="QLabel" name="pixmColor2" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>4</hsizetype>
<vsizetype>0</vsizetype>
<sizepolicy vsizetype="Fixed" hsizetype="Maximum" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -523,9 +560,7 @@
<item row="0" column="2" >
<widget class="QPushButton" name="ButtonColor1" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>4</hsizetype>
<vsizetype>0</vsizetype>
<sizepolicy vsizetype="Fixed" hsizetype="Maximum" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -553,9 +588,7 @@
<item row="0" column="0" >
<widget class="QLabel" name="textLabel1_3" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>4</hsizetype>
<vsizetype>5</vsizetype>
<sizepolicy vsizetype="Preferred" hsizetype="Maximum" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -602,12 +635,21 @@
</item>
<item>
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</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>
<widget class="QPushButton" name="Button_CustomizeEntryDetails" >
<property name="text" >
@ -650,26 +692,89 @@
<string>Security</string>
</attribute>
<layout class="QVBoxLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</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>
<layout class="QHBoxLayout" >
<property name="margin" >
<widget class="QGroupBox" name="groupBox_2" >
<property name="sizePolicy" >
<sizepolicy vsizetype="Minimum" hsizetype="Preferred" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</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" >
<number>6</number>
</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>
<widget class="QLabel" name="textLabel1" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>4</hsizetype>
<vsizetype>5</vsizetype>
<sizepolicy vsizetype="Preferred" hsizetype="Maximum" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -682,9 +787,7 @@
<item>
<widget class="QSpinBox" name="SpinBox_ClipboardTime" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>5</hsizetype>
<vsizetype>0</vsizetype>
<sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -713,45 +816,42 @@
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupBox_2" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>5</hsizetype>
<vsizetype>1</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="title" >
<string>Show passwords in plain text in:</string>
<property name="sizeHint" >
<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" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>0</number>
</property>
<item>
<widget class="QCheckBox" name="CheckBox_ShowPasswords" >
<widget class="QLabel" name="label_6" >
<property name="text" >
<string>Edit Entry Dialog</string>
<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="shortcut" >
<string>Alt+O</string>
<property name="wordWrap" >
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="CheckBox_ShowPasswords_PasswordDlg" >
<widget class="QCheckBox" name="checkBox_EnableBookmarkMenu" >
<property name="text" >
<string>Key Dialogs</string>
<string>Bookmarks</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer>
<property name="orientation" >
@ -760,7 +860,7 @@
<property name="sizeHint" >
<size>
<width>20</width>
<height>40</height>
<height>131</height>
</size>
</property>
</spacer>
@ -772,18 +872,25 @@
<string>Desktop Integration</string>
</attribute>
<layout class="QVBoxLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</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="QLabel" name="Label_IntPlugin_Error" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>5</hsizetype>
<vsizetype>4</vsizetype>
<sizepolicy vsizetype="Maximum" hsizetype="Preferred" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -799,9 +906,7 @@
<item>
<widget class="QGroupBox" name="groupBox" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>5</hsizetype>
<vsizetype>1</vsizetype>
<sizepolicy vsizetype="Minimum" hsizetype="Preferred" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -810,12 +915,21 @@
<string>Plug-Ins</string>
</property>
<layout class="QVBoxLayout" >
<property name="margin" >
<number>9</number>
</property>
<property name="spacing" >
<number>6</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="QRadioButton" name="Radio_IntPlugin_None" >
<property name="text" >
@ -842,12 +956,21 @@
</item>
<item>
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</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>
<widget class="QLabel" name="Label_IntPlugin_Info" >
<property name="text" >
@ -897,18 +1020,125 @@
<string>Advanced</string>
</attribute>
<layout class="QVBoxLayout" >
<property name="margin" >
<property name="spacing" >
<number>6</number>
</property>
<property name="leftMargin" >
<number>9</number>
</property>
<property name="spacing" >
<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>
<layout class="QGridLayout" >
<property name="margin" >
<property name="leftMargin" >
<number>0</number>
</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>
</property>
<item row="1" column="2" >
@ -979,9 +1209,7 @@
<item row="0" column="2" colspan="2" >
<widget class="QCheckBox" name="CheckBox_BrowserDefault" >
<property name="sizePolicy" >
<sizepolicy>
<hsizetype>4</hsizetype>
<vsizetype>0</vsizetype>
<sizepolicy vsizetype="Fixed" hsizetype="Maximum" >
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
@ -993,80 +1221,6 @@
</item>
</layout>
</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>
<widget class="QCheckBox" name="CheckBox_SaveRelativePaths" >
<property name="whatsThis" >

@ -29,13 +29,13 @@
#include <QApplication>
#include <QPainter>
#include <QPair>
#include <QMessageBox>
#include "main.h"
#include "PwmConfig.h"
#include "KpxConfig.h"
#include "EntryView.h"
#include "dialogs/EditEntryDlg.h"
#include "lib/AutoType.h"
// just for the lessThan funtion
QList<EntryViewItem*>* pItems;
KeepassEntryView* pEntryView;
@ -46,26 +46,9 @@ KeepassEntryView::KeepassEntryView(QWidget* parent):QTreeWidget(parent){
header()->setStretchLastSection(false);
header()->setClickable(true);
header()->setCascadingSectionResizes(true);
ColumnSizes.resize(NUM_COLUMNS);
QStringList ColumnSizeConfig=settings->value("Ui/ColumnSizes",QStringList()<<"1"<<"1"<<"1"<<"1"<<"1"<<"1"<<"1"<<"1"<<"1"<<"1"<<"1").toStringList();
for(int i=0;i<NUM_COLUMNS;i++)
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;
}
ColumnSizes=config->columnSizes();
Columns=config->columns();
ColumnOrder=config->columnOrder();
updateColumns();
@ -76,31 +59,16 @@ KeepassEntryView::KeepassEntryView(QWidget* parent):QTreeWidget(parent){
connect(header(),SIGNAL(sectionMoved(int,int,int)),this,SLOT(OnColumnMoved(int,int,int)));
Clipboard=QApplication::clipboard();
ContextMenu=new QMenu(this);
setAlternatingRowColors(config.AlternatingRowColors);
setAlternatingRowColors(config->alternatingRowColors());
pItems=&Items;
pEntryView=this;
}
KeepassEntryView::~KeepassEntryView(){
QStringList ColumnSizesConfig;
for(int i=0;i<ColumnSizes.size();i++){
ColumnSizesConfig<<QString::number((int)(ColumnSizes[i]));
}
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);
config->setColumnSizes(ColumnSizes);
config->setColumns(Columns);
config->setColumnOrder(ColumnOrder);
}
void KeepassEntryView::OnGroupChanged(IGroupHandle* group){
@ -164,7 +132,7 @@ void KeepassEntryView::OnHeaderSectionClicked(int index){
void KeepassEntryView::OnSaveAttachment(){
Q_ASSERT(selectedItems().size()==1);
CEditEntryDlg::saveAttachment(((EntryViewItem*)selectedItems()[0])->EntryHandle,this);
CEditEntryDlg::saveAttachment(((EntryViewItem*)selectedItems().first())->EntryHandle,this);
}
void KeepassEntryView::OnCloneEntry(){
@ -180,6 +148,17 @@ void KeepassEntryView::OnCloneEntry(){
void KeepassEntryView::OnDeleteEntry(){
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++){
db->deleteEntry(((EntryViewItem*)entries[i])->EntryHandle);
Items.removeAt(Items.indexOf((EntryViewItem*)entries[i]));
@ -193,18 +172,18 @@ void KeepassEntryView::OnDeleteEntry(){
void KeepassEntryView::updateEntry(EntryViewItem* item){
IEntryHandle* entry = item->EntryHandle;
int j=0;
if(Columns[0]){
if(Columns.at(0)){
item->setText(j++,entry->title());
item->setIcon(0,db->icon(entry->image()));
}
if(Columns[1]){
if(config.ListView_HideUsernames)
if (Columns.at(1)){
if(config->hideUsernames())
item->setText(j++,"******");
else
item->setText(j++,entry->username());}
if(Columns[2]){item->setText(j++,entry->url());}
if(Columns[3]){
if(config.ListView_HidePasswords)
if (Columns.at(2)){item->setText(j++,entry->url());}
if (Columns.at(3)){
if(config->hidePasswords())
item->setText(j++,"******");
else{
SecString password=entry->password();
@ -212,19 +191,19 @@ void KeepassEntryView::updateEntry(EntryViewItem* item){
item->setText(j++,password.string());
}
}
if(Columns[4]){
if (Columns.at(4)){
item->setText(j++,entry->comment().section('\n',0,0));}
if(Columns[5]){
if (Columns.at(5)){
item->setText(j++,entry->expire().dateToString(Qt::LocalDate));}
if(Columns[6]){
if (Columns.at(6)){
item->setText(j++,entry->creation().dateToString(Qt::LocalDate));}
if(Columns[7]){
if (Columns.at(7)){
item->setText(j++,entry->lastMod().dateToString(Qt::LocalDate));}
if(Columns[8]){
if (Columns.at(8)){
item->setText(j++,entry->lastAccess().dateToString(Qt::LocalDate));}
if(Columns[9]){
if (Columns.at(9)){
item->setText(j++,entry->binaryDesc());}
if(Columns[10] && ViewMode==ShowSearchResults){
if(Columns.at(10) && ViewMode==ShowSearchResults){
item->setText(j,entry->group()->title());
item->setIcon(j++,db->icon(entry->group()->image()));}
}
@ -279,44 +258,53 @@ void KeepassEntryView::OnEntryActivated(QTreeWidgetItem* item,int Column){
void KeepassEntryView::OnEditEntry(){
Q_ASSERT(selectedItems().size()==1);
editEntry((EntryViewItem*)selectedItems()[0]);
editEntry((EntryViewItem*)selectedItems().first());
}
void KeepassEntryView::OnEditOpenUrl(){
Q_ASSERT(selectedItems().size()==1);
openBrowser(((EntryViewItem*)selectedItems()[0])->text(logicalColIndex(2)));
openBrowser(((EntryViewItem*)selectedItems().first())->text(logicalColIndex(2)));
}
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.start(config.ClipboardTimeOut*1000);
ClipboardTimer.start(config->clipboardTimeOut()*1000);
}
void KeepassEntryView::OnPasswordToClipboard(){
SecString password;
password=((EntryViewItem*)selectedItems()[0])->EntryHandle->password();
password=((EntryViewItem*)selectedItems().first())->EntryHandle->password();
password.unlock();
Clipboard->setText(password.string(),QClipboard::Clipboard);
if(Clipboard->supportsSelection()){
Clipboard->setText(password.string(),QClipboard::Selection);
}
ClipboardTimer.setSingleShot(true);
ClipboardTimer.start(config.ClipboardTimeOut*1000);
ClipboardTimer.start(config->clipboardTimeOut()*1000);
}
void KeepassEntryView::OnClipboardTimeOut(){
Clipboard->clear(QClipboard::Clipboard);
if(Clipboard->supportsSelection()){
Clipboard->clear(QClipboard::Selection);
}
}
void KeepassEntryView::contextMenuEvent(QContextMenuEvent* e){
if(itemAt(e->pos())){
EntryViewItem* item=(EntryViewItem*)itemAt(e->pos());
if(selectedItems().size()==0){
if(!selectedItems().size()){
setItemSelected(item,true);
}
else{
if(!isItemSelected(item)){
while(selectedItems().size()){
setItemSelected(selectedItems()[0],false);
setItemSelected(selectedItems().first(),false);
}
setItemSelected(item,true);
}
@ -324,7 +312,7 @@ void KeepassEntryView::contextMenuEvent(QContextMenuEvent* e){
}
else
{while(selectedItems().size()){
setItemSelected(selectedItems()[0],false);}
setItemSelected(selectedItems().first(),false);}
}
e->accept();
ContextMenu->popup(e->globalPos());
@ -339,7 +327,7 @@ void KeepassEntryView::resizeEvent(QResizeEvent* e){
void KeepassEntryView::showSearchResults(){
if(ViewMode==Normal){
ViewMode=ShowSearchResults;
if(Columns[10])ColumnOrder[10]--;
if(Columns.at(10))ColumnOrder[10]--;
updateColumns();
}
clear();
@ -368,17 +356,17 @@ void KeepassEntryView::createItems(QList<IEntryHandle*>& entries){
Items.push_back(item);
Items.back()->EntryHandle=entries[i];
int j=0;
if(Columns[0]){
if (Columns.at(0)){
item->setText(j++,entries[i]->title());
item->setIcon(0,db->icon(entries[i]->image()));}
if(Columns[1]){
if(config.ListView_HideUsernames)
if (Columns.at(1)){
if(config->hideUsernames())
item->setText(j++,"******");
else
item->setText(j++,entries[i]->username());}
if(Columns[2]){item->setText(j++,entries[i]->url());}
if(Columns[3]){
if(config.ListView_HidePasswords)
if (Columns.at(2)){item->setText(j++,entries[i]->url());}
if (Columns.at(3)){
if(config->hidePasswords())
item->setText(j++,"******");
else{
SecString password=entries[i]->password();
@ -386,19 +374,19 @@ void KeepassEntryView::createItems(QList<IEntryHandle*>& entries){
item->setText(j++,password.string());
}
}
if(Columns[4]){
if (Columns.at(4)){
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));}
if(Columns[6]){
if (Columns.at(6)){
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));}
if(Columns[8]){
if (Columns.at(8)){
item->setText(j++,entries[i]->lastAccess().dateToString(Qt::LocalDate));}
if(Columns[9]){
if (Columns.at(9)){
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->setIcon(j++,db->icon(entries[i]->group()->image()));}
}
@ -418,43 +406,44 @@ void KeepassEntryView::setEntry(IEntryHandle* entry){
void KeepassEntryView::updateColumns(){
setColumnCount(0);
QStringList cols;
if(Columns[0]){
if (Columns.at(0)){
cols << tr("Title");}
if(Columns[1]){
if (Columns.at(1)){
cols << tr("Username");}
if(Columns[2]){
if (Columns.at(2)){
cols << tr("URL");}
if(Columns[3]){
if (Columns.at(3)){
cols << tr("Password");}
if(Columns[4]){
if (Columns.at(4)){
cols << tr("Comments");}
if(Columns[5]){
if (Columns.at(5)){
cols << tr("Expires");}
if(Columns[6]){
if (Columns.at(6)){
cols << tr("Creation");}
if(Columns[7]){
if (Columns.at(7)){
cols << tr("Last Change");}
if(Columns[8]){
if (Columns.at(8)){
cols << tr("Last Access");}
if(Columns[9]){
if (Columns.at(9)){
cols << tr("Attachment");}
if(Columns[10] && ViewMode==ShowSearchResults){
if(Columns.at(10) && ViewMode==ShowSearchResults){
cols << tr("Group");}
setHeaderLabels(cols);
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;
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);
while (i.hasNext()) {
i.next();
int index=i.value();
if(!Columns[index])continue;
if(!Columns.at(index))continue;
header()->moveSection(header()->visualIndex(logicalColIndex(index)),header()->count()-1);
}
@ -476,8 +465,8 @@ int KeepassEntryView::logicalColIndex(int LstIndex){
qDebug("%i",LstIndex);
int c=-1;
for(int i=0;i<NUM_COLUMNS;i++){
if(Columns[i])c++;
if(i==10 && Columns[10] && ViewMode!=ShowSearchResults)c--;
if(Columns.at(i))c++;
if(i==10 && Columns.at(10) && ViewMode!=ShowSearchResults)c--;
if(i==LstIndex)return c;
}
Q_ASSERT(false);
@ -490,18 +479,20 @@ void KeepassEntryView::resizeColumns(){
for(int i=0;i<NUM_COLUMNS;i++){
// if(i==10) continue; //skip "Group" column
if(!Columns[i])ColumnSizes[i]=0;
if(Columns[i] && ColumnSizes[i]==0)ColumnSizes[i]=0.1f*(float)w;
if(!Columns.at(i))
ColumnSizes[i]=0;
if(Columns.at(i) && !ColumnSizes.at(i))
ColumnSizes[i]=w/10;
}
for(int i=0;i<header()->count();i++){
sum+=ColumnSizes[columnListIndex(i)];
sum+=ColumnSizes.at(columnListIndex(i));
}
float stretch=((float)w)/((float)sum);
sum=0;
for(int i=0;i<header()->count();i++){
int lstIndex=columnListIndex(header()->logicalIndex(i));
int NewSize=qRound(stretch*(float)ColumnSizes[lstIndex]);
int NewSize=qRound(stretch*(float)ColumnSizes.at(lstIndex));
sum+=NewSize;
if(i==header()->count()-1){
NewSize+=(w-sum); // add rounding difference to the last column
@ -515,8 +506,8 @@ void KeepassEntryView::resizeColumns(){
int KeepassEntryView::columnListIndex(int LogicalIndex){
int c=-1; int i=0;
for(i;i<NUM_COLUMNS;i++){
if(Columns[i])c++;
if(i==10 && Columns[10] && ViewMode!=ShowSearchResults)c--;
if(Columns.at(i))c++;
if(i==10 && Columns.at(10) && ViewMode!=ShowSearchResults)c--;
if(c==LogicalIndex)break;
}
return i;
@ -548,10 +539,10 @@ void KeepassEntryView::mouseMoveEvent(QMouseEvent *event){
EntryViewItem* DragStartItem=(EntryViewItem*)itemAt(DragStartPos);
if(!DragStartItem){
while(selectedItems().size()){
setItemSelected(selectedItems()[0],false);}
setItemSelected(selectedItems().first(),false);}
return;
}
if(selectedItems().size()==0){
if(selectedItems().isEmpty()){
setItemSelected(DragStartItem,true);}
else{
bool AlreadySelected=false;
@ -560,7 +551,7 @@ void KeepassEntryView::mouseMoveEvent(QMouseEvent *event){
}
if(!AlreadySelected){
while(selectedItems().size()){
setItemSelected(selectedItems()[0],false);
setItemSelected(selectedItems().first(),false);
}
setItemSelected(DragStartItem,true);
}
@ -570,7 +561,7 @@ void KeepassEntryView::mouseMoveEvent(QMouseEvent *event){
QDrag *drag = new QDrag(this);
QMimeData *mimeData = new QMimeData;
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*)));
drag->setMimeData(mimeData);
drag->setPixmap(DragPixmap);
@ -593,7 +584,7 @@ void KeepassEntryView::removeDragItems(){
void KeepassEntryView::OnAutoType(){
Q_ASSERT(selectedItems().size()==1);
QString error;
AutoType::perform(((EntryViewItem*)selectedItems()[0])->EntryHandle,error);
AutoType::perform(((EntryViewItem*)selectedItems().first())->EntryHandle,error);
}
void KeepassEntryView::paintEvent(QPaintEvent * event){
@ -654,7 +645,7 @@ void KeepassEntryView::setCurrentEntry(IEntryHandle* entry){
bool found=false;
int i=0;
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;
setCurrentItem(Items[i]);
setCurrentItem(Items.at(i));
}

@ -27,8 +27,9 @@
#include <QHeaderView>
#include <QTimer>
#include <QClipboard>
#include <QVarLengthArray>
#include "../StandardDatabase.h"
#include <QBitArray>
#include <QList>
#include "../Kdb3Database.h"
#define NUM_COLUMNS 11
@ -49,7 +50,7 @@ class KeepassEntryView:public QTreeWidget{
QList<EntryViewItem*>Items;
QList<IEntryHandle*> SearchResults;
QMenu *ContextMenu;
QVarLengthArray<bool>Columns;
QBitArray Columns;
void setCurrentEntry(IEntryHandle* entry);
private:
void setEntry(IEntryHandle* entry);
@ -68,8 +69,8 @@ class KeepassEntryView:public QTreeWidget{
IGroupHandle* CurrentGroup;
enum EntryViewMode {Normal, ShowSearchResults};
EntryViewMode ViewMode;
QVarLengthArray<float>ColumnSizes;
QVarLengthArray<int>ColumnOrder;
QList<int> ColumnSizes;
QList<int> ColumnOrder;
float GroupColumnSize;
virtual void contextMenuEvent(QContextMenuEvent *event);

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

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

@ -33,6 +33,8 @@
#include <QPen>
#include <QBrush>
#include <QMenu>
#include <QMessageBox>
#include "KpxConfig.h"
#include "main.h"
#include "EntryView.h"
#include "GroupView.h"
@ -99,6 +101,12 @@ void KeepassGroupView::addChilds(GroupViewItem* item){
}
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();
if(item){
db->deleteGroup(item->GroupHandle);
@ -204,6 +212,7 @@ void KeepassGroupView::dragEnterEvent ( QDragEnterEvent * event ){
void KeepassGroupView::dragLeaveEvent ( QDragLeaveEvent * event ){
if(LastHoverItem){
LastHoverItem->setBackgroundColor(0,QApplication::palette().color(QPalette::Base));
LastHoverItem->setForeground(0,QBrush(QApplication::palette().color(QPalette::Text)));
}
if(InsLinePos!=-1){
int RemoveLine=InsLinePos;
@ -345,6 +354,15 @@ void KeepassGroupView::entryDragMoveEvent( QDragMoveEvent * event ){
event->ignore();
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){
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)));
LastHoverItem=Item;
}
event->accept();
return;

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

@ -21,7 +21,6 @@
#include <math.h>
#include <QPainter>
#include <QRectF>
#include "PwmConfig.h"
#include "main.h"
#include "WaitAnimationWidget.h"

@ -41,8 +41,8 @@
#include "main.h"
#include "lib/FileDialogs.h"
#include "PwmConfig.h"
#include "StandardDatabase.h"
#include "KpxConfig.h"
#include "Kdb3Database.h"
#include "mainwindow.h"
#include "crypto/yarrow.h"
using namespace std;
@ -61,8 +61,7 @@ using namespace std;
QHash<QString,QPixmap*>PixmapCache;
QHash<QString,QIcon*>IconCache;
CConfig config;
QSettings* settings;
KpxConfig *config;
QString AppDir;
QString PluginLoadError;
bool TrActive;
@ -74,38 +73,58 @@ inline void loadImages();
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);
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)
{
//test_getAllWindowTitles();
//exit(0);
QString ArgFile,ArgCfg,ArgLang,IniFilename;
QApplication* app=NULL;
AppDir=QString(argv[0]);
AppDir.truncate(AppDir.lastIndexOf("/"));
parseCmdLineArgs(argc,argv,ArgFile,ArgCfg,ArgLang);
//Load Config
if(ArgCfg==QString()){
if(!QDir(QDir::homePath()+"/.keepass").exists()){
if(ArgCfg.isEmpty()){
if(!QDir(QDir::homePath()+"/.keepassx").exists()){
QDir conf(QDir::homePath());
if(!conf.mkdir(".keepass")){
cout << "Warning: Could not create directory '~/.keepass'." << endl;}
if(!conf.mkdir(".keepassx")){
cout << "Warning: Could not create directory '~/.keepassx'." << endl;}
}
IniFilename=QDir::homePath()+"/.keepass/config";
config.loadFromIni(IniFilename);
IniFilename=QDir::homePath()+"/.keepassx/config";
}
else{
else
IniFilename=ArgCfg;
config.loadFromIni(IniFilename);}
settings = new QSettings(QDir::homePath()+"/.keepassx/config",QSettings::IniFormat);
config = new KpxConfig(IniFilename);
fileDlgHistory.load();
//Plugins
if(config.IntegrPlugin!=CConfig::NONE){
if(config->integrPlugin()!=KpxConfig::NoIntegr){
QString LibName="libkeepassx-";
if(config.IntegrPlugin==CConfig::KDE)
if(config->integrPlugin()==KpxConfig::KDE)
LibName+="kde.so";
else if(config.IntegrPlugin==CConfig::GNOME)
else if(config->integrPlugin()==KpxConfig::Gnome)
LibName+="gnome.so";
QString filename=findPlugin(LibName);
if(filename!=QString()){
@ -118,12 +137,12 @@ int main(int argc, char **argv)
else{
IFileDialog* fdlg=qobject_cast<IFileDialog*>(plugin.instance());
KpxFileDialogs::setPlugin(fdlg);
if(config.IntegrPlugin==CConfig::KDE){
if(config->integrPlugin()==KpxConfig::KDE){
IKdeInit* kdeinit=qobject_cast<IKdeInit*>(plugin.instance());
app=kdeinit->getMainAppObject(argc,argv);
if(!app)PluginLoadError=QObject::tr("Initialization failed.");
}
if(config.IntegrPlugin==CConfig::GNOME){
if(config->integrPlugin()==KpxConfig::Gnome){
IGnomeInit* ginit=qobject_cast<IGnomeInit*>(plugin.instance());
if(!ginit->init(argc,argv)){
KpxFileDialogs::setPlugin(NULL);
@ -139,7 +158,6 @@ int main(int argc, char **argv)
}
}
if(!app) QApplication* app=new QApplication(argc,argv);
parseCmdLineArgs(argc,argv,ArgFile,ArgCfg,ArgLang);
//Internationalization
@ -200,10 +218,6 @@ int main(int argc, char **argv)
r=app->exec();
}
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)){
templ.write(DetailViewTemplate.toUtf8());
@ -216,7 +230,7 @@ int main(int argc, char **argv)
fileDlgHistory.save();
delete app;
delete settings;
delete config;
return r;
}
@ -243,14 +257,14 @@ void createBanner(QLabel *Banner,const QPixmap* symbol,QString text){
QPixmap Pixmap;
createBanner(&Pixmap,symbol,text
,Banner->width()
,config.BannerColor1
,config.BannerColor2
,config.BannerTextColor);
,config->bannerColor1()
,config->bannerColor2()
,config->bannerTextColor());
Banner->setPixmap(Pixmap);
}
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){
@ -299,11 +313,11 @@ void openBrowser(QString UrlString){
QUrl url(UrlString);
if(url.scheme().isEmpty())
url=QUrl("http://"+UrlString);
if(settings->value("BrowserCmd","<<default>>").toString() == "<<default>>"){
if(config->urlCmd().isEmpty()){
QDesktopServices::openUrl(url);
}
else{
QStringList args=settings->value("BrowserCmd","<<default>>").toString().arg(url.toString()).split(' ');
QStringList args=config->urlCmd().arg(url.toString()).split(' ');
QString cmd=args.takeFirst();
QProcess::startDetached(cmd,args);
}
@ -338,7 +352,7 @@ const QIcon& getIcon(const QString& name){
return *CachedIcon;
QFileInfo IconFile(AppDir+"/../share/keepass/icons/"+name+".png");
if(!IconFile.isFile() || !IconFile.exists() || !IconFile.isReadable()){
//ERROR
///TODO 0.2.3 error handling
qWarning("%s",CSTR(name));
}
QIcon* NewIcon=new QIcon(AppDir+"/../share/keepass/icons/"+name+".png");
@ -352,7 +366,7 @@ const QPixmap* getPixmap(const QString& name){
return CachedPixmap;
QImage img;
if(!img.load(AppDir+"/../share/keepass/icons/"+name+".png")){
//ERROR
///TODO 0.2.3 error handling
qWarning("%s",CSTR(name));
}
QPixmap* NewPixmap=new QPixmap(QPixmap::fromImage(img));

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

@ -40,7 +40,6 @@
#include "KpxFirefox.h"
#include "lib/random.h"
#include "lib/IniReader.h"
#include "lib/AutoType.h"
#include "lib/FileDialogs.h"
#include "import/Import_PwManager.h"
@ -59,6 +58,7 @@
#include "dialogs/CollectEntropyDlg.h"
#include "dialogs/CustomizeDetailViewDlg.h"
#include "dialogs/ExpiredEntriesDlg.h"
#include "dialogs/TrashCanDlg.h"
//#include <QtDBus/QtDBus>
#include <iostream>
@ -77,11 +77,13 @@ KeepassMainWindow::KeepassMainWindow(const QString& ArgFile,QWidget *parent, Qt:
Start=true;
ShutingDown=false;
setupUi(this);
#ifdef QT_WS_MAC
setUnifiedTitleAndToolBarOnMac(true);
#endif
AutoType::MainWin=this;
setGeometry(settings->value("Ui/MainWindowGeometry",QVariant(geometry())).toRect());
VSplitter->restoreState(settings->value("Ui/VSplitterPos").toByteArray());
HSplitter->restoreState(settings->value("Ui/HSplitterPos").toByteArray());
setGeometry(config->mainWindowGeometry(geometry()));
VSplitter->restoreState(config->vSplitterPos());
HSplitter->restoreState(config->hSplitterPos());
SysTray=new QSystemTrayIcon(this);
setupToolbar();
setupIcons();
@ -91,18 +93,18 @@ KeepassMainWindow::KeepassMainWindow(const QString& ArgFile,QWidget *parent, Qt:
StatusBarSelection=new QLabel(statusBar());
statusBar()->addWidget(StatusBarGeneral,15);
statusBar()->addWidget(StatusBarSelection,85);
statusBar()->setVisible(config.ShowStatusbar);
statusBar()->setVisible(config->showStatusbar());
setupConnections();
FileOpen=false;
if(ArgFile!=QString())
if(!ArgFile.isEmpty())
openDatabase(QDir::cleanPath(QDir::current().absoluteFilePath(ArgFile)),false);
else if(settings->value("OpenLastFile",true).toBool() && (settings->value("LastFile","").toString()!=QString())){
QFileInfo file(settings->value("LastFile","").toString());
else if(config->openLastFile() && !config->lastFile().isEmpty()){
QFileInfo file(config->lastFile());
if(file.exists())
openDatabase(QDir::cleanPath(QDir::current().absoluteFilePath(settings->value("LastFile","").toString())),true);
openDatabase(QDir::cleanPath(QDir::current().absoluteFilePath(config->lastFile())),true);
else
settings->setValue("LastFile","");
config->setLastFile(QString());
}
// DBus Server of Qt 4.2 does not work - 4.3 snapshot seems to work fine
@ -162,6 +164,7 @@ void KeepassMainWindow::setupConnections(){
connect(ExtrasSettingsAction,SIGNAL(triggered(bool)),this,SLOT(OnExtrasSettings()));
connect(ExtrasPasswordGenAction,SIGNAL(triggered(bool)),this,SLOT(OnExtrasPasswordGen()));
connect(ExtrasShowExpiredEntriesAction,SIGNAL(triggered(bool)),this,SLOT(OnExtrasShowExpiredEntries()));
connect(ExtrasTrashCanAction,SIGNAL(triggered(bool)),this,SLOT(OnExtrasTrashCan()));
connect(HelpHandbookAction,SIGNAL(triggered()),this,SLOT(OnHelpHandbook()));
connect(HelpAboutAction,SIGNAL(triggered()),this,SLOT(OnHelpAbout()));
@ -179,13 +182,13 @@ void KeepassMainWindow::setupConnections(){
connect(HideSearchResultsAction,SIGNAL(triggered()),GroupView,SLOT(OnHideSearchResults()));
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(){
toolBar=new QToolBar(this);
addToolBar(toolBar);
toolBar->setIconSize(QSize(config.ToolbarIconSize,config.ToolbarIconSize));
toolBar->setIconSize(QSize(config->toolbarIconSize(),config->toolbarIconSize()));
ViewShowToolbarAction=toolBar->toggleViewAction();
toolBar->addAction(FileNewAction);
toolBar->addAction(FileOpenAction);
@ -228,11 +231,12 @@ void KeepassMainWindow::setupIcons(){
ExtrasSettingsAction->setIcon(getIcon("appsettings"));
ExtrasShowExpiredEntriesAction->setIcon(getIcon("expired"));
ExtrasPasswordGenAction->setIcon(getIcon("generator"));
ExtrasTrashCanAction->setIcon(getIcon("trashcan"));
EditAutoTypeAction->setIcon(getIcon("autotype"));
HelpHandbookAction->setIcon(getIcon("manual"));
HelpAboutAction->setIcon(getIcon("help"));
SysTray->setIcon(getIcon("keepassx_large"));
if(config.ShowSysTrayIcon)
if(config->showSysTrayIcon())
SysTray->show();
}
@ -259,10 +263,10 @@ void KeepassMainWindow::setupMenus(){
ViewShowToolbarAction->setText(tr("Show Toolbar"));
ViewMenu->insertAction(ViewShowEntryDetailsAction,ViewShowToolbarAction);
ViewShowToolbarAction->setChecked(config.Toolbar);
ViewShowEntryDetailsAction->setChecked(config.EntryDetails);
ViewHidePasswordsAction->setChecked(config.ListView_HidePasswords);
ViewHideUsernamesAction->setChecked(config.ListView_HideUsernames);
ViewShowToolbarAction->setChecked(config->showToolbar());
ViewShowEntryDetailsAction->setChecked(config->showEntryDetails());
ViewHidePasswordsAction->setChecked(config->hidePasswords());
ViewHideUsernamesAction->setChecked(config->hideUsernames());
ViewColumnsTitleAction->setChecked(EntryView->Columns[0]);
ViewColumnsUsernameAction->setChecked(EntryView->Columns[1]);
ViewColumnsUrlAction->setChecked(EntryView->Columns[2]);
@ -274,9 +278,9 @@ void KeepassMainWindow::setupMenus(){
ViewColumnsLastAccessAction->setChecked(EntryView->Columns[8]);
ViewColumnsAttachmentAction->setChecked(EntryView->Columns[9]);
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 22: ViewToolButtonSize22Action->setChecked(true); break;
case 28: ViewToolButtonSize28Action->setChecked(true); break;
@ -322,6 +326,8 @@ void KeepassMainWindow::setupMenus(){
FileSaveAsAction->setShortcut(tr("Shift+Ctrl+S"));
EditGroupSearchAction->setShortcut(tr("Shift+Ctrl+F"));
#endif
ExtrasTrashCanAction->setVisible(false); //For KP 2.x only
}
void KeepassMainWindow::setupDatabaseConnections(IDatabase* DB){
@ -336,8 +342,8 @@ void KeepassMainWindow::setupDatabaseConnections(IDatabase* DB){
void KeepassMainWindow::openDatabase(QString filename,bool IsAuto){
if(!IsAuto){
config.LastKeyLocation=QString();
config.LastKeyType=PASSWORD;}
config->setLastKeyLocation(QString());
config->setLastKeyType(PASSWORD);}
db=dynamic_cast<IDatabase*>(new Kdb3Database());
CPasswordDialog PasswordDlg(this,db,IsAuto,false);
PasswordDlg.setWindowTitle(filename);
@ -542,9 +548,9 @@ void KeepassMainWindow::updateDetailView(){
templ.replace("%group%",entry->group()->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());
if(!config.ListView_HidePasswords){
if(!config->hidePasswords()){
SecString password=entry->password();
password.unlock();
templ.replace("%password%",password.string());
@ -818,12 +824,12 @@ void KeepassMainWindow::OnColumnVisibilityChanged(QAction* action){
EntryView->Columns[9]=ViewColumnsAttachmentAction->isChecked();
EntryView->Columns[10]=ViewColumnsGroupAction->isChecked();
EntryView->updateColumns();
//if(FileOpen) EntryView->updateItems();
if(FileOpen) EntryView->refreshItems();
}
void KeepassMainWindow::OnUsernPasswVisibilityChanged(bool value){
config.ListView_HidePasswords=ViewHidePasswordsAction->isChecked();
config.ListView_HideUsernames=ViewHideUsernamesAction->isChecked();
config->setHidePasswords(ViewHidePasswordsAction->isChecked());
config->setHideUsernames(ViewHideUsernamesAction->isChecked());
EntryView->refreshItems();
}
@ -832,16 +838,16 @@ setStateFileModified(true);
}
void KeepassMainWindow::closeEvent(QCloseEvent* e){
if(!ShutingDown && config.MinimizeToTray){
if(!ShutingDown && config->minimizeToTray()){
e->ignore();
hide();
return;
}
settings->setValue("Ui/MainWindowGeometry",QVariant(geometry()));
settings->setValue("Ui/VSplitterPos",VSplitter->saveState());
settings->setValue("Ui/HSplitterPos",HSplitter->saveState());
config.ShowStatusbar=statusBar()->isVisible();
config->setMainWindowGeometry(geometry());
config->setVSplitterPos(VSplitter->saveState());
config->setHSplitterPos(HSplitter->saveState());
config->setShowStatusbar(statusBar()->isVisible());
if(FileOpen){
if(!closeDatabase()){
@ -860,8 +866,8 @@ void KeepassMainWindow::closeEvent(QCloseEvent* e){
void KeepassMainWindow::OnExtrasSettings(){
CSettingsDlg dlg(this);
if(dlg.exec()==QDialog::Accepted){
EntryView->setAlternatingRowColors(config.AlternatingRowColors);
SysTray->setVisible(config.ShowSysTrayIcon);
EntryView->setAlternatingRowColors(config->alternatingRowColors());
SysTray->setVisible(config->showSysTrayIcon());
}
}
@ -875,13 +881,13 @@ openBrowser(AppDir+"/../share/doc/keepass/index.html");
}
void KeepassMainWindow::OnViewShowToolbar(bool show){
config.Toolbar=show;
toolBar->setVisible(config.Toolbar);
config->setShowToolbar(show);
toolBar->setVisible(show);
}
void KeepassMainWindow::OnViewShowEntryDetails(bool show){
config.EntryDetails=show;
DetailView->setVisible(config.EntryDetails);
config->setShowEntryDetails(show);
DetailView->setVisible(show);
}
void KeepassMainWindow::OnItemExpanded(QTreeWidgetItem* item){
@ -913,24 +919,24 @@ void KeepassMainWindow::OnViewToolbarIconSize16(bool state){
if(!state)return;
ViewToolButtonSize22Action->setChecked(false);
ViewToolButtonSize28Action->setChecked(false);
config.ToolbarIconSize=16;
toolBar->setIconSize(QSize(config.ToolbarIconSize,config.ToolbarIconSize));
config->setToolbarIconSize(16);
toolBar->setIconSize(QSize(16,16));
}
void KeepassMainWindow::OnViewToolbarIconSize22(bool state){
if(!state)return;
ViewToolButtonSize16Action->setChecked(false);
ViewToolButtonSize28Action->setChecked(false);
config.ToolbarIconSize=22;
toolBar->setIconSize(QSize(config.ToolbarIconSize,config.ToolbarIconSize));
config->setToolbarIconSize(22);
toolBar->setIconSize(QSize(22,22));
}
void KeepassMainWindow::OnViewToolbarIconSize28(bool state){
if(!state)return;
ViewToolButtonSize16Action->setChecked(false);
ViewToolButtonSize22Action->setChecked(false);
config.ToolbarIconSize=28;
toolBar->setIconSize(QSize(config.ToolbarIconSize,config.ToolbarIconSize));
config->setToolbarIconSize(28);
toolBar->setIconSize(QSize(28,28));
}
void KeepassMainWindow::OnSysTrayActivated(QSystemTrayIcon::ActivationReason reason){
@ -946,14 +952,14 @@ void KeepassMainWindow::OnExtrasPasswordGen(){
void KeepassMainWindow::saveLastFilename(const QString& filename){
if(settings->value("OpenLastFile",true).toBool()){
if(settings->value("SaveRelativePath",true).toBool()){
if(config->openLastFile()){
if(config->saveRelativePaths()){
QString Path=filename.left(filename.lastIndexOf("/"));
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
settings->setValue("LastFile",filename);
config->setLastFile(filename);
}
}
@ -965,3 +971,16 @@ void KeepassMainWindow::OnExtrasShowExpiredEntries(){
}
}
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 <QToolButton>
#include <QSystemTrayIcon>
#include <QUrl>
#include "StandardDatabase.h"
#include "PwmConfig.h"
#include "Kdb3Database.h"
#include "KpxConfig.h"
#include "lib/EntryView.h"
#include "lib/GroupView.h"
#include "export/Export.h"
@ -82,6 +83,7 @@ class KeepassMainWindow : public QMainWindow, public Ui_MainWindow{
void OnExtrasSettings();
void OnExtrasPasswordGen();
void OnExtrasShowExpiredEntries();
void OnExtrasTrashCan();
void OnHelpAbout();
void OnHelpHandbook();
void OnItemExpanded(QTreeWidgetItem*);
@ -91,6 +93,7 @@ class KeepassMainWindow : public QMainWindow, public Ui_MainWindow{
void OnSysTrayActivated(QSystemTrayIcon::ActivationReason);
void OnImport(QAction*);
void OnExport(QAction*);
void OnDetailViewUrlClicked(const QUrl& url);
private:
void closeEvent(QCloseEvent* event);

@ -1,5 +1,5 @@
/***************************************************************************
* Copyright (C) 2005-2006 by Tarek Saidi *
* Copyright (C) 2005-2007 by Tarek Saidi *
* tarek.saidi@arcor.de *
* *
* This program is free software; you can redistribute it and/or modify *
@ -27,12 +27,12 @@ class IFileDialog{
public:
virtual ~IFileDialog(){}
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,
QStringList Filters)=0;
QStringList Filters,int SelectedFilter)=0;
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;
};

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