From d048d17e9ab9911156506cb995f3e33617f8553f Mon Sep 17 00:00:00 2001 From: Olivier SOLDANO <olivier.soldano@savoirfairelinux.com> Date: Thu, 28 Sep 2017 15:34:32 -0400 Subject: [PATCH] enable account password change MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit add the ui to change password of an account in account details. Change-Id: Ib7ccfb6632bd01bc6bcf9d84a23b90785a20038c Reviewed-by: Anthony Léonard <anthony.leonard@savoirfairelinux.com> --- accountdetails.cpp | 80 ++++++++++++++++++ accountdetails.h | 4 + accountdetails.ui | 206 ++++++++++++++++++++++++++++++++++++++++++--- stylesheet.css | 21 +++-- 4 files changed, 291 insertions(+), 20 deletions(-) diff --git a/accountdetails.cpp b/accountdetails.cpp index 8ce4e04..a536dd8 100644 --- a/accountdetails.cpp +++ b/accountdetails.cpp @@ -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(); +} diff --git a/accountdetails.h b/accountdetails.h index 3e28b35..f7f2e47 100644 --- a/accountdetails.h +++ b/accountdetails.h @@ -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(); }; diff --git a/accountdetails.ui b/accountdetails.ui index 6a8c94b..0e6e01c 100644 --- a/accountdetails.ui +++ b/accountdetails.ui @@ -100,8 +100,8 @@ <rect> <x>0</x> <y>0</y> - <width>843</width> - <height>726</height> + <width>829</width> + <height>912</height> </rect> </property> <layout class="QVBoxLayout" name="verticalLayout_12"> @@ -449,7 +449,7 @@ </property> </widget> </item> - <item row="4" column="0"> + <item row="12" column="0"> <widget class="QLabel" name="passwordLabel"> <property name="sizePolicy"> <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred"> @@ -473,7 +473,7 @@ </property> </widget> </item> - <item row="4" column="1"> + <item row="12" column="1"> <widget class="QLineEdit" name="lrcfg_password"> <property name="sizePolicy"> <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> @@ -495,7 +495,7 @@ </property> </widget> </item> - <item row="5" column="0"> + <item row="13" column="0"> <widget class="QLabel" name="proxyLabel"> <property name="sizePolicy"> <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred"> @@ -519,7 +519,7 @@ </property> </widget> </item> - <item row="5" column="1"> + <item row="13" column="1"> <widget class="QLineEdit" name="lrcfg_proxy"> <property name="sizePolicy"> <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> @@ -538,7 +538,7 @@ </property> </widget> </item> - <item row="6" column="0"> + <item row="14" column="0"> <widget class="QLabel" name="voicemailLabel"> <property name="sizePolicy"> <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred"> @@ -562,7 +562,7 @@ </property> </widget> </item> - <item row="6" column="1"> + <item row="14" column="1"> <widget class="QLineEdit" name="lrcfg_mailbox"> <property name="sizePolicy"> <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed"> @@ -581,7 +581,7 @@ </property> </widget> </item> - <item row="7" column="0"> + <item row="15" column="0"> <widget class="QCheckBox" name="lrcfg_autoAnswer"> <property name="font"> <font> @@ -599,7 +599,7 @@ </property> </widget> </item> - <item row="8" column="0"> + <item row="16" column="0"> <widget class="QCheckBox" name="lrcfg_upnpEnabled"> <property name="enabled"> <bool>true</bool> @@ -620,6 +620,188 @@ </property> </widget> </item> + <item row="4" column="1"> + <widget class="QLineEdit" name="oldPasswordLineEdit"> + <property name="minimumSize"> + <size> + <width>0</width> + <height>30</height> + </size> + </property> + <property name="toolTip"> + <string>Old password input line</string> + </property> + <property name="inputMask"> + <string/> + </property> + <property name="echoMode"> + <enum>QLineEdit::Password</enum> + </property> + <property name="placeholderText"> + <string>Input old password</string> + </property> + </widget> + </item> + <item row="4" column="0"> + <widget class="QLabel" name="oldPasswordLabel"> + <property name="font"> + <font> + <pointsize>11</pointsize> + </font> + </property> + <property name="styleSheet"> + <string notr="true">color: rgb(77, 77, 77);</string> + </property> + <property name="text"> + <string>Old Password</string> + </property> + </widget> + </item> + <item row="5" column="1"> + <widget class="QLineEdit" name="newPasswordLineEdit"> + <property name="minimumSize"> + <size> + <width>0</width> + <height>30</height> + </size> + </property> + <property name="toolTip"> + <string>New password text input</string> + </property> + <property name="echoMode"> + <enum>QLineEdit::Password</enum> + </property> + <property name="placeholderText"> + <string>Input new password</string> + </property> + </widget> + </item> + <item row="5" column="0"> + <widget class="QLabel" name="newPasswordLabel"> + <property name="font"> + <font> + <pointsize>11</pointsize> + <weight>50</weight> + <bold>false</bold> + </font> + </property> + <property name="styleSheet"> + <string notr="true">color: rgb(77, 77, 77);</string> + </property> + <property name="text"> + <string>New password</string> + </property> + </widget> + </item> + <item row="7" column="1"> + <widget class="QLineEdit" name="newPassConfirmationLineEdit"> + <property name="minimumSize"> + <size> + <width>0</width> + <height>30</height> + </size> + </property> + <property name="toolTip"> + <string>Password confirmation text input</string> + </property> + <property name="echoMode"> + <enum>QLineEdit::Password</enum> + </property> + <property name="placeholderText"> + <string>Input confirmation </string> + </property> + </widget> + </item> + <item row="7" column="0"> + <widget class="QLabel" name="newPassConfirmationLabel"> + <property name="font"> + <font> + <family>Cantarell</family> + <pointsize>11</pointsize> + </font> + </property> + <property name="styleSheet"> + <string notr="true">color: rgb(77, 77, 77);</string> + </property> + <property name="text"> + <string>New pass confirmation</string> + </property> + </widget> + </item> + <item row="9" column="1"> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <property name="topMargin"> + <number>0</number> + </property> + <item> + <widget class="QPushButton" name="changePassBtn"> + <property name="minimumSize"> + <size> + <width>0</width> + <height>30</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>500</width> + <height>100</height> + </size> + </property> + <property name="text"> + <string>Change password</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="confirmChangeBtn"> + <property name="minimumSize"> + <size> + <width>0</width> + <height>30</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>500</width> + <height>16777215</height> + </size> + </property> + <property name="text"> + <string>Ok</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="cancelChangeBtn"> + <property name="minimumSize"> + <size> + <width>0</width> + <height>30</height> + </size> + </property> + <property name="toolTip"> + <string>Cancel password change button</string> + </property> + <property name="text"> + <string>Cancel</string> + </property> + </widget> + </item> + </layout> + </item> + <item row="8" column="1"> + <widget class="QLabel" name="changePassInfo"> + <property name="styleSheet"> + <string notr="true">color: rgb(77, 77, 77);</string> + </property> + <property name="text"> + <string>Changing password ...</string> + </property> + <property name="alignment"> + <set>Qt::AlignCenter</set> + </property> + </widget> + </item> </layout> </item> <item> @@ -2034,7 +2216,7 @@ <property name="geometry"> <rect> <x>0</x> - <y>-34</y> + <y>0</y> <width>829</width> <height>760</height> </rect> @@ -2608,7 +2790,7 @@ <customwidget> <class>RingButton</class> <extends>QPushButton</extends> - <header location="global">ringbutton.h</header> + <header>ringbutton.h</header> </customwidget> <customwidget> <class>BannedContactsWidget</class> diff --git a/stylesheet.css b/stylesheet.css index 0a11cc4..b5d7c35 100644 --- a/stylesheet.css +++ b/stylesheet.css @@ -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; -- GitLab