1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
|
#include "form_connexion.h"
#include "form_plateform.h"
#include <QWidget>
#include <QGridLayout>
#include <QApplication>
#include <QThread>
#include <QShowEvent>
#include <QDebug>
form_connexion::form_connexion()
{
//FORM SETTINGS
setFixedSize(300,400);
setWindowFlags(Qt::FramelessWindowHint);
setWindowOpacity(1);
QPixmap bg(":/bgs/bg1");
bg = bg.scaled(bg.size() / 2, Qt::IgnoreAspectRatio);
QPalette palette;
palette.setBrush(QPalette::Background, bg);
this->setPalette(palette);
//Btn
btn_connexion = new QPushButton("Connexion", this);
btn_signup = new QPushButton("Register", this);
btn_connexion->setFixedSize(100, 25);
btn_signup->setFixedSize(100, 25);
btn_connexion->setEnabled(false);
//Texts
title = new QLabel("LogIn / SignUp", this);
title->setAlignment(Qt::AlignCenter);
title->setFixedSize(100,25);
text1 = new QLabel("Nickname : ", this);
text2 = new QLabel("Password : ", this);
//Inputs
name_input = new QLineEdit(this);
pass_input = new QLineEdit(this);
name_input->setFixedSize(150,25);
pass_input->setFixedSize(150,25);
pass_input->setEchoMode(QLineEdit::Password);
//Strings
name_acc = new QLabel("", this);
//Layout
panel_form = new QGridLayout(this);
title_lay = new QHBoxLayout(this);
btn_lay = new QHBoxLayout(this);
panel_co = new QGridLayout(this);
panel_form->addLayout(title_lay, 0, 0);
panel_form->addLayout(panel_co, 1, 0, Qt::AlignCenter);
panel_form->addLayout(btn_lay, 2, 0);
panel_co->addWidget(text1, 0, 0, Qt::AlignRight);
panel_co->addWidget(text2, 1, 0, Qt::AlignRight);
panel_co->addWidget(name_input, 0, 1, Qt::AlignLeft);
panel_co->addWidget(pass_input, 1, 1, Qt::AlignLeft);
btn_lay->addWidget(btn_connexion, Qt::AlignBottom);
btn_lay->addWidget(btn_signup, Qt::AlignBottom);
title_lay->addWidget(title);
//EVENTS
connect(name_input, SIGNAL(textChanged(const QString &)), this, SLOT(checkInputs()));
connect(pass_input, SIGNAL(textChanged(const QString &)), this, SLOT(checkInputs()));
connect(btn_connexion, SIGNAL(clicked()), this, SLOT(connexionToPlat()));
connect(this, SIGNAL(emitCAF()), this, SLOT(closeAnimForm()));
}
void form_connexion::connexionToPlat(){
//Check if account exists in database
//--
//IF EXISTS
//initialize a new instance of form_plateform
form_plateform *pf = new form_plateform;
pf->show();
//Get the name account
//Close form_connexion
emit emitCAF();
this->hide();
}
void form_connexion::checkInputs(){
if(name_input->text().length() > 4 && pass_input->text().length() > 5){
btn_connexion->setEnabled(true);
}else{
btn_connexion->setEnabled(false);
}
}
void form_connexion::openAnimForm(){
double opa = 0.1;
while(opa < 1.0){
opa = opa + 0.05;
QThread::msleep(20);
setWindowOpacity(opa);
}
}
void form_connexion::closeAnimForm(){
double opa = 1;
while(opa > 0.0){
opa = opa - 0.05;
QThread::msleep(20);
setWindowOpacity(opa);
}
}
QString form_connexion::getName(){
return name_input->text();
} |
Partager