void PasswordChangeDialog::connectSlots()
{
    connect(linePass1,SIGNAL(textChanged(QString)),this,SLOT(checkPasswords()));
    connect(linePass2,SIGNAL(textChanged(QString)),this,SLOT(checkPasswords()));
    connect(btnCancel,SIGNAL(clicked()),this,SLOT(close()));
    connect(btnConfirm,SIGNAL(clicked()),this,SLOT(changePassword()));
}
void PasswordChangeDialog::changePassword()
{
    QString opw = lineCurPas->text().trimmed();
    QString npw = linePass1->text().trimmed();

    if(!psqlSessionIsAdmin()){
        if(!psqlAuthenticate(m_role,opw)){
            QMessageBox::critical(this,tr("Error"),tr("La contrasena que introdujo es incorrecta.\nNingun cambio."));
            linePass1->clear();
            linePass2->clear();
            lineCurPas->selectAll();
            lineCurPas->setFocus();
            checkPasswords();
            return;
        }
    }

    setControlsEnabled(false);
    bool changed = psqlSetPassword(m_role,npw);
    setControlsEnabled(true);

    if(changed){
        QTimer::singleShot(0,this,SLOT(accept()));
    }else{
        QMessageBox::warning(this,tr("Error"),tr("Ocurrio un error intentando cambiar la contrasena.\nPor favor, intenta otra vez."));
    }
}
MasterPasswordDialog::MasterPasswordDialog(QWidget *parent)
  : QDialog(parent)
  , ui(new Ui::MasterPasswordDialog)
  , d_ptr(new MasterPasswordDialogPrivate)
{
  ui->setupUi(this);
  setWindowIcon(QIcon(":/images/ctSESAM.ico"));
  ui->infoLabel->setStyleSheet("font-weight: bold");
  setWindowTitle(QString("%1 %2").arg(AppName).arg(isPortable() ? " - PORTABLE" : ""));
  QObject::connect(ui->okPushButton, SIGNAL(pressed()), SLOT(okClicked()));
  QObject::connect(ui->passwordLineEdit, SIGNAL(textEdited(QString)), SLOT(checkPasswords()));
  QObject::connect(ui->repeatPasswordLineEdit, SIGNAL(textEdited(QString)), SLOT(checkPasswords()));
  setRepeatPassword(false);
  invalidatePassword();
  checkPasswords();
  resize(width(), 1);
}
void MasterPasswordDialog::setRepeatPassword(bool doRepeat)
{
  Q_D(MasterPasswordDialog);
  d->repeatedPasswordEntry = doRepeat;
  if (doRepeat) {
    invalidatePassword();
    ui->infoLabel->setText(tr("New master password"));
    ui->repeatPasswordLineEdit->show();
    ui->repeatPasswordLabel->show();
    ui->strengthLabel->show();
  }
  else {
    ui->infoLabel->setText(tr("Enter master password"));
    ui->repeatPasswordLineEdit->hide();
    ui->repeatPasswordLabel->hide();
    ui->strengthLabel->hide();
  }
  checkPasswords();
}