Re-factored the basic idea of the application: Engine is the main class that ownsWind...
[qtmeetings] / src / UserInterface / Utils / PasswordDialog.cpp
index 332b0b6..3a8590f 100644 (file)
@@ -7,7 +7,7 @@
 #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 );
@@ -61,10 +61,13 @@ PasswordDialog::PasswordDialog( QWidget *aParent, const QString &aPassword, cons
 
        // Enable the layout
        setLayout( layout );
+       
+       show();
 }
 
 PasswordDialog::~PasswordDialog()
 {
+       close();
 }
 
 void PasswordDialog::okButtonPressed()
@@ -75,8 +78,10 @@ void PasswordDialog::okButtonPressed()
        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() )
        {
@@ -88,25 +93,13 @@ void PasswordDialog::okButtonPressed()
                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 );
 }