Commit d048d17e authored by Olivier SOLDANO's avatar Olivier SOLDANO Committed by Anthony Léonard

enable account password change

add the ui to change password of an account in account details.

Change-Id: Ib7ccfb6632bd01bc6bcf9d84a23b90785a20038c
Reviewed-by: default avatarAnthony Léonard <anthony.leonard@savoirfairelinux.com>
parent 1cd9617a
......@@ -37,6 +37,7 @@ AccountDetails::AccountDetails(QWidget *parent) :
currentAccount_(nullptr)
{
ui->setupUi(this);
resetPasswordChangeUI();
setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
......@@ -93,6 +94,7 @@ AccountDetails::setAccount(Account* currentAccount) {
}
currentAccount_ = currentAccount;
resetPasswordChangeUI();
if (currentAccount_ == nullptr)
return;
......@@ -398,3 +400,81 @@ void AccountDetails::handle_nameRegistrationEnded(NameDirectory::RegisterNameSta
}
}
void
AccountDetails::on_changePassBtn_clicked()
{
ui->oldPasswordLabel->show();
ui->oldPasswordLineEdit->show();
ui->oldPasswordLabel->setEnabled(currentAccount_->archiveHasPassword());
ui->oldPasswordLineEdit->setEnabled(currentAccount_->archiveHasPassword());
ui->newPasswordLabel->show();
ui->newPasswordLineEdit->show();
ui->newPassConfirmationLabel->show();
ui->newPassConfirmationLineEdit->show();
ui->changePassBtn->hide();
ui->confirmChangeBtn->show();
ui->cancelChangeBtn->show();
}
void
AccountDetails::on_confirmChangeBtn_clicked()
{
ui->oldPasswordLineEdit->setStyleSheet("border-color: rgb(0, 192, 212);");
if (ui->newPassConfirmationLineEdit->text() == ui->newPasswordLineEdit->text()) {
ui->changePassInfo->show();
ui->changePassInfo->setText("Changing password ...");
// reset border stylesheet
ui->newPassConfirmationLineEdit->setStyleSheet("border-color: rgb(0, 192, 212);");
ui->newPasswordLineEdit->setStyleSheet("border-color: rgb(0, 192, 212);");
if (currentAccount_->changePassword(ui->oldPasswordLineEdit->text(), ui->newPasswordLineEdit->text())) {
resetPasswordChangeUI();
AccountModel::instance().save();
} else {
ui->oldPasswordLineEdit->setStyleSheet("border-color: rgb(204, 0, 0);");
ui->changePassInfo->setText("Wrong password");
}
} else {
// set borders red to show mismatch
ui->newPassConfirmationLineEdit->setStyleSheet("border-color: rgb(204, 0, 0);");
ui->newPasswordLineEdit->setStyleSheet("border-color: rgb(204, 0, 0);");
ui->changePassInfo->setText("New password and confirmation mismatched");
ui->changePassInfo->show();
}
}
void
AccountDetails::resetPasswordChangeUI()
{
ui->oldPasswordLabel->hide();
ui->oldPasswordLineEdit->clear();
ui->oldPasswordLineEdit->hide();
ui->oldPasswordLineEdit->setStyleSheet("border-color: rgb(0, 192, 212);");
ui->newPasswordLabel->hide();
ui->newPasswordLineEdit->clear();
ui->newPasswordLineEdit->hide();
ui->newPasswordLineEdit->setStyleSheet("border-color: rgb(0, 192, 212);");
ui->newPassConfirmationLabel->hide();
ui->newPassConfirmationLineEdit->clear();
ui->newPassConfirmationLineEdit->hide();
ui->newPassConfirmationLineEdit->setStyleSheet("border-color: rgb(0, 192, 212);");
ui->changePassBtn->show();
ui->confirmChangeBtn->hide();
ui->cancelChangeBtn->hide();
ui->changePassInfo->hide();
}
void AccountDetails::on_cancelChangeBtn_clicked()
{
resetPasswordChangeUI();
}
......@@ -66,6 +66,9 @@ private slots:
void videoCodecSelectionChanged(const QItemSelection& selected, const QItemSelection& deselected);
void exportOnRingEnded(Account::ExportOnRingStatus state, const QString& pin);
void handle_nameRegistrationEnded(NameDirectory::RegisterNameStatus status, const QString& name);
void on_changePassBtn_clicked();
void on_confirmChangeBtn_clicked();
void on_cancelChangeBtn_clicked();
private:
Ui::AccountDetails* ui;
......@@ -75,4 +78,5 @@ private:
QMap<QString, ACC_PTR > certMap_;
void stopRingtone();
void resetPasswordChangeUI();
};
This diff is collapsed.
......@@ -294,14 +294,15 @@ QPushButton#existingPushButton, QPushButton#newAccountButton, QPushButton#previo
QPushButton#cancelAddButton, QPushButton#exportOnRingButton, QPushButton#addDeviceButton, QPushButton#exportEndedOkButton,
QPushButton#errorPushButton, QPushButton#registerButton, QPushButton#sendContactRequestPageButton,
QPushButton#sendContactRequestButton, QPushButton#acceptCRButton, QPushButton#discardCRButton, QPushButton#deleteCancelBtn,
QPushButton#dhtImportBtn, QPushButton#fileImportBtn {
QPushButton#dhtImportBtn, QPushButton#fileImportBtn, QPushButton#changePassBtn, QPushButton#confirmChangeBtn {
background-color: #3AC0D2;
border: 0px;
color: white;
font: 14px;
}
QPushButton#blockCRButton, QPushButton#deleteAcceptBtn, QPushButton#debanButton, QPushButton#deleteButton, QPushButton#deleteBanBtn{
QPushButton#blockCRButton, QPushButton#deleteAcceptBtn, QPushButton#debanButton, QPushButton#deleteButton, QPushButton#deleteBanBtn,
QPushButton#cancelChangeBtn {
background-color: rgb(251, 72, 71);
border: 0px;
color: white;
......@@ -316,12 +317,13 @@ QPushButton#exportButton:hover, QPushButton#cancelAddButton:hover, QPushButton#e
QPushButton#addDeviceButton:hover, QPushButton#exportEndedOkButton:hover, QPushButton#errorPushButton:hover,
QPushButton#registerButton:hover, QPushButton#sendContactRequestPageButton:hover,
QPushButton#sendContactRequestButton:hover, QPushButton#acceptCRButton:hover, QPushButton#discardCRButton:hover,
QPushButton#deleteCancelBtn:hover, QPushButton#dhtImportBtn:hover, QPushButton#fileImportBtn:hover{
QPushButton#deleteCancelBtn:hover, QPushButton#dhtImportBtn:hover, QPushButton#fileImportBtn:hover,
QPushButton#changePassBtn:hover, QPushButton#confirmChangeBtn:hover{
background-color: #4dc6d6;
}
QPushButton#blockCRButton:hover, QPushButton#deleteAcceptBtn:hover, QPushButton#debanButton:hover,
QPushButton#deleteButton:hover, QPushButton#deleteBanBtn:hover{
QPushButton#deleteButton:hover, QPushButton#deleteBanBtn:hover, QPushButton#cancelChangeBtn:hover {
background-color: rgb(252, 91, 90);
}
......@@ -333,17 +335,19 @@ QPushButton#exportButton:pressed, QPushButton#cancelAddButton:pressed, QPushButt
QPushButton#addDeviceButton:pressed, QPushButton#exportEndedOkButton:pressed, QPushButton#errorPushButton:pressed,
QPushButton#registerButton:pressed, QPushButton#sendContactRequestPageButton:pressed,
QPushButton#sendContactRequestButton:pressed, QPushButton#acceptCRButton:pressed, QPushButton#discardCRButton:pressed,
QPushButton#deleteCancelBtn:pressed, QPushButton#dhtImportBtn:pressed, QPushButton#fileImportBtn:pressed{
QPushButton#deleteCancelBtn:pressed, QPushButton#dhtImportBtn:pressed, QPushButton#fileImportBtn:pressed,
QPushButton#changePassBtn:pressed, QPushButton#confirmChangeBtn:pressed {
background-color: #34acbd;
}
QPushButton#blockCRButton:pressed, QPushButton#deleteAcceptBtn:pressed, QPushButton#debanButton:pressed,
QPushButton#deleteBanBtn:pressed{
QPushButton#deleteBanBtn:pressed, QPushButton#cancelChangeBtn:pressed{
background-color: rgb(219, 55, 54);
}
QLineEdit#usernameEdit:enabled, QLineEdit#passwordEdit:enabled, QLineEdit#confirmPasswordEdit:enabled,
QLineEdit#pinEdit:enabled, QLineEdit#fullNameEdit:enabled, QLineEdit#archivePasswordInput:enabled {
QLineEdit#pinEdit:enabled, QLineEdit#fullNameEdit:enabled, QLineEdit#archivePasswordInput:enabled,
QLineEdit#oldPasswordLineEdit:enabled, QLineEdit#newPassConfirmationLineEdit:enabled, QLineEdit#newPasswordLineEdit:enabled{
border-color: rgb(0, 192, 212);
border-radius: 5px;
border-width: 1px;
......@@ -352,7 +356,8 @@ QLineEdit#pinEdit:enabled, QLineEdit#fullNameEdit:enabled, QLineEdit#archivePass
}
QLineEdit#usernameEdit:disabled, QLineEdit#passwordEdit:disabled, QLineEdit#confirmPasswordEdit:disabled,
QLineEdit#pinEdit:disabled, QLineEdit#fullNameEdit:disabled, QLineEdit#archivePasswordInput:disabled {
QLineEdit#pinEdit:disabled, QLineEdit#fullNameEdit:disabled, QLineEdit#archivePasswordInput:disabled,
QLineEdit#oldPasswordLineEdit:disabled{
border-color: rgb(159, 157, 154);
border-radius: 5px;
border-width: 1px;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment