146 lines
2.9 KiB
C++
146 lines
2.9 KiB
C++
#include "genpass.h"
|
|
#include "ui_genpass.h"
|
|
#include <QVector>
|
|
#include <QClipboard>
|
|
|
|
QString password2;
|
|
QVector<char> BigLetters= {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
|
|
QVector<char> SmallLetters = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
|
|
QVector<char> Numbers = {'1','2','3','4','5','6','7','8','9','0'};
|
|
QVector<char> Simvol = {'?','/','.',',','@'};/// is it all???
|
|
|
|
GenPass::GenPass(QWidget *parent) :
|
|
QWidget(parent),
|
|
ui(new Ui::GenPass)
|
|
{
|
|
ui->setupUi(this);
|
|
setWindowTitle("Generating new password");
|
|
ui->lineEdit->setText("здесь будет пароль");
|
|
ui->lineEdit->setStyleSheet("color: blue;");
|
|
}
|
|
|
|
|
|
|
|
GenPass::~GenPass()
|
|
{
|
|
delete ui;
|
|
}
|
|
|
|
void GenPass::on_pushButton_2_clicked()
|
|
{
|
|
QWidget::close() ;
|
|
}
|
|
|
|
|
|
void GenPass::on_pushButton_clicked()
|
|
{
|
|
|
|
}
|
|
|
|
|
|
//void GenPass::on_checkBox_4_stateChanged(int arg1)
|
|
//{
|
|
// /* if(ui->BL->isChecked()){
|
|
// ui->lineEdit->setText("здесь будет пароль");
|
|
// }
|
|
// */
|
|
//}
|
|
|
|
|
|
//void GenPass::on_img_clicked()
|
|
//{
|
|
// //ui->img->setIcon(QIcon("art-black-drawing-owl-Favim.com-4015576.jpg"));
|
|
//}
|
|
|
|
|
|
void GenPass::on_lineEdit_cursorPositionChanged(int arg1, int arg2)
|
|
{
|
|
|
|
}
|
|
//void GenPass::on_horizontalSlider_actionTriggered(int action)
|
|
//{
|
|
|
|
//}
|
|
QString GenPass::NewRandPassword(){
|
|
QString npasw;
|
|
QVector<char> rands;
|
|
QString password1 = "";
|
|
if(ui->BL->isChecked()){
|
|
rands+=BigLetters;
|
|
}
|
|
if(ui->SL->isChecked()){
|
|
rands+=SmallLetters;
|
|
}
|
|
if(ui->N->isChecked()){
|
|
rands+=Numbers;
|
|
}
|
|
if(ui->S->isChecked()){
|
|
rands+=Simvol;
|
|
}
|
|
if(rands.size()==0){
|
|
|
|
return "ты не выбрал из чего генерировать пароль";
|
|
}
|
|
|
|
int i = ui->SizeL->text().toInt();
|
|
|
|
int s = rands.size();
|
|
srand(time(0));
|
|
|
|
for(int k =0 ; k<i; k++){
|
|
|
|
password1+= rands[qrand() % s];
|
|
|
|
}
|
|
|
|
return password1;
|
|
}
|
|
|
|
|
|
void GenPass::on_ReFresher_clicked()
|
|
{
|
|
password2 = NewRandPassword();
|
|
ui->lineEdit->setText(password2);
|
|
///ui->lineEdit->selectedText();
|
|
}
|
|
|
|
|
|
void GenPass::on_Copy_clicked()
|
|
{
|
|
QClipboard *clipboard = QApplication::clipboard();
|
|
clipboard->setText(ui->lineEdit->text(), QClipboard::Clipboard);
|
|
}
|
|
|
|
|
|
void GenPass::on_SizeL_cursorPositionChanged(int arg1, int arg2)
|
|
{
|
|
|
|
}
|
|
|
|
|
|
//void GenPass::on_spinBox_textChanged(const QString &arg1)
|
|
//{
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
void GenPass::on_pushButton_3_clicked()
|
|
{
|
|
|
|
if( ui->lineEdit->echoMode()==QLineEdit::Password){
|
|
ui->lineEdit->setEchoMode(QLineEdit::Normal);
|
|
ui->pushButton_3->setIcon(QIcon("/home/nrumak/password_manager/PasswordManager/resource/view_show_icon_124811.png"));
|
|
}
|
|
else if(ui->lineEdit->echoMode() == QLineEdit::Normal){
|
|
ui->lineEdit->setEchoMode(QLineEdit::Password);
|
|
ui->pushButton_3->setIcon(QIcon("/home/nrumak/password_manager/PasswordManager/resource/view_hide_icon_124813.png"));
|
|
}
|
|
|
|
|
|
}
|
|
|