1 /***************************************************************************
2 * Copyright (C) 2005 by Tarek Saidi *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; version 2 of the License. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
22 #include "DatabaseSettingsDlg.h"
23 #include "Kdb3Database.h"
26 CDbSettingsDlg::CDbSettingsDlg(QWidget* parent,IDatabase* db, Qt::WFlags fl)
30 database=dynamic_cast<IKdbSettings*>(db);
32 setMaximumSize(size());
33 setMinimumSize(size());
34 createBanner(&BannerPixmap,getPixmap("appsettings"),tr("Settings"),width());
35 ComboAlgo->insertItem(0,tr("AES(Rijndael): 256 Bit (default)"));
36 ComboAlgo->insertItem(1,tr("Twofish: 256 Bit"));
37 ComboAlgo->setCurrentIndex(database->cryptAlgorithm()); //Achtung: AlgoID muss gleich dem ComboBox Index sein!
38 EditRounds->setText(QString::number( database->keyTransfRounds() ));
39 ButtonBench->setIcon(getIcon("alarmclock"));
40 connect( ButtonBox, SIGNAL( accepted() ), this, SLOT( OnOK() ) );
41 connect( ButtonBox, SIGNAL( rejected() ), this, SLOT( OnCancel() ) );
42 connect( ButtonBench, SIGNAL( clicked() ), this, SLOT( OnBenchmark() ) );
45 CDbSettingsDlg::~CDbSettingsDlg(){
48 void CDbSettingsDlg::paintEvent(QPaintEvent *event){
49 QDialog::paintEvent(event);
50 QPainter painter(this);
51 painter.setClipRegion(event->region());
52 painter.drawPixmap(QPoint(0,0),BannerPixmap);
55 void CDbSettingsDlg::OnCancel()
61 void CDbSettingsDlg::OnOK()
63 if(EditRounds->text()==""){
64 QMessageBox::warning(NULL,tr("Warning"),tr("Please determine the number of encryption rounds."),tr("OK"));
68 int rounds=EditRounds->text().toUInt(&valid,10);
70 QMessageBox::warning(NULL,tr("Error"),tr("'%1' is not valid integer value.").arg(EditRounds->text()),tr("OK"));
74 QMessageBox::warning(NULL,tr("Error"),tr("The number of encryption rounds have to be greater than 0."),tr("OK"));
77 database->setKeyTransfRounds(rounds);
78 database->setCryptAlgorithm((CryptAlgorithm)ComboAlgo->currentIndex());
82 void CDbSettingsDlg::OnBenchmark(){
83 EditRounds->setText(QString::number( KeyTransformBenchmark::benchmark(1000) ));