1 //********************************************************************************** 2 //EncryptPad Copyright 2016 Evgeny Pokhilko 3 //<http://www.evpo.net/encryptpad> 4 // 5 //This file is part of EncryptPad 6 // 7 //EncryptPad is free software: you can redistribute it and/or modify 8 //it under the terms of the GNU General Public License as published by 9 //the Free Software Foundation, either version 2 of the License, or 10 //(at your option) any later version. 11 // 12 //EncryptPad is distributed in the hope that it will be useful, 13 //but WITHOUT ANY WARRANTY; without even the implied warranty of 14 //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 //GNU General Public License for more details. 16 // 17 //You should have received a copy of the GNU General Public License 18 //along with EncryptPad. If not, see <http://www.gnu.org/licenses/>. 19 //********************************************************************************** 20 #ifndef PASSWORD_GENERATION_DIALOG_H 21 #define PASSWORD_GENERATION_DIALOG_H 22 23 #include <QDialog> 24 #include <QAbstractButton> 25 #include <QSpinBox> 26 #include <vector> 27 #include "passphrase_generator.h" 28 29 namespace Ui { 30 class PassphraseGenerationDialog; 31 } 32 33 class PassphraseGenerationDialog : public QDialog 34 { 35 Q_OBJECT 36 private: 37 Ui::PassphraseGenerationDialog *ui; 38 bool ignoreRegenerate; 39 bool allPassphrases; 40 int getLength(); 41 void setLength(int length); 42 EncryptPad::CharRange getCharRange(); 43 void setCharRange(EncryptPad::CharRange range); 44 45 struct Control2Length 46 { Control2LengthControl2Length47 Control2Length(QAbstractButton *control_p, int length_p) 48 :control(control_p), length(length_p){} 49 QAbstractButton *control; 50 int length; 51 }; 52 53 struct Control2CharRange 54 { Control2CharRangeControl2CharRange55 Control2CharRange(QAbstractButton *control_p, EncryptPad::CharRange range_p) 56 :control(control_p), range(range_p){} 57 QAbstractButton *control; 58 EncryptPad::CharRange range; 59 }; 60 61 struct SpinBox2CharRange 62 { SpinBox2CharRangeSpinBox2CharRange63 SpinBox2CharRange(QSpinBox *control_p, EncryptPad::CharRange range_p) 64 :control(control_p), range(range_p){} 65 QSpinBox *control; 66 EncryptPad::CharRange range; 67 }; 68 69 std::vector<Control2Length> control2LengthTable; 70 std::vector<Control2CharRange> control2CharRange; 71 std::vector<SpinBox2CharRange> maxControl2CharRange; 72 73 const Control2Length *getControl2LengthTable(); 74 const Control2CharRange *getControl2CharRange(); 75 const SpinBox2CharRange *getMaxControl2CharRange(); 76 77 public: 78 explicit PassphraseGenerationDialog(QWidget *parent = 0); 79 ~PassphraseGenerationDialog(); 80 81 QStringList getSettings(); 82 void setSettings(const QStringList &list); 83 QStringList getPassphrases() const; 84 QString getCurrentPassphrase() const; 85 bool getAllPassphrases() const; 86 87 private slots: 88 void on_actionRegenerate_triggered(); 89 void on_uiInsertAll_clicked(); 90 }; 91 92 #endif // PASSWORD_GENERATION_DIALOG_H 93