diff --git a/src/dialogs/CollectEntropyDlg.cpp b/src/dialogs/CollectEntropyDlg.cpp new file mode 100644 index 0000000..2d61c12 --- /dev/null +++ b/src/dialogs/CollectEntropyDlg.cpp @@ -0,0 +1,38 @@ +/*************************************************************************** + * Copyright (C) 2005-2006 by Tarek Saidi * + * tarek.saidi@arcor.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 +#include "CollectEntropyDlg.h" +#include "main.h" + +CollectEntropyDlg::CollectEntropyDlg(QWidget* parent):QDialog(parent){ + setupUi(this); + createBanner(&BannerPixmap,Icon_Settings32x32,tr("Entropy Collection"),width()); + + + +} + +void CollectEntropyDlg::paintEvent(QPaintEvent *event){ + QDialog::paintEvent(event); + QPainter painter(this); + painter.setClipRegion(event->region()); + painter.drawPixmap(QPoint(0,0),BannerPixmap); +} diff --git a/src/dialogs/CollectEntropyDlg.h b/src/dialogs/CollectEntropyDlg.h new file mode 100644 index 0000000..7fe53e4 --- /dev/null +++ b/src/dialogs/CollectEntropyDlg.h @@ -0,0 +1,42 @@ +/*************************************************************************** + * Copyright (C) 2005-2006 by Tarek Saidi * + * tarek.saidi@arcor.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 _COLLECT_ENTROPY_DLG_H_ +#define _COLLECT_ENTROPY_DLG_H_ + +#include "ui_CollectEntropyDlg.h" +#include +#include + +class CollectEntropyDlg: public QDialog, public Ui_CollectEntropyDlg{ + Q_OBJECT + public: + CollectEntropyDlg(QWidget* parent); + + private: + QPixmap BannerPixmap; + virtual void paintEvent(QPaintEvent* event); + +}; + + + + +#endif \ No newline at end of file diff --git a/src/forms/CollectEntropyDlg.ui b/src/forms/CollectEntropyDlg.ui new file mode 100644 index 0000000..c3d6c12 --- /dev/null +++ b/src/forms/CollectEntropyDlg.ui @@ -0,0 +1,120 @@ + + CollectEntropyDlg + + + + 0 + 0 + 476 + 279 + + + + Dialog + + + + + 10 + 80 + 411 + 51 + + + + Collecting entropy... +Please move the mouse and/or press some keys until enought entropy for a reseed of the random number generator is collected. + + + false + + + true + + + + + + 90 + 140 + 371 + 23 + + + + 24 + + + Qt::Horizontal + + + + + + 20 + 240 + 441 + 32 + + + + Qt::Horizontal + + + QDialogButtonBox::Ok + + + + + + 10 + 140 + 61 + 51 + + + + + + + WaitAnimationWidget + QWidget +
lib/WaitAnimationWidget.h
+
+
+ + + + buttonBox + rejected() + CollectEntropyDlg + reject() + + + 316 + 260 + + + 286 + 274 + + + + + buttonBox + accepted() + CollectEntropyDlg + accept() + + + 248 + 254 + + + 157 + 274 + + + + +
diff --git a/src/lib/WaitAnimationWidget.cpp b/src/lib/WaitAnimationWidget.cpp new file mode 100644 index 0000000..fbd78af --- /dev/null +++ b/src/lib/WaitAnimationWidget.cpp @@ -0,0 +1,75 @@ +/*************************************************************************** + * Copyright (C) 2005-2006 by Tarek Saidi * + * tarek.saidi@arcor.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 +#include +#include +#include "WaitAnimationWidget.h" + + +WaitAnimationWidget::WaitAnimationWidget(QWidget* parent):QWidget(parent){ + speed=60; + setRefreshRate(25); + CurAngle=0; + connect(&timer,SIGNAL(timeout()),this,SLOT(refreshAnimation())); + timer.start(); + +} + +void WaitAnimationWidget::setRefreshRate(int fps){ + DiffAngle=1.0f/((60.0f/(float)speed)*(float)fps); + timer.setInterval((1.0f/(float)fps)*1000.0f); +} + +void WaitAnimationWidget::refreshAnimation(){ + CurAngle+=DiffAngle; + if(CurAngle>1.0f)CurAngle-=1.0f; + for(int i=0;i<6;i++){ + float diff=CurAngle-i*0.16666667f; + if(diff>0.5f) + diff=1.0f-diff; + CircSizes[i]=1.0+exp(-10.0f*diff*diff); + } + repaint(); +} + +void WaitAnimationWidget::paintEvent(QPaintEvent* event){ + QPainter painter(this); + painter.setRenderHints(QPainter::Antialiasing,true); + for(int i=0;i<6;i++){ + float d=CircSizes[i]*6; + QRectF rect(CircPositions[i].x()-d/2,CircPositions[i].y()-d/2,d,d); + painter.drawEllipse(rect); + + } +} + +void WaitAnimationWidget::resizeEvent(QResizeEvent* event){ + float r; + if(width()>height()) + r=height()/2; + else + r=width()/2; + for(int i=0;i<6;i++){ + CircPositions[i].setX((r-10)*cos(-2.0*3.14159265*(0.16666667*i))+r); + CircPositions[i].setY((r-10)*sin(-2.0*3.14159265*(0.16666667*i))+r); + } + +} \ No newline at end of file diff --git a/src/lib/WaitAnimationWidget.h b/src/lib/WaitAnimationWidget.h new file mode 100644 index 0000000..1b89f06 --- /dev/null +++ b/src/lib/WaitAnimationWidget.h @@ -0,0 +1,44 @@ +/*************************************************************************** + * Copyright (C) 2005-2006 by Tarek Saidi * + * tarek.saidi@arcor.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 +#include +#include +#include +#include + +class WaitAnimationWidget:public QWidget{ + Q_OBJECT + public: + WaitAnimationWidget(QWidget* parent); + void setSpeed(int rpm){speed=rpm;} + void setRefreshRate(int fps); + public slots: + void refreshAnimation(); + private: + virtual void paintEvent(QPaintEvent* event); + virtual void resizeEvent(QResizeEvent* event); + QTimer timer; + int speed; + float CurAngle; + float DiffAngle; + float CircSizes[6]; + QPointF CircPositions[6]; +}; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index e09f965..680aab6 100755 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -52,6 +52,7 @@ #include "dialogs/PasswordDlg.h" #include "dialogs/SimplePasswordDlg.h" #include "dialogs/PasswordGenDlg.h" +#include "dialogs/CollectEntropyDlg.h" KeepassMainWindow::KeepassMainWindow(const QString& ArgFile,QWidget *parent, Qt::WFlags flags):QMainWindow(parent,flags){ @@ -367,7 +368,16 @@ return true; } -void KeepassMainWindow::OnFileNewKdb(){ +void KeepassMainWindow::OnFileNewKdb(){ + + /* + //Test + CollectEntropyDlg dialog(this); + dialog.exec(); + return; + //~Test + */ + CPasswordDialog dlg(this,true,false,true); dlg.setWindowTitle("New Database"); if(dlg.exec()==1){ diff --git a/src/src.pro b/src/src.pro index dbe3e90..dc60123 100755 --- a/src/src.pro +++ b/src/src.pro @@ -41,7 +41,8 @@ FORMS += forms/EditGroupDlg.ui \ forms/PasswordDlg.ui \ forms/EditEntryDlg.ui \ forms/PasswordGenDlg.ui \ - forms/SelectIconDlg.ui + forms/SelectIconDlg.ui \ + forms/CollectEntropyDlg.ui TRANSLATIONS += translations/keepass-de_DE.ts \ translations/keepass-ru_RU.ts \ translations/keepass-es_ES.ts \ @@ -68,6 +69,7 @@ HEADERS += lib/IniReader.h \ dialogs/EditEntryDlg.h \ dialogs/PasswordGenDlg.h \ dialogs/SelectIconDlg.h \ + dialogs/CollectEntropyDlg.h \ lib/random.h \ Database.h \ lib/KdePlugin.h \ @@ -85,7 +87,8 @@ HEADERS += lib/IniReader.h \ crypto/aestab.h \ crypto/aescpp.h \ crypto/sha256.h \ - crypto/yarrow.h + crypto/yarrow.h \ + lib/WaitAnimationWidget.h SOURCES += lib/IniReader.cpp \ lib/UrlLabel.cpp \ main.cpp \ @@ -108,6 +111,7 @@ SOURCES += lib/IniReader.cpp \ dialogs/EditEntryDlg.cpp \ dialogs/PasswordGenDlg.cpp \ dialogs/SelectIconDlg.cpp \ + dialogs/CollectEntropyDlg.cpp \ lib/random.cpp \ Database.cpp \ lib/KdePlugin.cpp \ @@ -120,7 +124,8 @@ SOURCES += lib/IniReader.cpp \ crypto/aestab.c \ crypto/aes_modes.c \ crypto/sha256.cpp \ - crypto/yarrow.cpp + crypto/yarrow.cpp \ + lib/WaitAnimationWidget.cpp QT += xml MOC_DIR = ../build/moc UI_DIR = ../build/ui