#include <QtDebug>
#include <QLabel>
-PasswordDialog::PasswordDialog( QWidget *aParent, const QString &aPassword, const QString &aText, const QString &aTitle ) :
+PasswordDialog::PasswordDialog( const QString &aPassword, const QString &aText, const QString &aTitle, QWidget *aParent ) :
QDialog( aParent )
{
setWindowTitle( aTitle.isNull() ? tr( "Enter password" ) : aTitle );
setModal( true );
- // Store the password hash to iPasswordHash
- // ( aPassword should be allready encoded )
-// QCryptographicHash *hash = new QCryptographicHash( QCryptographicHash::Md5 );
-// hash->addData( aPassword.toUtf8() );
-// iPasswordHash = hash->result();
-// delete hash;
iPasswordHash = aPassword.toUtf8();
/* Create the layout:
QCryptographicHash *hash = new QCryptographicHash( QCryptographicHash::Md5 );
hash->addData( iPasswordEdit->text().toUtf8() );
QByteArray userpw = hash->result();
- delete hash;
+ delete hash;
+ close();
+
// Compare the password hashes and emit corresponding signal tellin if the password was correct
if ( iPasswordHash == userpw.toHex() )
{
emit passwordEntered( PasswordDialog::Incorrect );
qDebug() << "Incorrect password!";
}
-
- // Close the dialog
- close();
}
void PasswordDialog::cancelButtonPressed()
{
qDebug() << "PasswordDialog::cancelButtonPressed()";
-
- emit passwordEntered( PasswordDialog::Canceled );
-
+
close();
-}
-
-PasswordDialog * PasswordDialog::query( QWidget *aParent, const QString &aPassword, const QString &aText, const QString &aTitle )
-{
- // Create a PasswordDialog instance and show it
- PasswordDialog* dlg = new PasswordDialog( aParent, aPassword, aText, aTitle );
- dlg->show();
- return dlg;
+ emit passwordEntered( PasswordDialog::Canceled );
}