示例#1
0
Registration::Registration(QWidget *parent) :
        QMainWindow(parent),
        ui(new Ui::Registration)
{
    ui->setupUi(this);
    QRect frect = frameGeometry();
    frect.moveCenter(QDesktopWidget().availableGeometry().center());
    move(frect.topLeft());

    this->setMaximumSize(406,220);
    ui->edit_haslo->setEchoMode(QLineEdit::Password);
    ui->edit_haslo2->setEchoMode(QLineEdit::Password);

    connect(ui->edit_haslo2,SIGNAL(textEdited(QString)),this,SLOT(passwdCmp()));
    connect(ui->edit_email,SIGNAL(textEdited(QString)),this,SLOT(checkEmail()));
    connect(ui->edit_login,SIGNAL(textEdited(QString)),this,SLOT(checkLogin()));
    connect(ui->button_cancel,SIGNAL(clicked()),this,SLOT(anuluj()));
    connect(ui->button_register,SIGNAL(clicked()),this,SLOT(rejestruj()));
}
示例#2
0
void Registration::rejestruj()
{
    if(checkLogin() && checkEmail() && passwdCmp())
    {
        QByteArray haslo = ui->edit_haslo->text().toUtf8();
        QCryptographicHash *hash = new QCryptographicHash(QCryptographicHash::Md5);
        hash->addData(haslo);
        QSqlQuery zapytanie("INSERT INTO users(login, password, email) VALUES ('"+ ui->edit_login->text()+"','"+hash->result().toHex()+"','"+ui->edit_email->text()+"');");
        this->close();
        if(zapytanie.numRowsAffected()!=0)
        {
            QMessageBox::information(0,"rejestracja","dodano nowego uzytkownika\n zalogowano automatycznie");
            Wydatnik::getInstance()->zaloguj(ui->edit_login->text(),hash->result().toHex());
        }
        else
        {
            QMessageBox::warning(0,"rejestracja","rejestracja nie powiodla sie");
        }
    }
    else
        Wydatnik::getInstance()->Error("Podano niepoprawne dane");
}
示例#3
0
CreateAccount::CreateAccount(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::CreateAccount)
{
    ui->setupUi(this);

    setMaxLengths();
    setupValidators();
    setupCards();

    ui->btnSubmit->setEnabled(false);
    ui->cardBox->setVisible(false);
    ui->dummyBox->setMinimumSize(ui->cardBox->sizeHint());

    ui->editEmail->setMinimumSize(ui->editEmail->sizeHint());
    createImageLabel(ui->lblTick, ":/tick.png");
    ui->lblTick->setVisible(false);
    ui->lblTick->setMinimumSize(ui->lblTick->sizeHint());

    // signals and slots

    connect(ui->editFirstname, SIGNAL(editingFinished()), this, SLOT(normalizeName()));
    connect(ui->editMiddlename, SIGNAL(editingFinished()), this, SLOT(normalizeName()));
    connect(ui->editLastname, SIGNAL(editingFinished()), this, SLOT(normalizeName()));
    connect(ui->editProfession, SIGNAL(editingFinished()), this, SLOT(normalizeName()));

    // connect required fields to submit
    connect(ui->editFirstname, SIGNAL(editingFinished()), this, SLOT(enableSubmit()));
    connect(ui->editLastname, SIGNAL(editingFinished()), this, SLOT(enableSubmit()));
    connect(ui->editEmail, SIGNAL(editingFinished()), this, SLOT(checkEmail()));
    connect(ui->editContact, SIGNAL(editingFinished()), this, SLOT(enableSubmit()));
    connect(ui->editAttachment, SIGNAL(textChanged(QString)), this, SLOT(enableSubmit()));
    connect(ui->editAmount, SIGNAL(editingFinished()), this, SLOT(enableSubmit()));

    connect(ui->btnAttachment, SIGNAL(clicked(bool)), this, SLOT(addAttachment()));
    connect(ui->btnReset, SIGNAL(clicked(bool)), this, SLOT(resetForm()));
}