Added entropy collection dialog

git-svn-id: https://svn.code.sf.net/p/keepassx/code/trunk@107 b624d157-de02-0410-bad0-e51aec6abb33
master
tarek_saidi 18 years ago
parent 0e2725ee06
commit c991307ef8
  1. 38
      src/dialogs/CollectEntropyDlg.cpp
  2. 42
      src/dialogs/CollectEntropyDlg.h
  3. 120
      src/forms/CollectEntropyDlg.ui
  4. 75
      src/lib/WaitAnimationWidget.cpp
  5. 44
      src/lib/WaitAnimationWidget.h
  6. 12
      src/mainwindow.cpp
  7. 11
      src/src.pro

@ -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 <QPainter>
#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);
}

@ -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 <QDialog>
#include <QPaintEvent>
class CollectEntropyDlg: public QDialog, public Ui_CollectEntropyDlg{
Q_OBJECT
public:
CollectEntropyDlg(QWidget* parent);
private:
QPixmap BannerPixmap;
virtual void paintEvent(QPaintEvent* event);
};
#endif

@ -0,0 +1,120 @@
<ui version="4.0" >
<class>CollectEntropyDlg</class>
<widget class="QDialog" name="CollectEntropyDlg" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>476</width>
<height>279</height>
</rect>
</property>
<property name="windowTitle" >
<string>Dialog</string>
</property>
<widget class="QLabel" name="label" >
<property name="geometry" >
<rect>
<x>10</x>
<y>80</y>
<width>411</width>
<height>51</height>
</rect>
</property>
<property name="text" >
<string>Collecting entropy...
Please move the mouse and/or press some keys until enought entropy for a reseed of the random number generator is collected.</string>
</property>
<property name="scaledContents" >
<bool>false</bool>
</property>
<property name="wordWrap" >
<bool>true</bool>
</property>
</widget>
<widget class="QProgressBar" name="progressBar" >
<property name="geometry" >
<rect>
<x>90</x>
<y>140</y>
<width>371</width>
<height>23</height>
</rect>
</property>
<property name="value" >
<number>24</number>
</property>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
</widget>
<widget class="QDialogButtonBox" name="buttonBox" >
<property name="geometry" >
<rect>
<x>20</x>
<y>240</y>
<width>441</width>
<height>32</height>
</rect>
</property>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons" >
<set>QDialogButtonBox::Ok</set>
</property>
</widget>
<widget class="WaitAnimationWidget" native="1" name="Animation" >
<property name="geometry" >
<rect>
<x>10</x>
<y>140</y>
<width>61</width>
<height>51</height>
</rect>
</property>
</widget>
</widget>
<customwidgets>
<customwidget>
<class>WaitAnimationWidget</class>
<extends>QWidget</extends>
<header>lib/WaitAnimationWidget.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>CollectEntropyDlg</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel" >
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel" >
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>CollectEntropyDlg</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel" >
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel" >
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>

@ -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 <math.h>
#include <QPainter>
#include <QRectF>
#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);
}
}

@ -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 <QWidget>
#include <QPaintEvent>
#include <QResizeEvent>
#include <QTimer>
#include <QPointF>
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];
};

@ -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){

@ -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