First commit for 0.2.3, some old functions still need to be ported to the new back-end api, i.e. import and export.
git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@104 b624d157-de02-0410-bad0-e51aec6abb33
This commit is contained in:
@@ -26,7 +26,7 @@
|
||||
#include "DatabaseSettingsDlg.h"
|
||||
|
||||
|
||||
CDbSettingsDlg::CDbSettingsDlg(QWidget* parent,Database* db, bool modal, Qt::WFlags fl)
|
||||
CDbSettingsDlg::CDbSettingsDlg(QWidget* parent,IDatabase* db, bool modal, Qt::WFlags fl)
|
||||
: QDialog(parent,fl)
|
||||
{
|
||||
setupUi(this);
|
||||
@@ -40,14 +40,17 @@ CDbSettingsDlg::~CDbSettingsDlg()
|
||||
}
|
||||
|
||||
void CDbSettingsDlg::showEvent(QShowEvent *event){
|
||||
//@NICHTVERGESSEN
|
||||
/*
|
||||
if(event->spontaneous()==false){
|
||||
createBanner(Banner,Icon_Settings32x32,tr("Settings"));
|
||||
ComboAlgo->insertItem(0,tr("AES(Rijndael): 256 Bit (default)"));
|
||||
ComboAlgo->insertItem(1,tr("Twofish: 256 Bit"));
|
||||
ComboAlgo->setCurrentIndex(database->CryptoAlgorithmus); //Achtung: AlgoID muss gleich dem ComboBox Index sein!
|
||||
EditRounds->setText(QString::number(database->KeyEncRounds));
|
||||
|
||||
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
void CDbSettingsDlg::OnCancel()
|
||||
@@ -72,8 +75,10 @@ if(rounds==0){
|
||||
QMessageBox::warning(NULL,tr("Error"),tr("The number of encryption rounds have to be greater than 0."),tr("OK"));
|
||||
return;
|
||||
}
|
||||
database->KeyEncRounds=rounds;
|
||||
database->CryptoAlgorithmus=ComboAlgo->currentIndex();
|
||||
|
||||
//@NICHTVERGESSEN
|
||||
//database->KeyEncRounds=rounds;
|
||||
//database->CryptoAlgorithmus=ComboAlgo->currentIndex();
|
||||
|
||||
done(1);
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ class CDbSettingsDlg : public QDialog, public Ui_dbsettingdlg_base
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CDbSettingsDlg(QWidget* parent,Database* db, bool modal = FALSE, Qt::WFlags fl = 0 );
|
||||
CDbSettingsDlg(QWidget* parent,IDatabase* db, bool modal = FALSE, Qt::WFlags fl = 0 );
|
||||
~CDbSettingsDlg();
|
||||
virtual void showEvent(QShowEvent *);
|
||||
/*$PUBLIC_FUNCTIONS$*/
|
||||
@@ -49,7 +49,7 @@ public slots:
|
||||
virtual void OnOK();
|
||||
|
||||
private:
|
||||
Database* database;
|
||||
IDatabase* database;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -43,79 +43,79 @@
|
||||
|
||||
|
||||
|
||||
CEditEntryDlg::CEditEntryDlg(Database* _db, CEntry* _entry,QWidget* parent, bool modal, Qt::WFlags fl)
|
||||
CEditEntryDlg::CEditEntryDlg(IDatabase* _db, IEntryHandle* _entry,QWidget* parent, bool modal, Qt::WFlags fl)
|
||||
: QDialog(parent,fl)
|
||||
{
|
||||
Q_ASSERT(_db);
|
||||
Q_ASSERT(_entry);
|
||||
entry=_entry;
|
||||
db=_db;
|
||||
setupUi(this);
|
||||
createBanner(Banner,Icon_Key32x32,tr("Edit Entry"));
|
||||
ModFlag=false;
|
||||
connect(Edit_Password_w, SIGNAL(editingFinished()), this, SLOT(OnPasswordwLostFocus()));
|
||||
connect(Edit_Password_w, SIGNAL(textChanged(const QString&)), this, SLOT( OnPasswordwTextChanged(const QString&)));
|
||||
connect(Edit_Password, SIGNAL(textChanged(const QString&)), this, SLOT( OnPasswordTextChanged(const QString&)));
|
||||
connect(ButtonEchoMode, SIGNAL(clicked()), this, SLOT( ChangeEchoMode()));
|
||||
connect(ButtonCancel, SIGNAL(clicked()), this, SLOT( OnButtonCancel()));
|
||||
connect(ButtonOpenAttachment, SIGNAL(clicked()), this, SLOT( OnNewAttachment()));
|
||||
connect(ButtonDeleteAttachment, SIGNAL(clicked()), this, SLOT( OnDeleteAttachment()));
|
||||
connect(ButtonSaveAttachment, SIGNAL(clicked()), this, SLOT( OnSaveAttachment()));
|
||||
connect(ButtonGenPw, SIGNAL(clicked()), this, SLOT( OnButtonGenPw()));
|
||||
connect(ButtonOK, SIGNAL(clicked()),this,SLOT(OnButtonOK()));
|
||||
connect(CheckBox_ExpiresNever,SIGNAL(stateChanged(int)),this,SLOT(OnCheckBoxExpiresNeverChanged(int)));
|
||||
connect(Button_CustomIcons,SIGNAL(clicked()),this,SLOT(OnCustomIcons()));
|
||||
|
||||
ButtonOpenAttachment->setIcon(*Icon_FileOpen);
|
||||
ButtonDeleteAttachment->setIcon(*Icon_EditDelete);
|
||||
ButtonSaveAttachment->setIcon(*Icon_FileSave);
|
||||
|
||||
if(entry->BinaryData.isNull()){
|
||||
ButtonSaveAttachment->setDisabled(true);
|
||||
ButtonDeleteAttachment->setDisabled(true);}
|
||||
setWindowTitle(entry->Title);
|
||||
setWindowIcon(db->icon(entry->ImageID));
|
||||
Edit_Title->setText(entry->Title);
|
||||
Edit_UserName->setText(entry->UserName);
|
||||
Edit_URL->setText(entry->URL);
|
||||
entry->Password.unlock();
|
||||
Edit_Password->setText(entry->Password.string());
|
||||
Edit_Password_w->setText(entry->Password.string());
|
||||
entry->Password.lock();
|
||||
if(!config.ShowPasswords)
|
||||
ChangeEchoMode();
|
||||
OnPasswordwLostFocus();
|
||||
int bits=(entry->Password.length()*8);
|
||||
Label_Bits->setText(tr("%1 Bit").arg(QString::number(bits)));
|
||||
if(bits>128)
|
||||
bits=128;
|
||||
Progress_Quali->setValue(100*bits/128);
|
||||
Edit_Attachment->setText(entry->BinaryDesc);
|
||||
Edit_Comment->setPlainText(entry->Additional);
|
||||
InitGroupComboBox();
|
||||
InitIconComboBox();
|
||||
if(entry->BinaryData.length()==0)
|
||||
Label_AttachmentSize->setText("");
|
||||
else{
|
||||
QString unit;
|
||||
int faktor;
|
||||
int prec;
|
||||
if(entry->BinaryData.length()<1000){unit=" Byte";faktor=1;prec=0;}
|
||||
else {if(entry->BinaryData.length()<1000000){unit=" kB";faktor=1000;prec=1;}
|
||||
else{unit=" MB";faktor=1000000;prec=1;}
|
||||
}
|
||||
Label_AttachmentSize->setText(QString::number((float)entry->BinaryData.length()/(float)faktor,'f',prec)+unit);
|
||||
}
|
||||
if(entry->Expire==Date_Never){
|
||||
DateTime_Expire->setDisabled(true);
|
||||
CheckBox_ExpiresNever->setChecked(true);
|
||||
}
|
||||
else{
|
||||
DateTime_Expire->setDateTime(entry->Expire);
|
||||
}
|
||||
Q_ASSERT(_db);
|
||||
Q_ASSERT(_entry);
|
||||
entry=_entry;
|
||||
db=_db;
|
||||
setupUi(this);
|
||||
createBanner(&BannerPixmap,Icon_Key32x32,tr("Edit Entry"),width());
|
||||
ModFlag=false;
|
||||
connect(Edit_Password_w, SIGNAL(editingFinished()), this, SLOT(OnPasswordwLostFocus()));
|
||||
connect(Edit_Password_w, SIGNAL(textChanged(const QString&)), this, SLOT( OnPasswordwTextChanged(const QString&)));
|
||||
connect(Edit_Password, SIGNAL(textChanged(const QString&)), this, SLOT( OnPasswordTextChanged(const QString&)));
|
||||
connect(ButtonEchoMode, SIGNAL(clicked()), this, SLOT( ChangeEchoMode()));
|
||||
connect(ButtonCancel, SIGNAL(clicked()), this, SLOT( OnButtonCancel()));
|
||||
connect(ButtonOpenAttachment, SIGNAL(clicked()), this, SLOT( OnNewAttachment()));
|
||||
connect(ButtonDeleteAttachment, SIGNAL(clicked()), this, SLOT( OnDeleteAttachment()));
|
||||
connect(ButtonSaveAttachment, SIGNAL(clicked()), this, SLOT( OnSaveAttachment()));
|
||||
connect(ButtonGenPw, SIGNAL(clicked()), this, SLOT( OnButtonGenPw()));
|
||||
connect(ButtonOK, SIGNAL(clicked()),this,SLOT(OnButtonOK()));
|
||||
connect(CheckBox_ExpiresNever,SIGNAL(stateChanged(int)),this,SLOT(OnCheckBoxExpiresNeverChanged(int)));
|
||||
connect(Button_CustomIcons,SIGNAL(clicked()),this,SLOT(OnCustomIcons()));
|
||||
|
||||
ButtonOpenAttachment->setIcon(*Icon_FileOpen);
|
||||
ButtonDeleteAttachment->setIcon(*Icon_EditDelete);
|
||||
ButtonSaveAttachment->setIcon(*Icon_FileSave);
|
||||
|
||||
|
||||
setWindowTitle(entry->title());
|
||||
setWindowIcon(db->icon(entry->image()));
|
||||
Edit_Title->setText(entry->title());
|
||||
Edit_UserName->setText(entry->username());
|
||||
Edit_URL->setText(entry->url());
|
||||
SecString Password=entry->password();
|
||||
Password.unlock();
|
||||
Edit_Password->setText(Password.string());
|
||||
Edit_Password_w->setText(Password.string());
|
||||
Password.lock();
|
||||
if(!config.ShowPasswords)
|
||||
ChangeEchoMode();
|
||||
OnPasswordwLostFocus();
|
||||
int bits=(Password.length()*8);
|
||||
Label_Bits->setText(tr("%1 Bit").arg(QString::number(bits)));
|
||||
if(bits>128)
|
||||
bits=128;
|
||||
Progress_Quali->setValue(100*bits/128);
|
||||
Edit_Attachment->setText(entry->binaryDesc());
|
||||
Edit_Comment->setPlainText(entry->comment());
|
||||
InitGroupComboBox();
|
||||
InitIconComboBox();
|
||||
|
||||
if(!entry->binarySize()){
|
||||
ButtonSaveAttachment->setDisabled(true);
|
||||
ButtonDeleteAttachment->setDisabled(true);
|
||||
Label_AttachmentSize->setText("");
|
||||
}
|
||||
else{
|
||||
QString unit;
|
||||
int faktor;
|
||||
int prec;
|
||||
if(entry->binarySize()<1000){unit=" Byte";faktor=1;prec=0;}
|
||||
else
|
||||
if(entry->binarySize()<1000000){unit=" kB";faktor=1000;prec=1;}
|
||||
else{unit=" MB";faktor=1000000;prec=1;}
|
||||
Label_AttachmentSize->setText(QString::number((float)entry->binarySize()/(float)faktor,'f',prec)+unit);
|
||||
}
|
||||
if(entry->expire()==Date_Never){
|
||||
DateTime_Expire->setDisabled(true);
|
||||
CheckBox_ExpiresNever->setChecked(true);
|
||||
}
|
||||
else{
|
||||
DateTime_Expire->setDateTime(entry->expire());
|
||||
}
|
||||
}
|
||||
|
||||
CEditEntryDlg::~CEditEntryDlg()
|
||||
@@ -133,80 +133,95 @@ if(event->spontaneous()==false){
|
||||
}
|
||||
}
|
||||
|
||||
void CEditEntryDlg::InitIconComboBox(){
|
||||
for(int i=0;i<db->numIcons();i++){
|
||||
Combo_IconPicker->insertItem(i,db->icon(i),"");
|
||||
void CEditEntryDlg::paintEvent(QPaintEvent *event){
|
||||
QDialog::paintEvent(event);
|
||||
QPainter painter(this);
|
||||
painter.setClipRegion(event->region());
|
||||
painter.drawPixmap(QPoint(0,0),BannerPixmap);
|
||||
}
|
||||
Combo_IconPicker->setCurrentIndex(entry->ImageID);
|
||||
|
||||
void CEditEntryDlg::InitIconComboBox(){
|
||||
for(int i=0;i<db->numIcons();i++){
|
||||
Combo_IconPicker->insertItem(i,db->icon(i),"");
|
||||
}
|
||||
Combo_IconPicker->setCurrentIndex(entry->image());
|
||||
}
|
||||
|
||||
|
||||
void CEditEntryDlg::InitGroupComboBox(){
|
||||
QString tmp;
|
||||
int i;
|
||||
for(i=0;i!=db->numGroups();i++){
|
||||
tmp="";
|
||||
for(int j=0;j<db->group(i).Level;j++)tmp+=" ";
|
||||
Combo_Group->insertItem(i,db->icon(db->group(i).ImageID),
|
||||
tmp+db->group(i).Name);
|
||||
}
|
||||
Combo_Group->setCurrentIndex(db->getGroupIndex(entry->GroupID));
|
||||
QString Space;
|
||||
groups=db->sortedGroups();
|
||||
for(int i=0;i<groups.size();i++){
|
||||
Space.fill(' ',2*groups[i]->level());
|
||||
Combo_Group->insertItem(i,db->icon(groups[i]->image()),Space+groups[i]->title());
|
||||
if(groups[i]==entry->group()){
|
||||
Combo_Group->setCurrentIndex(i);
|
||||
GroupIndex=i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CEditEntryDlg::OnButtonOK()
|
||||
{
|
||||
bool EntryMoved=false;
|
||||
if(QString::compare(Edit_Password->text(),Edit_Password_w->text())!=0){
|
||||
QMessageBox::warning(NULL,tr("Warning"),tr("Password and password repetition are not equal.\nPlease check your input."),tr("OK"));
|
||||
return;
|
||||
}
|
||||
bool EntryMoved=false;
|
||||
if(QString::compare(Edit_Password->text(),Edit_Password_w->text())!=0){
|
||||
QMessageBox::warning(NULL,tr("Warning"),tr("Password and password repetition are not equal.\nPlease check your input."),tr("OK"));
|
||||
return;
|
||||
}
|
||||
|
||||
if(CheckBox_ExpiresNever->checkState()==Qt::Checked){
|
||||
DateTime_Expire->setDateTime(Date_Never);}
|
||||
if(CheckBox_ExpiresNever->checkState()==Qt::Checked){
|
||||
DateTime_Expire->setDateTime(Date_Never);
|
||||
}
|
||||
|
||||
if(DateTime_Expire->dateTime()!=entry->Expire)
|
||||
ModFlag=true;
|
||||
if(entry->Title!=Edit_Title->text())
|
||||
ModFlag=true;
|
||||
if(entry->UserName!=Edit_UserName->text())
|
||||
ModFlag=true;
|
||||
if(entry->URL!=Edit_URL->text())
|
||||
ModFlag=true;
|
||||
if(entry->Additional!=Edit_Comment->toPlainText())
|
||||
ModFlag=true;
|
||||
entry->Password.unlock();
|
||||
if(entry->Password.string()!=Edit_Password->text())
|
||||
ModFlag=true;
|
||||
entry->Password.lock();
|
||||
if(entry->ImageID!=Combo_IconPicker->currentIndex())
|
||||
ModFlag=true;
|
||||
|
||||
entry->Expire=DateTime_Expire->dateTime();
|
||||
entry->LastAccess=QDateTime::currentDateTime();
|
||||
if(ModFlag)entry->LastMod=QDateTime::currentDateTime();
|
||||
entry->Title=Edit_Title->text();
|
||||
entry->UserName=Edit_UserName->text();
|
||||
entry->URL=Edit_URL->text();
|
||||
QString s=Edit_Password->text();
|
||||
entry->Password.setString(s,true);
|
||||
entry->Additional=Edit_Comment->toPlainText();
|
||||
if(Combo_Group->currentIndex()!=db->getGroupIndex(entry->GroupID)){
|
||||
db->moveEntry(entry,&db->group(Combo_Group->currentIndex()));
|
||||
EntryMoved=true; ModFlag=true;
|
||||
}
|
||||
if(entry->ImageID<BUILTIN_ICONS && Combo_IconPicker->currentIndex()>=BUILTIN_ICONS)
|
||||
entry->OldImgID=entry->ImageID;
|
||||
entry->ImageID=Combo_IconPicker->currentIndex();
|
||||
|
||||
if(ModFlag&&EntryMoved)done(2);
|
||||
else if(ModFlag)done(1);
|
||||
else done(0);
|
||||
if(DateTime_Expire->dateTime()!=entry->expire())
|
||||
ModFlag=true;
|
||||
if(entry->title()!=Edit_Title->text())
|
||||
ModFlag=true;
|
||||
if(entry->username()!=Edit_UserName->text())
|
||||
ModFlag=true;
|
||||
if(entry->url()!=Edit_URL->text())
|
||||
ModFlag=true;
|
||||
if(entry->comment()!=Edit_Comment->toPlainText())
|
||||
ModFlag=true;
|
||||
SecString pw=entry->password();
|
||||
pw.unlock();
|
||||
QString password=pw.string();
|
||||
if(password!=Edit_Password->text())
|
||||
ModFlag=true;
|
||||
pw.lock();
|
||||
password.fill('X');
|
||||
if(entry->image()!=Combo_IconPicker->currentIndex())
|
||||
ModFlag=true;
|
||||
|
||||
if(ModFlag){
|
||||
entry->setExpire(DateTime_Expire->dateTime());
|
||||
entry->setLastAccess(QDateTime::currentDateTime());
|
||||
entry->setLastMod(QDateTime::currentDateTime());
|
||||
entry->setTitle(Edit_Title->text());
|
||||
entry->setUsername(Edit_UserName->text());
|
||||
entry->setUrl(Edit_URL->text());
|
||||
SecString pw;
|
||||
QString password=Edit_Password->text();
|
||||
pw.setString(password,true);
|
||||
entry->setPassword(pw);
|
||||
entry->setComment(Edit_Comment->toPlainText());
|
||||
}
|
||||
if(Combo_Group->currentIndex()!=GroupIndex){
|
||||
db->moveEntry(entry,groups[Combo_Group->currentIndex()]);
|
||||
EntryMoved=true; ModFlag=true;
|
||||
}
|
||||
entry->setImage(Combo_IconPicker->currentIndex());
|
||||
|
||||
if(ModFlag&&EntryMoved)done(2);
|
||||
else if(ModFlag)done(1);
|
||||
else done(0);
|
||||
|
||||
}
|
||||
|
||||
void CEditEntryDlg::OnButtonCancel()
|
||||
{
|
||||
entry->LastAccess=QDateTime::currentDateTime();
|
||||
done(0);
|
||||
entry->setLastAccess(QDateTime::currentDateTime());
|
||||
done(0);
|
||||
}
|
||||
|
||||
void CEditEntryDlg::ChangeEchoMode()
|
||||
@@ -238,14 +253,11 @@ void CEditEntryDlg::OnPasswordwTextChanged(const QString& w)
|
||||
|
||||
if(QString::compare(Edit_Password_w->text(),Edit_Password->text().mid(0,(Edit_Password_w->text().length())))!=0){
|
||||
QPalette palette;
|
||||
palette.setColor(Edit_Password_w->foregroundRole(),QColor(255,125,125));
|
||||
palette.setColor(Edit_Password_w->backgroundRole(),QColor(255,125,125));
|
||||
Edit_Password_w->setPalette(palette);
|
||||
}else
|
||||
{
|
||||
///@FIXME should set correct background color... it's not always white!
|
||||
QPalette palette;
|
||||
palette.setColor(Edit_Password_w->foregroundRole(),QColor(255,255,255));
|
||||
Edit_Password_w->setPalette(palette);
|
||||
Edit_Password_w->setPalette(QApplication::palette());
|
||||
}
|
||||
|
||||
|
||||
@@ -256,102 +268,95 @@ void CEditEntryDlg::OnPasswordwLostFocus()
|
||||
{
|
||||
if(QString::compare(Edit_Password_w->text(),Edit_Password->text())!=0){
|
||||
QPalette palette;
|
||||
palette.setColor(Edit_Password_w->foregroundRole(),QColor(255,125,125));
|
||||
palette.setColor(Edit_Password_w->backgroundRole(),QColor(255,125,125));
|
||||
Edit_Password_w->setPalette(palette);
|
||||
}
|
||||
else
|
||||
{
|
||||
///@FIXME should set correct background color... it's not always white!
|
||||
QPalette palette;
|
||||
palette.setColor(Edit_Password_w->foregroundRole(),QColor(255,255,255));
|
||||
Edit_Password_w->setPalette(palette);
|
||||
Edit_Password_w->setPalette(QApplication::palette ());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void CEditEntryDlg::OnNewAttachment()
|
||||
{
|
||||
QString filename=QFileDialog::getOpenFileName(this,tr("Add Attachment..."),QDir::homePath());
|
||||
if(filename=="")return;
|
||||
QFile file(filename);
|
||||
if(file.open(QIODevice::ReadOnly)==false){
|
||||
file.close();
|
||||
QMessageBox::warning(NULL,tr("Error"),tr("Could not open file."),tr("OK"));
|
||||
return;
|
||||
}
|
||||
ModFlag=true;
|
||||
entry->BinaryData=file.readAll();
|
||||
file.close();
|
||||
QFileInfo info(filename);
|
||||
entry->BinaryDesc=info.fileName();
|
||||
file.close();
|
||||
Edit_Attachment->setText(entry->BinaryDesc);
|
||||
QString unit;
|
||||
int faktor;
|
||||
int prec;
|
||||
if(entry->BinaryData.length()<1000){unit=" Byte";faktor=1;prec=0;}
|
||||
else {if(entry->BinaryData.length()<1000000){unit=" kB";faktor=1000;prec=1;}
|
||||
else{unit=" MB";faktor=1000000;prec=1;}
|
||||
{
|
||||
QString filename=QFileDialog::getOpenFileName(this,tr("Add Attachment..."),QDir::homePath());
|
||||
if(filename=="")return;
|
||||
QFile file(filename);
|
||||
if(file.open(QIODevice::ReadOnly)==false){
|
||||
file.close();
|
||||
QMessageBox::warning(NULL,tr("Error"),tr("Could not open file."),tr("OK"));
|
||||
return;
|
||||
}
|
||||
Label_AttachmentSize->setText(QString::number((float)entry->BinaryData.length()/(float)faktor,'f',prec)+unit);
|
||||
ButtonOpenAttachment->setEnabled(true);
|
||||
ButtonSaveAttachment->setEnabled(true);
|
||||
ButtonDeleteAttachment->setEnabled(true);
|
||||
ModFlag=true;
|
||||
entry->setBinary(file.readAll());
|
||||
file.close();
|
||||
QFileInfo info(filename);
|
||||
entry->setBinaryDesc(info.fileName());
|
||||
Edit_Attachment->setText(entry->binaryDesc());
|
||||
QString unit;
|
||||
int faktor;
|
||||
int prec;
|
||||
if(entry->binarySize()<1000){unit=" Byte";faktor=1;prec=0;}
|
||||
else {if(entry->binarySize()<1000000){unit=" kB";faktor=1000;prec=1;}
|
||||
else{unit=" MB";faktor=1000000;prec=1;}
|
||||
}
|
||||
Label_AttachmentSize->setText(QString::number((float)entry->binarySize()/(float)faktor,'f',prec)+unit);
|
||||
ButtonOpenAttachment->setEnabled(true);
|
||||
ButtonSaveAttachment->setEnabled(true);
|
||||
ButtonDeleteAttachment->setEnabled(true);
|
||||
}
|
||||
|
||||
void CEditEntryDlg::OnSaveAttachment(){
|
||||
saveAttachment(entry,this);
|
||||
saveAttachment(entry,this);
|
||||
}
|
||||
|
||||
void CEditEntryDlg::saveAttachment(CEntry* pEntry, QWidget* ParentWidget)
|
||||
void CEditEntryDlg::saveAttachment(IEntryHandle* pEntry, QWidget* ParentWidget)
|
||||
{
|
||||
QFileDialog FileDlg(ParentWidget,tr("Save Attachment..."),QDir::homePath());
|
||||
FileDlg.selectFile(pEntry->BinaryDesc);
|
||||
FileDlg.setAcceptMode(QFileDialog::AcceptSave);
|
||||
if(!FileDlg.exec())return;
|
||||
QString filename=FileDlg.selectedFiles()[0];
|
||||
QFile file(filename);
|
||||
if(file.exists()){
|
||||
int r=QMessageBox::warning(ParentWidget,tr("Overwrite?"),tr("A file with this name already exists.\nDo you want to replace it?"),tr("Yes"),tr("No"),NULL,1,1);
|
||||
if(r==1)return;
|
||||
if(file.remove()==false){
|
||||
QMessageBox::critical(NULL,tr("Error"),tr("Could not remove old file."),tr("OK"));
|
||||
return;}
|
||||
}
|
||||
if(file.open(QIODevice::WriteOnly)==false){
|
||||
QMessageBox::critical(NULL,tr("Error"),tr("Could not create new file."),tr("OK"));
|
||||
return;
|
||||
}
|
||||
if(!pEntry->binarySize()){
|
||||
QMessageBox::information(NULL,tr("Error"),tr("The chosen entry has no attachment or it is empty."),tr("OK"));
|
||||
return;
|
||||
}
|
||||
QFileDialog FileDlg(ParentWidget,tr("Save Attachment..."),QDir::homePath());
|
||||
FileDlg.selectFile(pEntry->binaryDesc());
|
||||
FileDlg.setAcceptMode(QFileDialog::AcceptSave);
|
||||
if(!FileDlg.exec())return;
|
||||
QString filename=FileDlg.selectedFiles()[0];
|
||||
QFile file(filename);
|
||||
if(!file.open(QIODevice::WriteOnly | QIODevice::Truncate)){
|
||||
QMessageBox::critical(NULL,tr("Error"),tr("Could not open file."),tr("OK"));
|
||||
return;
|
||||
}
|
||||
|
||||
int r=file.write(pEntry->binary());
|
||||
if(r==-1){
|
||||
file.close();
|
||||
QMessageBox::critical(NULL,tr("Error"),tr("Error while writing the file."),tr("OK"));
|
||||
return;
|
||||
}
|
||||
if(r!=pEntry->binarySize()){
|
||||
file.close();
|
||||
QMessageBox::critical(NULL,tr("Error"),tr("Error while writing the file."),tr("OK"));
|
||||
return;
|
||||
}
|
||||
file.close();
|
||||
|
||||
int r=file.write(pEntry->BinaryData);
|
||||
if(r==-1){
|
||||
file.close();
|
||||
QMessageBox::critical(NULL,tr("Error"),tr("Error while writing the file."),"OK");
|
||||
return;
|
||||
}
|
||||
if(r!=pEntry->BinaryData.length()){
|
||||
file.close();
|
||||
QMessageBox::critical(NULL,tr("Error"),tr("Error while writing the file."),tr("OK"));
|
||||
return;
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
|
||||
void CEditEntryDlg::OnDeleteAttachment()
|
||||
{
|
||||
int r=QMessageBox::warning(this,tr("Delete Attachment?"),tr("You are about to delete the attachment of this entry.\nAre you sure?"),tr("Yes"),tr("No, Cancel"),NULL,1,1);
|
||||
if(r==0){
|
||||
ModFlag=true;
|
||||
entry->BinaryData.clear();
|
||||
entry->BinaryData=QByteArray();
|
||||
entry->BinaryDesc="";
|
||||
Edit_Attachment->setText("");
|
||||
Label_AttachmentSize->setText("");
|
||||
ButtonOpenAttachment->setEnabled(true);
|
||||
ButtonSaveAttachment->setDisabled(true);
|
||||
ButtonDeleteAttachment->setDisabled(true);
|
||||
}
|
||||
int r=QMessageBox::warning(this,tr("Delete Attachment?"),tr("You are about to delete the attachment of this entry.\nAre you sure?"),tr("Yes"),tr("No, Cancel"),NULL,1,1);
|
||||
if(r==0){
|
||||
ModFlag=true;
|
||||
entry->setBinary(QByteArray());
|
||||
entry->setBinaryDesc("");
|
||||
Edit_Attachment->setText("");
|
||||
Label_AttachmentSize->setText("");
|
||||
ButtonOpenAttachment->setEnabled(true);
|
||||
ButtonSaveAttachment->setDisabled(true);
|
||||
ButtonDeleteAttachment->setDisabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
void CEditEntryDlg::OnButtonGenPw()
|
||||
@@ -382,10 +387,3 @@ if(r!=-1){
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*$SPECIALIZATION$*/
|
||||
|
||||
|
||||
//#include "editentrydlg.moc"
|
||||
|
||||
|
||||
@@ -24,53 +24,44 @@
|
||||
#include <QPixmap>
|
||||
#include <QShowEvent>
|
||||
#include "main.h"
|
||||
#include "PwManager.h"
|
||||
#include "StandardDatabase.h"
|
||||
|
||||
class CEditEntryDlg : public QDialog, public Ui_EditEntryDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CEditEntryDlg(Database* _db, CEntry* _entry,QWidget* parent = 0, bool modal = FALSE, Qt::WFlags fl = 0);
|
||||
~CEditEntryDlg();
|
||||
virtual void showEvent(QShowEvent *);
|
||||
/*$PUBLIC_FUNCTIONS$*/
|
||||
|
||||
public slots:
|
||||
virtual void OnButtonOK();
|
||||
/*$PUBLIC_SLOTS$*/
|
||||
|
||||
protected:
|
||||
/*$PROTECTED_FUNCTIONS$*/
|
||||
|
||||
protected slots:
|
||||
/*$PROTECTED_SLOTS$*/
|
||||
|
||||
public:
|
||||
CEntry* entry;
|
||||
Database* db;
|
||||
QPixmap* banner_pixmap;
|
||||
bool ModFlag;
|
||||
|
||||
|
||||
void CreateBanner();
|
||||
void InitGroupComboBox();
|
||||
void InitIconComboBox();
|
||||
static void saveAttachment(CEntry* pEntry, QWidget* ParentWidget=NULL);
|
||||
|
||||
|
||||
public slots:
|
||||
void OnPasswordwLostFocus();
|
||||
void OnPasswordwTextChanged(const QString&);
|
||||
void OnPasswordTextChanged(const QString&);
|
||||
void ChangeEchoMode();
|
||||
void OnButtonCancel();
|
||||
void OnNewAttachment();
|
||||
void OnDeleteAttachment();
|
||||
void OnSaveAttachment();
|
||||
void OnButtonGenPw();
|
||||
void OnCheckBoxExpiresNeverChanged(int state);
|
||||
void OnCustomIcons();
|
||||
Q_OBJECT
|
||||
public:
|
||||
CEditEntryDlg(IDatabase* _db, IEntryHandle* _entry,QWidget* parent = 0, bool modal = FALSE, Qt::WFlags fl = 0);
|
||||
~CEditEntryDlg();
|
||||
void InitGroupComboBox();
|
||||
void InitIconComboBox();
|
||||
static void saveAttachment(IEntryHandle* pEntry, QWidget* ParentWidget=NULL);
|
||||
|
||||
IEntryHandle* entry;
|
||||
IDatabase* db;
|
||||
bool ModFlag;
|
||||
int GroupIndex;
|
||||
QList<IGroupHandle*> groups;
|
||||
QPixmap BannerPixmap;
|
||||
|
||||
public slots:
|
||||
void OnPasswordwLostFocus();
|
||||
void OnPasswordwTextChanged(const QString&);
|
||||
void OnPasswordTextChanged(const QString&);
|
||||
void ChangeEchoMode();
|
||||
void OnButtonCancel();
|
||||
void OnNewAttachment();
|
||||
void OnDeleteAttachment();
|
||||
void OnSaveAttachment();
|
||||
void OnButtonGenPw();
|
||||
void OnCheckBoxExpiresNeverChanged(int state);
|
||||
void OnCustomIcons();
|
||||
void OnButtonOK();
|
||||
|
||||
private:
|
||||
virtual void showEvent(QShowEvent *);
|
||||
virtual void paintEvent(QPaintEvent*);
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -26,17 +26,31 @@
|
||||
#include "EditGroupDlg.h"
|
||||
#include "SelectIconDlg.h"
|
||||
|
||||
|
||||
CEditGroupDialog::CEditGroupDialog(Database* database,QWidget* parent, bool modal, Qt::WFlags fl)
|
||||
CEditGroupDialog::CEditGroupDialog(IDatabase* database,IGroupHandle* Handle,QWidget* parent, bool modal, Qt::WFlags fl)
|
||||
: QDialog(parent,fl)
|
||||
{
|
||||
setupUi(this);
|
||||
db=database;
|
||||
IconID=0;
|
||||
connect( ButtonOK, SIGNAL( clicked() ), this, SLOT( OnOK() ) );
|
||||
connect( ButtonCancel, SIGNAL( clicked() ), this, SLOT( OnCancel() ) );
|
||||
connect( Button_Icon, SIGNAL( clicked() ), this, SLOT( OnIconDlg() ));
|
||||
ModFlag=false;
|
||||
setupUi(this);
|
||||
db=database;
|
||||
handle=Handle;
|
||||
group=new CGroup();
|
||||
group->Title=handle->title();
|
||||
group->Image=handle->image();
|
||||
connect( ButtonOK, SIGNAL( clicked() ), this, SLOT( OnOK() ) );
|
||||
connect( ButtonCancel, SIGNAL( clicked() ), this, SLOT( OnCancel() ) );
|
||||
connect( Button_Icon, SIGNAL( clicked() ), this, SLOT( OnIconDlg() ));
|
||||
}
|
||||
|
||||
|
||||
CEditGroupDialog::CEditGroupDialog(IDatabase* database,CGroup* Group,QWidget* parent, bool modal, Qt::WFlags fl)
|
||||
: QDialog(parent,fl)
|
||||
{
|
||||
setupUi(this);
|
||||
db=database;
|
||||
group=Group;
|
||||
handle=NULL;
|
||||
connect( ButtonOK, SIGNAL( clicked() ), this, SLOT( OnOK() ) );
|
||||
connect( ButtonCancel, SIGNAL( clicked() ), this, SLOT( OnCancel() ) );
|
||||
connect( Button_Icon, SIGNAL( clicked() ), this, SLOT( OnIconDlg() ));
|
||||
}
|
||||
|
||||
CEditGroupDialog::~CEditGroupDialog()
|
||||
@@ -44,36 +58,47 @@ CEditGroupDialog::~CEditGroupDialog()
|
||||
}
|
||||
|
||||
void CEditGroupDialog::showEvent(QShowEvent *event){
|
||||
if(event->spontaneous()==false){
|
||||
EditTitle->setText(GroupName);
|
||||
for(int i=0;i<db->numIcons();i++){
|
||||
ComboIconPicker->insertItem(i,db->icon(i),"");
|
||||
if(event->spontaneous()==false){
|
||||
EditTitle->setText(group->Title);
|
||||
for(int i=0;i<db->numIcons();i++){
|
||||
ComboIconPicker->insertItem(i,db->icon(i),"");
|
||||
}
|
||||
ComboIconPicker->setCurrentIndex(group->Image);
|
||||
}
|
||||
ComboIconPicker->setCurrentIndex(IconID);
|
||||
}
|
||||
}
|
||||
|
||||
void CEditGroupDialog::OnOK()
|
||||
{
|
||||
GroupName=EditTitle->text();
|
||||
IconID=ComboIconPicker->currentIndex();
|
||||
done(1);
|
||||
int r=1;
|
||||
if(EditTitle->text()!=group->Title){
|
||||
group->Title=EditTitle->text();
|
||||
r=2;
|
||||
}
|
||||
if(ComboIconPicker->currentIndex()!=group->Image){
|
||||
group->Image=ComboIconPicker->currentIndex();
|
||||
r=2;
|
||||
}
|
||||
if(handle){
|
||||
handle->setTitle(group->Title);
|
||||
handle->setImage(group->Image);
|
||||
}
|
||||
done(r);
|
||||
}
|
||||
|
||||
void CEditGroupDialog::OnCancel()
|
||||
{
|
||||
done(0);
|
||||
done(0);
|
||||
}
|
||||
|
||||
|
||||
void CEditGroupDialog::OnIconDlg(){
|
||||
CSelectIconDlg dlg(db,IconID,this);
|
||||
int r=dlg.exec();
|
||||
if(r!=-1){
|
||||
ComboIconPicker->clear();
|
||||
for(int i=0;i<db->numIcons();i++)
|
||||
ComboIconPicker->insertItem(i,db->icon(i),"");
|
||||
IconID=r;
|
||||
ComboIconPicker->setCurrentIndex(IconID);
|
||||
}
|
||||
CSelectIconDlg dlg(db,group->Image,this);
|
||||
int r=dlg.exec();
|
||||
if(r!=-1){
|
||||
ComboIconPicker->clear();
|
||||
for(int i=0;i<db->numIcons();i++)
|
||||
ComboIconPicker->insertItem(i,db->icon(i),"");
|
||||
group->Image=r;
|
||||
ComboIconPicker->setCurrentIndex(r);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,18 +29,15 @@
|
||||
class CEditGroupDialog : public QDialog, public Ui_EditGroupDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CEditGroupDialog(Database*,QWidget* parent = 0, bool modal = FALSE, Qt::WFlags fl = 0 );
|
||||
~CEditGroupDialog();
|
||||
bool ModFlag;
|
||||
virtual void showEvent(QShowEvent *event);
|
||||
int IconID;
|
||||
QString GroupName;
|
||||
|
||||
CEditGroupDialog(IDatabase*,IGroupHandle*,QWidget* parent = 0, bool modal = FALSE, Qt::WFlags fl = 0 );
|
||||
CEditGroupDialog(IDatabase*,CGroup*,QWidget* parent = 0, bool modal = FALSE, Qt::WFlags fl = 0 );
|
||||
~CEditGroupDialog();
|
||||
virtual void showEvent(QShowEvent *event);
|
||||
private:
|
||||
Database* db;
|
||||
|
||||
IDatabase* db;
|
||||
IGroupHandle* handle;
|
||||
CGroup* group;
|
||||
|
||||
public slots:
|
||||
virtual void OnOK();
|
||||
|
||||
@@ -124,89 +124,110 @@ KeyType=BOTH;
|
||||
|
||||
void CPasswordDialog::OnButtonBrowse()
|
||||
{
|
||||
QString filename=QFileDialog::getOpenFileName(this,tr("Select a Key File"),QDir::homePath(),tr("*.key"));
|
||||
if(filename=="")return;
|
||||
QFile file(filename);
|
||||
if(file.exists()){
|
||||
Combo_Dirs->setEditText(filename);
|
||||
return;
|
||||
}
|
||||
QMessageBox::warning(this,tr("Error"),tr("Unexpected Error: File does not exist."),tr("OK"),"","",0,0);
|
||||
QFileDialog FileDlg(this,tr("Select a Key File"),QDir::homePath());
|
||||
FileDlg.setFilters(QStringList()<<tr("All Files (*)") << tr("Key Files (*.key)"));
|
||||
FileDlg.setFileMode(QFileDialog::ExistingFile);
|
||||
if(!FileDlg.exec())return;
|
||||
if(!FileDlg.selectedFiles().size())return;
|
||||
QFile file(FileDlg.selectedFiles()[0]);
|
||||
if(file.exists()){
|
||||
Combo_Dirs->setEditText(FileDlg.selectedFiles()[0]);
|
||||
return;
|
||||
}
|
||||
QMessageBox::warning(this,tr("Error"),tr("Unexpected Error: File does not exist."),tr("OK"),"","",0,0);
|
||||
}
|
||||
|
||||
void CPasswordDialog::OnButtonBrowse_Set()
|
||||
{
|
||||
QString filename=QFileDialog::getSaveFileName(this,tr("Select a Key File"),QDir::homePath(),tr("*.key"));
|
||||
if(filename=="")return;
|
||||
Combo_Dirs->setEditText(filename);
|
||||
QFileDialog FileDlg(this,tr("Select a Key File"),QDir::homePath());
|
||||
FileDlg.setFilters(QStringList()<<tr("All Files (*)") << tr("Key Files (*.key)"));
|
||||
FileDlg.setFileMode(QFileDialog::AnyFile);
|
||||
if(!FileDlg.exec())return;
|
||||
if(!FileDlg.selectedFiles().size())return;
|
||||
Combo_Dirs->setEditText(FileDlg.selectedFiles()[0]);
|
||||
}
|
||||
|
||||
void CPasswordDialog::OnCancel()
|
||||
{
|
||||
done(0);
|
||||
done(0);
|
||||
}
|
||||
|
||||
void CPasswordDialog::OnOK(){
|
||||
password=Edit_Password->text();
|
||||
keyfile=Combo_Dirs->currentText();
|
||||
password=Edit_Password->text();
|
||||
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);
|
||||
return;}
|
||||
|
||||
if(KeyType==BOTH){
|
||||
if(password==""){
|
||||
QMessageBox::warning(this,tr("Error"),tr("Please enter a Password."),tr("OK"),"","",0,0);
|
||||
if(password=="" && keyfile==""){
|
||||
QMessageBox::warning(this,tr("Error"),tr("Please enter a Password or select a key file."),tr("OK"),"","",0,0);
|
||||
return;}
|
||||
if(keyfile==""){
|
||||
QMessageBox::warning(this,tr("Error"),tr("Please choose a key file."),tr("OK"),"","",0,0);
|
||||
return;}
|
||||
}
|
||||
|
||||
if(KeyType==BOTH || KeyType==KEYFILE){
|
||||
QFileInfo fileinfo(keyfile);
|
||||
if(!fileinfo.exists()){
|
||||
QMessageBox::warning(this,tr("Error"),tr("The selected key file or directory does not exist."),tr("OK"),"","",0,0);
|
||||
return;
|
||||
}
|
||||
if(!fileinfo.isReadable()){
|
||||
QMessageBox::warning(this,tr("Error"),tr("The selected key file or directory is not readable.\nPlease check your permissions."),tr("OK"),"","",0,0);
|
||||
return;
|
||||
}
|
||||
if(fileinfo.isDir()){
|
||||
if(keyfile.right(1)!="/")keyfile+="/";
|
||||
QFile file(keyfile+"pwsafe.key");
|
||||
if(!file.exists()){
|
||||
QDir dir(keyfile);
|
||||
QStringList files;
|
||||
files=dir.entryList(QStringList()<<"*.key",QDir::Files);
|
||||
if(!files.size()){
|
||||
QMessageBox::warning(this,tr("Error"),tr("The given directory does not contain any key files."),tr("OK"),"","",0,0);
|
||||
if(KeyType==BOTH){
|
||||
if(password==""){
|
||||
QMessageBox::warning(this,tr("Error"),tr("Please enter a Password."),tr("OK"),"","",0,0);
|
||||
return;}
|
||||
if(files.size()>1){
|
||||
QMessageBox::warning(this,tr("Error"),tr("The given directory contains more then one key file.\nPlease specify the key file directly."),tr("OK"),"","",0,0);
|
||||
return;}
|
||||
QFile file(keyfile+files[0]);
|
||||
Q_ASSERT(file.exists());
|
||||
if(!QFileInfo(file).isReadable()){
|
||||
QMessageBox::warning(this,tr("Error"),tr("The key file found in the given directory is not readable.\nPlease check your permissions."),tr("OK"),"","",0,0);
|
||||
return;}
|
||||
keyfile+=files[0];
|
||||
}else{
|
||||
if(!QFileInfo(file).isReadable()){
|
||||
QMessageBox::warning(this,tr("Error"),tr("The key file found in the given directory is not readable.\nPlease check your permissions."),tr("OK"),"","",0,0);
|
||||
return;}
|
||||
keyfile+="pwsafe.key";
|
||||
if(keyfile==""){
|
||||
QMessageBox::warning(this,tr("Error"),tr("Please choose a key file."),tr("OK"),"","",0,0);
|
||||
return;}
|
||||
}
|
||||
}else{
|
||||
QFile file(keyfile);
|
||||
if(!file.exists()){
|
||||
QMessageBox::warning(this,tr("Error"),tr("Key file could not be found."),tr("OK"),"","",0,0);
|
||||
return;}
|
||||
if(!QFileInfo(file).isReadable()){
|
||||
QMessageBox::warning(this,tr("Error"),tr("Key file is not readable.\nPlease check your permissions."),tr("OK"),"","",0,0);
|
||||
return;}
|
||||
}
|
||||
|
||||
if(KeyType==BOTH || KeyType==KEYFILE){
|
||||
QFileInfo fileinfo(keyfile);
|
||||
if(Mode_Set){
|
||||
if(fileinfo.exists()){
|
||||
switch(QMessageBox::question(this,tr("File exists."),tr("A file with the selected name already exists, should this file be used as key file\nor do you want to overwrite it with a new generated one?"),
|
||||
tr("Use"),tr("Overwrite"),tr("Cancel"),0,2)){
|
||||
case 0: OverwriteKeyFile=false;
|
||||
break;
|
||||
case 1: OverwriteKeyFile=true;
|
||||
break;
|
||||
case 2: return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else{
|
||||
if(!fileinfo.exists()){
|
||||
QMessageBox::warning(this,tr("Error"),tr("The selected key file or directory does not exist."),tr("OK"),"","",0,0);
|
||||
return;
|
||||
}
|
||||
if(!fileinfo.isReadable()){
|
||||
QMessageBox::warning(this,tr("Error"),tr("The selected key file or directory is not readable.\nPlease check your permissions."),tr("OK"),"","",0,0);
|
||||
return;
|
||||
}
|
||||
if(fileinfo.isDir()){
|
||||
if(keyfile.right(1)!="/")keyfile+="/";
|
||||
QFile file(keyfile+"pwsafe.key");
|
||||
if(!file.exists()){
|
||||
QDir dir(keyfile);
|
||||
QStringList files;
|
||||
files=dir.entryList(QStringList()<<"*.key",QDir::Files);
|
||||
if(!files.size()){
|
||||
QMessageBox::warning(this,tr("Error"),tr("The given directory does not contain any key files."),tr("OK"),"","",0,0);
|
||||
return;}
|
||||
if(files.size()>1){
|
||||
QMessageBox::warning(this,tr("Error"),tr("The given directory contains more then one key file.\nPlease specify the key file directly."),tr("OK"),"","",0,0);
|
||||
return;}
|
||||
QFile file(keyfile+files[0]);
|
||||
Q_ASSERT(file.exists());
|
||||
if(!QFileInfo(file).isReadable()){
|
||||
QMessageBox::warning(this,tr("Error"),tr("The key file found in the given directory is not readable.\nPlease check your permissions."),tr("OK"),"","",0,0);
|
||||
return;}
|
||||
keyfile+=files[0];
|
||||
}else{
|
||||
if(!QFileInfo(file).isReadable()){
|
||||
QMessageBox::warning(this,tr("Error"),tr("The key file found in the given directory is not readable.\nPlease check your permissions."),tr("OK"),"","",0,0);
|
||||
return;}
|
||||
keyfile+="pwsafe.key";
|
||||
}
|
||||
}else{
|
||||
QFile file(keyfile);
|
||||
if(!file.exists()){
|
||||
QMessageBox::warning(this,tr("Error"),tr("Key file could not be found."),tr("OK"),"","",0,0);
|
||||
return;}
|
||||
if(!QFileInfo(file).isReadable()){
|
||||
QMessageBox::warning(this,tr("Error"),tr("Key file is not readable.\nPlease check your permissions."),tr("OK"),"","",0,0);
|
||||
return;}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(config.RememberLastKey){
|
||||
|
||||
@@ -37,6 +37,7 @@ public:
|
||||
QString keyfile;
|
||||
QString password;
|
||||
tKeyType KeyType;
|
||||
bool OverwriteKeyFile;
|
||||
|
||||
CPasswordDialog(QWidget* parent = 0, bool modal = false,
|
||||
bool ShowExitButton = false, bool KeyMode_Set=false, Qt::WFlags fl = 0 );
|
||||
|
||||
@@ -18,22 +18,24 @@
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include <QLineEdit>
|
||||
#include <QCheckBox>
|
||||
#include <QRegExp>
|
||||
#include <QMessageBox>
|
||||
#include "main.h"
|
||||
#include "PwmConfig.h"
|
||||
#include "PwManager.h"
|
||||
#include "SearchDlg.h"
|
||||
#include <qlineedit.h>
|
||||
#include <qcheckbox.h>
|
||||
#include <qregexp.h>
|
||||
#include <qmessagebox.h>
|
||||
|
||||
CSearchDlg::CSearchDlg(Database* _db,CGroup* pGroup,QWidget* parent, bool modal, Qt::WFlags fl)
|
||||
|
||||
CSearchDlg::CSearchDlg(IDatabase* database,IGroupHandle* Group,QWidget* parent, bool modal, Qt::WFlags fl)
|
||||
: QDialog(parent,fl)
|
||||
{
|
||||
setupUi(this);
|
||||
connect( Button_Search, SIGNAL( clicked() ), this, SLOT( OnButtonSearch() ) );
|
||||
connect( Button_Close, SIGNAL( clicked() ), this, SLOT( OnButtonClose() ) );
|
||||
|
||||
connect( Button_Search, SIGNAL( clicked() ), this, SLOT( OnSearch() ) );
|
||||
connect( Button_Close, SIGNAL( clicked() ), this, SLOT( OnClose() ) );
|
||||
db=database;
|
||||
group=Group;
|
||||
createBanner(Banner,Icon_Search32x32,tr("Search"));
|
||||
checkBox_Cs->setChecked(config.SearchOptions[0]);
|
||||
checkBox_regExp->setChecked(config.SearchOptions[1]);
|
||||
@@ -43,14 +45,11 @@ checkBox_Password->setChecked(config.SearchOptions[4]);
|
||||
checkBox_Comment->setChecked(config.SearchOptions[5]);
|
||||
checkBox_URL->setChecked(config.SearchOptions[6]);
|
||||
checkBox_Attachment->setChecked(config.SearchOptions[7]);
|
||||
if(pGroup)
|
||||
if(group)
|
||||
checkBox_Recursive->setChecked(config.SearchOptions[8]);
|
||||
else{
|
||||
checkBox_Recursive->setChecked(false);
|
||||
checkBox_Recursive->setEnabled(false);}
|
||||
|
||||
db=_db;
|
||||
group=pGroup;
|
||||
}
|
||||
|
||||
CSearchDlg::~CSearchDlg()
|
||||
@@ -66,60 +65,24 @@ config.SearchOptions[7]=checkBox_Attachment->isChecked();
|
||||
if(group) config.SearchOptions[8]=checkBox_Recursive->isChecked();
|
||||
}
|
||||
|
||||
void CSearchDlg::OnButtonClose()
|
||||
void CSearchDlg::OnClose()
|
||||
{
|
||||
done(0);
|
||||
done(0);
|
||||
}
|
||||
|
||||
void CSearchDlg::OnButtonSearch()
|
||||
void CSearchDlg::OnSearch()
|
||||
{
|
||||
Hits.clear();
|
||||
txt=Edit_Search->text();
|
||||
regexp=checkBox_regExp->isChecked();
|
||||
if(txt==""){
|
||||
QMessageBox::information(this,tr("Notice"),tr("Please enter a search string."),tr("OK"));
|
||||
return;}
|
||||
|
||||
for(int i=0;i<db->numEntries();i++){
|
||||
if(group){
|
||||
if(checkBox_Recursive->isChecked()){
|
||||
QList<int> groups=db->getChildIds(group);
|
||||
groups << group->ID;
|
||||
bool IsInAnyGroup=false;
|
||||
for(int j=0; j<groups.size();j++){
|
||||
if(db->entry(i).GroupID == groups[j]){IsInAnyGroup=true; break;}}
|
||||
if(!IsInAnyGroup)continue;
|
||||
}
|
||||
else
|
||||
if(db->entry(i).GroupID != group->ID)continue;
|
||||
}
|
||||
|
||||
bool hit=false;
|
||||
if(checkBox_Title->isChecked()) hit=hit||search(db->entry(i).Title);
|
||||
if(checkBox_Username->isChecked()) hit=hit||search(db->entry(i).UserName);
|
||||
if(checkBox_URL->isChecked()) hit=hit||search(db->entry(i).URL);
|
||||
if(checkBox_Comment->isChecked()) hit=hit||search(db->entry(i).Additional);
|
||||
if(checkBox_Attachment->isChecked()) hit=hit||search(db->entry(i).BinaryDesc);
|
||||
db->entry(i).Password.unlock();
|
||||
if(checkBox_Password->isChecked()) hit=hit||search(db->entry(i).Password.string());
|
||||
db->entry(i).Password.lock();
|
||||
if(hit)Hits.push_back(db->entry(i).sID);
|
||||
}
|
||||
|
||||
done(1);
|
||||
|
||||
bool Fields[6];
|
||||
Fields[0]=checkBox_Title->isChecked();
|
||||
Fields[1]=checkBox_Username->isChecked();
|
||||
Fields[2]=checkBox_URL->isChecked();
|
||||
Fields[3]=checkBox_Password->isChecked();
|
||||
Fields[4]=checkBox_Comment->isChecked();
|
||||
Fields[5]=checkBox_Attachment->isChecked();
|
||||
Result=db->search(group,Edit_Search->text(),checkBox_Cs->isChecked(),checkBox_regExp->isChecked(),checkBox_Recursive->isChecked(),Fields);
|
||||
done(1);
|
||||
}
|
||||
|
||||
|
||||
bool CSearchDlg::search(const QString& str){
|
||||
|
||||
if(regexp){
|
||||
QRegExp exp(txt,checkBox_Cs->isChecked() ? Qt::CaseSensitive : Qt::CaseInsensitive);
|
||||
if(str.contains(exp)==0)return false;}
|
||||
else{
|
||||
if(str.contains(txt,checkBox_Cs->isChecked() ? Qt::CaseSensitive : Qt::CaseInsensitive)==0)return false;}
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -21,27 +21,23 @@
|
||||
#define SEARCHDLG_H
|
||||
#include "ui_SearchDlg.h"
|
||||
#include "main.h"
|
||||
#include "PwManager.h"
|
||||
#include "Database.h"
|
||||
|
||||
class CSearchDlg : public QDialog, public Ui_Search_Dlg
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CSearchDlg(Database* _db, CGroup* pGroup=NULL,QWidget* parent = 0,
|
||||
bool modal = FALSE, Qt::WFlags fl = 0 );
|
||||
CSearchDlg(IDatabase* database, IGroupHandle* group=NULL,QWidget* parent = 0, bool modal = true, Qt::WFlags fl = 0 );
|
||||
~CSearchDlg();
|
||||
QList<quint32> Hits;
|
||||
QList<IEntryHandle*> Result;
|
||||
|
||||
public slots:
|
||||
virtual void OnButtonClose();
|
||||
virtual void OnButtonSearch();
|
||||
virtual void OnClose();
|
||||
virtual void OnSearch();
|
||||
|
||||
private:
|
||||
QString txt;
|
||||
CGroup* group;
|
||||
bool regexp;
|
||||
Database* db;
|
||||
bool search(const QString& str);
|
||||
IGroupHandle* group;
|
||||
IDatabase* db;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -24,102 +24,104 @@
|
||||
#include <QFile>
|
||||
#include <QPixmap>
|
||||
#include <QMessageBox>
|
||||
#include <QShowEvent>
|
||||
#include "SelectIconDlg.h"
|
||||
|
||||
|
||||
|
||||
CSelectIconDlg::CSelectIconDlg(Database* database,int CurrentID,QWidget* parent, bool modal, Qt::WFlags fl):QDialog(parent,fl){
|
||||
setupUi(this);
|
||||
db=database;
|
||||
CtxMenu=new QMenu(this);
|
||||
ReplaceAction=CtxMenu->addAction(*Icon_Swap,tr("Replace..."));
|
||||
DeleteAction=CtxMenu->addAction(*Icon_EditDelete,tr("Delete"));
|
||||
connect(Button_AddIcon, SIGNAL(clicked()), this, SLOT(OnAddIcon()));
|
||||
connect(Button_PickIcon, SIGNAL(clicked()), this, SLOT(OnPickIcon()));
|
||||
connect(Button_Cancel, SIGNAL(clicked()), this, SLOT(OnCancel()));
|
||||
connect(DeleteAction,SIGNAL(triggered()),this,SLOT(OnDelete()));
|
||||
connect(ReplaceAction,SIGNAL(triggered()),this,SLOT(OnReplace()));
|
||||
connect(List,SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),this,SLOT(OnSelectionChanged(QListWidgetItem*,QListWidgetItem*)));
|
||||
updateView();
|
||||
List->setCurrentItem(List->item(CurrentID));
|
||||
CSelectIconDlg::CSelectIconDlg(IDatabase* database,int CurrentId,QWidget* parent, bool modal, Qt::WFlags fl):QDialog(parent,fl){
|
||||
setupUi(this);
|
||||
db=database;
|
||||
Id=CurrentId;
|
||||
CtxMenu=new QMenu(this);
|
||||
ReplaceAction=CtxMenu->addAction(*Icon_Swap,tr("Replace..."));
|
||||
DeleteAction=CtxMenu->addAction(*Icon_EditDelete,tr("Delete"));
|
||||
connect(Button_AddIcon, SIGNAL(clicked()), this, SLOT(OnAddIcon()));
|
||||
connect(Button_PickIcon, SIGNAL(clicked()), this, SLOT(OnPickIcon()));
|
||||
connect(Button_Cancel, SIGNAL(clicked()), this, SLOT(OnCancel()));
|
||||
connect(DeleteAction,SIGNAL(triggered()),this,SLOT(OnDelete()));
|
||||
connect(ReplaceAction,SIGNAL(triggered()),this,SLOT(OnReplace()));
|
||||
connect(List,SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),this,SLOT(OnSelectionChanged(QListWidgetItem*,QListWidgetItem*)));
|
||||
}
|
||||
|
||||
void CSelectIconDlg::updateView(){
|
||||
List->clear();
|
||||
for(int i=0; i<db->numIcons(); i++){
|
||||
QListWidgetItem* item;
|
||||
if(i<BUILTIN_ICONS)
|
||||
List->addItem(item=new QListWidgetItem(QIcon(db->icon(i)),QString::number(i)));
|
||||
else
|
||||
if(!db->icon(i).isNull())
|
||||
List->addItem(item=new QListWidgetItem(QIcon(db->icon(i)),"["+QString::number(i)+"]"));
|
||||
item->setData(32,i);
|
||||
}
|
||||
List->clear();
|
||||
for(int i=0; i<db->numIcons(); i++){
|
||||
QListWidgetItem* item;
|
||||
if(i<BUILTIN_ICONS)
|
||||
List->addItem(item=new QListWidgetItem(QIcon(db->icon(i)),QString::number(i)));
|
||||
else
|
||||
if(!db->icon(i).isNull())
|
||||
List->addItem(item=new QListWidgetItem(QIcon(db->icon(i)),"["+QString::number(i)+"]"));
|
||||
item->setData(32,i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CSelectIconDlg::OnAddIcon(){
|
||||
QStringList filenames=QFileDialog::getOpenFileNames(this,tr("Add Icons..."),QDir::homePath(),tr("Images (%1)")
|
||||
.arg("*.png *.jpeg *.jpg *.bmp *.gif *.bpm *.pgm *.ppm *.xbm *xpm"));
|
||||
QString errors;
|
||||
for(int i=0;i<filenames.size();i++){
|
||||
QPixmap icon;
|
||||
if(!icon.load(filenames[i])){
|
||||
errors+=tr("%1: File could not be loaded.\n").arg(filenames[i].section("/",-1));
|
||||
continue;}
|
||||
db->addIcon(icon.scaled(16,16,Qt::KeepAspectRatio,Qt::SmoothTransformation));
|
||||
}
|
||||
if(errors.size())
|
||||
QMessageBox::warning(this,tr("Error"),tr("An error occured while loading the icon(s):\n%1").arg(errors));
|
||||
updateView();
|
||||
List->setCurrentItem(List->item(List->count()-1));
|
||||
QStringList filenames=QFileDialog::getOpenFileNames(this,tr("Add Icons..."),QDir::homePath(),tr("Images (%1)")
|
||||
.arg("*.png *.jpeg *.jpg *.bmp *.gif *.bpm *.pgm *.ppm *.xbm *xpm"));
|
||||
QString errors;
|
||||
for(int i=0;i<filenames.size();i++){
|
||||
QPixmap icon;
|
||||
if(!icon.load(filenames[i])){
|
||||
errors+=tr("%1: File could not be loaded.\n").arg(filenames[i].section("/",-1));
|
||||
continue;}
|
||||
dynamic_cast<ICustomIcons*>(db)->addIcon(icon.scaled(16,16,Qt::KeepAspectRatio,Qt::SmoothTransformation));
|
||||
}
|
||||
if(errors.size())
|
||||
QMessageBox::warning(this,tr("Error"),tr("An error occured while loading the icon(s):\n%1").arg(errors));
|
||||
updateView();
|
||||
List->setCurrentItem(List->item(List->count()-1));
|
||||
}
|
||||
|
||||
void CSelectIconDlg::contextMenuEvent(QContextMenuEvent *event){
|
||||
|
||||
QListWidgetItem* item=List->itemAt(List->mapFromParent(event->pos()));
|
||||
|
||||
if(!item)return;
|
||||
if(item->data(32).toInt()<BUILTIN_ICONS){
|
||||
DeleteAction->setDisabled(true);
|
||||
ReplaceAction->setDisabled(true);}
|
||||
else{
|
||||
DeleteAction->setDisabled(false);
|
||||
ReplaceAction->setDisabled(false);}
|
||||
|
||||
event->accept();
|
||||
CtxMenu->popup(event->globalPos());
|
||||
void CSelectIconDlg::contextMenuEvent(QContextMenuEvent *event){
|
||||
QListWidgetItem* item=List->itemAt(List->mapFromParent(event->pos()));
|
||||
if(!item)return;
|
||||
if(item->data(32).toInt()<BUILTIN_ICONS){
|
||||
DeleteAction->setDisabled(true);
|
||||
ReplaceAction->setDisabled(true);}
|
||||
else{
|
||||
DeleteAction->setDisabled(false);
|
||||
ReplaceAction->setDisabled(false);}
|
||||
event->accept();
|
||||
CtxMenu->popup(event->globalPos());
|
||||
}
|
||||
|
||||
void CSelectIconDlg::OnDelete(){
|
||||
db->removeIcon(List->currentItem()->data(32).toInt());
|
||||
updateView();
|
||||
List->setCurrentItem(List->item(0));
|
||||
dynamic_cast<ICustomIcons*>(db)->removeIcon(List->currentItem()->data(32).toInt());
|
||||
updateView();
|
||||
List->setCurrentItem(List->item(0));
|
||||
}
|
||||
|
||||
void CSelectIconDlg::OnReplace(){
|
||||
QString filename=QFileDialog::getOpenFileName(this,tr("Add Icons..."),QDir::homePath(),tr("Images (%1)")
|
||||
.arg("*.png *.jpeg *.jpg *.bmp *.gif *.bpm *.pgm *.ppm *.xbm *xpm"));
|
||||
if(filename==QString())return;
|
||||
QPixmap icon;
|
||||
if(!icon.load(filename)){
|
||||
QMessageBox::warning(this,tr("Error"),tr("An error occured while loading the icon."));
|
||||
return;
|
||||
}
|
||||
db->replaceIcon(List->currentItem()->data(32).toInt(),icon.scaled(16,16,Qt::KeepAspectRatio,Qt::SmoothTransformation));
|
||||
List->currentItem()->setIcon(QIcon(db->icon(List->currentItem()->data(32).toInt())));
|
||||
QString filename=QFileDialog::getOpenFileName(this,tr("Add Icons..."),QDir::homePath(),tr("Images (%1)")
|
||||
.arg("*.png *.jpeg *.jpg *.bmp *.gif *.bpm *.pgm *.ppm *.xbm *xpm"));
|
||||
if(filename==QString())return;
|
||||
QPixmap icon;
|
||||
if(!icon.load(filename)){
|
||||
QMessageBox::warning(this,tr("Error"),tr("An error occured while loading the icon."));
|
||||
return;
|
||||
}
|
||||
dynamic_cast<ICustomIcons*>(db)->replaceIcon(List->currentItem()->data(32).toInt(),icon.scaled(16,16,Qt::KeepAspectRatio,Qt::SmoothTransformation));
|
||||
List->currentItem()->setIcon(QIcon(db->icon(List->currentItem()->data(32).toInt())));
|
||||
}
|
||||
|
||||
void CSelectIconDlg::OnPickIcon(){
|
||||
done(List->currentItem()->data(32).toInt());
|
||||
done(List->currentItem()->data(32).toInt());
|
||||
}
|
||||
|
||||
void CSelectIconDlg::OnCancel(){
|
||||
done(-1);
|
||||
done(-1);
|
||||
}
|
||||
|
||||
|
||||
void CSelectIconDlg::OnSelectionChanged(QListWidgetItem* cur,QListWidgetItem* prev){
|
||||
Button_PickIcon->setEnabled(cur);
|
||||
|
||||
Button_PickIcon->setEnabled(cur);
|
||||
}
|
||||
|
||||
void CSelectIconDlg::showEvent(QShowEvent *event){
|
||||
if(!event->spontaneous()){
|
||||
updateView();
|
||||
List->setCurrentItem(List->item(Id));
|
||||
}
|
||||
}
|
||||
@@ -31,7 +31,7 @@
|
||||
class CSelectIconDlg:public QDialog, public Ui_SelectIconDlg{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CSelectIconDlg(Database* db,int,QWidget* parent = 0, bool modal = false, Qt::WFlags fl = 0);
|
||||
CSelectIconDlg(IDatabase* db,int ImageID,QWidget* parent = 0, bool modal = false, Qt::WFlags fl = 0);
|
||||
|
||||
public slots:
|
||||
void OnAddIcon();
|
||||
@@ -42,14 +42,16 @@ public slots:
|
||||
void OnSelectionChanged(QListWidgetItem*,QListWidgetItem*);
|
||||
|
||||
private:
|
||||
Database* db;
|
||||
void updateView();
|
||||
QMenu* CtxMenu;
|
||||
QAction* DeleteAction;
|
||||
QAction* ReplaceAction;
|
||||
int Id;
|
||||
IDatabase* db;
|
||||
void updateView();
|
||||
QMenu* CtxMenu;
|
||||
QAction* DeleteAction;
|
||||
QAction* ReplaceAction;
|
||||
|
||||
protected:
|
||||
virtual void contextMenuEvent(QContextMenuEvent *event);
|
||||
virtual void showEvent(QShowEvent* event);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#include "main.h"
|
||||
#include "PwmConfig.h"
|
||||
#include <qpixmap.h>
|
||||
@@ -99,6 +100,7 @@ close();
|
||||
|
||||
void CSettingsDlg::OnTextColor()
|
||||
{
|
||||
|
||||
QColor c=QColorDialog::getColor(textcolor,this);
|
||||
if(c.isValid()){
|
||||
textcolor=c;
|
||||
@@ -106,7 +108,10 @@ QPixmap *px=new QPixmap(pixmTextColor->width(),pixmTextColor->height());
|
||||
px->fill(c);
|
||||
pixmTextColor->clear();
|
||||
pixmTextColor->setPixmap(*px);
|
||||
createBanner(Banner,Icon_Settings32x32,tr("Settings"),color1,color2,textcolor);}
|
||||
//NICHT VERGESSEN!
|
||||
//createBanner(Banner,Icon_Settings32x32,tr("Settings"),color1,color2,textcolor);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -119,7 +124,8 @@ 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);}
|
||||
//createBanner(Banner,Icon_Settings32x32,tr("Settings"),color1,color2,textcolor);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -132,7 +138,7 @@ 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);
|
||||
//createBanner(Banner,Icon_Settings32x32,tr("Settings"),color1,color2,textcolor);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user