import comment
git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@1 b624d157-de02-0410-bad0-e51aec6abb33
This commit is contained in:
98
src/dialogs/AboutDlg.cpp
Executable file
98
src/dialogs/AboutDlg.cpp
Executable file
@@ -0,0 +1,98 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2005 by Tarek Saidi *
|
||||
* tarek@linux *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#include "mainwindow.h"
|
||||
#include <qmessagebox.h>
|
||||
#include <qscrollview.h>
|
||||
#include <qlabel.h>
|
||||
#include <qdialog.h>
|
||||
#include <qfile.h>
|
||||
|
||||
#include "AboutDlg.h"
|
||||
|
||||
CAboutDialog::CAboutDialog(QWidget* parent, const char* name, bool modal, WFlags fl)
|
||||
: AboutDlg(parent,name, modal,fl)
|
||||
{
|
||||
mainwnd=((CMainWindow*)parentWidget());
|
||||
mainwnd->CreateBanner(Banner,mainwnd->Icon_Key32x32,trUtf8("Keepass für Linux"));
|
||||
Link_Homepage=new LinkLabel(this,"Link_Homepage",trUtf8("http://keepass.de.vu"),80,143);
|
||||
Link_EMail=new LinkLabel(this,"Link_EMail",trUtf8("tarek.saidi@arcor.de"),80,163);
|
||||
Link_License=new LinkLabel(this,"Link_License",trUtf8("Lizenz"),80,183);
|
||||
connect(Link_License,SIGNAL(clicked()),this,SLOT(OnLicenseClicked()));
|
||||
connect(Link_EMail,SIGNAL(clicked()),this,SLOT(OnEMailClicked()));
|
||||
connect(Link_Homepage,SIGNAL(clicked()),this,SLOT(OnHomepageClicked()));
|
||||
Label0->setText(Label0->text().arg(KEEPASS_VERSION));
|
||||
|
||||
}
|
||||
|
||||
CAboutDialog::~CAboutDialog()
|
||||
{
|
||||
delete Link_Homepage;
|
||||
delete Link_EMail;
|
||||
delete Link_License;
|
||||
}
|
||||
|
||||
void CAboutDialog::OnClose()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
void CAboutDialog::OnLicenseClicked(){
|
||||
|
||||
QDialog dlg(this,NULL,true);
|
||||
QScrollView scroll(&dlg);
|
||||
QLabel label(&scroll,"License-Scroll");
|
||||
scroll.addChild(&label);
|
||||
QFile gpl(((CMainWindow*)parentWidget())->appdir+"/../share/keepass/license.txt");
|
||||
if(!gpl.exists()){
|
||||
QMessageBox::critical(this,trUtf8("Fehler"),trUtf8("Die Datei '%1' konnte nicht gefunden werden.")
|
||||
.arg("'license.txt'")+"\n"+trUtf8("Die Anwendung wurde möglicherweiße nicht korrekt installiert.")
|
||||
,trUtf8("OK"),0,0,2,1);
|
||||
return;
|
||||
}
|
||||
|
||||
if(!gpl.open(IO_ReadOnly)){
|
||||
QMessageBox::critical(this,trUtf8("Fehler"),trUtf8("Die Datei '%1' konnte nicht geöffnet werden.")
|
||||
.arg("'license.txt'")+trUtf8("Es trat folgender Fehler auf:\n%1").arg(gpl.errorString())
|
||||
,trUtf8("OK"),0,0,2,1);
|
||||
return;
|
||||
}
|
||||
char* buffer=new char[gpl.size()];
|
||||
long l=gpl.readBlock(buffer,gpl.size());
|
||||
gpl.close();
|
||||
label.setText(QString::fromUtf8(buffer,l));
|
||||
label.setGeometry(0,0,500,800);
|
||||
dlg.setFixedWidth(500);
|
||||
dlg.setFixedHeight(400);
|
||||
dlg.setCaption(trUtf8("Lizenz"));
|
||||
scroll.setGeometry(0,0,500,400);
|
||||
dlg.exec();
|
||||
delete buffer;
|
||||
|
||||
}
|
||||
|
||||
void CAboutDialog::OnHomepageClicked(){
|
||||
mainwnd->OpenURL("http://keepass.de.vu");
|
||||
}
|
||||
|
||||
void CAboutDialog::OnEMailClicked(){
|
||||
mainwnd->OpenURL("mailto:tarek.saidi@arcor.de");
|
||||
}
|
||||
|
||||
57
src/dialogs/AboutDlg.h
Executable file
57
src/dialogs/AboutDlg.h
Executable file
@@ -0,0 +1,57 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2005 by Tarek Saidi *
|
||||
* tarek@linux *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
#ifndef _ABOUTDIALOG_H_
|
||||
#define _ABOUTDIALOG_H_
|
||||
#include "ui_AboutDlg.h"
|
||||
#include "lib/UrlLabel.h"
|
||||
#include "mainwindow.h"
|
||||
|
||||
|
||||
|
||||
class CAboutDialog : public AboutDlg
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
LinkLabel *Link_Homepage,*Link_EMail,*Link_License;
|
||||
public:
|
||||
CAboutDialog(QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
|
||||
~CAboutDialog();
|
||||
|
||||
CMainWindow* mainwnd;
|
||||
/*$PUBLIC_FUNCTIONS$*/
|
||||
|
||||
public slots:
|
||||
/*$PUBLIC_SLOTS$*/
|
||||
|
||||
protected:
|
||||
/*$PROTECTED_FUNCTIONS$*/
|
||||
|
||||
protected slots:
|
||||
/*$PROTECTED_SLOTS$*/
|
||||
|
||||
public slots:
|
||||
virtual void OnClose();
|
||||
void OnHomepageClicked();
|
||||
void OnEMailClicked();
|
||||
void OnLicenseClicked();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
225
src/dialogs/ChangeKeyDlg.cpp
Executable file
225
src/dialogs/ChangeKeyDlg.cpp
Executable file
@@ -0,0 +1,225 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2005 by Tarek Saidi *
|
||||
* tarek@linux *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
#include "mainwindow.h"
|
||||
#include "PwManager.h"
|
||||
#include "../lib/random.h"
|
||||
#include "ChangeKeyDlg.h"
|
||||
//QT
|
||||
#include <qlineedit.h>
|
||||
#include <qcombobox.h>
|
||||
#include <qpushbutton.h>
|
||||
#include <qcheckbox.h>
|
||||
#include <qdir.h>
|
||||
#include <qfiledialog.h>
|
||||
#include <qmessagebox.h>
|
||||
|
||||
|
||||
|
||||
CChangeKeyDlg::CChangeKeyDlg(QWidget* parent,PwDatabase* _db,const char* name, bool modal, WFlags fl)
|
||||
: ChangeKeyDialog(parent,name, modal,fl)
|
||||
{
|
||||
db=_db;
|
||||
parentwnd=((CMainWindow*)parentWidget());
|
||||
parentwnd->CreateBanner(Banner,parentwnd->Icon_Key32x32,trUtf8("Hauptschlüssel ändern"));
|
||||
if(!parentwnd->config.ShowPasswords)ChangeEchoMode();
|
||||
///@PlatformSpecific
|
||||
QDir media("/media");
|
||||
if(media.exists()){
|
||||
Paths=media.entryList("*",QDir::Dirs);
|
||||
Paths.erase(Paths.begin()); // delete "."
|
||||
Paths.erase(Paths.begin()); // delete ".."
|
||||
|
||||
for(int i=0;i<Paths.count();i++){
|
||||
Paths[i]="/media/"+Paths[i];
|
||||
}
|
||||
Paths.prepend("< none >");
|
||||
}
|
||||
for(int i=0;i<Paths.count();i++){
|
||||
Combo_Dirs->insertItem(0,Paths[i]);
|
||||
IsFile.append(false);
|
||||
}
|
||||
}
|
||||
|
||||
CChangeKeyDlg::~CChangeKeyDlg()
|
||||
{
|
||||
}
|
||||
|
||||
void CChangeKeyDlg::OnOK()
|
||||
{
|
||||
if(CheckBox_Both->isChecked()){
|
||||
if(password==""){QMessageBox::warning(this,trUtf8("Fehler"),trUtf8("Bitte geben Sie ein Passwort ein.")
|
||||
,trUtf8("OK"),"","",0,0);
|
||||
return;}
|
||||
if(keyfile==""){QMessageBox::warning(this,trUtf8("Fehler"),trUtf8("Bitte wählen Sie eine Schlüsseldatei.")
|
||||
,trUtf8("OK"),"","",0,0);
|
||||
return;}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(password=="" && keyfile==""){QMessageBox::warning(this,trUtf8("Fehler"),trUtf8("Geben Sie bitte ein Passwort ein oder wählen Sie eine Schlüsseldatei.")
|
||||
,trUtf8("OK"),"","",0,0);
|
||||
return;}
|
||||
}
|
||||
|
||||
UINT8 file_key[32]={0};
|
||||
UINT8 pw_key[32]={0};
|
||||
|
||||
if(keyfile!=""){
|
||||
QFile file(keyfile);
|
||||
if(file.exists()){
|
||||
int r=QMessageBox::warning(this,trUtf8("Vorhandene Datei überschreiben?"),trUtf8("Unter dem gewählten Dateinamen existiert bereits eine Datei.\nSoll sie überschrieben werden?"),"Ja","Nein",NULL,1,1);
|
||||
if(r==1)return;}
|
||||
getRandomBytes(file_key,1,32,true);
|
||||
if(file.open(IO_WriteOnly | IO_Truncate)==false){
|
||||
QMessageBox::critical(this,trUtf8("Fehler"),trUtf8("Schlüsseldatei konnte nicht geöffnet werden."),"OK",0,0,2,1);
|
||||
return;
|
||||
}
|
||||
if(file.writeBlock((char*)file_key,32)!=32){
|
||||
file.close();
|
||||
QMessageBox::critical(this,trUtf8("Fehler"),trUtf8("Das Schreiben der Schlüsseldatei ist fehlgeschlagen."),"OK",0,0,2,1);
|
||||
return;
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
|
||||
if(CheckBox_Both->isChecked() || keyfile==""){
|
||||
if(password!=Edit_Password_2->text()){
|
||||
QMessageBox::critical(this,trUtf8("Fehler"),trUtf8("Passwort und Passwortwiederholung stimmen nicht überein.\nBitte prüfen Sie Ihre Eingabe."),"OK",0,0,2,1);
|
||||
return;}}
|
||||
|
||||
if(CheckBox_Both->isChecked())db->CalcMasterKeyByFileAndPw(keyfile, password);
|
||||
else if(password=="")db->CalcMasterKeyByFile(keyfile);
|
||||
else if(keyfile==""){db->CalcMasterKeyByPassword(password);}
|
||||
|
||||
done(1);
|
||||
}
|
||||
|
||||
void CChangeKeyDlg::OnSelect()
|
||||
{
|
||||
if(Button_Browse->isEnabled()){
|
||||
keyfile=QFileDialog::getSaveFileName(QDir::homeDirPath(),"",this,trUtf8("Schlüsseldatei öffnen"));
|
||||
if(keyfile=="")return;
|
||||
Combo_Dirs->insertItem(keyfile);
|
||||
Combo_Dirs->setCurrentItem(Combo_Dirs->count()-1);
|
||||
if(!CheckBox_Both->isChecked()){
|
||||
Edit_Password->setDisabled(true);
|
||||
Edit_Password->setText("");
|
||||
password="";
|
||||
}
|
||||
Paths.append(keyfile);
|
||||
IsFile.append(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CChangeKeyDlg::OnBrowse()
|
||||
{
|
||||
QString dir=QFileDialog::getExistingDirectory(QDir::homeDirPath(),NULL,trUtf8("Verzeichnis wählen"));
|
||||
if(dir=="")return;
|
||||
keyfile=dir+"/pwsafe.key";
|
||||
Combo_Dirs->insertItem(dir);
|
||||
Combo_Dirs->setCurrentItem(Combo_Dirs->count()-1);
|
||||
if(!CheckBox_Both->isChecked()){
|
||||
Edit_Password->setDisabled(true);
|
||||
Edit_Password_2->setDisabled(true);
|
||||
Edit_Password->setText("");
|
||||
Edit_Password_2->setText("");
|
||||
password="";
|
||||
}
|
||||
Paths.append(dir);
|
||||
IsFile.append(false);
|
||||
}
|
||||
|
||||
|
||||
void CChangeKeyDlg::OnCancel()
|
||||
{
|
||||
done(0);
|
||||
}
|
||||
|
||||
void CChangeKeyDlg::OnPasswordChanged(const QString& str)
|
||||
{
|
||||
if(str!="" && !(CheckBox_Both->isChecked())){
|
||||
Combo_Dirs->setDisabled(true);
|
||||
Button_Browse->setDisabled(true);}
|
||||
else{
|
||||
Combo_Dirs->setEnabled(true);
|
||||
Button_Browse->setEnabled(true);}
|
||||
Edit_Password_2->setText("");
|
||||
password=str;
|
||||
}
|
||||
|
||||
void CChangeKeyDlg::OnPassword2Changed(const QString& str)
|
||||
{
|
||||
}
|
||||
|
||||
void CChangeKeyDlg::OnComboChanged(int i)
|
||||
{
|
||||
if(i==0){
|
||||
keyfile="";
|
||||
Edit_Password->setEnabled(true);
|
||||
Edit_Password_2->setEnabled(true);
|
||||
return;
|
||||
}
|
||||
if(IsFile[i]==true)keyfile=Paths[i];
|
||||
else keyfile=Paths[i]+"/pwsafe.key";
|
||||
|
||||
if(!CheckBox_Both->isChecked()){
|
||||
Edit_Password->setText("");
|
||||
Edit_Password->setDisabled(true);
|
||||
Edit_Password_2->setText("");
|
||||
Edit_Password_2->setDisabled(true);}
|
||||
|
||||
}
|
||||
|
||||
void CChangeKeyDlg::OnCheckBoxChanged(int i)
|
||||
{
|
||||
if(i==QButton::NoChange)return;
|
||||
if(i==QButton::On){
|
||||
Combo_Dirs->setEnabled(true);
|
||||
Button_Browse->setEnabled(true);
|
||||
Edit_Password->setEnabled(true);
|
||||
Edit_Password_2->setEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
void CChangeKeyDlg::ChangeEchoMode()
|
||||
{
|
||||
if(Edit_Password->echoMode()==QLineEdit::Normal){
|
||||
Edit_Password->setEchoMode(QLineEdit::Password);
|
||||
Edit_Password_2->setEchoMode(QLineEdit::Password);
|
||||
}
|
||||
else
|
||||
{
|
||||
Edit_Password->setEchoMode(QLineEdit::Normal);
|
||||
Edit_Password_2->setEchoMode(QLineEdit::Normal);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*$SPECIALIZATION$*/
|
||||
|
||||
|
||||
//#include "changekeydlg.moc"
|
||||
|
||||
71
src/dialogs/ChangeKeyDlg.h
Executable file
71
src/dialogs/ChangeKeyDlg.h
Executable file
@@ -0,0 +1,71 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2005 by Tarek Saidi *
|
||||
* tarek@linux *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
#include "mainwindow.h"
|
||||
#ifndef _CHANGEKEYDLG_H_
|
||||
#define _CHANGEKEYDLG_H_
|
||||
#include "ui_ChangeKeyDlg.h"
|
||||
#include <qstringlist.h>
|
||||
#include <qvaluelist.h>
|
||||
#include <qfile.h>
|
||||
|
||||
class CChangeKeyDlg : public ChangeKeyDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CChangeKeyDlg(QWidget* parent,PwDatabase* db, const char* name = 0, bool modal = true, WFlags fl = 0 );
|
||||
~CChangeKeyDlg();
|
||||
/*$PUBLIC_FUNCTIONS$*/
|
||||
|
||||
public slots:
|
||||
/*$PUBLIC_SLOTS$*/
|
||||
|
||||
protected:
|
||||
/*$PROTECTED_FUNCTIONS$*/
|
||||
|
||||
protected slots:
|
||||
/*$PROTECTED_SLOTS$*/
|
||||
|
||||
public slots:
|
||||
virtual void OnSelect();
|
||||
virtual void OnBrowse();
|
||||
virtual void OnCancel();
|
||||
virtual void OnOK();
|
||||
virtual void OnComboChanged(int i);
|
||||
virtual void OnCheckBoxChanged(int i);
|
||||
virtual void OnPasswordChanged(const QString& str);
|
||||
virtual void OnPassword2Changed(const QString& str);
|
||||
virtual void ChangeEchoMode();
|
||||
|
||||
|
||||
private:
|
||||
PwDatabase* db;
|
||||
CMainWindow* parentwnd;
|
||||
QStringList Paths;
|
||||
QValueList<bool> IsFile;
|
||||
|
||||
public:
|
||||
QString keyfile;
|
||||
QFile* pKeyFile;
|
||||
QString password;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
84
src/dialogs/DatabaseSettingsDlg.cpp
Executable file
84
src/dialogs/DatabaseSettingsDlg.cpp
Executable file
@@ -0,0 +1,84 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2005 by Tarek Saidi *
|
||||
* tarek@linux *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
#include <qcombobox.h>
|
||||
#include <qlineedit.h>
|
||||
#include <qmessagebox.h>
|
||||
#include "mainwindow.h"
|
||||
#include "DatabaseSettingsDlg.h"
|
||||
|
||||
|
||||
CDbSettingsDlg::CDbSettingsDlg(CMainWindow* parent,Database* db, const char* name, bool modal, WFlags fl)
|
||||
: dbsettingdlg_base(parent,name, modal,fl)
|
||||
{
|
||||
database=db;
|
||||
}
|
||||
|
||||
CDbSettingsDlg::~CDbSettingsDlg()
|
||||
{
|
||||
}
|
||||
|
||||
void CDbSettingsDlg::showEvent(QShowEvent *event){
|
||||
if(event->spontaneous()==false){
|
||||
((CMainWindow*)parentWidget())->CreateBanner(Banner,((CMainWindow*)parentWidget())->Icon_Settings32x32,"Einstellungen");
|
||||
ComboAlgo->insertItem(trUtf8("AES(Rijndael): 256 Bit (Standard)"),0);
|
||||
ComboAlgo->insertItem(trUtf8("Twofish: 256 Bit"),1);
|
||||
ComboAlgo->setCurrentItem(database->CryptoAlgorithmus); //Achtung: AlgoID muss gleich dem ComboBox Index sein!
|
||||
EditRounds->setText(QString::number(database->KeyEncRounds));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void CDbSettingsDlg::OnCancel()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
|
||||
void CDbSettingsDlg::OnOK()
|
||||
{
|
||||
if(EditRounds->text()==""){
|
||||
QMessageBox::warning(NULL,trUtf8("Fehler"),trUtf8("Geben Sie bitte die Anzahl der Verschlüsselungsrunden an."),trUtf8("OK"));
|
||||
return;
|
||||
}
|
||||
bool valid;
|
||||
int rounds=EditRounds->text().toUInt(&valid,10);
|
||||
if(valid==false){
|
||||
QMessageBox::warning(NULL,trUtf8("Fehler"),EditRounds->text()+trUtf8(" ist kein gültiger Zahlenwert"),trUtf8("OK"));
|
||||
return;
|
||||
}
|
||||
if(rounds==0){
|
||||
QMessageBox::warning(NULL,trUtf8("Fehler"),trUtf8("Die Anzahl an Verschlüsselungsrunden muss mindestens 1 betragen."),trUtf8("OK"));
|
||||
return;
|
||||
}
|
||||
database->KeyEncRounds=rounds;
|
||||
database->CryptoAlgorithmus=ComboAlgo->currentItem();
|
||||
|
||||
close();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*$SPECIALIZATION$*/
|
||||
|
||||
|
||||
//#include "databasesettingsdlg.moc"
|
||||
|
||||
54
src/dialogs/DatabaseSettingsDlg.h
Executable file
54
src/dialogs/DatabaseSettingsDlg.h
Executable file
@@ -0,0 +1,54 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2005 by Tarek Saidi *
|
||||
* tarek@linux *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
#ifndef DBSETTINGSDLG_H
|
||||
#define DBSETTINGSDLG_H
|
||||
#include "ui_DatabaseSettingsDlg.h"
|
||||
#include "mainwindow.h"
|
||||
#include "Database.h"
|
||||
|
||||
class CDbSettingsDlg : public dbsettingdlg_base
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CDbSettingsDlg(CMainWindow* parent,Database* db,const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
|
||||
~CDbSettingsDlg();
|
||||
virtual void showEvent(QShowEvent *);
|
||||
/*$PUBLIC_FUNCTIONS$*/
|
||||
|
||||
public slots:
|
||||
/*$PUBLIC_SLOTS$*/
|
||||
|
||||
protected:
|
||||
/*$PROTECTED_FUNCTIONS$*/
|
||||
|
||||
protected slots:
|
||||
/*$PROTECTED_SLOTS$*/
|
||||
|
||||
public slots:
|
||||
virtual void OnCancel();
|
||||
virtual void OnOK();
|
||||
|
||||
private:
|
||||
Database* database;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
371
src/dialogs/EditEntryDlg.cpp
Executable file
371
src/dialogs/EditEntryDlg.cpp
Executable file
@@ -0,0 +1,371 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2005 by Tarek Saidi *
|
||||
* tarek@linux *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
#include "mainwindow.h"
|
||||
|
||||
#include <qpushbutton.h>
|
||||
#include <qpalette.h>
|
||||
#include <qfont.h>
|
||||
#include <qlineedit.h>
|
||||
#include <qlabel.h>
|
||||
#include <qprogressbar.h>
|
||||
#include <qtextedit.h>
|
||||
#include <qpixmap.h>
|
||||
#include <qcolor.h>
|
||||
#include <qcombobox.h>
|
||||
#include <qpainter.h>
|
||||
#include <qpen.h>
|
||||
#include <qfiledialog.h>
|
||||
#include <qmessagebox.h>
|
||||
|
||||
|
||||
#include "PasswordGenDlg.h"
|
||||
#include "EditEntryDlg.h"
|
||||
|
||||
|
||||
|
||||
CEditEntryDlg::CEditEntryDlg(QWidget* parent, const char* name, bool modal, WFlags fl)
|
||||
: EditEntryDialog(parent,name, modal,fl)
|
||||
{
|
||||
|
||||
pw=((CMainWindow*)parentWidget())->db;
|
||||
mainwnd=((CMainWindow*)parentWidget());
|
||||
mainwnd->CreateBanner(Banner,mainwnd->Icon_Key32x32,trUtf8("Eintrag bearbeiten"));
|
||||
ModFlag=false;
|
||||
}
|
||||
|
||||
CEditEntryDlg::~CEditEntryDlg()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void CEditEntryDlg::showEvent(QShowEvent *event){
|
||||
|
||||
if(event->spontaneous()==false){
|
||||
if(entry->pBinaryData==NULL){
|
||||
ButtonSaveAttachment->setDisabled(true);
|
||||
ButtonDeleteAttachment->setDisabled(true);
|
||||
}
|
||||
setCaption(entry->Title);
|
||||
setIcon(mainwnd->EntryIcons[entry->ImageID]);
|
||||
Edit_Title->setText(entry->Title);
|
||||
Edit_UserName->setText(entry->UserName);
|
||||
Edit_URL->setText(entry->URL);
|
||||
Edit_Password->setText(entry->Password.getString());
|
||||
Edit_Password_w->setText(entry->Password.getString());
|
||||
entry->Password.delRef();
|
||||
if(!mainwnd->config.ShowPasswords)ChangeEchoMode();
|
||||
OnPasswordwLostFocus();
|
||||
int bits=(entry->Password.length()*8);
|
||||
Label_Bits->setText(QString::number(bits)+" Bit");
|
||||
if(bits>128)bits=128;
|
||||
Progress_Quali->setProgress(bits,128);
|
||||
Progress_Quali->setPercentageVisible(false);
|
||||
Edit_Attachment->setText(entry->BinaryDesc);
|
||||
Edit_Comment->setText(entry->Additional);
|
||||
InitGroupComboBox();
|
||||
InitIconComboBox();
|
||||
Edit_Expire_Date->setText((entry->Expire.GetString(0)).mid(0,10));
|
||||
Edit_Expire_Time->setText((entry->Expire.GetString(0)).mid(11,8));
|
||||
if(entry->BinaryDataLength==0){
|
||||
Label_AttachmentSize->setText("");
|
||||
}
|
||||
else
|
||||
{
|
||||
QString unit;
|
||||
int faktor;
|
||||
int prec;
|
||||
if(entry->BinaryDataLength<1000){unit=" Byte";faktor=1;prec=0;}
|
||||
else {if(entry->BinaryDataLength<1000000){unit=" kB";faktor=1000;prec=1;}
|
||||
else{unit=" MB";faktor=1000000;prec=1;}
|
||||
}
|
||||
Label_AttachmentSize->setText(QString::number((float)entry->BinaryDataLength/(float)faktor,'f',prec)+unit);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void CEditEntryDlg::InitIconComboBox(){
|
||||
for(int i=0;i<52;i++){
|
||||
Combo_IconPicker->insertItem(((CMainWindow*)parentWidget())->EntryIcons[i],"",i);
|
||||
}
|
||||
Combo_IconPicker->setCurrentItem(entry->ImageID);
|
||||
}
|
||||
|
||||
|
||||
void CEditEntryDlg::InitGroupComboBox(){
|
||||
QString tmp;
|
||||
int i;
|
||||
for(i=0;i!=pw->Groups.size();i++){
|
||||
tmp="";
|
||||
for(int j=0;j<pw->Groups[i].Level;j++)tmp+=" ";
|
||||
Combo_Group->insertItem(((CMainWindow*)parentWidget())->EntryIcons[pw->Groups[i].ImageID],
|
||||
tmp+pw->Groups[i].Name,i);
|
||||
}
|
||||
Combo_Group->setCurrentItem(pw->getGroupIndex(entry->GroupID));
|
||||
}
|
||||
|
||||
void CEditEntryDlg::OnButtonOK()
|
||||
{
|
||||
|
||||
if(QString::compare(Edit_Password->text(),Edit_Password_w->text())!=0){
|
||||
QMessageBox::warning(NULL,"Stopp",QString::fromUtf8("Passwort und Passwortwiederholung stimmen\nnicht überein."),"OK");
|
||||
return;
|
||||
}
|
||||
QString str=Edit_Expire_Date->text();
|
||||
if(CPwmTime::IsValidDate(str)==false){
|
||||
QMessageBox::warning(NULL,"Stopp",QString::fromUtf8(str+" ist kein gültiges Datum."),"OK");
|
||||
return;
|
||||
}
|
||||
|
||||
str=Edit_Expire_Time->text();
|
||||
if(CPwmTime::IsValidTime(str)==false){
|
||||
QMessageBox::warning(NULL,"Stopp",QString::fromUtf8(str+" ist keine gültige Uhrzeit."),"OK");
|
||||
return;
|
||||
}
|
||||
|
||||
CPwmTime tmp_Expire;
|
||||
tmp_Expire.SetDate(Edit_Expire_Date->text());
|
||||
tmp_Expire.SetTime(Edit_Expire_Time->text());
|
||||
if(tmp_Expire!=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->text())
|
||||
ModFlag=true;
|
||||
QString& passw=entry->Password.getString();
|
||||
if(passw!=Edit_Password->text())
|
||||
ModFlag=true;
|
||||
entry->Password.delRef();
|
||||
|
||||
entry->Expire.SetDate(Edit_Expire_Date->text());
|
||||
entry->Expire.SetTime(Edit_Expire_Time->text());
|
||||
entry->LastAccess.SetToNow();
|
||||
if(ModFlag)entry->LastMod.SetToNow();
|
||||
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->text();
|
||||
if(Combo_Group->currentItem()!=pw->getGroupIndex(entry->GroupID)){
|
||||
pw->moveEntry(entry,&pw->Groups[Combo_Group->currentItem()]);
|
||||
}
|
||||
entry->ImageID=Combo_IconPicker->currentItem();
|
||||
done(1);
|
||||
}
|
||||
|
||||
void CEditEntryDlg::OnButtonCancel()
|
||||
{
|
||||
entry->LastAccess.SetToNow();
|
||||
done(0);
|
||||
}
|
||||
|
||||
void CEditEntryDlg::ChangeEchoMode()
|
||||
{
|
||||
if(Edit_Password->echoMode()==QLineEdit::Normal){
|
||||
Edit_Password->setEchoMode(QLineEdit::Password);
|
||||
Edit_Password_w->setEchoMode(QLineEdit::Password);
|
||||
}
|
||||
else
|
||||
{
|
||||
Edit_Password->setEchoMode(QLineEdit::Normal);
|
||||
Edit_Password_w->setEchoMode(QLineEdit::Normal);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void CEditEntryDlg::OnPasswordTextChanged(const QString& txt)
|
||||
{
|
||||
Edit_Password_w->setText("");
|
||||
int bits=(Edit_Password->text().length()*8);
|
||||
Label_Bits->setText(QString::number(bits)+" Bit");
|
||||
if(bits>128)bits=128;
|
||||
Progress_Quali->setProgress(bits,128);
|
||||
}
|
||||
|
||||
void CEditEntryDlg::OnPasswordwTextChanged(const QString& w)
|
||||
{
|
||||
|
||||
if(QString::compare(Edit_Password_w->text(),Edit_Password->text().mid(0,(Edit_Password_w->text().length())))!=0){
|
||||
Edit_Password_w->setPaletteBackgroundColor(QColor(255,125,125));
|
||||
}else
|
||||
{
|
||||
Edit_Password_w->setPaletteBackgroundColor(QColor(255,255,255)); ///@FIXME Standart-Hintergrundfarbe nicht weiß
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void CEditEntryDlg::OnPasswordwLostFocus()
|
||||
{
|
||||
if(QString::compare(Edit_Password_w->text(),Edit_Password->text())!=0){
|
||||
Edit_Password_w->setPaletteBackgroundColor(QColor(255,125,125));
|
||||
}
|
||||
else
|
||||
{
|
||||
Edit_Password_w->setPaletteBackgroundColor(QColor(255,255,255)); ///@FIXME Standart-Hintergrundfarbe nicht weiß
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void CEditEntryDlg::OnExpDateLostFocus()
|
||||
{
|
||||
QString str=Edit_Expire_Date->text();
|
||||
if(CPwmTime::IsValidDate(str)==false){
|
||||
Edit_Expire_Date->setPaletteBackgroundColor(QColor(255,125,125));
|
||||
}
|
||||
else
|
||||
{
|
||||
Edit_Expire_Date->setPaletteBackgroundColor(QColor(255,255,255));///@FIXME Standart-Hintergrundfarbe nicht weiß
|
||||
}
|
||||
}
|
||||
|
||||
void CEditEntryDlg::OnExpTimeLostFocus()
|
||||
{
|
||||
QString str=Edit_Expire_Time->text();
|
||||
if(CPwmTime::IsValidTime(str)==false){
|
||||
Edit_Expire_Time->setPaletteBackgroundColor(QColor(255,125,125));
|
||||
}
|
||||
else
|
||||
{
|
||||
Edit_Expire_Time->setPaletteBackgroundColor(QColor(255,255,255));///@FIXME Standart-Hintergrundfarbe nicht weiß
|
||||
}
|
||||
}
|
||||
|
||||
void CEditEntryDlg::OnNewAttachment()
|
||||
{
|
||||
QString filename=QFileDialog::getOpenFileName(QDir::homeDirPath(),"",this,QString::fromUtf8("Anhang hinzufügen..."));
|
||||
if(filename=="")return;
|
||||
QFile file(filename);
|
||||
if(file.open(IO_ReadOnly)==false){
|
||||
file.close();
|
||||
QMessageBox::warning(NULL,trUtf8("Fehler"),trUtf8("Datei konnte nicht geöffnet werden."),"OK");
|
||||
return;
|
||||
}
|
||||
ModFlag=true;
|
||||
if(entry->pBinaryData)delete [] entry->pBinaryData;
|
||||
entry->pBinaryData = new UINT8 [file.size()];
|
||||
|
||||
if(entry->pBinaryData==NULL){
|
||||
file.close();
|
||||
QMessageBox::critical(NULL,"Fehler",QString::fromUtf8("Es ist nicht genügend Arbeitsspeicher für diesen Vorgang vorhanden."),"OK");
|
||||
return;
|
||||
}
|
||||
entry->BinaryDataLength=file.size();
|
||||
file.readBlock((char*)entry->pBinaryData,file.size());
|
||||
file.close();
|
||||
QFileInfo info(filename);
|
||||
entry->BinaryDesc=info.fileName();
|
||||
file.close();
|
||||
Edit_Attachment->setText(entry->BinaryDesc);
|
||||
QString unit;
|
||||
int faktor;
|
||||
int prec;
|
||||
if(entry->BinaryDataLength<1000){unit=" Byte";faktor=1;prec=0;}
|
||||
else {if(entry->BinaryDataLength<1000000){unit=" kB";faktor=1000;prec=1;}
|
||||
else{unit=" MB";faktor=1000000;prec=1;}
|
||||
}
|
||||
Label_AttachmentSize->setText(QString::number((float)entry->BinaryDataLength/(float)faktor,'f',prec)+unit);
|
||||
ButtonOpenAttachment->setEnabled(true);
|
||||
ButtonSaveAttachment->setEnabled(true);
|
||||
ButtonDeleteAttachment->setEnabled(true);
|
||||
}
|
||||
|
||||
void CEditEntryDlg::OnSaveAttachment()
|
||||
{
|
||||
QString filename=QFileDialog::getSaveFileName(QDir::homeDirPath(),"",this,trUtf8("Anhang speichern..."));
|
||||
if(filename=="")return;
|
||||
QFile file(filename);
|
||||
if(file.exists()){
|
||||
int r=QMessageBox::warning(this,QString::fromUtf8("Vorhandene Datei überschreiben?"),QString::fromUtf8("Unter dem gewählten Dateinamen existiert bereits eine Datei.\nSoll sie überschrieben werden?"),"Ja","Nein",NULL,1,1);
|
||||
if(r==1)return;
|
||||
if(file.remove()==false){
|
||||
QMessageBox::critical(NULL,"Fehler",QString::fromUtf8("Datei konnte nicht überschrieben werden."),"OK");
|
||||
return;}
|
||||
}
|
||||
if(file.open(IO_WriteOnly)==false){
|
||||
QMessageBox::critical(NULL,"Fehler",QString::fromUtf8("Datei konnte nicht erstellt werden."),"OK");
|
||||
return;
|
||||
}
|
||||
|
||||
int r=file.writeBlock((char*)entry->pBinaryData,entry->BinaryDataLength);
|
||||
if(r==-1){
|
||||
file.close();
|
||||
QMessageBox::critical(NULL,"Fehler",QString::fromUtf8("Beim schreiben in der Datei ist ein Fehler aufgetreten."),"OK");
|
||||
return;
|
||||
}
|
||||
if(r!=entry->BinaryDataLength){
|
||||
file.close();
|
||||
QMessageBox::critical(NULL,"Fehler",QString::fromUtf8("Die Datei konnte nicht vollständig geschrieben werden."),"OK");
|
||||
return;
|
||||
}
|
||||
file.close();
|
||||
}
|
||||
|
||||
void CEditEntryDlg::OnDeleteAttachment()
|
||||
{
|
||||
int r=QMessageBox::warning(this,trUtf8("Anhang löschen?"),trUtf8("Sie sind dabei den Anhang zu löschen.\nSind Sie sicher, dass Sie dies tun wollen?"),trUtf8("Ja"),trUtf8("Nein"),NULL,1,1);
|
||||
if(r==0){
|
||||
ModFlag=true;
|
||||
delete[]entry->pBinaryData;
|
||||
entry->pBinaryData=NULL;
|
||||
entry->BinaryDataLength=0;
|
||||
entry->BinaryDesc="";
|
||||
Edit_Attachment->setText("");
|
||||
Label_AttachmentSize->setText("");
|
||||
ButtonOpenAttachment->setEnabled(true);
|
||||
ButtonSaveAttachment->setDisabled(true);
|
||||
ButtonDeleteAttachment->setDisabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
void CEditEntryDlg::OnButtonGenPw()
|
||||
{
|
||||
CGenPwDialog* pDlg=new CGenPwDialog(this,0,true);
|
||||
pDlg->show();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*$SPECIALIZATION$*/
|
||||
|
||||
|
||||
//#include "editentrydlg.moc"
|
||||
|
||||
74
src/dialogs/EditEntryDlg.h
Executable file
74
src/dialogs/EditEntryDlg.h
Executable file
@@ -0,0 +1,74 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2005 by Tarek Saidi *
|
||||
* tarek@linux *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
#include "mainwindow.h"
|
||||
#ifndef EDITENTRYDLG_H
|
||||
#define EDITENTRYDLG_H
|
||||
#include "ui_EditEntryDlg.h"
|
||||
|
||||
class CEditEntryDlg : public EditEntryDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CEditEntryDlg(QWidget* parent = 0, const char* name = 0, bool modal = FALSE, 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:
|
||||
CMainWindow* mainwnd;
|
||||
CEntry* entry;
|
||||
PwDatabase* pw;
|
||||
QPixmap* banner_pixmap;
|
||||
bool ModFlag;
|
||||
|
||||
|
||||
void CreateBanner();
|
||||
void InitGroupComboBox();
|
||||
void InitIconComboBox();
|
||||
|
||||
|
||||
public slots:
|
||||
virtual void OnExpTimeLostFocus();
|
||||
virtual void OnExpDateLostFocus();
|
||||
virtual void OnPasswordwLostFocus();
|
||||
virtual void OnPasswordwTextChanged(const QString&);
|
||||
virtual void OnPasswordTextChanged(const QString&);
|
||||
virtual void ChangeEchoMode();
|
||||
virtual void OnButtonCancel();
|
||||
virtual void OnNewAttachment();
|
||||
virtual void OnDeleteAttachment();
|
||||
virtual void OnSaveAttachment();
|
||||
virtual void OnButtonGenPw();
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
68
src/dialogs/EditGroupDlg.cpp
Executable file
68
src/dialogs/EditGroupDlg.cpp
Executable file
@@ -0,0 +1,68 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2005 by Tarek Saidi *
|
||||
* tarek@linux *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#include "mainwindow.h"
|
||||
|
||||
#include <qcombobox.h>
|
||||
#include <qlineedit.h>
|
||||
#include "EditGroupDlg.h"
|
||||
|
||||
|
||||
CEditGroupDialog::CEditGroupDialog(QWidget* parent, const char* name, bool modal, WFlags fl)
|
||||
: EditGroupDialog(parent,name, modal,fl)
|
||||
{
|
||||
IconID=0;
|
||||
}
|
||||
|
||||
CEditGroupDialog::~CEditGroupDialog()
|
||||
{
|
||||
}
|
||||
|
||||
void CEditGroupDialog::showEvent(QShowEvent *event){
|
||||
if(event->spontaneous()==false){
|
||||
EditTitle->setText(GroupName);
|
||||
for(int i=0;i<52;i++){
|
||||
ComboIconPicker->insertItem(((CMainWindow*)parentWidget())->EntryIcons[i],"",i);
|
||||
}
|
||||
ComboIconPicker->setCurrentItem(IconID);
|
||||
}}
|
||||
|
||||
void CEditGroupDialog::OnOK()
|
||||
{
|
||||
GroupName=EditTitle->text();
|
||||
IconID=ComboIconPicker->currentItem();
|
||||
OK=true;
|
||||
close();
|
||||
}
|
||||
|
||||
void CEditGroupDialog::OnCancel()
|
||||
{
|
||||
OK=false;
|
||||
close();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*$SPECIALIZATION$*/
|
||||
|
||||
|
||||
//#include "editgroupdlg.moc"
|
||||
|
||||
55
src/dialogs/EditGroupDlg.h
Executable file
55
src/dialogs/EditGroupDlg.h
Executable file
@@ -0,0 +1,55 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2005 by Tarek Saidi *
|
||||
* tarek@linux *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef EDITGROUPDLG_H
|
||||
#define EDITGROUPDLG_H
|
||||
|
||||
#include "ui_EditGroupDlg.h"
|
||||
#include <qstring.h>
|
||||
|
||||
class CEditGroupDialog : public EditGroupDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CEditGroupDialog(QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
|
||||
~CEditGroupDialog();
|
||||
virtual void showEvent(QShowEvent *event);
|
||||
/*$PUBLIC_FUNCTIONS$*/
|
||||
|
||||
protected:
|
||||
/*$PROTECTED_FUNCTIONS$*/
|
||||
|
||||
protected slots:
|
||||
/*$PROTECTED_SLOTS$*/
|
||||
|
||||
public:
|
||||
int IconID;
|
||||
QString GroupName;
|
||||
bool OK;
|
||||
|
||||
|
||||
public slots:
|
||||
virtual void OnOK();
|
||||
virtual void OnCancel();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
149
src/dialogs/LanguageDlg.cpp
Executable file
149
src/dialogs/LanguageDlg.cpp
Executable file
@@ -0,0 +1,149 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2005 by Tarek Saidi *
|
||||
* mail@tarek-saidi.de *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
#include "mainwindow.h"
|
||||
#include "LanguageDlg.h"
|
||||
#include <qtranslator.h>
|
||||
#include <qdir.h>
|
||||
#include <qstringlist.h>
|
||||
#include <qlistview.h>
|
||||
#include <qmessagebox.h>
|
||||
#include <iostream.h>
|
||||
|
||||
const char* infostrings[]={
|
||||
QT_TRANSLATE_NOOP("_INFO","$TRANSL_AUTHOR"),
|
||||
QT_TRANSLATE_NOOP("_INFO","$TRANSL_AUTHOR_CONTACT"),
|
||||
QT_TRANSLATE_NOOP("_INFO","$TRANSL_LANGUAGE"),
|
||||
QT_TRANSLATE_NOOP("_INFO","$TRANSL_VERSION")};
|
||||
const char* msg[]={QT_TRANSLATE_NOOP("_MSG","Die Änderung der Sprache wird erst nach einem Neustart von Keepass wirksam."),
|
||||
QT_TRANSLATE_NOOP("_MSG","OK"),
|
||||
QT_TRANSLATE_NOOP("_MSG","Hinweis")};
|
||||
|
||||
CLanguageDlg::CLanguageDlg(QWidget* parent, const char* name, WFlags fl)
|
||||
: LanguageDlg(parent,name,fl)
|
||||
{
|
||||
parentwnd=((CMainWindow*)parentWidget());
|
||||
parentwnd->CreateBanner(Banner,parentwnd->Icon_I18n32x32,trUtf8("Spracheinstellungen"));
|
||||
|
||||
QListViewItem* item;
|
||||
QString& config_lang=parentwnd->config.Language;
|
||||
QStringList files;
|
||||
|
||||
QString langdir=parentwnd->appdir+"/../share/keepass/i18n/";
|
||||
QDir dir(langdir);
|
||||
if(dir.exists()){
|
||||
files=dir.entryList("*.qm",QDir::Files);
|
||||
}
|
||||
|
||||
List->insertItem(item=new QListViewItem(List,"","Deutsch","-","-"));
|
||||
if(config_lang=="_DEUTSCH_")item->setPixmap(0,*parentwnd->Icon_Ok16x16);
|
||||
pItems.push_back(item);
|
||||
filenames.push_back("_DEUTSCH_");
|
||||
|
||||
|
||||
for(int i=0;i<files.count();i++){
|
||||
QTranslator translator;
|
||||
if(!translator.load(langdir+files[i])){
|
||||
QMessageBox::warning(this,tr("Warnung"),tr("Die Datei '%1' konnte nicht geladen werden.").arg(files[i]),tr("OK"),0,0,2,1);
|
||||
continue;}
|
||||
List->insertItem(item=new QListViewItem(List,"",translator.findMessage("_INFO","$TRANSL_LANGUAGE").translation()
|
||||
,translator.findMessage("_INFO","$TRANSL_VERSION").translation()
|
||||
,translator.findMessage("_INFO","$TRANSL_AUTHOR").translation()));
|
||||
if(config_lang==files[i])item->setPixmap(0,*parentwnd->Icon_Ok16x16);
|
||||
pItems.push_back(item);
|
||||
filenames.push_back(files[i]);
|
||||
}
|
||||
}
|
||||
|
||||
CLanguageDlg::~CLanguageDlg()
|
||||
{
|
||||
}
|
||||
|
||||
void CLanguageDlg::showEvent(QShowEvent *event){
|
||||
if(event->spontaneous()==false){
|
||||
List->setColumnWidth(0,20);
|
||||
int width=(List->width()-4-20)/3;
|
||||
List->setColumnWidth(1,width);
|
||||
List->setColumnWidth(2,width);
|
||||
List->setColumnWidth(3,width);
|
||||
}
|
||||
}
|
||||
|
||||
void CLanguageDlg::OnItemRightClick(QListViewItem* item)
|
||||
{
|
||||
//CTX-MENU
|
||||
|
||||
}
|
||||
|
||||
void CLanguageDlg::OnItemDoubleClicked(QListViewItem* item) // == Slot für Button "wählen"
|
||||
{
|
||||
int i;
|
||||
QString langdir=parentwnd->appdir+"/../share/keepass/i18n/";
|
||||
|
||||
for(i=0;i<pItems.size();i++){
|
||||
if(item==pItems[i])break;
|
||||
if(i==pItems.size()-1){
|
||||
cout << QString("unexpected error in %1, line %2").arg(__FILE__).arg(__LINE__) << endl;
|
||||
exit(-1);}
|
||||
}
|
||||
if(filenames[i]!="_DEUTSCH_"){
|
||||
QTranslator translator;
|
||||
if(!translator.load(langdir+filenames[i])){
|
||||
QMessageBox::warning(this,tr("Warnung"),tr("Die Datei '%1' konnte nicht geladen werden.").arg(filenames[i]),tr("OK"),0,0,2,1);
|
||||
return;
|
||||
}
|
||||
QMessageBox::information(this,translator.findMessage("_MSG",msg[2]).translation()
|
||||
,translator.findMessage("_MSG",msg[0]).translation()
|
||||
,translator.findMessage("_MSG",msg[1]).translation()
|
||||
,0,0,2,1);
|
||||
}
|
||||
else QMessageBox::information(this,QString::fromUtf8(msg[2]),QString::fromUtf8(msg[0]),QString::fromUtf8(msg[1]),0,0,2,1);
|
||||
parentwnd->config.Language=filenames[i];
|
||||
|
||||
for(int j=0;j<pItems.size();j++){
|
||||
if(j==i)pItems[j]->setPixmap(0,*parentwnd->Icon_Ok16x16);
|
||||
else pItems[j]->setPixmap(0,0);}
|
||||
|
||||
List->setColumnWidth(0,20);
|
||||
int width=(List->width()-4-20)/3;
|
||||
List->setColumnWidth(1,width);
|
||||
List->setColumnWidth(2,width);
|
||||
List->setColumnWidth(3,width);
|
||||
|
||||
}
|
||||
|
||||
void CLanguageDlg::OnApplyButtonClicked()
|
||||
{
|
||||
QListViewItem* item=List->selectedItem();
|
||||
if(item)OnItemDoubleClicked(item);
|
||||
else QMessageBox::information(this,tr("Hinweis"),trUtf8("Es ist keine Übersetzung aufsgewählt."),tr("OK"),0,0,2,1);
|
||||
}
|
||||
|
||||
void CLanguageDlg::OnButtonCloseClicked()
|
||||
{
|
||||
done(0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*$SPECIALIZATION$*/
|
||||
|
||||
|
||||
59
src/dialogs/LanguageDlg.h
Executable file
59
src/dialogs/LanguageDlg.h
Executable file
@@ -0,0 +1,59 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2005 by Tarek Saidi *
|
||||
* mail@tarek-saidi.de *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
#include "mainwindow.h"
|
||||
#ifndef _LANGUAGEDLG_H_
|
||||
#define _LANGUAGEDLG_H_
|
||||
#include "ui_LanguageDlg.h"
|
||||
#include <qpixmap.h>
|
||||
|
||||
|
||||
|
||||
class CLanguageDlg : public LanguageDlg
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CLanguageDlg(QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
|
||||
~CLanguageDlg();
|
||||
CMainWindow* parentwnd;
|
||||
vector<QString> filenames;
|
||||
vector<QListViewItem*> pItems;
|
||||
/*$PUBLIC_FUNCTIONS$*/
|
||||
|
||||
public slots:
|
||||
/*$PUBLIC_SLOTS$*/
|
||||
|
||||
|
||||
protected:
|
||||
/*$PROTECTED_FUNCTIONS$*/
|
||||
|
||||
|
||||
protected slots:
|
||||
/*$PROTECTED_SLOTS$*/
|
||||
virtual void showEvent(QShowEvent *e);
|
||||
virtual void OnItemDoubleClicked(QListViewItem* item);
|
||||
virtual void OnItemRightClick(QListViewItem* item);
|
||||
virtual void OnButtonCloseClicked();
|
||||
virtual void OnApplyButtonClicked();
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
206
src/dialogs/PasswordDlg.cpp
Executable file
206
src/dialogs/PasswordDlg.cpp
Executable file
@@ -0,0 +1,206 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2005 by Tarek Saidi *
|
||||
* tarek@linux *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#include "mainwindow.h"
|
||||
|
||||
#include "PasswordDlg.h"
|
||||
#include <qdir.h>
|
||||
#include <qstringlist.h>
|
||||
#include <qcheckbox.h>
|
||||
#include <qvaluelist.h>
|
||||
#include <qlineedit.h>
|
||||
#include <qcombobox.h>
|
||||
#include <qpushbutton.h>
|
||||
#include <qfiledialog.h>
|
||||
#include <qmessagebox.h>
|
||||
|
||||
|
||||
|
||||
CPasswordDialog::CPasswordDialog(QWidget* parent, const char* name, bool modal, WFlags fl)
|
||||
: PasswordDlg(parent,name, modal,fl)
|
||||
{
|
||||
parentwnd=((CMainWindow*)parentWidget());
|
||||
parentwnd->CreateBanner(Banner,parentwnd->Icon_Key32x32,trUtf8("Datenbank öffnen"));
|
||||
Label_select=new LinkLabel((QWidget*)groupframe,"Select",trUtf8("Datei manuell wählen..."),410,100);
|
||||
connect(Label_select,SIGNAL(clicked()),this,SLOT(OnSelectClicked()));
|
||||
///@PlatformSpecific
|
||||
QDir media("/media");
|
||||
if(media.exists()){
|
||||
Paths=media.entryList("*",QDir::Dirs);
|
||||
Paths.erase(Paths.begin()); // delete "."
|
||||
Paths.erase(Paths.begin()); // delete ".."
|
||||
|
||||
for(int i=0;i<Paths.count();i++){
|
||||
Paths[i]="/media/"+Paths[i];
|
||||
}
|
||||
Paths.prepend(trUtf8("< keiner >"));
|
||||
}
|
||||
for(int i=0;i<Paths.count();i++){
|
||||
Combo_Dirs->insertItem(0,Paths[i]);
|
||||
IsFile.append(false);
|
||||
}
|
||||
|
||||
if(!parentwnd->config.ShowPasswords)ChangeEchoMode();
|
||||
|
||||
}
|
||||
|
||||
CPasswordDialog::~CPasswordDialog()
|
||||
{
|
||||
delete Label_select;
|
||||
}
|
||||
|
||||
void CPasswordDialog::OnComboSelectionChanged(int i)
|
||||
{
|
||||
if(i==0){
|
||||
keyfile="";
|
||||
Edit_Password->setEnabled(true);
|
||||
return;
|
||||
}
|
||||
QFile file;
|
||||
if(IsFile[i]==true)file.setName(Paths[i]);
|
||||
else file.setName(Paths[i]+"/pwsafe.key");
|
||||
|
||||
if(file.exists()){
|
||||
keyfile=file.name();
|
||||
if(!CheckBox_Both->isChecked()){
|
||||
Edit_Password->setText("");
|
||||
Edit_Password->setDisabled(true);}
|
||||
return;
|
||||
}
|
||||
QMessageBox::warning(this,"Datei nicht gefunden",QString::fromUtf8("Im gewählten Verzeichnis konnte keine Schlüsseldatei gefunden werden.\nStellen Sie sicher, dass der Schlüssel-Datenträger ordnungsgemäß eingehängt (mounted) ist.\nSollte die Schlüsseldatei nicht den Dateinamen 'pwsafe.key' haben, nutzen Sie bitte die manuelle Dateiauswahl."),"OK","","",0,0);
|
||||
Edit_Password->setEnabled(true);
|
||||
Combo_Dirs->setCurrentItem(0);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void CPasswordDialog::OnButtonBrowse()
|
||||
{
|
||||
///@PlatformSpecific
|
||||
QString dir=QFileDialog::getExistingDirectory(QDir::homeDirPath(),NULL,QString::fromUtf8("Verzeichnis wählen"));
|
||||
if(dir=="")return;
|
||||
|
||||
QFile file(dir+"/pwsafe.key");
|
||||
if(file.exists()){
|
||||
keyfile=dir+"/pwsafe.key";
|
||||
Combo_Dirs->insertItem(dir);
|
||||
Combo_Dirs->setCurrentItem(Combo_Dirs->count()-1);
|
||||
if(!CheckBox_Both->isChecked()){
|
||||
Edit_Password->setDisabled(true);
|
||||
Edit_Password->setText("");
|
||||
password="";
|
||||
}
|
||||
Paths.append(dir);
|
||||
IsFile.append(false);
|
||||
return;}
|
||||
QMessageBox::warning(this,"Datei nicht gefunden",QString::fromUtf8("Im gewählten Verzeichnis konnte keine Schlüsseldatei gefunden werden.\nStellen Sie sicher, dass der Schlüssel-Datenträger ordnungsgemäß eingehängt (mounted) ist.\nSollte die Schlüsseldatei nicht den Dateinamen 'pwsafe.key' haben, nutzen Sie bitte die manuelle Dateiauswahl."),"OK","","",0,0);
|
||||
}
|
||||
|
||||
void CPasswordDialog::OnSelectClicked()
|
||||
{
|
||||
if(Button_Browse->isEnabled()){
|
||||
keyfile=QFileDialog::getOpenFileName(QDir::homeDirPath(),"",this,QString::fromUtf8("Schlüsseldatei öffnen"));
|
||||
if(keyfile=="")return;
|
||||
Combo_Dirs->insertItem(keyfile);
|
||||
Combo_Dirs->setCurrentItem(Combo_Dirs->count()-1);
|
||||
if(!CheckBox_Both->isChecked()){
|
||||
Edit_Password->setDisabled(true);
|
||||
Edit_Password->setText("");
|
||||
password="";
|
||||
}
|
||||
Paths.append(keyfile);
|
||||
IsFile.append(true);
|
||||
}
|
||||
}
|
||||
|
||||
void CPasswordDialog::OnCancel()
|
||||
{
|
||||
canceled=true;
|
||||
close();
|
||||
}
|
||||
|
||||
void CPasswordDialog::OnOK()
|
||||
{
|
||||
canceled=false;
|
||||
|
||||
if(CheckBox_Both->isChecked()){
|
||||
if(password==""){QMessageBox::warning(this,trUtf8("Fehler"),trUtf8("Bitte geben Sie ein Passwort ein.")
|
||||
,trUtf8("OK"),"","",0,0);
|
||||
return;}
|
||||
if(keyfile==""){QMessageBox::warning(this,trUtf8("Fehler"),trUtf8("Bitte wählen Sie eine Schlüsseldatei.")
|
||||
,trUtf8("OK"),"","",0,0);
|
||||
return;}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(password=="" && keyfile==""){QMessageBox::warning(this,trUtf8("Fehler"),trUtf8("Geben Sie bitte ein Passwort ein oder wählen Sie eine Schlüsseldatei.")
|
||||
,trUtf8("OK"),"","",0,0);
|
||||
return;}
|
||||
}
|
||||
close();
|
||||
}
|
||||
|
||||
void CPasswordDialog::OnPasswordChanged(const QString &txt)
|
||||
{
|
||||
password=Edit_Password->text();
|
||||
if(txt!="" && !(CheckBox_Both->isChecked())){
|
||||
Combo_Dirs->setDisabled(true);
|
||||
Button_Browse->setDisabled(true);}
|
||||
else{
|
||||
Combo_Dirs->setEnabled(true);
|
||||
Button_Browse->setEnabled(true);}
|
||||
|
||||
}
|
||||
|
||||
void CPasswordDialog::OnCheckBox_BothChanged(int state)
|
||||
{
|
||||
if(state==QButton::On){
|
||||
Combo_Dirs->setEnabled(true);
|
||||
Button_Browse->setEnabled(true);
|
||||
Edit_Password->setEnabled(true);}
|
||||
else{
|
||||
Edit_Password->setText("");
|
||||
}
|
||||
}
|
||||
|
||||
void CPasswordDialog::ChangeEchoMode()
|
||||
{
|
||||
|
||||
if(Edit_Password->echoMode()==QLineEdit::Normal){
|
||||
Edit_Password->setEchoMode(QLineEdit::Password);
|
||||
}
|
||||
else
|
||||
{
|
||||
Edit_Password->setEchoMode(QLineEdit::Normal);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*$SPECIALIZATION$*/
|
||||
|
||||
|
||||
//#include "passworddialog.moc"
|
||||
|
||||
71
src/dialogs/PasswordDlg.h
Executable file
71
src/dialogs/PasswordDlg.h
Executable file
@@ -0,0 +1,71 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2005 by Tarek Saidi *
|
||||
* tarek@linux *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
#include "mainwindow.h"
|
||||
#ifndef PASSWORDDIALOG_H
|
||||
#define PASSWORDDIALOG_H
|
||||
#include "lib/UrlLabel.h"
|
||||
#include "ui_PasswordDlg.h"
|
||||
|
||||
class CPasswordDialog : public PasswordDlg
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
||||
CMainWindow* parentwnd;
|
||||
int NumComboEntries;
|
||||
QStringList Paths;
|
||||
QValueList<bool> IsFile;
|
||||
LinkLabel* Label_select;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
QString keyfile;
|
||||
QString password;
|
||||
bool canceled;
|
||||
|
||||
|
||||
public:
|
||||
CPasswordDialog(QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
|
||||
~CPasswordDialog();
|
||||
/*$PUBLIC_FUNCTIONS$*/
|
||||
|
||||
public slots:
|
||||
/*$PUBLIC_SLOTS$*/
|
||||
|
||||
virtual void OnOK();
|
||||
virtual void OnCancel();
|
||||
virtual void OnSelectClicked();
|
||||
virtual void OnButtonBrowse();
|
||||
protected:
|
||||
/*$PROTECTED_FUNCTIONS$*/
|
||||
|
||||
protected slots:
|
||||
/*$PROTECTED_SLOTS$*/
|
||||
|
||||
public slots:
|
||||
virtual void OnComboSelectionChanged(int);
|
||||
virtual void OnPasswordChanged(const QString &txt);
|
||||
virtual void OnCheckBox_BothChanged(int state);
|
||||
virtual void ChangeEchoMode();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
236
src/dialogs/PasswordGenDlg.cpp
Executable file
236
src/dialogs/PasswordGenDlg.cpp
Executable file
@@ -0,0 +1,236 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2005 by Tarek Saidi *
|
||||
* tarek@linux *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#include <fstream>
|
||||
#include <qspinbox.h>
|
||||
#include <qmessagebox.h>
|
||||
#include "PasswordGenDlg.h"
|
||||
#include <qradiobutton.h>
|
||||
#include <qlineedit.h>
|
||||
#include <qcheckbox.h>
|
||||
#include <qprogressbar.h>
|
||||
|
||||
CGenPwDialog::CGenPwDialog(QWidget* parent, const char* name, bool modal, WFlags fl)
|
||||
: GenPwDlg(parent,name, modal,fl)
|
||||
{
|
||||
mainwnd=(CMainWindow*)(((CEditEntryDlg*)parentWidget())->parentWidget());
|
||||
mainwnd->CreateBanner(Banner,mainwnd->Icon_Key32x32,QString::fromUtf8("Passwort generieren"));
|
||||
|
||||
|
||||
|
||||
Radio_1->setChecked(true);
|
||||
|
||||
Edit_chars->setDisabled(true);
|
||||
}
|
||||
|
||||
CGenPwDialog::~CGenPwDialog()
|
||||
{
|
||||
}
|
||||
|
||||
void CGenPwDialog::OnRadio1StateChanged(int state)
|
||||
{
|
||||
switch (state){
|
||||
case QButton::On:
|
||||
Radio_2->setChecked(false);
|
||||
checkBox1->setEnabled(true);
|
||||
checkBox2->setEnabled(true);
|
||||
checkBox3->setEnabled(true);
|
||||
checkBox4->setEnabled(true);
|
||||
checkBox5->setEnabled(true);
|
||||
checkBox6->setEnabled(true);
|
||||
checkBox7->setEnabled(true);
|
||||
checkBox8->setEnabled(true);
|
||||
break;
|
||||
case QButton::Off:
|
||||
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);
|
||||
|
||||
break;
|
||||
case QButton::NoChange:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CGenPwDialog::OnRadio2StateChanged(int state)
|
||||
{
|
||||
switch (state){
|
||||
case QButton::On:
|
||||
Radio_1->setChecked(false);
|
||||
Edit_chars->setEnabled(true);
|
||||
break;
|
||||
case QButton::Off:
|
||||
if(Radio_1->isChecked()==false)Radio_1->setChecked(true);
|
||||
Edit_chars->setDisabled(true);
|
||||
break;
|
||||
case QButton::NoChange:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CGenPwDialog::OnGeneratePw()
|
||||
{
|
||||
/*
|
||||
Großbuchstaben 65...90
|
||||
Kleinbuchstaben 97...122
|
||||
Zahlen 48...57
|
||||
Sonderzeichen 33...47;58...64;91...96;123...126
|
||||
Minus 45
|
||||
Unterstrich 95
|
||||
ANSI >127
|
||||
*/
|
||||
|
||||
int num=0;
|
||||
char assoctable[255];
|
||||
|
||||
if(Radio_1->isChecked()){
|
||||
if(checkBox1->isChecked()){
|
||||
num+=AddToAssoctable(assoctable,65,90,num);
|
||||
}
|
||||
|
||||
if(checkBox2->isChecked()){
|
||||
num+=AddToAssoctable(assoctable,97,122,num);
|
||||
}
|
||||
|
||||
if(checkBox3->isChecked()){
|
||||
num+=AddToAssoctable(assoctable,48,57,num);
|
||||
}
|
||||
|
||||
if(checkBox4->isChecked()){
|
||||
num+=AddToAssoctable(assoctable,33,47,num);
|
||||
num+=AddToAssoctable(assoctable,58,64,num);
|
||||
num+=AddToAssoctable(assoctable,91,96,num);
|
||||
num+=AddToAssoctable(assoctable,123,126,num);
|
||||
}
|
||||
|
||||
if(checkBox5->isChecked()){
|
||||
num+=AddToAssoctable(assoctable,32,32,num);
|
||||
}
|
||||
|
||||
|
||||
if(checkBox6->isChecked() && !checkBox4->isChecked()){
|
||||
num+=AddToAssoctable(assoctable,45,45,num);
|
||||
}
|
||||
|
||||
if(checkBox7->isChecked() && !checkBox4->isChecked()){
|
||||
num+=AddToAssoctable(assoctable,95,95,num);
|
||||
}
|
||||
|
||||
if(checkBox8->isChecked()){
|
||||
num+=AddToAssoctable(assoctable,128,255,num);
|
||||
}
|
||||
}else
|
||||
{
|
||||
QString str=Edit_chars->text();
|
||||
int i=0;
|
||||
while(str.length()>0){
|
||||
assoctable[i]=(char)((QChar)str[0]);
|
||||
str.remove(str[0]);
|
||||
i++;
|
||||
num++;
|
||||
}
|
||||
}
|
||||
if(num==0){
|
||||
if(Radio_2->isChecked())QMessageBox::information(this,"Hinweis",QString::fromUtf8("Es wird mindestens ein Zeichen benötigt"),"OK");
|
||||
else QMessageBox::information(this,"Hinweis",QString::fromUtf8("Es muss mindestens ein Gruppe von Zeichen gewählt werden"),"OK");
|
||||
return;
|
||||
}
|
||||
int length=Spin_Num->value();
|
||||
char* buffer=new char[length+1];
|
||||
buffer[length]=0;
|
||||
FILE *dev_random;
|
||||
if(Check_strongrandom->isChecked()){
|
||||
dev_random = fopen("/dev/random","r");}
|
||||
else
|
||||
{dev_random = fopen("/dev/urandom","r");}
|
||||
|
||||
if (dev_random==NULL){
|
||||
QMessageBox::critical(this,"Fehler",QString::fromUtf8("'/dev/random' bzw. '/dev/urandom' konnte nicht zum lesen geöffnet werden."),"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(QString::number(bits)+" Bit");
|
||||
if(bits>128)bits=128;
|
||||
Progress_Quali->setProgress(bits,128);
|
||||
Progress_Quali->setPercentageVisible(false);
|
||||
}
|
||||
|
||||
int CGenPwDialog::AddToAssoctable(char* table,int start,int end,int pos){
|
||||
for(int i=start;i<=end;i++){
|
||||
table[pos]=i;
|
||||
pos++;
|
||||
}
|
||||
return (end-start)+1;
|
||||
}
|
||||
|
||||
|
||||
bool CGenPwDialog::trim(unsigned char &x, int r){
|
||||
if(x<r)return true;
|
||||
if(256%r!=0)return false;
|
||||
x=x-(x/r)*r;
|
||||
return true;
|
||||
}
|
||||
|
||||
void CGenPwDialog::OnAccept()
|
||||
{
|
||||
((CEditEntryDlg*)parentWidget())->Edit_Password->setText(Edit_dest->text());
|
||||
((CEditEntryDlg*)parentWidget())->Edit_Password_w->setText(Edit_dest->text());
|
||||
((CEditEntryDlg*)parentWidget())->ModFlag=true;
|
||||
close();
|
||||
}
|
||||
|
||||
void CGenPwDialog::OnCancel()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*$SPECIALIZATION$*/
|
||||
|
||||
|
||||
//#include "genpwdialog.moc"
|
||||
|
||||
60
src/dialogs/PasswordGenDlg.h
Executable file
60
src/dialogs/PasswordGenDlg.h
Executable file
@@ -0,0 +1,60 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2005 by Tarek Saidi *
|
||||
* tarek@linux *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
#include "mainwindow.h"
|
||||
#ifndef GENPWDIALOG_H
|
||||
#define GENPWDIALOG_H
|
||||
#include "ui_PasswordGenDlg.h"
|
||||
#include "EditEntryDlg.h"
|
||||
|
||||
|
||||
|
||||
class CGenPwDialog : public GenPwDlg
|
||||
{
|
||||
Q_OBJECT
|
||||
private:
|
||||
int AddToAssoctable(char* table,int start,int end,int pos);
|
||||
bool trim(unsigned char &value,int range);
|
||||
public:
|
||||
CGenPwDialog(QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
|
||||
~CGenPwDialog();
|
||||
/*$PUBLIC_FUNCTIONS$*/
|
||||
|
||||
public slots:
|
||||
/*$PUBLIC_SLOTS$*/
|
||||
|
||||
protected:
|
||||
/*$PROTECTED_FUNCTIONS$*/
|
||||
|
||||
protected slots:
|
||||
/*$PROTECTED_SLOTS$*/
|
||||
public:
|
||||
CMainWindow* mainwnd;
|
||||
public slots:
|
||||
virtual void OnGeneratePw();
|
||||
public slots:
|
||||
virtual void OnRadio2StateChanged(int);
|
||||
public slots:
|
||||
virtual void OnRadio1StateChanged(int);
|
||||
virtual void OnCancel();
|
||||
virtual void OnAccept();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
97
src/dialogs/SearchDlg.cpp
Executable file
97
src/dialogs/SearchDlg.cpp
Executable file
@@ -0,0 +1,97 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2005 by Tarek Saidi *
|
||||
* mail@tarek-saidi.de *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#include "PwManager.h"
|
||||
#include "SearchDlg.h"
|
||||
#include <qlineedit.h>
|
||||
#include <qcheckbox.h>
|
||||
#include <qregexp.h>
|
||||
#include <qmessagebox.h>
|
||||
|
||||
CSearchDlg::CSearchDlg(CGroup* pGroup,QWidget* parent, const char* name, bool modal, WFlags fl)
|
||||
: Search_Dlg(parent,name, modal,fl)
|
||||
{
|
||||
parentwnd=(CMainWindow*)parent;
|
||||
parentwnd->CreateBanner(Banner,parentwnd->Icon_Search32x32,tr("Suchen"));
|
||||
group=pGroup;
|
||||
pw=parentwnd->db;
|
||||
|
||||
checkBox_Cs->setChecked(parentwnd->config.SearchOptions[0]);
|
||||
checkBox_regExp->setChecked(parentwnd->config.SearchOptions[1]);
|
||||
checkBox_Title->setChecked(parentwnd->config.SearchOptions[2]);
|
||||
checkBox_Username->setChecked(parentwnd->config.SearchOptions[3]);
|
||||
checkBox_Password->setChecked(parentwnd->config.SearchOptions[4]);
|
||||
checkBox_Comment->setChecked(parentwnd->config.SearchOptions[5]);
|
||||
checkBox_URL->setChecked(parentwnd->config.SearchOptions[6]);
|
||||
checkBox_Attachment->setChecked(parentwnd->config.SearchOptions[7]);
|
||||
}
|
||||
|
||||
CSearchDlg::~CSearchDlg()
|
||||
{
|
||||
parentwnd->config.SearchOptions[0]=checkBox_Cs->isChecked();
|
||||
parentwnd->config.SearchOptions[1]=checkBox_regExp->isChecked();
|
||||
parentwnd->config.SearchOptions[2]=checkBox_Title->isChecked();
|
||||
parentwnd->config.SearchOptions[3]=checkBox_Username->isChecked();
|
||||
parentwnd->config.SearchOptions[4]=checkBox_Password->isChecked();
|
||||
parentwnd->config.SearchOptions[5]=checkBox_Comment->isChecked();
|
||||
parentwnd->config.SearchOptions[6]=checkBox_URL->isChecked();
|
||||
parentwnd->config.SearchOptions[7]=checkBox_Attachment->isChecked();
|
||||
}
|
||||
|
||||
void CSearchDlg::OnButtonClose()
|
||||
{
|
||||
done(0);
|
||||
}
|
||||
|
||||
|
||||
void CSearchDlg::OnButtonSearch()
|
||||
{
|
||||
txt=Edit_Search->text();
|
||||
regexp=checkBox_regExp->isChecked();
|
||||
if(txt==""){
|
||||
QMessageBox::information(this,trUtf8("Hinweis"),trUtf8("Bitte geben Sie einen Suchbegriff ein."),"OK",0,0);
|
||||
return;}
|
||||
|
||||
for(int i=0;i<pw->Entries.size();i++){
|
||||
if(group){if(pw->Entries[i].GroupID != group->ID)continue;}
|
||||
bool hit=false;
|
||||
if(checkBox_Title->isChecked()) hit=hit||search(pw->Entries[i].Title);
|
||||
if(checkBox_Username->isChecked()) hit=hit||search(pw->Entries[i].UserName);
|
||||
if(checkBox_URL->isChecked()) hit=hit||search(pw->Entries[i].URL);
|
||||
if(checkBox_Comment->isChecked()) hit=hit||search(pw->Entries[i].Additional);
|
||||
if(checkBox_Attachment->isChecked()) hit=hit||search(pw->Entries[i].BinaryDesc);
|
||||
if(checkBox_Password->isChecked()) hit=hit||search(pw->Entries[i].Password.getString());
|
||||
pw->Entries[i].Password.delRef();
|
||||
if(hit)hits.push_back(&pw->Entries[i]);
|
||||
}
|
||||
done(1);
|
||||
}
|
||||
bool CSearchDlg::search(QString& str){
|
||||
if(regexp){
|
||||
QRegExp exp(txt,checkBox_Cs->isChecked());
|
||||
if(str.contains(exp)==0)return false;}
|
||||
else{
|
||||
if(str.contains(txt,checkBox_Cs->isChecked())==0)return false;}
|
||||
return true;
|
||||
}
|
||||
|
||||
/*$SPECIALIZATION$*/
|
||||
|
||||
|
||||
63
src/dialogs/SearchDlg.h
Executable file
63
src/dialogs/SearchDlg.h
Executable file
@@ -0,0 +1,63 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2005 by Tarek Saidi *
|
||||
* mail@tarek-saidi.de *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
#include "mainwindow.h"
|
||||
#ifndef SEARCHDLG_H
|
||||
#define SEARCHDLG_H
|
||||
#include "ui_SearchDlg.h"
|
||||
|
||||
class CSearchDlg : public Search_Dlg
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CSearchDlg(CGroup* pGroup=NULL,QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
|
||||
~CSearchDlg();
|
||||
/*$PUBLIC_FUNCTIONS$*/
|
||||
|
||||
public slots:
|
||||
/*$PUBLIC_SLOTS$*/
|
||||
|
||||
protected:
|
||||
/*$PROTECTED_FUNCTIONS$*/
|
||||
|
||||
protected slots:
|
||||
/*$PROTECTED_SLOTS$*/
|
||||
|
||||
public slots:
|
||||
virtual void OnButtonClose();
|
||||
public slots:
|
||||
virtual void OnButtonSearch();
|
||||
|
||||
|
||||
private:
|
||||
CMainWindow* parentwnd;
|
||||
CGroup* group;
|
||||
PwDatabase* pw;
|
||||
QString txt;
|
||||
bool regexp;
|
||||
bool search(QString&);
|
||||
|
||||
public:
|
||||
vector<CEntry*> hits;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
125
src/dialogs/SettingsDlg.cpp
Executable file
125
src/dialogs/SettingsDlg.cpp
Executable file
@@ -0,0 +1,125 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2005 by Tarek Saidi *
|
||||
* tarek@linux *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
#include "mainwindow.h"
|
||||
#include <qpixmap.h>
|
||||
#include <qcheckbox.h>
|
||||
#include <qspinbox.h>
|
||||
#include <qcolordialog.h>
|
||||
#include <qlineedit.h>
|
||||
#include "SettingsDlg.h"
|
||||
|
||||
|
||||
CSettingsDlg::CSettingsDlg(QWidget* parent, const char* name, bool modal, WFlags fl)
|
||||
: SettingsDialog(parent,name, modal,fl)
|
||||
{
|
||||
pw=((CMainWindow*)parentWidget())->db;
|
||||
mainwnd=((CMainWindow*)parentWidget());
|
||||
mainwnd->CreateBanner(Banner,mainwnd->Icon_Settings32x32,trUtf8("Einstellungen"));
|
||||
|
||||
CheckBox_OpenLast->setChecked(mainwnd->config.OpenLast);
|
||||
SpinBox_ClipboardTime->setValue(mainwnd->config.ClipboardTimeOut);
|
||||
pixmTextColor->setPixmap(*(new QPixmap(pixmTextColor->width(),pixmTextColor->height())));
|
||||
pixmTextColor->pixmap()->fill(mainwnd->config.BannerTextColor);
|
||||
|
||||
pixmColor1->setPixmap(*(new QPixmap(pixmColor1->width(),pixmColor1->height())));
|
||||
pixmColor1->pixmap()->fill(mainwnd->config.BannerColor1);
|
||||
|
||||
pixmColor2->setPixmap(*(new QPixmap(pixmColor2->width(),pixmColor2->height())));
|
||||
pixmColor2->pixmap()->fill(mainwnd->config.BannerColor2);
|
||||
|
||||
color1=mainwnd->config.BannerColor1;
|
||||
color2=mainwnd->config.BannerColor2;
|
||||
textcolor=mainwnd->config.BannerTextColor;
|
||||
|
||||
CheckBox_ShowPasswords->setChecked(mainwnd->config.ShowPasswords);
|
||||
Edit_BrowserCmd->setText(mainwnd->config.OpenUrlCommand);
|
||||
CheckBox_ExpandGroupTree->setChecked(mainwnd->config.ExpandGroupTree);
|
||||
|
||||
}
|
||||
|
||||
CSettingsDlg::~CSettingsDlg()
|
||||
{
|
||||
}
|
||||
|
||||
void CSettingsDlg::OnOK()
|
||||
{
|
||||
mainwnd->config.OpenLast=CheckBox_OpenLast->isChecked();
|
||||
mainwnd->config.ClipboardTimeOut=SpinBox_ClipboardTime->value();
|
||||
mainwnd->config.BannerColor1=color1;
|
||||
mainwnd->config.BannerColor2=color2;
|
||||
mainwnd->config.BannerTextColor=textcolor;
|
||||
mainwnd->config.ShowPasswords=CheckBox_ShowPasswords->isChecked();
|
||||
mainwnd->config.OpenUrlCommand=Edit_BrowserCmd->text();
|
||||
mainwnd->config.ExpandGroupTree=CheckBox_ExpandGroupTree->isChecked();
|
||||
close();
|
||||
}
|
||||
|
||||
void CSettingsDlg::OnCancel()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
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);
|
||||
mainwnd->CreateBanner(Banner,mainwnd->Icon_Settings32x32,trUtf8("Einstellungen"),color1,color2,textcolor);}
|
||||
}
|
||||
|
||||
|
||||
void CSettingsDlg::OnColor2()
|
||||
{
|
||||
QColor c=QColorDialog::getColor(color2,this);
|
||||
if(c.isValid()){
|
||||
color2=c;
|
||||
QPixmap *px=new QPixmap(pixmColor2->width(),pixmColor2->height());
|
||||
px->fill(c);
|
||||
pixmColor2->clear();
|
||||
pixmColor2->setPixmap(*px);
|
||||
mainwnd->CreateBanner(Banner,mainwnd->Icon_Settings32x32,trUtf8("Einstellungen"),color1,color2,textcolor);}
|
||||
}
|
||||
|
||||
|
||||
void CSettingsDlg::OnColor1()
|
||||
{
|
||||
QColor c=QColorDialog::getColor(color1,this);
|
||||
if(c.isValid()){
|
||||
color1=c;
|
||||
QPixmap *px=new QPixmap(pixmColor1->width(),pixmColor1->height());
|
||||
px->fill(c);
|
||||
pixmColor1->clear();
|
||||
pixmColor1->setPixmap(*px);
|
||||
mainwnd->CreateBanner(Banner,mainwnd->Icon_Settings32x32,trUtf8("Einstellungen"),color1,color2,textcolor);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*$SPECIALIZATION$*/
|
||||
|
||||
|
||||
//#include "settingsdlg.moc"
|
||||
|
||||
60
src/dialogs/SettingsDlg.h
Executable file
60
src/dialogs/SettingsDlg.h
Executable file
@@ -0,0 +1,60 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2005 by Tarek Saidi *
|
||||
* tarek@linux *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
#include "mainwindow.h"
|
||||
#ifndef SETTINGSDLG_H
|
||||
#define SETTINGSDLG_H
|
||||
|
||||
#include "ui_SettingsDlg.h"
|
||||
#include <qcolor.h>
|
||||
|
||||
class CSettingsDlg : public SettingsDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CMainWindow* mainwnd;
|
||||
PwDatabase* pw;
|
||||
CSettingsDlg(QWidget* parent = 0, const char* name = 0, bool modal = FALSE, 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();
|
||||
|
||||
private:
|
||||
QColor color1,color2,textcolor;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
58
src/dialogs/SimplePasswordDlg.cpp
Executable file
58
src/dialogs/SimplePasswordDlg.cpp
Executable file
@@ -0,0 +1,58 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2005 by Tarek Saidi *
|
||||
* mail@tarek-saidi.de *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#include "SimplePasswordDlg.h"
|
||||
#include <qlineedit.h>
|
||||
#include <qpushbutton.h>
|
||||
|
||||
CSimplePasswordDialog::CSimplePasswordDialog(bool HidePw,QWidget* parent, const char* name, bool modal, WFlags fl)
|
||||
: SimplePasswordDialog(parent,name, modal,fl)
|
||||
{
|
||||
if(HidePw)Button_HidePassword->toggle();
|
||||
}
|
||||
|
||||
CSimplePasswordDialog::~CSimplePasswordDialog()
|
||||
{
|
||||
}
|
||||
|
||||
void CSimplePasswordDialog::OnCancel()
|
||||
{
|
||||
done(0);
|
||||
}
|
||||
|
||||
|
||||
void CSimplePasswordDialog::OnOK()
|
||||
{
|
||||
password=EditPassword->text();
|
||||
done(1);
|
||||
}
|
||||
|
||||
|
||||
void CSimplePasswordDialog::OnHidePasswordToggled(bool state)
|
||||
{
|
||||
if(state)EditPassword->setEchoMode(QLineEdit::Password);
|
||||
else EditPassword->setEchoMode(QLineEdit::Normal);
|
||||
}
|
||||
|
||||
|
||||
/*$SPECIALIZATION$*/
|
||||
|
||||
|
||||
54
src/dialogs/SimplePasswordDlg.h
Executable file
54
src/dialogs/SimplePasswordDlg.h
Executable file
@@ -0,0 +1,54 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) 2005 by Tarek Saidi *
|
||||
* mail@tarek-saidi.de *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation; either version 2 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program; if not, write to the *
|
||||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef _SIMPLEPASSWORDDIALOG_H
|
||||
#define _SIMPLEPASSWORDDIALOG_H
|
||||
|
||||
#include "ui_SimplePasswordDlg.h"
|
||||
|
||||
class CSimplePasswordDialog : public SimplePasswordDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
CSimplePasswordDialog(bool HidePw,QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
|
||||
~CSimplePasswordDialog();
|
||||
/*$PUBLIC_FUNCTIONS$*/
|
||||
|
||||
public slots:
|
||||
/*$PUBLIC_SLOTS$*/
|
||||
|
||||
protected:
|
||||
/*$PROTECTED_FUNCTIONS$*/
|
||||
|
||||
protected slots:
|
||||
/*$PROTECTED_SLOTS$*/
|
||||
public: QString password;
|
||||
|
||||
public slots:
|
||||
virtual void OnCancel();
|
||||
public slots:
|
||||
virtual void OnOK();
|
||||
public slots:
|
||||
virtual void OnHidePasswordToggled(bool state);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user