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
master
tarek_saidi 18 years ago
parent 7e54d5f317
commit 08d9ff59c9
  1. 2
      src/PwmConfig.h
  2. 8
      src/dialogs/EditEntryDlg.cpp
  3. 395
      src/dialogs/PasswordGenDlg.cpp
  4. 53
      src/dialogs/PasswordGenDlg.h
  5. 214
      src/dialogs/SettingsDlg.cpp
  6. 7
      src/dialogs/SettingsDlg.h
  7. 3
      src/forms/CollectEntropyDlg.ui
  8. 801
      src/forms/PasswordGenDlg.ui
  9. 50
      src/forms/SettingsDlg.ui
  10. 11
      src/lib/FileDialogs.cpp
  11. 72
      src/main.cpp
  12. 3
      src/main.h
  13. 130
      src/mainwindow.cpp
  14. 24
      src/plugins/gnome/keepassx-gnome.cpp
  15. 2
      src/plugins/gnome/keepassx-gnome.pro
  16. 4
      src/plugins/kde/keepassx-kde.pro

@ -57,7 +57,7 @@ enum IntegrPluginType{NONE,KDE,GNOME};
bool ShowStatusbar; bool ShowStatusbar;
bool AlternatingRowColors; bool AlternatingRowColors;
QString MountDir; QString MountDir;
bool RememberLastKey; //location and type, not the key itself bool RememberLastKey;
tKeyType LastKeyType; tKeyType LastKeyType;
QString LastKeyLocation; QString LastKeyLocation;
int ToolbarIconSize; int ToolbarIconSize;

@ -361,8 +361,12 @@ void CEditEntryDlg::OnDeleteAttachment()
void CEditEntryDlg::OnButtonGenPw() void CEditEntryDlg::OnButtonGenPw()
{ {
CGenPwDialog* pDlg=new CGenPwDialog(this,true); CGenPwDialog dlg(this,true);
pDlg->show(); if(dlg.exec()){
Edit_Password->setText(dlg.Edit_dest->text());
Edit_Password_w->setText(dlg.Edit_dest->text());
ModFlag=true;
}
} }

@ -18,214 +18,257 @@
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/ ***************************************************************************/
#include <fstream> #include <QSpinBox>
#include <qspinbox.h> #include <QMessageBox>
#include <qmessagebox.h> #include <QRadioButton>
#include "PasswordGenDlg.h" #include <QLineEdit>
#include <qradiobutton.h> #include <QCheckBox>
#include <qlineedit.h>
#include <qcheckbox.h>
#include <QProgressBar> #include <QProgressBar>
#include <QPainter>
#include <math.h>
#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) : QDialog(parent,fl)
{ {
setupUi(this); setupUi(this);
createBanner(Banner,Icon_Key32x32,tr("Password Generator")); createBanner(&BannerPixmap,Icon_Key32x32,tr("Password Generator"),width());
Radio_1->setChecked(true);
Edit_chars->setDisabled(true); connect(ButtonGenerate,SIGNAL(clicked()),this,SLOT(OnGeneratePw()));
connect(ButtonGenerate,SIGNAL(clicked()),this,SLOT(OnGeneratePw())); connect(Radio_1,SIGNAL(toggled(bool)),this,SLOT(OnRadio1StateChanged(bool)));
connect(Radio_1,SIGNAL(toggled(bool)),this,SLOT(OnRadio1StateChanged(bool))); connect(Radio_2,SIGNAL(toggled(bool)),this,SLOT(OnRadio2StateChanged(bool)));
connect(Radio_2,SIGNAL(toggled(bool)),this,SLOT(OnRadio2StateChanged(bool))); connect(DialogButtons,SIGNAL(rejected()),this,SLOT(OnCancel()));
connect(Button_Cancel,SIGNAL(clicked()),this,SLOT(OnCancel())); connect(DialogButtons,SIGNAL(accepted()),this,SLOT(OnAccept()));
connect(ButtonOK,SIGNAL(clicked()),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) CGenPwDialog::~CGenPwDialog(){
{ config.PwGenOptions[0]=Radio_1->isChecked();
if(state){ config.PwGenOptions[1]=checkBox1->isChecked();
Radio_2->setChecked(false); config.PwGenOptions[2]=checkBox2->isChecked();
checkBox1->setEnabled(true); config.PwGenOptions[3]=checkBox3->isChecked();
checkBox2->setEnabled(true); config.PwGenOptions[4]=checkBox4->isChecked();
checkBox3->setEnabled(true); config.PwGenOptions[5]=checkBox5->isChecked();
checkBox4->setEnabled(true); config.PwGenOptions[6]=checkBox6->isChecked();
checkBox5->setEnabled(true); config.PwGenOptions[7]=checkBox7->isChecked();
checkBox6->setEnabled(true); config.PwGenOptions[8]=Check_CollectEntropy->isChecked();
checkBox7->setEnabled(true); config.PwGenOptions[9]=Check_CollectOncePerSession->isChecked();
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);
} }
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){ if(state){
Radio_1->setChecked(false); checkBox1->setEnabled(true);
Edit_chars->setEnabled(true); checkBox2->setEnabled(true);
} checkBox3->setEnabled(true);
else{ checkBox4->setEnabled(true);
if(Radio_1->isChecked()==false)Radio_1->setChecked(true); checkBox5->setEnabled(true);
Edit_chars->setDisabled(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() void CGenPwDialog::OnGeneratePw()
{ {
/* /*-------------------------------------------------------
------- ASCII
ASCII -------------------------------------------------------
------- "A...Z" 65...90
"A...Z" 65...90 "a...z" 97...122
"a...z" 97...122 "0...9" 48...57
"0...9" 48...57 Special Charakters 33...47; 58...64; 91...96; 123...126
Special Charakters 33...47;58...64;91...96;123...126 "-" 45
"-" 45 "_" 95
"_" 95 -------------------------------------------------------
ANSI >127 */
*/
int num=0;
int num=0; char assoctable[255];
char assoctable[255];
if(Radio_1->isChecked()){
if(Radio_1->isChecked()){ if(checkBox1->isChecked())
if(checkBox1->isChecked()){ num+=AddToAssoctable(assoctable,65,90,num);
num+=AddToAssoctable(assoctable,65,90,num); if(checkBox2->isChecked())
} num+=AddToAssoctable(assoctable,97,122,num);
if(checkBox3->isChecked())
if(checkBox2->isChecked()){ num+=AddToAssoctable(assoctable,48,57,num);
num+=AddToAssoctable(assoctable,97,122,num); if(checkBox4->isChecked()){
} num+=AddToAssoctable(assoctable,33,47,num);
num+=AddToAssoctable(assoctable,58,64,num);
if(checkBox3->isChecked()){ num+=AddToAssoctable(assoctable,91,96,num);
num+=AddToAssoctable(assoctable,48,57,num); num+=AddToAssoctable(assoctable,123,126,num);}
} if(checkBox5->isChecked())
num+=AddToAssoctable(assoctable,32,32,num);
if(checkBox4->isChecked()){ if(checkBox6->isChecked() && !checkBox4->isChecked())
num+=AddToAssoctable(assoctable,33,47,num); num+=AddToAssoctable(assoctable,45,45,num);
num+=AddToAssoctable(assoctable,58,64,num); if(checkBox7->isChecked() && !checkBox4->isChecked())
num+=AddToAssoctable(assoctable,91,96,num); num+=AddToAssoctable(assoctable,95,95,num);
num+=AddToAssoctable(assoctable,123,126,num); }
} else{
QString str=Edit_chars->text();
if(checkBox5->isChecked()){ for(int i=0;i<str.length();i++){
num+=AddToAssoctable(assoctable,32,32,num); assoctable[i]=str[i].toAscii();
} num++;
}
}
if(checkBox6->isChecked() && !checkBox4->isChecked()){ if(num==0){
num+=AddToAssoctable(assoctable,45,45,num); if(Radio_2->isChecked())
} QMessageBox::information(this,tr("Notice"),tr("You need to enter at least one character"),tr("OK"));
else
if(checkBox7->isChecked() && !checkBox4->isChecked()){ QMessageBox::information(this,tr("Notice"),QString::fromUtf8("You need to select at least one character group."),"OK");
num+=AddToAssoctable(assoctable,95,95,num); return;
} }
int length=Spin_Num->value();
if(checkBox8->isChecked()){ char* buffer=new char[length+1];
num+=AddToAssoctable(assoctable,128,255,num); buffer[length]=0;
}
}else if(Check_CollectEntropy->isChecked()){
{ if((Check_CollectOncePerSession->isChecked() && !EntropyCollected) || !Check_CollectOncePerSession->isChecked()){
QString str=Edit_chars->text(); CollectEntropyDlg dlg(this);
int i=0; dlg.exec();
while(str.length()>0){ EntropyCollected=true;
assoctable[i]=((QChar)str[0]).toAscii(); }
str.remove(str[0]); }
i++;
num++; unsigned char tmp;
} for(int i=0;i<length;i++){
}
if(num==0){ do randomize(&tmp,1);
if(Radio_2->isChecked())QMessageBox::information(this,tr("Notice"),tr("You need to enter at least one character"),tr("OK")); while(!trim(tmp,num));
else QMessageBox::information(this,tr("Notice"),QString::fromUtf8("You need to select at least one character group."),"OK");
return; buffer[i]=assoctable[tmp];
} }
int length=Spin_Num->value();
char* buffer=new char[length+1]; Edit_dest->setText(buffer);
buffer[length]=0; delete [] buffer;
FILE *dev_random; if(AcceptButton)AcceptButton->setEnabled(true);
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;i<length;i++){
do{
fread(&tmp,1,1,dev_random);
}while(trim(tmp,num)==false);
buffer[i]=assoctable[tmp];
}
Edit_dest->setText(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);
} }
int CGenPwDialog::AddToAssoctable(char* table,int start,int end,int pos){ int CGenPwDialog::AddToAssoctable(char* table,int start,int end,int pos){
for(int i=start;i<=end;i++){ for(int i=start;i<=end;i++){
table[pos]=i; table[pos]=i;
pos++; pos++;
} }
return (end-start)+1; return (end-start)+1;
} }
bool CGenPwDialog::trim(unsigned char &x, int r){ bool CGenPwDialog::trim(unsigned char &x, int r){
if(x<r)return true; if(x<r)
if(256%r!=0)return false; return true;
x=x-(x/r)*r; if(256%r!=0)
return true; return false;
x=x-(x/r)*r;
return true;
}
void CGenPwDialog::estimateQuality(){
int num=0;
if(Radio_1->isChecked()){
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() void CGenPwDialog::OnAccept()
{ {
((CEditEntryDlg*)parentWidget())->Edit_Password->setText(Edit_dest->text()); done(1);
((CEditEntryDlg*)parentWidget())->Edit_Password_w->setText(Edit_dest->text());
((CEditEntryDlg*)parentWidget())->ModFlag=true;
close();
} }
void CGenPwDialog::OnCancel() 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"

@ -17,39 +17,40 @@
* Free Software Foundation, Inc., * * Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/ ***************************************************************************/
#include "main.h"
#ifndef GENPWDIALOG_H #ifndef GENPWDIALOG_H
#define GENPWDIALOG_H #define GENPWDIALOG_H
#include <QPixmap>
#include <QPaintEvent>
#include "ui_PasswordGenDlg.h" #include "ui_PasswordGenDlg.h"
#include "main.h"
#include "EditEntryDlg.h" #include "EditEntryDlg.h"
class CGenPwDialog : public QDialog, public Ui_GenPwDlg class CGenPwDialog : public QDialog, public Ui_GenPwDlg
{ {
Q_OBJECT Q_OBJECT
private: public:
int AddToAssoctable(char* table,int start,int end,int pos); CGenPwDialog(QWidget* parent = 0, bool ShowCancelButton=false, Qt::WFlags fl = 0 );
bool trim(unsigned char &value,int range); ~CGenPwDialog();
public:
CGenPwDialog(QWidget* parent = 0, bool modal = FALSE, Qt::WFlags fl = 0 ); private:
~CGenPwDialog(); int AddToAssoctable(char* table,int start,int end,int pos);
/*$PUBLIC_FUNCTIONS$*/ bool trim(unsigned char &value,int range);
virtual void paintEvent(QPaintEvent* event);
public slots: QPixmap BannerPixmap;
/*$PUBLIC_SLOTS$*/ static bool EntropyCollected;
QPushButton* AcceptButton;
protected:
/*$PROTECTED_FUNCTIONS$*/ private slots:
virtual void OnGeneratePw();
protected slots: virtual void OnRadio2StateChanged(bool);
/*$PROTECTED_SLOTS$*/ virtual void OnRadio1StateChanged(bool);
public slots: virtual void OnCancel();
virtual void OnGeneratePw(); virtual void OnAccept();
virtual void OnRadio2StateChanged(bool); void estimateQuality();
virtual void OnRadio1StateChanged(bool); void OnCollectEntropyChanged(int);
virtual void OnCancel();
virtual void OnAccept();
}; };
#endif #endif

@ -30,46 +30,70 @@
#include <QPainter> #include <QPainter>
#include "SettingsDlg.h" #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); setupUi(this);
connect(DialogButtons, SIGNAL( accepted() ), this, SLOT( OnOK() ) ); connect(DialogButtons, SIGNAL( accepted() ), this, SLOT( OnOK() ) );
connect(DialogButtons, SIGNAL( rejected() ), this, SLOT( OnCancel() ) ); connect(DialogButtons, SIGNAL( rejected() ), this, SLOT( OnCancel() ) );
connect(ButtonColor1, SIGNAL( clicked() ), this, SLOT( OnColor1() ) ); connect(DialogButtons, SIGNAL( clicked(QAbstractButton*)), this, SLOT(OnOtherButton(QAbstractButton*)));
connect(ButtonColor2, SIGNAL( clicked() ), this, SLOT( OnColor2() ) );
connect(ButtonTextColor, SIGNAL( clicked() ), this, SLOT( OnTextColor() ) ); connect(ButtonColor1, SIGNAL( clicked() ), this, SLOT( OnColor1() ) );
connect(CheckBox_OpenLast,SIGNAL(stateChanged(int)),this,SLOT(OnCeckBoxOpenLastChanged(int))); connect(ButtonColor2, SIGNAL( clicked() ), this, SLOT( OnColor2() ) );
connect(Button_MountDirBrowse,SIGNAL(clicked()),this,SLOT(OnMountDirBrowse())); connect(ButtonTextColor, SIGNAL( clicked() ), this, SLOT( OnTextColor() ) );
createBanner(&BannerPixmap,Icon_Settings32x32,tr("Settings"),width()); connect(CheckBox_OpenLast,SIGNAL(stateChanged(int)),this,SLOT(OnCeckBoxOpenLastChanged(int)));
CheckBox_OpenLast->setChecked(config.OpenLast); connect(Button_MountDirBrowse,SIGNAL(clicked()),this,SLOT(OnMountDirBrowse()));
SpinBox_ClipboardTime->setValue(config.ClipboardTimeOut);
connect(Radio_IntPlugin_None,SIGNAL(toggled(bool)),this,SLOT(OnIntPluginNone(bool)));
QPixmap *pxt=new QPixmap(pixmTextColor->width(),pixmTextColor->height()); connect(Radio_IntPlugin_Gnome,SIGNAL(toggled(bool)),this,SLOT(OnIntPluginGnome(bool)));
pxt->fill(config.BannerTextColor); connect(Radio_IntPlugin_Kde,SIGNAL(toggled(bool)),this,SLOT(OnIntPluginKde(bool)));
pixmTextColor->clear();
pixmTextColor->setPixmap(*pxt);
createBanner(&BannerPixmap,Icon_Settings32x32,tr("Settings"),width());
QPixmap *px1=new QPixmap(pixmColor1->width(),pixmColor1->height()); CheckBox_OpenLast->setChecked(config.OpenLast);
px1->fill(config.BannerColor1); SpinBox_ClipboardTime->setValue(config.ClipboardTimeOut);
pixmColor1->clear();
pixmColor1->setPixmap(*px1); QPixmap *pxt=new QPixmap(pixmTextColor->width(),pixmTextColor->height());
pxt->fill(config.BannerTextColor);
QPixmap *px2=new QPixmap(pixmColor2->width(),pixmColor2->height()); pixmTextColor->clear();
px2->fill(config.BannerColor2); pixmTextColor->setPixmap(*pxt);
pixmColor2->clear();
pixmColor2->setPixmap(*px2); QPixmap *px1=new QPixmap(pixmColor1->width(),pixmColor1->height());
px1->fill(config.BannerColor1);
color1=config.BannerColor1; pixmColor1->clear();
color2=config.BannerColor2; pixmColor1->setPixmap(*px1);
textcolor=config.BannerTextColor;
CheckBox_ShowPasswords->setChecked(config.ShowPasswords); QPixmap *px2=new QPixmap(pixmColor2->width(),pixmColor2->height());
Edit_BrowserCmd->setText(config.OpenUrlCommand); px2->fill(config.BannerColor2);
CheckBox_ExpandGroupTree->setChecked(config.ExpandGroupTree); pixmColor2->clear();
CheckBox_AlternatingRowColors->setChecked(config.AlternatingRowColors); pixmColor2->setPixmap(*px2);
Edit_MountDir->setText(config.MountDir);
CheckBox_RememberLastKey->setChecked(config.RememberLastKey); 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("<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;
}
if(!PluginsModified)
Label_IntPlugin_Info->hide();
} }
CSettingsDlg::~CSettingsDlg() CSettingsDlg::~CSettingsDlg()
@ -83,71 +107,83 @@ void CSettingsDlg::paintEvent(QPaintEvent *event){
painter.drawPixmap(QPoint(0,0),BannerPixmap); painter.drawPixmap(QPoint(0,0),BannerPixmap);
} }
void CSettingsDlg::OnOK() void CSettingsDlg::OnOK()
{ {
config.OpenLast=CheckBox_OpenLast->isChecked(); apply();
config.ClipboardTimeOut=SpinBox_ClipboardTime->value(); close();
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();
} }
void CSettingsDlg::OnCancel() 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); void CSettingsDlg::apply(){
if(c.isValid()){ config.OpenLast=CheckBox_OpenLast->isChecked();
textcolor=c; config.ClipboardTimeOut=SpinBox_ClipboardTime->value();
QPixmap *px=new QPixmap(pixmTextColor->width(),pixmTextColor->height()); config.BannerColor1=color1;
px->fill(c); config.BannerColor2=color2;
pixmTextColor->clear(); config.BannerTextColor=textcolor;
pixmTextColor->setPixmap(*px); config.ShowPasswords=CheckBox_ShowPasswords->isChecked();
//NICHT VERGESSEN! config.OpenUrlCommand=Edit_BrowserCmd->text();
//createBanner(Banner,Icon_Settings32x32,tr("Settings"),color1,color2,textcolor); 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() void CSettingsDlg::OnColor2()
{ {
QColor c=QColorDialog::getColor(color2,this); QColor c=QColorDialog::getColor(color2,this);
if(c.isValid()){ if(c.isValid()){
color2=c; color2=c;
QPixmap *px=new QPixmap(pixmColor2->width(),pixmColor2->height()); QPixmap *px=new QPixmap(pixmColor2->width(),pixmColor2->height());
px->fill(c); px->fill(c);
pixmColor2->clear(); pixmColor2->clear();
pixmColor2->setPixmap(*px); pixmColor2->setPixmap(*px);
//createBanner(Banner,Icon_Settings32x32,tr("Settings"),color1,color2,textcolor); createBanner(&BannerPixmap,Icon_Settings32x32,tr("Settings"),width(),color1,color2,textcolor);
} }
} }
void CSettingsDlg::OnColor1() void CSettingsDlg::OnColor1()
{ {
QColor c=QColorDialog::getColor(color1,this); QColor c=QColorDialog::getColor(color1,this);
if(c.isValid()){ if(c.isValid()){
color1=c; color1=c;
QPixmap *px=new QPixmap(pixmColor1->width(),pixmColor1->height()); QPixmap *px=new QPixmap(pixmColor1->width(),pixmColor1->height());
px->fill(c); px->fill(c);
pixmColor1->clear(); pixmColor1->clear();
pixmColor1->setPixmap(*px); pixmColor1->setPixmap(*px);
//createBanner(Banner,Icon_Settings32x32,tr("Settings"),color1,color2,textcolor); createBanner(&BannerPixmap,Icon_Settings32x32,tr("Settings"),width(),color1,color2,textcolor);
} }
} }
void CSettingsDlg::OnCeckBoxOpenLastChanged(int state){ void CSettingsDlg::OnCeckBoxOpenLastChanged(int state){
@ -165,3 +201,15 @@ if(dir!=QString()){
Edit_MountDir->setText(dir); 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();
}

@ -41,13 +41,20 @@ class CSettingsDlg : public QDialog, public Ui_SettingsDialog
virtual void OnTextColor(); virtual void OnTextColor();
virtual void OnColor2(); virtual void OnColor2();
virtual void OnColor1(); virtual void OnColor1();
void OnOtherButton(QAbstractButton*);
void OnIntPluginNone(bool);
void OnIntPluginGnome(bool);
void OnIntPluginKde(bool);
void OnCeckBoxOpenLastChanged(int state); void OnCeckBoxOpenLastChanged(int state);
void OnMountDirBrowse(); void OnMountDirBrowse();
private: private:
virtual void paintEvent(QPaintEvent*); virtual void paintEvent(QPaintEvent*);
void apply();
QColor color1,color2,textcolor; QColor color1,color2,textcolor;
QPixmap BannerPixmap; QPixmap BannerPixmap;
static bool PluginsModified;
}; };
#endif #endif

@ -80,9 +80,6 @@ Please move the mouse and/or press some keys until enought entropy for a reseed
<property name="orientation" > <property name="orientation" >
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="format" >
<string>%v Bits</string>
</property>
</widget> </widget>
</item> </item>
<item> <item>

@ -32,382 +32,429 @@
<property name="windowTitle" > <property name="windowTitle" >
<string>Password Generator</string> <string>Password Generator</string>
</property> </property>
<widget class="QProgressBar" name="Progress_Quali" > <layout class="QVBoxLayout" >
<property name="geometry" > <property name="margin" >
<rect> <number>9</number>
<x>130</x>
<y>400</y>
<width>180</width>
<height>15</height>
</rect>
</property> </property>
<property name="orientation" > <property name="spacing" >
<enum>Qt::Horizontal</enum> <number>6</number>
</property> </property>
</widget> <item>
<widget class="QLineEdit" name="Edit_dest" > <spacer>
<property name="geometry" > <property name="orientation" >
<rect> <enum>Qt::Vertical</enum>
<x>130</x> </property>
<y>370</y> <property name="sizeHint" >
<width>250</width> <size>
<height>21</height> <width>20</width>
</rect> <height>50</height>
</property> </size>
</widget> </property>
<widget class="QLabel" name="Label_Bits" > </spacer>
<property name="geometry" > </item>
<rect> <item>
<x>320</x> <widget class="QGroupBox" name="groupBox1" >
<y>399</y> <property name="title" >
<width>60</width> <string>Options</string>
<height>16</height> </property>
</rect> <layout class="QVBoxLayout" >
</property> <property name="margin" >
<property name="text" > <number>10</number>
<string/> </property>
</property> <property name="spacing" >
</widget> <number>6</number>
<widget class="QPushButton" name="ButtonOK" > </property>
<property name="geometry" > <item>
<rect> <widget class="QRadioButton" name="Radio_1" >
<x>263</x> <property name="text" >
<y>440</y> <string>Use follo&amp;wing character groups:</string>
<width>90</width> </property>
<height>25</height> <property name="shortcut" >
</rect> <string>Alt+W</string>
</property> </property>
<property name="text" > </widget>
<string>Accep&amp;t</string> </item>
</property> <item>
</widget> <layout class="QHBoxLayout" >
<widget class="QPushButton" name="Button_Cancel" > <property name="margin" >
<property name="geometry" > <number>0</number>
<rect> </property>
<x>360</x> <property name="spacing" >
<y>440</y> <number>6</number>
<width>90</width> </property>
<height>25</height> <item>
</rect> <spacer>
</property> <property name="orientation" >
<property name="text" > <enum>Qt::Horizontal</enum>
<string>&amp;Cancel</string> </property>
</property> <property name="sizeType" >
</widget> <enum>QSizePolicy::Fixed</enum>
<widget class="QPushButton" name="ButtonGenerate" > </property>
<property name="geometry" > <property name="sizeHint" >
<rect> <size>
<x>381</x> <width>30</width>
<y>370</y> <height>20</height>
<width>70</width> </size>
<height>21</height> </property>
</rect> </spacer>
</property> </item>
<property name="text" > <item>
<string>Generate</string> <layout class="QVBoxLayout" >
</property> <property name="margin" >
</widget> <number>0</number>
<widget class="QLabel" name="textLabel4" > </property>
<property name="geometry" > <property name="spacing" >
<rect> <number>0</number>
<x>20</x> </property>
<y>370</y> <item>
<width>110</width> <widget class="QCheckBox" name="checkBox1" >
<height>20</height> <property name="text" >
</rect> <string>&amp;Upper Letters</string>
</property> </property>
<property name="text" > <property name="shortcut" >
<string>New Password:</string> <string>Alt+U</string>
</property> </property>
</widget> <property name="checked" >
<widget class="QLabel" name="textLabel5" > <bool>true</bool>
<property name="geometry" > </property>
<rect> </widget>
<x>20</x> </item>
<y>400</y> <item>
<width>110</width> <widget class="QCheckBox" name="checkBox2" >
<height>20</height> <property name="text" >
</rect> <string>&amp;Lower Letters</string>
</property> </property>
<property name="text" > <property name="shortcut" >
<string>Quality:</string> <string>Alt+L</string>
</property> </property>
</widget> <property name="checked" >
<widget class="Line" name="line3" > <bool>true</bool>
<property name="geometry" > </property>
<rect> </widget>
<x>0</x> </item>
<y>420</y> <item>
<width>460</width> <widget class="QCheckBox" name="checkBox3" >
<height>20</height> <property name="text" >
</rect> <string>&amp;Numbers</string>
</property> </property>
<property name="frameShape" > <property name="shortcut" >
<enum>QFrame::HLine</enum> <string>Alt+N</string>
</property> </property>
<property name="frameShadow" > <property name="checked" >
<enum>QFrame::Sunken</enum> <bool>true</bool>
</property> </property>
<property name="orientation" > </widget>
<enum>Qt::Horizontal</enum> </item>
</property> <item>
</widget> <widget class="QCheckBox" name="checkBox4" >
<widget class="QGroupBox" name="groupBox1" > <property name="text" >
<property name="geometry" > <string>&amp;Special Characters</string>
<rect> </property>
<x>10</x> <property name="checked" >
<y>60</y> <bool>true</bool>
<width>440</width> </property>
<height>280</height> </widget>
</rect> </item>
</property> </layout>
<property name="title" > </item>
<string>Options</string> <item>
</property> <layout class="QVBoxLayout" >
<widget class="QLineEdit" name="Edit_chars" > <property name="margin" >
<property name="geometry" > <number>0</number>
<rect> </property>
<x>30</x> <property name="spacing" >
<y>170</y> <number>0</number>
<width>400</width> </property>
<height>21</height> <item>
</rect> <widget class="QCheckBox" name="checkBox5" >
</property> <property name="text" >
</widget> <string>White &amp;Spaces</string>
<widget class="QSpinBox" name="Spin_Num" > </property>
<property name="geometry" > <property name="shortcut" >
<rect> <string>Alt+S</string>
<x>120</x> </property>
<y>220</y> </widget>
<width>310</width> </item>
<height>21</height> <item>
</rect> <widget class="QCheckBox" name="checkBox6" >
</property> <property name="text" >
<property name="maximum" > <string>Minus</string>
<number>1000</number> </property>
</property> </widget>
<property name="minimum" > </item>
<number>1</number> <item>
</property> <widget class="QCheckBox" name="checkBox7" >
<property name="value" > <property name="text" >
<number>20</number> <string>U&amp;nderline</string>
</property> </property>
</widget> <property name="shortcut" >
<widget class="QCheckBox" name="checkBox1" > <string>Alt+N</string>
<property name="geometry" > </property>
<rect> </widget>
<x>120</x> </item>
<y>40</y> <item>
<width>131</width> <spacer>
<height>20</height> <property name="orientation" >
</rect> <enum>Qt::Vertical</enum>
</property> </property>
<property name="text" > <property name="sizeHint" >
<string>&amp;Upper Letters</string> <size>
</property> <width>20</width>
<property name="shortcut" > <height>40</height>
<string>Alt+U</string> </size>
</property> </property>
<property name="checked" > </spacer>
<bool>true</bool> </item>
</property> </layout>
</widget> </item>
<widget class="QCheckBox" name="checkBox2" > <item>
<property name="geometry" > <spacer>
<rect> <property name="orientation" >
<x>120</x> <enum>Qt::Horizontal</enum>
<y>60</y> </property>
<width>140</width> <property name="sizeHint" >
<height>20</height> <size>
</rect> <width>40</width>
</property> <height>20</height>
<property name="text" > </size>
<string>&amp;Lower Letters</string> </property>
</property> </spacer>
<property name="shortcut" > </item>
<string>Alt+L</string> </layout>
</property> </item>
<property name="checked" > <item>
<bool>true</bool> <widget class="QRadioButton" name="Radio_2" >
</property> <property name="text" >
</widget> <string>Use &amp;only following characters:</string>
<widget class="QCheckBox" name="checkBox3" > </property>
<property name="geometry" > <property name="shortcut" >
<rect> <string>Alt+O</string>
<x>120</x> </property>
<y>80</y> </widget>
<width>140</width> </item>
<height>20</height> <item>
</rect> <layout class="QHBoxLayout" >
</property> <property name="margin" >
<property name="text" > <number>0</number>
<string>&amp;Numbers</string> </property>
</property> <property name="spacing" >
<property name="shortcut" > <number>6</number>
<string>Alt+N</string> </property>
</property> <item>
<property name="checked" > <spacer>
<bool>true</bool> <property name="orientation" >
</property> <enum>Qt::Horizontal</enum>
</widget> </property>
<widget class="QCheckBox" name="checkBox4" > <property name="sizeType" >
<property name="geometry" > <enum>QSizePolicy::Fixed</enum>
<rect> </property>
<x>120</x> <property name="sizeHint" >
<y>100</y> <size>
<width>140</width> <width>30</width>
<height>20</height> <height>20</height>
</rect> </size>
</property> </property>
<property name="text" > </spacer>
<string>&amp;Special Characters</string> </item>
</property> <item>
<property name="checked" > <widget class="QLineEdit" name="Edit_chars" >
<bool>true</bool> <property name="maxLength" >
</property> <number>255</number>
</widget> </property>
<widget class="QCheckBox" name="checkBox6" > </widget>
<property name="geometry" > </item>
<rect> </layout>
<x>260</x> </item>
<y>60</y> <item>
<width>170</width> <spacer>
<height>20</height> <property name="orientation" >
</rect> <enum>Qt::Vertical</enum>
</property> </property>
<property name="text" > <property name="sizeHint" >
<string>Minus</string> <size>
</property> <width>20</width>
</widget> <height>20</height>
<widget class="QCheckBox" name="checkBox7" > </size>
<property name="geometry" > </property>
<rect> </spacer>
<x>260</x> </item>
<y>80</y> <item>
<width>170</width> <layout class="QHBoxLayout" >
<height>20</height> <property name="margin" >
</rect> <number>0</number>
</property> </property>
<property name="text" > <property name="spacing" >
<string>U&amp;nderline</string> <number>6</number>
</property> </property>
<property name="shortcut" > <item>
<string>Alt+N</string> <widget class="QLabel" name="textLabel1" >
</property> <property name="text" >
</widget> <string>Length:</string>
<widget class="QCheckBox" name="checkBox8" > </property>
<property name="geometry" > </widget>
<rect> </item>
<x>260</x> <item>
<y>100</y> <widget class="QSpinBox" name="Spin_Num" >
<width>170</width> <property name="maximum" >
<height>20</height> <number>10000</number>
</rect> </property>
</property> <property name="minimum" >
<property name="text" > <number>1</number>
<string>h&amp;igher ANSI-Characters</string> </property>
</property> <property name="value" >
<property name="shortcut" > <number>20</number>
<string>Alt+H</string> </property>
</property> </widget>
</widget> </item>
<widget class="QRadioButton" name="Radio_2" > <item>
<property name="geometry" > <spacer>
<rect> <property name="orientation" >
<x>10</x> <enum>Qt::Horizontal</enum>
<y>150</y> </property>
<width>420</width> <property name="sizeType" >
<height>16</height> <enum>QSizePolicy::Fixed</enum>
</rect> </property>
</property> <property name="sizeHint" >
<property name="text" > <size>
<string>Use &amp;only following characters:</string> <width>10</width>
</property> <height>20</height>
<property name="shortcut" > </size>
<string>Alt+O</string> </property>
</property> </spacer>
</widget> </item>
<widget class="QLabel" name="textLabel1" > <item>
<property name="geometry" > <widget class="QLabel" name="textLabel5" >
<rect> <property name="text" >
<x>10</x> <string>Quality:</string>
<y>220</y> </property>
<width>110</width> </widget>
<height>21</height> </item>
</rect> <item>
</property> <widget class="QProgressBar" name="Progress_Quali" >
<property name="text" > <property name="sizePolicy" >
<string>Length:</string> <sizepolicy>
</property> <hsizetype>7</hsizetype>
</widget> <vsizetype>1</vsizetype>
<widget class="QRadioButton" name="Radio_1" > <horstretch>0</horstretch>
<property name="geometry" > <verstretch>0</verstretch>
<rect> </sizepolicy>
<x>10</x> </property>
<y>20</y> <property name="maximumSize" >
<width>420</width> <size>
<height>21</height> <width>16777215</width>
</rect> <height>16777215</height>
</property> </size>
<property name="text" > </property>
<string>Use follo&amp;wing character groups:</string> <property name="maximum" >
</property> <number>128</number>
<property name="shortcut" > </property>
<string>Alt+W</string> <property name="value" >
</property> <number>0</number>
</widget> </property>
<widget class="QCheckBox" name="checkBox5" > <property name="orientation" >
<property name="geometry" > <enum>Qt::Horizontal</enum>
<rect> </property>
<x>260</x> </widget>
<y>40</y> </item>
<width>170</width> </layout>
<height>20</height> </item>
</rect> <item>
</property> <layout class="QHBoxLayout" >
<property name="text" > <property name="margin" >
<string>White &amp;Spaces</string> <number>0</number>
</property> </property>
<property name="shortcut" > <property name="spacing" >
<string>Alt+S</string> <number>6</number>
</property> </property>
</widget> <item>
<widget class="QCheckBox" name="Check_strongrandom" > <widget class="QCheckBox" name="Check_CollectEntropy" >
<property name="geometry" > <property name="text" >
<rect> <string>Enable entropy collection</string>
<x>120</x> </property>
<y>250</y> <property name="shortcut" >
<width>310</width> <string>Alt+M</string>
<height>21</height> </property>
</rect> <property name="checked" >
</property> <bool>true</bool>
<property name="text" > </property>
<string>Force entropy collection</string> </widget>
</property> </item>
<property name="shortcut" > <item>
<string>Alt+M</string> <widget class="QCheckBox" name="Check_CollectOncePerSession" >
</property> <property name="text" >
<property name="checked" > <string>Collect only once per session</string>
<bool>true</bool> </property>
</property> </widget>
</widget> </item>
</widget> <item>
<widget class="QLabel" name="Banner" > <spacer>
<property name="geometry" > <property name="orientation" >
<rect> <enum>Qt::Horizontal</enum>
<x>0</x> </property>
<y>0</y> <property name="sizeHint" >
<width>460</width> <size>
<height>50</height> <width>40</width>
</rect> <height>20</height>
</property> </size>
<property name="pixmap" > </property>
<pixmap/> </spacer>
</property> </item>
<property name="scaledContents" > </layout>
<bool>true</bool> </item>
</property> </layout>
</widget> </widget>
</item>
<item>
<layout class="QHBoxLayout" >
<property name="margin" >
<number>0</number>
</property>
<property name="spacing" >
<number>6</number>
</property>
<item>
<widget class="QLabel" name="textLabel4" >
<property name="text" >
<string>New Password:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="Edit_dest" />
</item>
<item>
<widget class="QPushButton" name="ButtonGenerate" >
<property name="text" >
<string>Generate</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="Line" name="line3" >
<property name="frameShape" >
<enum>QFrame::HLine</enum>
</property>
<property name="frameShadow" >
<enum>QFrame::Sunken</enum>
</property>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="DialogButtons" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons" >
<set>QDialogButtonBox::NoButton</set>
</property>
</widget>
</item>
</layout>
</widget> </widget>
<layoutdefault spacing="6" margin="11" /> <layoutdefault spacing="6" margin="11" />
<tabstops> <tabstops>
@ -419,15 +466,11 @@
<tabstop>checkBox5</tabstop> <tabstop>checkBox5</tabstop>
<tabstop>checkBox6</tabstop> <tabstop>checkBox6</tabstop>
<tabstop>checkBox7</tabstop> <tabstop>checkBox7</tabstop>
<tabstop>checkBox8</tabstop>
<tabstop>Radio_2</tabstop> <tabstop>Radio_2</tabstop>
<tabstop>Edit_chars</tabstop> <tabstop>Edit_chars</tabstop>
<tabstop>Spin_Num</tabstop> <tabstop>Check_CollectEntropy</tabstop>
<tabstop>Check_strongrandom</tabstop>
<tabstop>Edit_dest</tabstop> <tabstop>Edit_dest</tabstop>
<tabstop>ButtonGenerate</tabstop> <tabstop>ButtonGenerate</tabstop>
<tabstop>ButtonOK</tabstop>
<tabstop>Button_Cancel</tabstop>
</tabstops> </tabstops>
<resources/> <resources/>
<connections/> <connections/>

@ -52,8 +52,17 @@
</item> </item>
<item> <item>
<widget class="QTabWidget" name="tabWidget4" > <widget class="QTabWidget" name="tabWidget4" >
<property name="whatsThis" >
<string>The integration plugins provide features like usage of the native file dialogs and message boxes of the particular desktop environments.</string>
</property>
<property name="tabPosition" >
<enum>QTabWidget::North</enum>
</property>
<property name="tabShape" >
<enum>QTabWidget::Rounded</enum>
</property>
<property name="currentIndex" > <property name="currentIndex" >
<number>3</number> <number>2</number>
</property> </property>
<widget class="QWidget" name="tab" > <widget class="QWidget" name="tab" >
<attribute name="title" > <attribute name="title" >
@ -453,7 +462,7 @@
</widget> </widget>
<widget class="QWidget" name="tab_2" > <widget class="QWidget" name="tab_2" >
<attribute name="title" > <attribute name="title" >
<string>Intergration Plug-ins</string> <string>Desktop Integration</string>
</attribute> </attribute>
<layout class="QVBoxLayout" > <layout class="QVBoxLayout" >
<property name="margin" > <property name="margin" >
@ -463,7 +472,7 @@
<number>6</number> <number>6</number>
</property> </property>
<item> <item>
<widget class="QLabel" name="label_3" > <widget class="QLabel" name="Label_IntPlugin_Error" >
<property name="sizePolicy" > <property name="sizePolicy" >
<sizepolicy> <sizepolicy>
<hsizetype>5</hsizetype> <hsizetype>5</hsizetype>
@ -473,7 +482,10 @@
</sizepolicy> </sizepolicy>
</property> </property>
<property name="text" > <property name="text" >
<string>&lt; some text about plugin usage ></string> <string/>
</property>
<property name="wordWrap" >
<bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>
@ -498,21 +510,21 @@
<number>6</number> <number>6</number>
</property> </property>
<item> <item>
<widget class="QRadioButton" name="radioButton" > <widget class="QRadioButton" name="Radio_IntPlugin_None" >
<property name="text" > <property name="text" >
<string>None</string> <string>None</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QRadioButton" name="radioButton_2" > <widget class="QRadioButton" name="Radio_IntPlugin_Gnome" >
<property name="text" > <property name="text" >
<string>Gnome Desktop Integration (Gtk 2.x)</string> <string>Gnome Desktop Integration (Gtk 2.x)</string>
</property> </property>
</widget> </widget>
</item> </item>
<item> <item>
<widget class="QRadioButton" name="radioButton_3" > <widget class="QRadioButton" name="Radio_IntPlugin_Kde" >
<property name="text" > <property name="text" >
<string>KDE 4 Desktop Integration</string> <string>KDE 4 Desktop Integration</string>
</property> </property>
@ -529,6 +541,13 @@
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<item>
<widget class="QLabel" name="Label_IntPlugin_Info" >
<property name="text" >
<string>You need to restart the program before the changes take effect.</string>
</property>
</widget>
</item>
<item> <item>
<spacer> <spacer>
<property name="orientation" > <property name="orientation" >
@ -543,7 +562,7 @@
</spacer> </spacer>
</item> </item>
<item> <item>
<widget class="QPushButton" name="Button_ConfigureDesktopPlugin" > <widget class="QPushButton" name="IntPlugin_Button_Config" >
<property name="text" > <property name="text" >
<string>Configure...</string> <string>Configure...</string>
</property> </property>
@ -551,6 +570,19 @@
</item> </item>
</layout> </layout>
</item> </item>
<item>
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" >
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout> </layout>
</widget> </widget>
<widget class="QWidget" name="tab" > <widget class="QWidget" name="tab" >
@ -652,7 +684,7 @@
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="standardButtons" > <property name="standardButtons" >
<set>QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set> <set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok</set>
</property> </property>
</widget> </widget>
</item> </item>

@ -73,8 +73,11 @@ QStringList QtStandardFileDialogs::openExistingFilesDialog(QWidget* parent,QStri
} }
QString QtStandardFileDialogs::saveFileDialog(QWidget* parent,QString title,QString dir,QStringList Filters,bool ShowOverwriteWarning){ QString QtStandardFileDialogs::saveFileDialog(QWidget* parent,QString title,QString dir,QStringList Filters,bool ShowOverwriteWarning){
QFileDialog FileDlg(parent,title,dir);
return QString(); FileDlg.setFilters(Filters);
FileDlg.setFileMode(QFileDialog::AnyFile);
FileDlg.setAcceptMode(QFileDialog::AcceptSave);
FileDlg.setConfirmOverwrite(ShowOverwriteWarning);
if(!FileDlg.exec())return QString();
return FileDlg.selectedFiles()[0];
} }

@ -52,9 +52,12 @@ using namespace std;
#include <X11/keysymdef.h> #include <X11/keysymdef.h>
#include <X11/Xlib.h> #include <X11/Xlib.h>
#endif #endif
#define CSTR(x)(x.toUtf8().data())
CConfig config; CConfig config;
QString AppDir; QString AppDir;
QString PluginLoadError;
bool TrActive; bool TrActive;
QPixmap *Icon_Key32x32; QPixmap *Icon_Key32x32;
QPixmap *Icon_Settings32x32; QPixmap *Icon_Settings32x32;
@ -81,6 +84,7 @@ QIcon *Icon_Configure;
QIcon *Icon_Help; QIcon *Icon_Help;
QIcon *Icon_AutoType; QIcon *Icon_AutoType;
QIcon *Icon_Swap; QIcon *Icon_Swap;
QIcon *Icon_FileSaveDisabled;
inline void loadImages(); inline void loadImages();
inline void parseCmdLineArgs(int argc, char** argv,QString &ArgFile,QString& ArgCfg,QString& ArgLang); inline void parseCmdLineArgs(int argc, char** argv,QString &ArgFile,QString& ArgCfg,QString& ArgLang);
@ -92,6 +96,9 @@ int main(int argc, char **argv)
QString ArgFile,ArgCfg,ArgLang,IniFilename; QString ArgFile,ArgCfg,ArgLang,IniFilename;
QApplication* app=NULL; QApplication* app=NULL;
AppDir=QString(argv[0]);
AppDir.truncate(AppDir.lastIndexOf("/"));
//Load Config //Load Config
if(ArgCfg==QString()){ if(ArgCfg==QString()){
if(!QDir(QDir::homePath()+"/.keepass").exists()){ if(!QDir(QDir::homePath()+"/.keepass").exists()){
@ -114,29 +121,39 @@ int main(int argc, char **argv)
LibName+="kde.so"; LibName+="kde.so";
else if(config.IntegrPlugin==CConfig::GNOME) else if(config.IntegrPlugin==CConfig::GNOME)
LibName+="gnome.so"; LibName+="gnome.so";
QPluginLoader plugin("/home/tarek/Documents/KeePassX/src/plugins/gnome/"+LibName); QString filename=findPlugin(LibName);
if(!plugin.load()){ if(filename!=QString()){
qWarning("Could not load destop integration plugin:"); QPluginLoader plugin(filename);
qWarning(plugin.errorString().toUtf8().data()); if(!plugin.load()){
PluginLoadError=plugin.errorString();
qWarning("Could not load desktop integration plugin:");
qWarning(CSTR(PluginLoadError));
}
else{
IFileDialog* fdlg=qobject_cast<IFileDialog*>(plugin.instance());
KpxFileDialogs::setPlugin(fdlg);
if(config.IntegrPlugin==CConfig::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){
IGnomeInit* ginit=qobject_cast<IGnomeInit*>(plugin.instance());
if(!ginit->init(argc,argv)){
KpxFileDialogs::setPlugin(NULL);
qWarning("GtkIntegrPlugin: Gtk init failed.");
PluginLoadError=QObject::tr("Initialization failed.");
}
}
}
} }
else{ else{
IFileDialog* fdlg=qobject_cast<IFileDialog*>(plugin.instance()); qWarning(CSTR(QString("Could not load desktop integration plugin: File '%1' not found.").arg(LibName)));
KpxFileDialogs::setPlugin(fdlg); PluginLoadError=QObject::tr("Could not locate library file.");
if(config.IntegrPlugin==CConfig::KDE){
IKdeInit* kdeinit=qobject_cast<IKdeInit*>(plugin.instance());
app=kdeinit->getMainAppObject(argc,argv);
}
if(config.IntegrPlugin==CConfig::GNOME){
IGnomeInit* ginit=qobject_cast<IGnomeInit*>(plugin.instance());
if(!ginit->init(argc,argv))
KpxFileDialogs::setPlugin(NULL);
}
} }
} }
if(!app) QApplication* app=new QApplication(argc,argv); if(!app) QApplication* app=new QApplication(argc,argv);
parseCmdLineArgs(argc,argv,ArgFile,ArgCfg,ArgLang); parseCmdLineArgs(argc,argv,ArgFile,ArgCfg,ArgLang);
AppDir=app->applicationDirPath();
//Internationalization //Internationalization
@ -257,9 +274,9 @@ QString decodeFileError(QFile::FileError Code){
} }
void openBrowser(QString url){ void openBrowser(QString url){
QStringList args=config.OpenUrlCommand.arg(url).split(' '); QStringList args=config.OpenUrlCommand.arg(url).split(' ');
QString cmd=args.takeFirst(); QString cmd=args.takeFirst();
QProcess::startDetached(cmd,args); QProcess::startDetached(cmd,args);
} }
@ -333,6 +350,7 @@ _loadIcon(Icon_Configure,"/actions/configure.png");
_loadIcon(Icon_Help,"/actions/help.png"); _loadIcon(Icon_Help,"/actions/help.png");
_loadIcon(Icon_AutoType,"/apps/ktouch.png"); _loadIcon(Icon_AutoType,"/apps/ktouch.png");
_loadIcon(Icon_Swap,"/actions/reload.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){ void showErrMsg(const QString& msg,QWidget* parent){
QMessageBox::critical(parent,QObject::tr("Error"),msg,QObject::tr("OK")); 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();
}

@ -39,6 +39,8 @@ void createBanner(QPixmap* Pixmap, QPixmap* IconAlpha,const QString& Text,int Wi
void openBrowser(QString url); void openBrowser(QString url);
void showErrMsg(const QString& msg,QWidget* parent=NULL); void showErrMsg(const QString& msg,QWidget* parent=NULL);
QString decodeFileError(QFile::FileError Code); QString decodeFileError(QFile::FileError Code);
QString findPlugin(const QString& filename);
extern QString PluginLoadError;
extern CConfig config; extern CConfig config;
extern QString AppDir; extern QString AppDir;
@ -69,6 +71,7 @@ extern QIcon *Icon_Configure;
extern QIcon *Icon_Help; extern QIcon *Icon_Help;
extern QIcon *Icon_AutoType; extern QIcon *Icon_AutoType;
extern QIcon *Icon_Swap; extern QIcon *Icon_Swap;
extern QIcon *Icon_FileSaveDisabled;
#endif #endif

@ -327,7 +327,7 @@ void KeepassMainWindow::openDatabase(QString filename,bool IsAuto){
StatusBarGeneral->setText(tr("Loading Database...")); StatusBarGeneral->setText(tr("Loading Database..."));
if(db->load(filename)==true){ if(db->load(filename)==true){
if(config.OpenLast)config.LastFile=filename; if(config.OpenLast)config.LastFile=filename;
setWindowTitle(tr("KeePassX - %1").arg(filename)); setWindowTitle(tr("%1 - KeePassX").arg(filename));
GroupView->createItems(); GroupView->createItems();
EntryView->showGroup(NULL); EntryView->showGroup(NULL);
setStateFileOpen(true); setStateFileOpen(true);
@ -350,28 +350,28 @@ void KeepassMainWindow::openDatabase(QString filename,bool IsAuto){
bool KeepassMainWindow::closeDatabase(){ bool KeepassMainWindow::closeDatabase(){
Q_ASSERT(FileOpen); Q_ASSERT(FileOpen);
Q_ASSERT(db!=NULL); Q_ASSERT(db!=NULL);
if(ModFlag){ if(ModFlag){
int r=QMessageBox::question(this,tr("Save modified file?"), 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); 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==2)return false; //Abbrechen
if(r==0) //Ja (Datei speichern) if(r==0) //Ja (Datei speichern)
if(!OnFileSave())return false; if(!OnFileSave())return false;
} }
db->close(); db->close();
delete db; delete db;
db=NULL; db=NULL;
EntryView->db=NULL; EntryView->db=NULL;
EntryView->clear(); EntryView->clear();
EntryView->Items.clear(); EntryView->Items.clear();
GroupView->db=NULL; GroupView->db=NULL;
GroupView->clear(); GroupView->clear();
GroupView->Items.clear(); GroupView->Items.clear();
SearchResults.clear(); SearchResults.clear();
setStateFileOpen(false); setStateFileOpen(false);
setWindowTitle("KeePassX Password Manager"); setWindowTitle("KeePassX Password Manager");
return true; return true;
} }
@ -422,7 +422,7 @@ void KeepassMainWindow::OnFileNewKdb(){
return; return;
} }
} }
setWindowTitle(tr("KeePassX - %1").arg(tr("[new]"))); setWindowTitle(tr("%1 - KeePassX").arg(tr("[new]")));
GroupView->db=db; GroupView->db=db;
EntryView->db=db; EntryView->db=db;
GroupView->createItems(); GroupView->createItems();
@ -501,9 +501,15 @@ else{
void KeepassMainWindow::setStateFileModified(bool mod){ void KeepassMainWindow::setStateFileModified(bool mod){
if(!FileOpen)return; if(!FileOpen){
ModFlag=mod; FileSaveAction->setIcon(*Icon_FileSave);
FileSaveAction->setEnabled(mod); return;
}
ModFlag=mod;
if(mod)
FileSaveAction->setIcon(*Icon_FileSave);
else
FileSaveAction->setIcon(*Icon_FileSaveDisabled);
} }
void KeepassMainWindow::setStateGroupSelected(SelectionState s){ void KeepassMainWindow::setStateGroupSelected(SelectionState s){
@ -535,32 +541,33 @@ void KeepassMainWindow::setStateGroupSelected(SelectionState s){
} }
void KeepassMainWindow::updateDetailView(){ void KeepassMainWindow::updateDetailView(){
if(EntryView->selectedItems().size()!=1){ if(EntryView->selectedItems().size()!=1){
DetailView->setPlainText(""); DetailView->setPlainText("");
return;} return;
}
IEntryHandle* entry=((EntryViewItem*)(EntryView->selectedItems()[0]))->EntryHandle;
QString str=tr("<B>Group: </B>%1 <B>Title: </B>%2 <B>Username: </B>%3 <B>URL: </B><a href=%4>%4</a> <B>Password: </B>%5 <B>Creation: </B>%6 <B>Last Change: </B>%7 <B>LastAccess: </B>%8 <B>Expires: </B>%9"); IEntryHandle* entry=((EntryViewItem*)(EntryView->selectedItems()[0]))->EntryHandle;
QString str=tr("<B>Group: </B>%1 <B>Title: </B>%2 <B>Username: </B>%3 <B>URL: </B><a href=%4>%4</a> <B>Password: </B>%5 <B>Creation: </B>%6 <B>Last Change: </B>%7 <B>LastAccess: </B>%8 <B>Expires: </B>%9");
str=str.arg(entry->group()->title()).arg(entry->title());
str=str.arg(entry->group()->title()).arg(entry->title());
if(!config.ListView_HideUsernames) str=str.arg(entry->username());
else str=str.arg("****"); if(!config.ListView_HideUsernames) str=str.arg(entry->username());
else str=str.arg("****");
str=str.arg(entry->url());
str=str.arg(entry->url());
if(!config.ListView_HidePasswords){
SecString password=entry->password(); if(!config.ListView_HidePasswords){
password.unlock(); SecString password=entry->password();
str=str.arg(password.string()); password.unlock();
} str=str.arg(password.string());
else str=str.arg("****"); }
else str=str.arg("****");
str=str .arg(entry->creation().toString(Qt::LocalDate))
.arg(entry->lastMod().toString(Qt::LocalDate)) str=str .arg(entry->creation().toString(Qt::LocalDate))
.arg(entry->lastAccess().toString(Qt::LocalDate)) .arg(entry->lastMod().toString(Qt::LocalDate))
.arg(entry->expire().toString(Qt::LocalDate)); .arg(entry->lastAccess().toString(Qt::LocalDate))
DetailView->setHtml(str); .arg(entry->expire().toString(Qt::LocalDate));
DetailView->setHtml(str);
} }
@ -663,19 +670,16 @@ return true;
} }
bool KeepassMainWindow::OnFileSaveAs(){ bool KeepassMainWindow::OnFileSaveAs(){
QFileDialog FileDlg(this,tr("Save Database As..."),QDir::homePath()); QString filename=KpxFileDialogs::saveFile(this,"MainWindow_FileSave",
FileDlg.setFilters(QStringList()<< tr("KeePass Databases (*.kdb)")<< tr("All Files (*)")); tr("Save Database..."),QStringList()<<tr("KeePass Databases (*.kdb)")<< tr("All Files (*)"));
FileDlg.setFileMode(QFileDialog::AnyFile); if(filename==QString())return false;
FileDlg.setAcceptMode(QFileDialog::AcceptSave); if(!db->changeFile(filename)){
if(!FileDlg.exec())return false;
if(!FileDlg.selectedFiles().size())return false;
if(!db->changeFile(FileDlg.selectedFiles()[0])){
showErrMsg(tr("File could not be saved.\n%1").arg(db->getError())); showErrMsg(tr("File could not be saved.\n%1").arg(db->getError()));
db->changeFile(QString()); db->changeFile(QString());
setWindowTitle(tr("KeePassX - [unsaved]").arg(FileDlg.selectedFiles()[0])); setWindowTitle(tr("KeePassX - [unsaved]").arg(filename));
return false; return false;
} }
setWindowTitle(tr("KeePassX - %1").arg(FileDlg.selectedFiles()[0])); setWindowTitle(tr("%1 - KeePassX").arg(filename));
return OnFileSave(); return OnFileSave();
} }
@ -950,7 +954,7 @@ void KeepassMainWindow::OnGroupSelectionChanged(IGroupHandle* group){
} }
void KeepassMainWindow::OnEntryChanged(SelectionState Selection){ void KeepassMainWindow::OnEntryChanged(SelectionState Selection){
//DETAIL-VIEW!!! updateDetailView();
setStateEntrySelected(Selection); setStateEntrySelected(Selection);
} }

@ -113,4 +113,26 @@ QStringList GnomePlugin::openExistingFilesDialog(QWidget* parent,QString title,Q
return filenames; return filenames;
} }
QString GnomePlugin::saveFileDialog(QWidget* parent,QString title,QString dir,QStringList Filters,bool OverWriteWarn){return QString();} 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<NumFilters;i++){
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(FileDlg),filters[i]);
}
if (gtk_dialog_run(GTK_DIALOG(FileDlg)) == GTK_RESPONSE_ACCEPT){
char* filename_cstring=gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(FileDlg));
filename = QString::fromUtf8(filename_cstring);
g_free(filename_cstring);
}
gtk_widget_destroy(FileDlg);
return filename;}

@ -13,4 +13,4 @@ HEADERS += keepassx-gnome.h
SOURCES += keepassx-gnome.cpp SOURCES += keepassx-gnome.cpp
MOC_DIR = build/moc MOC_DIR = build/moc
OBJECTS_DIR = build/ OBJECTS_DIR = build/
LIBS+=-lgtk-x11-2.0 LIBS+=-L /opt/gnome/lib -lgtk-x11-2.0

@ -1,9 +1,9 @@
INCLUDEPATH += /usr/lib/kde4/include INCLUDEPATH += /opt/kde4/include
TEMPLATE = lib TEMPLATE = lib
CONFIG += plugin release CONFIG += plugin release
HEADERS += keepassx-kde.h HEADERS += keepassx-kde.h
SOURCES += keepassx-kde.cpp SOURCES += keepassx-kde.cpp
MOC_DIR = build/moc MOC_DIR = build/moc
OBJECTS_DIR = build/ OBJECTS_DIR = build/
LIBS+=-L/usr/lib/kde4/lib -lkio -lkdecore LIBS+=-L/opt/kde4/lib -lkio -lkdecore