From 08d9ff59c9e871196586d25f3b7eb741e45489aa Mon Sep 17 00:00:00 2001 From: tarek_saidi Date: Sun, 26 Nov 2006 22:15:00 +0000 Subject: [PATCH] overworked password generation dialog, enabled yarrow and entropy collection, some work on the integration plugins, plugin settings tab is finished git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@119 b624d157-de02-0410-bad0-e51aec6abb33 --- src/PwmConfig.h | 2 +- src/dialogs/EditEntryDlg.cpp | 8 +- src/dialogs/PasswordGenDlg.cpp | 395 +++++++------ src/dialogs/PasswordGenDlg.h | 53 +- src/dialogs/SettingsDlg.cpp | 214 ++++--- src/dialogs/SettingsDlg.h | 7 + src/forms/CollectEntropyDlg.ui | 3 - src/forms/PasswordGenDlg.ui | 801 ++++++++++++++------------- src/forms/SettingsDlg.ui | 50 +- src/lib/FileDialogs.cpp | 11 +- src/main.cpp | 72 ++- src/main.h | 3 + src/mainwindow.cpp | 130 ++--- src/plugins/gnome/keepassx-gnome.cpp | 24 +- src/plugins/gnome/keepassx-gnome.pro | 2 +- src/plugins/kde/keepassx-kde.pro | 4 +- 16 files changed, 1007 insertions(+), 772 deletions(-) diff --git a/src/PwmConfig.h b/src/PwmConfig.h index 0607e26..add5294 100755 --- a/src/PwmConfig.h +++ b/src/PwmConfig.h @@ -57,7 +57,7 @@ enum IntegrPluginType{NONE,KDE,GNOME}; bool ShowStatusbar; bool AlternatingRowColors; QString MountDir; - bool RememberLastKey; //location and type, not the key itself + bool RememberLastKey; tKeyType LastKeyType; QString LastKeyLocation; int ToolbarIconSize; diff --git a/src/dialogs/EditEntryDlg.cpp b/src/dialogs/EditEntryDlg.cpp index 8f5ecbc..6638fdb 100755 --- a/src/dialogs/EditEntryDlg.cpp +++ b/src/dialogs/EditEntryDlg.cpp @@ -361,8 +361,12 @@ void CEditEntryDlg::OnDeleteAttachment() void CEditEntryDlg::OnButtonGenPw() { -CGenPwDialog* pDlg=new CGenPwDialog(this,true); -pDlg->show(); + CGenPwDialog dlg(this,true); + if(dlg.exec()){ + Edit_Password->setText(dlg.Edit_dest->text()); + Edit_Password_w->setText(dlg.Edit_dest->text()); + ModFlag=true; + } } diff --git a/src/dialogs/PasswordGenDlg.cpp b/src/dialogs/PasswordGenDlg.cpp index b65f74e..dc6dd6c 100755 --- a/src/dialogs/PasswordGenDlg.cpp +++ b/src/dialogs/PasswordGenDlg.cpp @@ -18,214 +18,257 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#include -#include -#include -#include "PasswordGenDlg.h" -#include -#include -#include +#include +#include +#include +#include +#include #include +#include +#include +#include "PasswordGenDlg.h" +#include "CollectEntropyDlg.h" +#include "crypto/yarrow.h" +#include "PwmConfig.h" -CGenPwDialog::CGenPwDialog(QWidget* parent, bool modal, Qt::WFlags fl) +bool CGenPwDialog::EntropyCollected=false; + +CGenPwDialog::CGenPwDialog(QWidget* parent, bool StandAloneMode,Qt::WFlags fl) : QDialog(parent,fl) { -setupUi(this); -createBanner(Banner,Icon_Key32x32,tr("Password Generator")); -Radio_1->setChecked(true); -Edit_chars->setDisabled(true); -connect(ButtonGenerate,SIGNAL(clicked()),this,SLOT(OnGeneratePw())); -connect(Radio_1,SIGNAL(toggled(bool)),this,SLOT(OnRadio1StateChanged(bool))); -connect(Radio_2,SIGNAL(toggled(bool)),this,SLOT(OnRadio2StateChanged(bool))); -connect(Button_Cancel,SIGNAL(clicked()),this,SLOT(OnCancel())); -connect(ButtonOK,SIGNAL(clicked()),this,SLOT(OnAccept())); -} + setupUi(this); + createBanner(&BannerPixmap,Icon_Key32x32,tr("Password Generator"),width()); + + connect(ButtonGenerate,SIGNAL(clicked()),this,SLOT(OnGeneratePw())); + connect(Radio_1,SIGNAL(toggled(bool)),this,SLOT(OnRadio1StateChanged(bool))); + connect(Radio_2,SIGNAL(toggled(bool)),this,SLOT(OnRadio2StateChanged(bool))); + connect(DialogButtons,SIGNAL(rejected()),this,SLOT(OnCancel())); + connect(DialogButtons,SIGNAL(accepted()),this,SLOT(OnAccept())); + connect(checkBox1,SIGNAL(clicked()),this,SLOT(estimateQuality())); + connect(checkBox2,SIGNAL(clicked()),this,SLOT(estimateQuality())); + connect(checkBox3,SIGNAL(clicked()),this,SLOT(estimateQuality())); + connect(checkBox4,SIGNAL(clicked()),this,SLOT(estimateQuality())); + connect(checkBox5,SIGNAL(clicked()),this,SLOT(estimateQuality())); + connect(checkBox6,SIGNAL(clicked()),this,SLOT(estimateQuality())); + connect(checkBox7,SIGNAL(clicked()),this,SLOT(estimateQuality())); + connect(Spin_Num,SIGNAL(valueChanged(int)),this,SLOT(estimateQuality())); + connect(Check_CollectEntropy,SIGNAL(stateChanged(int)),this,SLOT(OnCollectEntropyChanged(int))); + connect(Edit_chars,SIGNAL(textChanged(const QString&)),this,SLOT(estimateQuality())); + + if(StandAloneMode){ + AcceptButton=DialogButtons->addButton(tr("Accept"),QDialogButtonBox::AcceptRole); + AcceptButton->setDisabled(true); + DialogButtons->addButton(QDialogButtonBox::Cancel); + } + else{ + DialogButtons->addButton(tr("OK"),QDialogButtonBox::AcceptRole); + AcceptButton=NULL; + } + + Radio_1->setChecked(config.PwGenOptions[0]); + Edit_chars->setDisabled(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]); + estimateQuality(); -CGenPwDialog::~CGenPwDialog() -{ } -void CGenPwDialog::OnRadio1StateChanged(bool state) -{ -if(state){ - Radio_2->setChecked(false); - checkBox1->setEnabled(true); - checkBox2->setEnabled(true); - checkBox3->setEnabled(true); - checkBox4->setEnabled(true); - checkBox5->setEnabled(true); - checkBox6->setEnabled(true); - checkBox7->setEnabled(true); - checkBox8->setEnabled(true); -}else{ - if(Radio_2->isChecked()==false)Radio_2->setChecked(true); - checkBox1->setDisabled(true); - checkBox2->setDisabled(true); - checkBox3->setDisabled(true); - checkBox4->setDisabled(true); - checkBox5->setDisabled(true); - checkBox6->setDisabled(true); - checkBox7->setDisabled(true); - checkBox8->setDisabled(true); +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(); } +void CGenPwDialog::paintEvent(QPaintEvent *event){ + QDialog::paintEvent(event); + QPainter painter(this); + painter.setClipRegion(event->region()); + painter.drawPixmap(QPoint(0,0),BannerPixmap); } -void CGenPwDialog::OnRadio2StateChanged(bool state) +void CGenPwDialog::OnRadio1StateChanged(bool state) { -if(state){ - Radio_1->setChecked(false); - Edit_chars->setEnabled(true); -} -else{ - if(Radio_1->isChecked()==false)Radio_1->setChecked(true); - Edit_chars->setDisabled(true); + if(state){ + checkBox1->setEnabled(true); + checkBox2->setEnabled(true); + checkBox3->setEnabled(true); + checkBox4->setEnabled(true); + checkBox5->setEnabled(true); + checkBox6->setEnabled(true); + checkBox7->setEnabled(true); + }else{ + checkBox1->setDisabled(true); + checkBox2->setDisabled(true); + checkBox3->setDisabled(true); + checkBox4->setDisabled(true); + checkBox5->setDisabled(true); + checkBox6->setDisabled(true); + checkBox7->setDisabled(true); + } + estimateQuality(); } +void CGenPwDialog::OnRadio2StateChanged(bool state){ + if(state) + Edit_chars->setEnabled(true); + else + Edit_chars->setDisabled(true); + + estimateQuality(); } void CGenPwDialog::OnGeneratePw() { -/* -------- - ASCII -------- -"A...Z" 65...90 -"a...z" 97...122 -"0...9" 48...57 -Special Charakters 33...47;58...64;91...96;123...126 -"-" 45 -"_" 95 -ANSI >127 -*/ - -int num=0; -char assoctable[255]; - -if(Radio_1->isChecked()){ -if(checkBox1->isChecked()){ -num+=AddToAssoctable(assoctable,65,90,num); -} - -if(checkBox2->isChecked()){ -num+=AddToAssoctable(assoctable,97,122,num); -} - -if(checkBox3->isChecked()){ -num+=AddToAssoctable(assoctable,48,57,num); -} - -if(checkBox4->isChecked()){ -num+=AddToAssoctable(assoctable,33,47,num); -num+=AddToAssoctable(assoctable,58,64,num); -num+=AddToAssoctable(assoctable,91,96,num); -num+=AddToAssoctable(assoctable,123,126,num); -} - -if(checkBox5->isChecked()){ -num+=AddToAssoctable(assoctable,32,32,num); -} - - -if(checkBox6->isChecked() && !checkBox4->isChecked()){ -num+=AddToAssoctable(assoctable,45,45,num); -} - -if(checkBox7->isChecked() && !checkBox4->isChecked()){ -num+=AddToAssoctable(assoctable,95,95,num); -} - -if(checkBox8->isChecked()){ -num+=AddToAssoctable(assoctable,128,255,num); -} -}else -{ -QString str=Edit_chars->text(); -int i=0; -while(str.length()>0){ -assoctable[i]=((QChar)str[0]).toAscii(); -str.remove(str[0]); -i++; -num++; -} -} -if(num==0){ -if(Radio_2->isChecked())QMessageBox::information(this,tr("Notice"),tr("You need to enter at least one character"),tr("OK")); -else QMessageBox::information(this,tr("Notice"),QString::fromUtf8("You need to select at least one character group."),"OK"); -return; -} -int length=Spin_Num->value(); -char* buffer=new char[length+1]; -buffer[length]=0; -FILE *dev_random; -if(Check_strongrandom->isChecked()){ -dev_random = fopen("/dev/random","r");} -else -{dev_random = fopen("/dev/urandom","r");} - -if (dev_random==NULL){ -QMessageBox::critical(this,tr("Error"),tr("Could not open '/dev/random' or '/dev/urandom'."),tr("OK")); -return; -} -unsigned char tmp; - -for(int i=0;isetText(buffer); -delete [] buffer; -fclose(dev_random); - -int bits; -if(checkBox8->isChecked())bits=length*8; -else bits=length*7; -Label_Bits->setText(tr("%1 Bit").arg(QString::number(bits))); -if(bits>128)bits=128; -Progress_Quali->setRange(0,128); -Progress_Quali->setValue(bits); -Progress_Quali->setTextVisible(false); + /*------------------------------------------------------- + ASCII + ------------------------------------------------------- + "A...Z" 65...90 + "a...z" 97...122 + "0...9" 48...57 + Special Charakters 33...47; 58...64; 91...96; 123...126 + "-" 45 + "_" 95 + ------------------------------------------------------- + */ + + int num=0; + char assoctable[255]; + + if(Radio_1->isChecked()){ + if(checkBox1->isChecked()) + num+=AddToAssoctable(assoctable,65,90,num); + if(checkBox2->isChecked()) + num+=AddToAssoctable(assoctable,97,122,num); + if(checkBox3->isChecked()) + num+=AddToAssoctable(assoctable,48,57,num); + if(checkBox4->isChecked()){ + num+=AddToAssoctable(assoctable,33,47,num); + num+=AddToAssoctable(assoctable,58,64,num); + num+=AddToAssoctable(assoctable,91,96,num); + num+=AddToAssoctable(assoctable,123,126,num);} + if(checkBox5->isChecked()) + num+=AddToAssoctable(assoctable,32,32,num); + if(checkBox6->isChecked() && !checkBox4->isChecked()) + num+=AddToAssoctable(assoctable,45,45,num); + if(checkBox7->isChecked() && !checkBox4->isChecked()) + num+=AddToAssoctable(assoctable,95,95,num); + } + else{ + QString str=Edit_chars->text(); + for(int i=0;iisChecked()) + QMessageBox::information(this,tr("Notice"),tr("You need to enter at least one character"),tr("OK")); + else + QMessageBox::information(this,tr("Notice"),QString::fromUtf8("You need to select at least one character group."),"OK"); + return; + } + int length=Spin_Num->value(); + char* buffer=new char[length+1]; + buffer[length]=0; + + if(Check_CollectEntropy->isChecked()){ + if((Check_CollectOncePerSession->isChecked() && !EntropyCollected) || !Check_CollectOncePerSession->isChecked()){ + CollectEntropyDlg dlg(this); + dlg.exec(); + EntropyCollected=true; + } + } + + unsigned char tmp; + for(int i=0;isetText(buffer); + delete [] buffer; + if(AcceptButton)AcceptButton->setEnabled(true); } - + int CGenPwDialog::AddToAssoctable(char* table,int start,int end,int pos){ -for(int i=start;i<=end;i++){ -table[pos]=i; -pos++; -} -return (end-start)+1; + for(int i=start;i<=end;i++){ + table[pos]=i; + pos++; + } + return (end-start)+1; } bool CGenPwDialog::trim(unsigned char &x, int r){ -if(xisChecked()){ + if(checkBox1->isChecked()) + num+=26; + if(checkBox2->isChecked()) + num+=26; + if(checkBox3->isChecked()) + num+=10; + if(checkBox4->isChecked()) + num+=32; + if(checkBox5->isChecked()) + num++; + if(checkBox6->isChecked() && !checkBox4->isChecked()) + num++; + if(checkBox7->isChecked() && !checkBox4->isChecked()) + num++; + } + else + num=Edit_chars->text().length(); + + float bits=0; + if(num)bits=log(num)/log(2); + bits=bits*((float)Spin_Num->value()); + Progress_Quali->setFormat(tr("%1 Bits").arg((int)bits)); + Progress_Quali->update(); + if(bits>128)bits=128; + Progress_Quali->setValue(bits); } void CGenPwDialog::OnAccept() { -((CEditEntryDlg*)parentWidget())->Edit_Password->setText(Edit_dest->text()); -((CEditEntryDlg*)parentWidget())->Edit_Password_w->setText(Edit_dest->text()); -((CEditEntryDlg*)parentWidget())->ModFlag=true; -close(); + done(1); } void CGenPwDialog::OnCancel() { -close(); + done(0); } +void CGenPwDialog::OnCollectEntropyChanged(int state){ + if(state==Qt::Checked) + Check_CollectOncePerSession->setDisabled(false); + else + Check_CollectOncePerSession->setDisabled(true); - - -/*$SPECIALIZATION$*/ - - -//#include "genpwdialog.moc" - +} diff --git a/src/dialogs/PasswordGenDlg.h b/src/dialogs/PasswordGenDlg.h index 342b1fb..5fe3e88 100755 --- a/src/dialogs/PasswordGenDlg.h +++ b/src/dialogs/PasswordGenDlg.h @@ -17,39 +17,40 @@ * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ -#include "main.h" + #ifndef GENPWDIALOG_H #define GENPWDIALOG_H + +#include +#include #include "ui_PasswordGenDlg.h" +#include "main.h" #include "EditEntryDlg.h" - - class CGenPwDialog : public QDialog, public Ui_GenPwDlg { - Q_OBJECT -private: -int AddToAssoctable(char* table,int start,int end,int pos); -bool trim(unsigned char &value,int range); -public: - CGenPwDialog(QWidget* parent = 0, bool modal = FALSE, Qt::WFlags fl = 0 ); - ~CGenPwDialog(); - /*$PUBLIC_FUNCTIONS$*/ - -public slots: - /*$PUBLIC_SLOTS$*/ - -protected: - /*$PROTECTED_FUNCTIONS$*/ - -protected slots: - /*$PROTECTED_SLOTS$*/ -public slots: - virtual void OnGeneratePw(); - virtual void OnRadio2StateChanged(bool); - virtual void OnRadio1StateChanged(bool); - virtual void OnCancel(); - virtual void OnAccept(); + Q_OBJECT + public: + CGenPwDialog(QWidget* parent = 0, bool ShowCancelButton=false, Qt::WFlags fl = 0 ); + ~CGenPwDialog(); + + private: + int AddToAssoctable(char* table,int start,int end,int pos); + bool trim(unsigned char &value,int range); + virtual void paintEvent(QPaintEvent* event); + QPixmap BannerPixmap; + static bool EntropyCollected; + QPushButton* AcceptButton; + + private slots: + virtual void OnGeneratePw(); + virtual void OnRadio2StateChanged(bool); + virtual void OnRadio1StateChanged(bool); + virtual void OnCancel(); + virtual void OnAccept(); + void estimateQuality(); + void OnCollectEntropyChanged(int); + }; #endif diff --git a/src/dialogs/SettingsDlg.cpp b/src/dialogs/SettingsDlg.cpp index a57c8da..69c1ae5 100755 --- a/src/dialogs/SettingsDlg.cpp +++ b/src/dialogs/SettingsDlg.cpp @@ -30,46 +30,70 @@ #include #include "SettingsDlg.h" +bool CSettingsDlg::PluginsModified=false; -CSettingsDlg::CSettingsDlg(QWidget* parent) -: QDialog(parent,Qt::Dialog) + +CSettingsDlg::CSettingsDlg(QWidget* parent):QDialog(parent,Qt::Dialog) { -setupUi(this); -connect(DialogButtons, SIGNAL( accepted() ), this, SLOT( OnOK() ) ); -connect(DialogButtons, SIGNAL( rejected() ), this, SLOT( OnCancel() ) ); -connect(ButtonColor1, SIGNAL( clicked() ), this, SLOT( OnColor1() ) ); -connect(ButtonColor2, SIGNAL( clicked() ), this, SLOT( OnColor2() ) ); -connect(ButtonTextColor, SIGNAL( clicked() ), this, SLOT( OnTextColor() ) ); -connect(CheckBox_OpenLast,SIGNAL(stateChanged(int)),this,SLOT(OnCeckBoxOpenLastChanged(int))); -connect(Button_MountDirBrowse,SIGNAL(clicked()),this,SLOT(OnMountDirBrowse())); -createBanner(&BannerPixmap,Icon_Settings32x32,tr("Settings"),width()); -CheckBox_OpenLast->setChecked(config.OpenLast); -SpinBox_ClipboardTime->setValue(config.ClipboardTimeOut); - -QPixmap *pxt=new QPixmap(pixmTextColor->width(),pixmTextColor->height()); -pxt->fill(config.BannerTextColor); -pixmTextColor->clear(); -pixmTextColor->setPixmap(*pxt); - -QPixmap *px1=new QPixmap(pixmColor1->width(),pixmColor1->height()); -px1->fill(config.BannerColor1); -pixmColor1->clear(); -pixmColor1->setPixmap(*px1); - -QPixmap *px2=new QPixmap(pixmColor2->width(),pixmColor2->height()); -px2->fill(config.BannerColor2); -pixmColor2->clear(); -pixmColor2->setPixmap(*px2); - -color1=config.BannerColor1; -color2=config.BannerColor2; -textcolor=config.BannerTextColor; -CheckBox_ShowPasswords->setChecked(config.ShowPasswords); -Edit_BrowserCmd->setText(config.OpenUrlCommand); -CheckBox_ExpandGroupTree->setChecked(config.ExpandGroupTree); -CheckBox_AlternatingRowColors->setChecked(config.AlternatingRowColors); -Edit_MountDir->setText(config.MountDir); -CheckBox_RememberLastKey->setChecked(config.RememberLastKey); + setupUi(this); + connect(DialogButtons, SIGNAL( accepted() ), this, SLOT( OnOK() ) ); + connect(DialogButtons, SIGNAL( rejected() ), this, SLOT( OnCancel() ) ); + connect(DialogButtons, SIGNAL( clicked(QAbstractButton*)), this, SLOT(OnOtherButton(QAbstractButton*))); + + connect(ButtonColor1, SIGNAL( clicked() ), this, SLOT( OnColor1() ) ); + connect(ButtonColor2, SIGNAL( clicked() ), this, SLOT( OnColor2() ) ); + connect(ButtonTextColor, SIGNAL( clicked() ), this, SLOT( OnTextColor() ) ); + connect(CheckBox_OpenLast,SIGNAL(stateChanged(int)),this,SLOT(OnCeckBoxOpenLastChanged(int))); + connect(Button_MountDirBrowse,SIGNAL(clicked()),this,SLOT(OnMountDirBrowse())); + + connect(Radio_IntPlugin_None,SIGNAL(toggled(bool)),this,SLOT(OnIntPluginNone(bool))); + connect(Radio_IntPlugin_Gnome,SIGNAL(toggled(bool)),this,SLOT(OnIntPluginGnome(bool))); + connect(Radio_IntPlugin_Kde,SIGNAL(toggled(bool)),this,SLOT(OnIntPluginKde(bool))); + + + createBanner(&BannerPixmap,Icon_Settings32x32,tr("Settings"),width()); + CheckBox_OpenLast->setChecked(config.OpenLast); + SpinBox_ClipboardTime->setValue(config.ClipboardTimeOut); + + QPixmap *pxt=new QPixmap(pixmTextColor->width(),pixmTextColor->height()); + pxt->fill(config.BannerTextColor); + pixmTextColor->clear(); + pixmTextColor->setPixmap(*pxt); + + QPixmap *px1=new QPixmap(pixmColor1->width(),pixmColor1->height()); + px1->fill(config.BannerColor1); + pixmColor1->clear(); + pixmColor1->setPixmap(*px1); + + QPixmap *px2=new QPixmap(pixmColor2->width(),pixmColor2->height()); + px2->fill(config.BannerColor2); + pixmColor2->clear(); + pixmColor2->setPixmap(*px2); + + color1=config.BannerColor1; + color2=config.BannerColor2; + textcolor=config.BannerTextColor; + CheckBox_ShowPasswords->setChecked(config.ShowPasswords); + Edit_BrowserCmd->setText(config.OpenUrlCommand); + CheckBox_ExpandGroupTree->setChecked(config.ExpandGroupTree); + CheckBox_AlternatingRowColors->setChecked(config.AlternatingRowColors); + Edit_MountDir->setText(config.MountDir); + CheckBox_RememberLastKey->setChecked(config.RememberLastKey); + + if(PluginLoadError==QString()) + Label_IntPlugin_Error->hide(); + else + Label_IntPlugin_Error->setText(QString("

%1

") + .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; + } + + if(!PluginsModified) + Label_IntPlugin_Info->hide(); } CSettingsDlg::~CSettingsDlg() @@ -83,71 +107,83 @@ void CSettingsDlg::paintEvent(QPaintEvent *event){ painter.drawPixmap(QPoint(0,0),BannerPixmap); } + + void CSettingsDlg::OnOK() { -config.OpenLast=CheckBox_OpenLast->isChecked(); -config.ClipboardTimeOut=SpinBox_ClipboardTime->value(); -config.BannerColor1=color1; -config.BannerColor2=color2; -config.BannerTextColor=textcolor; -config.ShowPasswords=CheckBox_ShowPasswords->isChecked(); -config.OpenUrlCommand=Edit_BrowserCmd->text(); -config.ExpandGroupTree=CheckBox_ExpandGroupTree->isChecked(); -config.AlternatingRowColors=CheckBox_AlternatingRowColors->isChecked(); -config.MountDir=Edit_MountDir->text(); -if(config.MountDir!="" && config.MountDir.right(1)!="/") - config.MountDir+="/"; -config.RememberLastKey=CheckBox_RememberLastKey->isChecked(); -close(); + apply(); + close(); } void CSettingsDlg::OnCancel() { -close(); + close(); } -void CSettingsDlg::OnTextColor() -{ +void CSettingsDlg::OnOtherButton(QAbstractButton* button){ + if(DialogButtons->buttonRole(button)==QDialogButtonBox::ApplyRole) + apply(); +} -QColor c=QColorDialog::getColor(textcolor,this); -if(c.isValid()){ -textcolor=c; -QPixmap *px=new QPixmap(pixmTextColor->width(),pixmTextColor->height()); -px->fill(c); -pixmTextColor->clear(); -pixmTextColor->setPixmap(*px); -//NICHT VERGESSEN! -//createBanner(Banner,Icon_Settings32x32,tr("Settings"),color1,color2,textcolor); +void CSettingsDlg::apply(){ + config.OpenLast=CheckBox_OpenLast->isChecked(); + config.ClipboardTimeOut=SpinBox_ClipboardTime->value(); + config.BannerColor1=color1; + config.BannerColor2=color2; + config.BannerTextColor=textcolor; + config.ShowPasswords=CheckBox_ShowPasswords->isChecked(); + config.OpenUrlCommand=Edit_BrowserCmd->text(); + config.ExpandGroupTree=CheckBox_ExpandGroupTree->isChecked(); + config.AlternatingRowColors=CheckBox_AlternatingRowColors->isChecked(); + config.MountDir=Edit_MountDir->text(); + if(config.MountDir!="" && config.MountDir.right(1)!="/") + config.MountDir+="/"; + config.RememberLastKey=CheckBox_RememberLastKey->isChecked(); + 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; } - + +void CSettingsDlg::OnTextColor() +{ + QColor c=QColorDialog::getColor(textcolor,this); + if(c.isValid()){ + textcolor=c; + QPixmap *px=new QPixmap(pixmTextColor->width(),pixmTextColor->height()); + px->fill(c); + pixmTextColor->clear(); + pixmTextColor->setPixmap(*px); + createBanner(&BannerPixmap,Icon_Settings32x32,tr("Settings"),width(),color1,color2,textcolor); + } } void CSettingsDlg::OnColor2() { -QColor c=QColorDialog::getColor(color2,this); -if(c.isValid()){ -color2=c; -QPixmap *px=new QPixmap(pixmColor2->width(),pixmColor2->height()); -px->fill(c); -pixmColor2->clear(); -pixmColor2->setPixmap(*px); -//createBanner(Banner,Icon_Settings32x32,tr("Settings"),color1,color2,textcolor); -} + QColor c=QColorDialog::getColor(color2,this); + if(c.isValid()){ + color2=c; + QPixmap *px=new QPixmap(pixmColor2->width(),pixmColor2->height()); + px->fill(c); + pixmColor2->clear(); + pixmColor2->setPixmap(*px); + createBanner(&BannerPixmap,Icon_Settings32x32,tr("Settings"),width(),color1,color2,textcolor); + } } void CSettingsDlg::OnColor1() { -QColor c=QColorDialog::getColor(color1,this); -if(c.isValid()){ -color1=c; -QPixmap *px=new QPixmap(pixmColor1->width(),pixmColor1->height()); -px->fill(c); -pixmColor1->clear(); -pixmColor1->setPixmap(*px); -//createBanner(Banner,Icon_Settings32x32,tr("Settings"),color1,color2,textcolor); -} + QColor c=QColorDialog::getColor(color1,this); + if(c.isValid()){ + color1=c; + QPixmap *px=new QPixmap(pixmColor1->width(),pixmColor1->height()); + px->fill(c); + pixmColor1->clear(); + pixmColor1->setPixmap(*px); + createBanner(&BannerPixmap,Icon_Settings32x32,tr("Settings"),width(),color1,color2,textcolor); + } } void CSettingsDlg::OnCeckBoxOpenLastChanged(int state){ @@ -165,3 +201,15 @@ if(dir!=QString()){ Edit_MountDir->setText(dir); } } + +void CSettingsDlg::OnIntPluginNone(bool toggled){ + Label_IntPlugin_Info->show(); +} + +void CSettingsDlg::OnIntPluginGnome(bool toggled){ + Label_IntPlugin_Info->show(); +} + +void CSettingsDlg::OnIntPluginKde(bool toggled){ + Label_IntPlugin_Info->show(); +} \ No newline at end of file diff --git a/src/dialogs/SettingsDlg.h b/src/dialogs/SettingsDlg.h index f97df9b..dd78853 100755 --- a/src/dialogs/SettingsDlg.h +++ b/src/dialogs/SettingsDlg.h @@ -41,13 +41,20 @@ class CSettingsDlg : public QDialog, public Ui_SettingsDialog virtual void OnTextColor(); virtual void OnColor2(); virtual void OnColor1(); + void OnOtherButton(QAbstractButton*); + void OnIntPluginNone(bool); + void OnIntPluginGnome(bool); + void OnIntPluginKde(bool); void OnCeckBoxOpenLastChanged(int state); void OnMountDirBrowse(); private: virtual void paintEvent(QPaintEvent*); + void apply(); QColor color1,color2,textcolor; QPixmap BannerPixmap; + static bool PluginsModified; + }; #endif diff --git a/src/forms/CollectEntropyDlg.ui b/src/forms/CollectEntropyDlg.ui index aaf38c6..1421bf1 100644 --- a/src/forms/CollectEntropyDlg.ui +++ b/src/forms/CollectEntropyDlg.ui @@ -80,9 +80,6 @@ Please move the mouse and/or press some keys until enought entropy for a reseed Qt::Horizontal - - %v Bits - diff --git a/src/forms/PasswordGenDlg.ui b/src/forms/PasswordGenDlg.ui index 9201aa4..2961b6a 100644 --- a/src/forms/PasswordGenDlg.ui +++ b/src/forms/PasswordGenDlg.ui @@ -32,382 +32,429 @@ Password Generator - - - - 130 - 400 - 180 - 15 - + + + 9 - - Qt::Horizontal + + 6 - - - - - 130 - 370 - 250 - 21 - - - - - - - 320 - 399 - 60 - 16 - - - - - - - - - - 263 - 440 - 90 - 25 - - - - Accep&t - - - - - - 360 - 440 - 90 - 25 - - - - &Cancel - - - - - - 381 - 370 - 70 - 21 - - - - Generate - - - - - - 20 - 370 - 110 - 20 - - - - New Password: - - - - - - 20 - 400 - 110 - 20 - - - - Quality: - - - - - - 0 - 420 - 460 - 20 - - - - QFrame::HLine - - - QFrame::Sunken - - - Qt::Horizontal - - - - - - 10 - 60 - 440 - 280 - - - - Options - - - - - 30 - 170 - 400 - 21 - - - - - - - 120 - 220 - 310 - 21 - - - - 1000 - - - 1 - - - 20 - - - - - - 120 - 40 - 131 - 20 - - - - &Upper Letters - - - Alt+U - - - true - - - - - - 120 - 60 - 140 - 20 - - - - &Lower Letters - - - Alt+L - - - true - - - - - - 120 - 80 - 140 - 20 - - - - &Numbers - - - Alt+N - - - true - - - - - - 120 - 100 - 140 - 20 - - - - &Special Characters - - - true - - - - - - 260 - 60 - 170 - 20 - - - - Minus - - - - - - 260 - 80 - 170 - 20 - - - - U&nderline - - - Alt+N - - - - - - 260 - 100 - 170 - 20 - - - - h&igher ANSI-Characters - - - Alt+H - - - - - - 10 - 150 - 420 - 16 - - - - Use &only following characters: - - - Alt+O - - - - - - 10 - 220 - 110 - 21 - - - - Length: - - - - - - 10 - 20 - 420 - 21 - - - - Use follo&wing character groups: - - - Alt+W - - - - - - 260 - 40 - 170 - 20 - - - - White &Spaces - - - Alt+S - - - - - - 120 - 250 - 310 - 21 - - - - Force entropy collection - - - Alt+M - - - true - - - - - - - 0 - 0 - 460 - 50 - - - - - - - true - - + + + + Qt::Vertical + + + + 20 + 50 + + + + + + + + Options + + + + 10 + + + 6 + + + + + Use follo&wing character groups: + + + Alt+W + + + + + + + 0 + + + 6 + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 30 + 20 + + + + + + + + 0 + + + 0 + + + + + &Upper Letters + + + Alt+U + + + true + + + + + + + &Lower Letters + + + Alt+L + + + true + + + + + + + &Numbers + + + Alt+N + + + true + + + + + + + &Special Characters + + + true + + + + + + + + + 0 + + + 0 + + + + + White &Spaces + + + Alt+S + + + + + + + Minus + + + + + + + U&nderline + + + Alt+N + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Use &only following characters: + + + Alt+O + + + + + + + 0 + + + 6 + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 30 + 20 + + + + + + + + 255 + + + + + + + + + Qt::Vertical + + + + 20 + 20 + + + + + + + + 0 + + + 6 + + + + + Length: + + + + + + + 10000 + + + 1 + + + 20 + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 10 + 20 + + + + + + + + Quality: + + + + + + + + 7 + 1 + 0 + 0 + + + + + 16777215 + 16777215 + + + + 128 + + + 0 + + + Qt::Horizontal + + + + + + + + + 0 + + + 6 + + + + + Enable entropy collection + + + Alt+M + + + true + + + + + + + Collect only once per session + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + 0 + + + 6 + + + + + New Password: + + + + + + + + + + Generate + + + + + + + + + QFrame::HLine + + + QFrame::Sunken + + + Qt::Horizontal + + + + + + + Qt::Horizontal + + + QDialogButtonBox::NoButton + + + + @@ -419,15 +466,11 @@ checkBox5 checkBox6 checkBox7 - checkBox8 Radio_2 Edit_chars - Spin_Num - Check_strongrandom + Check_CollectEntropy Edit_dest ButtonGenerate - ButtonOK - Button_Cancel diff --git a/src/forms/SettingsDlg.ui b/src/forms/SettingsDlg.ui index 30c0e45..84fd076 100644 --- a/src/forms/SettingsDlg.ui +++ b/src/forms/SettingsDlg.ui @@ -52,8 +52,17 @@ + + The integration plugins provide features like usage of the native file dialogs and message boxes of the particular desktop environments. + + + QTabWidget::North + + + QTabWidget::Rounded + - 3 + 2 @@ -453,7 +462,7 @@ - Intergration Plug-ins + Desktop Integration @@ -463,7 +472,7 @@ 6 - + 5 @@ -473,7 +482,10 @@ - < some text about plugin usage > + + + + true @@ -498,21 +510,21 @@ 6 - + None - + Gnome Desktop Integration (Gtk 2.x) - + KDE 4 Desktop Integration @@ -529,6 +541,13 @@ 6 + + + + You need to restart the program before the changes take effect. + + + @@ -543,7 +562,7 @@ - + Configure... @@ -551,6 +570,19 @@ + + + + Qt::Vertical + + + + 20 + 40 + + + + @@ -652,7 +684,7 @@ Qt::Horizontal - QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok + QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok diff --git a/src/lib/FileDialogs.cpp b/src/lib/FileDialogs.cpp index 677cce9..b50e807 100644 --- a/src/lib/FileDialogs.cpp +++ b/src/lib/FileDialogs.cpp @@ -73,8 +73,11 @@ QStringList QtStandardFileDialogs::openExistingFilesDialog(QWidget* parent,QStri } QString QtStandardFileDialogs::saveFileDialog(QWidget* parent,QString title,QString dir,QStringList Filters,bool ShowOverwriteWarning){ - - return QString(); - - + QFileDialog FileDlg(parent,title,dir); + FileDlg.setFilters(Filters); + FileDlg.setFileMode(QFileDialog::AnyFile); + FileDlg.setAcceptMode(QFileDialog::AcceptSave); + FileDlg.setConfirmOverwrite(ShowOverwriteWarning); + if(!FileDlg.exec())return QString(); + return FileDlg.selectedFiles()[0]; } diff --git a/src/main.cpp b/src/main.cpp index be67d33..1a2e3e2 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -52,9 +52,12 @@ using namespace std; #include #include #endif - + +#define CSTR(x)(x.toUtf8().data()) + CConfig config; QString AppDir; +QString PluginLoadError; bool TrActive; QPixmap *Icon_Key32x32; QPixmap *Icon_Settings32x32; @@ -81,6 +84,7 @@ QIcon *Icon_Configure; QIcon *Icon_Help; QIcon *Icon_AutoType; QIcon *Icon_Swap; +QIcon *Icon_FileSaveDisabled; inline void loadImages(); inline void parseCmdLineArgs(int argc, char** argv,QString &ArgFile,QString& ArgCfg,QString& ArgLang); @@ -92,6 +96,9 @@ int main(int argc, char **argv) QString ArgFile,ArgCfg,ArgLang,IniFilename; QApplication* app=NULL; + AppDir=QString(argv[0]); + AppDir.truncate(AppDir.lastIndexOf("/")); + //Load Config if(ArgCfg==QString()){ if(!QDir(QDir::homePath()+"/.keepass").exists()){ @@ -114,29 +121,39 @@ int main(int argc, char **argv) LibName+="kde.so"; else if(config.IntegrPlugin==CConfig::GNOME) LibName+="gnome.so"; - QPluginLoader plugin("/home/tarek/Documents/KeePassX/src/plugins/gnome/"+LibName); - if(!plugin.load()){ - qWarning("Could not load destop integration plugin:"); - qWarning(plugin.errorString().toUtf8().data()); + QString filename=findPlugin(LibName); + if(filename!=QString()){ + QPluginLoader plugin(filename); + if(!plugin.load()){ + PluginLoadError=plugin.errorString(); + qWarning("Could not load desktop integration plugin:"); + qWarning(CSTR(PluginLoadError)); + } + else{ + IFileDialog* fdlg=qobject_cast(plugin.instance()); + KpxFileDialogs::setPlugin(fdlg); + if(config.IntegrPlugin==CConfig::KDE){ + IKdeInit* kdeinit=qobject_cast(plugin.instance()); + app=kdeinit->getMainAppObject(argc,argv); + if(!app)PluginLoadError=QObject::tr("Initialization failed."); + } + if(config.IntegrPlugin==CConfig::GNOME){ + IGnomeInit* ginit=qobject_cast(plugin.instance()); + if(!ginit->init(argc,argv)){ + KpxFileDialogs::setPlugin(NULL); + qWarning("GtkIntegrPlugin: Gtk init failed."); + PluginLoadError=QObject::tr("Initialization failed."); + } + } + } } else{ - IFileDialog* fdlg=qobject_cast(plugin.instance()); - KpxFileDialogs::setPlugin(fdlg); - if(config.IntegrPlugin==CConfig::KDE){ - IKdeInit* kdeinit=qobject_cast(plugin.instance()); - app=kdeinit->getMainAppObject(argc,argv); - } - if(config.IntegrPlugin==CConfig::GNOME){ - IGnomeInit* ginit=qobject_cast(plugin.instance()); - if(!ginit->init(argc,argv)) - KpxFileDialogs::setPlugin(NULL); - } + qWarning(CSTR(QString("Could not load desktop integration plugin: File '%1' not found.").arg(LibName))); + PluginLoadError=QObject::tr("Could not locate library file."); } } if(!app) QApplication* app=new QApplication(argc,argv); - parseCmdLineArgs(argc,argv,ArgFile,ArgCfg,ArgLang); - AppDir=app->applicationDirPath(); - + parseCmdLineArgs(argc,argv,ArgFile,ArgCfg,ArgLang); //Internationalization @@ -257,9 +274,9 @@ QString decodeFileError(QFile::FileError Code){ } void openBrowser(QString url){ -QStringList args=config.OpenUrlCommand.arg(url).split(' '); -QString cmd=args.takeFirst(); -QProcess::startDetached(cmd,args); + QStringList args=config.OpenUrlCommand.arg(url).split(' '); + QString cmd=args.takeFirst(); + QProcess::startDetached(cmd,args); } @@ -333,6 +350,7 @@ _loadIcon(Icon_Configure,"/actions/configure.png"); _loadIcon(Icon_Help,"/actions/help.png"); _loadIcon(Icon_AutoType,"/apps/ktouch.png"); _loadIcon(Icon_Swap,"/actions/reload.png"); +Icon_FileSaveDisabled=new QIcon(Icon_FileSave->pixmap(32,32,QIcon::Disabled)); } @@ -393,3 +411,13 @@ int i=1; void showErrMsg(const QString& msg,QWidget* parent){ QMessageBox::critical(parent,QObject::tr("Error"),msg,QObject::tr("OK")); } + +QString findPlugin(const QString& filename){ + QFileInfo info; + + info.setFile(AppDir+"/../lib/keepassx/"+filename); + if(info.exists() && info.isFile()) + return AppDir+"/../lib/keepassx/"+filename; + + return QString(); +} diff --git a/src/main.h b/src/main.h index fb17b0e..56f456b 100644 --- a/src/main.h +++ b/src/main.h @@ -39,6 +39,8 @@ void createBanner(QPixmap* Pixmap, QPixmap* IconAlpha,const QString& Text,int Wi void openBrowser(QString url); void showErrMsg(const QString& msg,QWidget* parent=NULL); QString decodeFileError(QFile::FileError Code); +QString findPlugin(const QString& filename); +extern QString PluginLoadError; extern CConfig config; extern QString AppDir; @@ -69,6 +71,7 @@ extern QIcon *Icon_Configure; extern QIcon *Icon_Help; extern QIcon *Icon_AutoType; extern QIcon *Icon_Swap; +extern QIcon *Icon_FileSaveDisabled; #endif diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 65d4999..5a3dbde 100755 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -327,7 +327,7 @@ void KeepassMainWindow::openDatabase(QString filename,bool IsAuto){ StatusBarGeneral->setText(tr("Loading Database...")); if(db->load(filename)==true){ if(config.OpenLast)config.LastFile=filename; - setWindowTitle(tr("KeePassX - %1").arg(filename)); + setWindowTitle(tr("%1 - KeePassX").arg(filename)); GroupView->createItems(); EntryView->showGroup(NULL); setStateFileOpen(true); @@ -350,28 +350,28 @@ void KeepassMainWindow::openDatabase(QString filename,bool IsAuto){ bool KeepassMainWindow::closeDatabase(){ -Q_ASSERT(FileOpen); -Q_ASSERT(db!=NULL); -if(ModFlag){ - int r=QMessageBox::question(this,tr("Save modified file?"), - tr("The current file was modified. Do you want\nto save the changes?"),tr("Yes"),tr("No"),tr("Cancel"),2,2); - if(r==2)return false; //Abbrechen - if(r==0) //Ja (Datei speichern) - if(!OnFileSave())return false; -} -db->close(); -delete db; -db=NULL; -EntryView->db=NULL; -EntryView->clear(); -EntryView->Items.clear(); -GroupView->db=NULL; -GroupView->clear(); -GroupView->Items.clear(); -SearchResults.clear(); -setStateFileOpen(false); -setWindowTitle("KeePassX Password Manager"); -return true; + Q_ASSERT(FileOpen); + Q_ASSERT(db!=NULL); + if(ModFlag){ + int r=QMessageBox::question(this,tr("Save modified file?"), + tr("The current file was modified. Do you want\nto save the changes?"),tr("Yes"),tr("No"),tr("Cancel"),2,2); + if(r==2)return false; //Abbrechen + if(r==0) //Ja (Datei speichern) + if(!OnFileSave())return false; + } + db->close(); + delete db; + db=NULL; + EntryView->db=NULL; + EntryView->clear(); + EntryView->Items.clear(); + GroupView->db=NULL; + GroupView->clear(); + GroupView->Items.clear(); + SearchResults.clear(); + setStateFileOpen(false); + setWindowTitle("KeePassX Password Manager"); + return true; } @@ -422,7 +422,7 @@ void KeepassMainWindow::OnFileNewKdb(){ return; } } - setWindowTitle(tr("KeePassX - %1").arg(tr("[new]"))); + setWindowTitle(tr("%1 - KeePassX").arg(tr("[new]"))); GroupView->db=db; EntryView->db=db; GroupView->createItems(); @@ -501,9 +501,15 @@ else{ void KeepassMainWindow::setStateFileModified(bool mod){ -if(!FileOpen)return; -ModFlag=mod; -FileSaveAction->setEnabled(mod); + if(!FileOpen){ + FileSaveAction->setIcon(*Icon_FileSave); + return; + } + ModFlag=mod; + if(mod) + FileSaveAction->setIcon(*Icon_FileSave); + else + FileSaveAction->setIcon(*Icon_FileSaveDisabled); } void KeepassMainWindow::setStateGroupSelected(SelectionState s){ @@ -535,32 +541,33 @@ void KeepassMainWindow::setStateGroupSelected(SelectionState s){ } void KeepassMainWindow::updateDetailView(){ -if(EntryView->selectedItems().size()!=1){ - DetailView->setPlainText(""); - return;} - -IEntryHandle* entry=((EntryViewItem*)(EntryView->selectedItems()[0]))->EntryHandle; -QString str=tr("Group: %1 Title: %2 Username: %3 URL: %4 Password: %5 Creation: %6 Last Change: %7 LastAccess: %8 Expires: %9"); - -str=str.arg(entry->group()->title()).arg(entry->title()); - -if(!config.ListView_HideUsernames) str=str.arg(entry->username()); -else str=str.arg("****"); - -str=str.arg(entry->url()); - -if(!config.ListView_HidePasswords){ - SecString password=entry->password(); - password.unlock(); - str=str.arg(password.string()); -} -else str=str.arg("****"); - -str=str .arg(entry->creation().toString(Qt::LocalDate)) - .arg(entry->lastMod().toString(Qt::LocalDate)) - .arg(entry->lastAccess().toString(Qt::LocalDate)) - .arg(entry->expire().toString(Qt::LocalDate)); -DetailView->setHtml(str); + if(EntryView->selectedItems().size()!=1){ + DetailView->setPlainText(""); + return; + } + + IEntryHandle* entry=((EntryViewItem*)(EntryView->selectedItems()[0]))->EntryHandle; + QString str=tr("Group: %1 Title: %2 Username: %3 URL: %4 Password: %5 Creation: %6 Last Change: %7 LastAccess: %8 Expires: %9"); + + str=str.arg(entry->group()->title()).arg(entry->title()); + + if(!config.ListView_HideUsernames) str=str.arg(entry->username()); + else str=str.arg("****"); + + str=str.arg(entry->url()); + + if(!config.ListView_HidePasswords){ + SecString password=entry->password(); + password.unlock(); + str=str.arg(password.string()); + } + else str=str.arg("****"); + + str=str .arg(entry->creation().toString(Qt::LocalDate)) + .arg(entry->lastMod().toString(Qt::LocalDate)) + .arg(entry->lastAccess().toString(Qt::LocalDate)) + .arg(entry->expire().toString(Qt::LocalDate)); + DetailView->setHtml(str); } @@ -663,19 +670,16 @@ return true; } bool KeepassMainWindow::OnFileSaveAs(){ - QFileDialog FileDlg(this,tr("Save Database As..."),QDir::homePath()); - FileDlg.setFilters(QStringList()<< tr("KeePass Databases (*.kdb)")<< tr("All Files (*)")); - FileDlg.setFileMode(QFileDialog::AnyFile); - FileDlg.setAcceptMode(QFileDialog::AcceptSave); - if(!FileDlg.exec())return false; - if(!FileDlg.selectedFiles().size())return false; - if(!db->changeFile(FileDlg.selectedFiles()[0])){ + QString filename=KpxFileDialogs::saveFile(this,"MainWindow_FileSave", + tr("Save Database..."),QStringList()<changeFile(filename)){ showErrMsg(tr("File could not be saved.\n%1").arg(db->getError())); db->changeFile(QString()); - setWindowTitle(tr("KeePassX - [unsaved]").arg(FileDlg.selectedFiles()[0])); + setWindowTitle(tr("KeePassX - [unsaved]").arg(filename)); return false; } - setWindowTitle(tr("KeePassX - %1").arg(FileDlg.selectedFiles()[0])); + setWindowTitle(tr("%1 - KeePassX").arg(filename)); return OnFileSave(); } @@ -950,7 +954,7 @@ void KeepassMainWindow::OnGroupSelectionChanged(IGroupHandle* group){ } void KeepassMainWindow::OnEntryChanged(SelectionState Selection){ - //DETAIL-VIEW!!! + updateDetailView(); setStateEntrySelected(Selection); } diff --git a/src/plugins/gnome/keepassx-gnome.cpp b/src/plugins/gnome/keepassx-gnome.cpp index 5b30280..de00790 100644 --- a/src/plugins/gnome/keepassx-gnome.cpp +++ b/src/plugins/gnome/keepassx-gnome.cpp @@ -113,4 +113,26 @@ QStringList GnomePlugin::openExistingFilesDialog(QWidget* parent,QString title,Q return filenames; } -QString GnomePlugin::saveFileDialog(QWidget* parent,QString title,QString dir,QStringList Filters,bool OverWriteWarn){return QString();} \ No newline at end of file +QString GnomePlugin::saveFileDialog(QWidget* parent,QString title,QString dir,QStringList Filters,bool OverWriteWarn){ + unsigned int NumFilters=Filters.size(); + GtkWidget *FileDlg; + QString filename; + FileDlg=gtk_file_chooser_dialog_new(CSTR(title),NULL, + GTK_FILE_CHOOSER_ACTION_SAVE, + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, + NULL); + gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(FileDlg),CSTR(dir)); + gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(FileDlg),OverWriteWarn); + GtkFileFilter** filters=parseFilterStrings(Filters); + + for(int i=0;i