Initial commit
[keepassx] / src / dialogs / PasswordGenDlg.h
1 /***************************************************************************
2  *   Copyright (C) 2005 by Tarek Saidi                                     *
3  *   tarek@linux                                                           *
4  *                                                                         *
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.               *
8
9  *                                                                         *
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.                          *
14  *                                                                         *
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  ***************************************************************************/
20  
21 #ifndef GENPWDIALOG_H
22 #define GENPWDIALOG_H
23
24 #include "ui_PasswordGenDlg.h"
25 #include "EditEntryDlg.h"
26
27 class CGenPwDialog : public QDialog, public Ui_GenPwDlg
28 {
29         Q_OBJECT
30         public:
31                 CGenPwDialog(QWidget* parent, bool StandAloneMode, Qt::WFlags fl = 0);
32                 ~CGenPwDialog();
33         
34         private:
35                 struct PwGroup {
36                         int start;
37                         int end;
38                 };
39                 void AddToAssoctable(QList<QChar>& table,int start,int end,int& pos);
40                 PwGroup AddToAssoctableGroup(QList<QChar>& table,int start,int end,int& pos);
41                 void paintEvent(QPaintEvent* event);
42                 QString generatePasswordInternal(int length);
43                 QPixmap BannerPixmap;
44                 static bool EntropyCollected;
45                 QPushButton* AcceptButton;
46         
47         private slots:
48                 void OnGeneratePw();
49                 void OnCancel();
50                 void OnAccept();
51                 void estimateQuality();
52                 void OnCollectEntropyChanged(int);
53                 void SwapEchoMode();
54                 void setGenerateEnabled();
55                 void setAcceptEnabled(const QString& str);
56 };
57
58 class PassCharValidator : public QValidator
59 {
60         Q_OBJECT
61         
62         public:
63                 PassCharValidator(QObject* parent);
64                 State validate(QString& input, int& pos) const;
65 };
66
67 #endif
68