void Launcher::returnHome() { this->close(); Home *home = new Home(m_parent); home->show(); }
void Login::onLoginClicked() { if(ui->lineEdit->text().isEmpty() || ui->lineEdit_2->text().isEmpty()) { ui->label->show(); ui->lineEdit->clear(); ui->lineEdit_2->clear(); }else{ //here is the login section QSqlDatabase *db2 = new QSqlDatabase(); *db2 = QSqlDatabase::database(); db2->setDatabaseName(Includes::Path()); if(!db2->open()) { QMessageBox amsg; amsg.setText("Unable To Connect To Database"); amsg.exec(); } //Write the Tables to the database QByteArray password; password = ui->lineEdit_2->text().toUtf8(); password = QCryptographicHash::hash(password,QCryptographicHash::Sha3_512).toBase64(); QSqlQuery query; query.prepare("SELECT username, password FROM user WHERE username =(?)"); query.bindValue(0, ui->lineEdit->text().toHtmlEscaped()); if( !query.exec() ) { QMessageBox msg; msg.setText("query 1 has an Error()"); msg.exec(); } //compare the retrieved values and the entered one. QString username1; QString password1; while(query.next()) { username1 = query.value(0).toString(); password1 = query.value(1).toString(); } if(username1 == ui->lineEdit->text()){ if(password1 == password){ Home *home = new Home(); home->show();;//if validate open the main app this->close(); }else { ui->label->show(); ui->lineEdit->clear(); ui->lineEdit_2->clear(); } }else { ui->label->show(); ui->lineEdit->clear(); ui->lineEdit_2->clear(); } } }
void Settings::closeEvent(QCloseEvent *event) { Home *home = new Home(); home->show(); }