Finished PasswordDlg,

Added Text Export

git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@56 b624d157-de02-0410-bad0-e51aec6abb33
This commit is contained in:
tariq
2006-03-16 08:09:08 +00:00
parent 416c7d70d3
commit 6154859afc
14 changed files with 209 additions and 49 deletions

View File

@@ -36,6 +36,32 @@ CPasswordDialog::CPasswordDialog(QWidget* parent, const char* name, bool modal,
{
setupUi(this);
createBanner(Banner,Icon_Key32x32,tr("Database Key"));
QDir media(config.MountDir);
if(media.exists()){
QStringList Paths;
Paths=media.entryList("*",QDir::Dirs);
Paths.erase(Paths.begin()); // delete "."
Paths.erase(Paths.begin()); // delete ".."
for(int i=0;i<Paths.count();i++)
Combo_Dirs->addItem(config.MountDir+Paths[i]);
}
Combo_Dirs->setEditText(QString());
if(config.RememberLastKey){
switch(config.LastKeyType){
case PASSWORD: setStatePasswordOnly(); break;
case KEYFILE: setStateKeyFileOnly();
Combo_Dirs->setEditText(config.LastKeyLocation);
break;
case BOTH: setStateBoth();
CheckBox_Both->setChecked(true);
Combo_Dirs->setEditText(config.LastKeyLocation);
break;
}
}
connect( Combo_Dirs, SIGNAL( editTextChanged(const QString&) ),this, SLOT( OnComboTextChanged(const QString&)));
connect( ButtonCancel, SIGNAL( clicked() ), this, SLOT( OnCancel() ) );
connect( Edit_Password, SIGNAL( textChanged(const QString&) ), this, SLOT( OnPasswordChanged(const QString&) ) );
@@ -56,19 +82,6 @@ if(!ChangeKeyMode){
connect( ButtonBrowse, SIGNAL( clicked() ), this, SLOT( OnButtonBrowse_Set() ) );
}
QDir media(config.MountDir);
if(media.exists()){
QStringList Paths;
Paths=media.entryList("*",QDir::Dirs);
Paths.erase(Paths.begin()); // delete "."
Paths.erase(Paths.begin()); // delete ".."
for(int i=0;i<Paths.count();i++)
Combo_Dirs->addItem(config.MountDir+Paths[i]);
}
Combo_Dirs->setEditText(QString());
if(!config.ShowPasswords)ChangeEchoMode();
}
@@ -79,6 +92,7 @@ ButtonBrowse->setEnabled(false);
Label_KeyFile->setEnabled(false);
Label_Password->setEnabled(true);
Edit_Password->setEnabled(true);
Edit_PasswordRep->setEnabled(true);
ButtonChangeEchoMode->setEnabled(true);
KeyType=PASSWORD;
}
@@ -90,6 +104,7 @@ ButtonBrowse->setEnabled(true);
Label_KeyFile->setEnabled(true);
Label_Password->setEnabled(false);
Edit_Password->setEnabled(false);
Edit_PasswordRep->setEnabled(false);
ButtonChangeEchoMode->setEnabled(false);
KeyType=KEYFILE;
}
@@ -101,6 +116,7 @@ ButtonBrowse->setEnabled(true);
Label_KeyFile->setEnabled(true);
Label_Password->setEnabled(true);
Edit_Password->setEnabled(true);
Edit_PasswordRep->setEnabled(true);
ButtonChangeEchoMode->setEnabled(true);
KeyType=BOTH;
}
@@ -192,14 +208,22 @@ if(KeyType==BOTH || KeyType==KEYFILE){
return;}
}
}
if(config.RememberLastKey){
config.LastKeyLocation=keyfile;
config.LastKeyType=KeyType;
}
done(1);
}
void CPasswordDialog::OnOK_Set(){
password=Edit_Password->text();
if(password!=Edit_PasswordRep->text()){
QMessageBox::warning(this,tr("Warning"),tr("Password an password repetition are not equal.\nPlease check your input."),tr("OK"),"","",0,0);
return;}
keyfile=Combo_Dirs->currentText();
if(password=="" && keyfile==""){
QMessageBox::warning(this,tr("Error"),tr("Please enter a Password or select a key file."),tr("OK"),"","",0,0);
QMessageBox::warning(this,tr("Error"),tr("Please enter a password or select a key file."),tr("OK"),"","",0,0);
return;}
QFile file(keyfile);
@@ -224,10 +248,15 @@ if(QFileInfo(file).isDir()){
return;}
}
}
if(config.RememberLastKey){
config.LastKeyLocation=keyfile;
config.LastKeyType=KeyType;
}
done(1);
}
void CPasswordDialog::OnPasswordChanged(const QString &txt){
Edit_PasswordRep->setText("");
if(CheckBox_Both->isChecked() || txt==QString())
setStateBoth();
else
@@ -263,10 +292,12 @@ if(state==Qt::Unchecked){
}
void CPasswordDialog::ChangeEchoMode(){
if(Edit_Password->echoMode()==QLineEdit::Normal)
if(Edit_Password->echoMode()==QLineEdit::Normal){
Edit_Password->setEchoMode(QLineEdit::Password);
else
Edit_PasswordRep->setEchoMode(QLineEdit::Password);}
else{
Edit_Password->setEchoMode(QLineEdit::Normal);
Edit_PasswordRep->setEchoMode(QLineEdit::Normal);}
}

View File

@@ -31,11 +31,12 @@ CSettingsDlg::CSettingsDlg(QWidget* parent, const char* name, bool modal, Qt::WF
: QDialog(parent,name, modal,fl)
{
setupUi(this);
connect( ButtonOK, SIGNAL( clicked() ), this, SLOT( OnOK() ) );
connect( ButtonCancel, SIGNAL( clicked() ), 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(ButtonOK, SIGNAL( clicked() ), this, SLOT( OnOK() ) );
connect(ButtonCancel, SIGNAL( clicked() ), 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)));
createBanner(Banner,Icon_Settings32x32,tr("Settings"));
CheckBox_OpenLast->setChecked(config.OpenLast);
SpinBox_ClipboardTime->setValue(config.ClipboardTimeOut);
@@ -58,13 +59,12 @@ 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);
}
CSettingsDlg::~CSettingsDlg()
@@ -85,6 +85,7 @@ 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();
}
@@ -132,7 +133,14 @@ createBanner(Banner,Icon_Settings32x32,tr("Settings"),color1,color2,textcolor);
}
}
void CSettingsDlg::OnCeckBoxOpenLastChanged(int state){
if(state==Qt::Checked){
CheckBox_RememberLastKey->setEnabled(true);
}else{
CheckBox_RememberLastKey->setEnabled(false);
CheckBox_RememberLastKey->setChecked(false);
}
}
/*$SPECIALIZATION$*/

View File

@@ -20,7 +20,6 @@
#include "main.h"
#ifndef SETTINGSDLG_H
#define SETTINGSDLG_H
#include "ui_SettingsDlg.h"
#include <qcolor.h>
@@ -31,24 +30,14 @@ class CSettingsDlg : public QDialog, public Ui_SettingsDialog
public:
CSettingsDlg(QWidget* parent = 0, const char* name = 0, bool modal = FALSE, Qt::WFlags fl = 0 );
~CSettingsDlg();
/*$PUBLIC_FUNCTIONS$*/
public slots:
/*$PUBLIC_SLOTS$*/
protected:
/*$PROTECTED_FUNCTIONS$*/
protected slots:
/*$PROTECTED_SLOTS$*/
public slots:
virtual void OnCancel();
public slots:
virtual void OnOK();
virtual void OnTextColor();
virtual void OnColor2();
virtual void OnColor1();
void OnCeckBoxOpenLastChanged(int state);
private:
QColor color1,color2,textcolor;