From f9edd39bba64a0fd92c6e9820f3265618d2057fc Mon Sep 17 00:00:00 2001 From: a68366 Date: Sat, 14 May 2016 14:28:42 +0300 Subject: [PATCH 1/2] fix(profile): change password buttons behaviour Closes #3300 --- src/widget/form/profileform.cpp | 17 +++++++++++++++++ src/widget/form/profileform.h | 1 + 2 files changed, 18 insertions(+) diff --git a/src/widget/form/profileform.cpp b/src/widget/form/profileform.cpp index de0e679a0..524e5a3fe 100644 --- a/src/widget/form/profileform.cpp +++ b/src/widget/form/profileform.cpp @@ -122,6 +122,8 @@ ProfileForm::ProfileForm(QWidget *parent) : connect(bodyUI->logoutButton, &QPushButton::clicked, this, &ProfileForm::onLogoutClicked); connect(bodyUI->deletePassButton, &QPushButton::clicked, this, &ProfileForm::onDeletePassClicked); connect(bodyUI->changePassButton, &QPushButton::clicked, this, &ProfileForm::onChangePassClicked); + connect(bodyUI->deletePassButton, &QPushButton::clicked, this, &ProfileForm::setPasswordButtonsText); + connect(bodyUI->changePassButton, &QPushButton::clicked, this, &ProfileForm::setPasswordButtonsText); connect(bodyUI->saveQr, &QPushButton::clicked, this, &ProfileForm::onSaveQrClicked); connect(bodyUI->copyQr, &QPushButton::clicked, this, &ProfileForm::onCopyQrClicked); connect(bodyUI->toxmeRegisterButton, &QPushButton::clicked, this, &ProfileForm::onRegisterButtonClicked); @@ -389,6 +391,20 @@ void ProfileForm::onLogoutClicked() nexus.showLogin(); } +void ProfileForm::setPasswordButtonsText() +{ + if (!Nexus::getProfile()->isEncrypted()) + { + bodyUI->changePassButton->setText(tr("Set profile password", "button text")); + bodyUI->deletePassButton->setVisible(false); + } + else + { + bodyUI->changePassButton->setText(tr("Change password", "button text")); + bodyUI->deletePassButton->setVisible(true); + } +} + void ProfileForm::onCopyQrClicked() { QApplication::clipboard()->setImage(*qr->getImage()); @@ -444,6 +460,7 @@ void ProfileForm::retranslateUi() { bodyUI->retranslateUi(this); nameLabel->setText(tr("User Profile")); + setPasswordButtonsText(); // We have to add the toxId tooltip here and not in the .ui or Qt won't know how to translate it dynamically toxId->setToolTip(tr("This bunch of characters tells other Tox clients how to contact you.\nShare it with your friends to communicate.")); } diff --git a/src/widget/form/profileform.h b/src/widget/form/profileform.h index 288d62ca2..762124bf7 100644 --- a/src/widget/form/profileform.h +++ b/src/widget/form/profileform.h @@ -67,6 +67,7 @@ public slots: void onLogoutClicked(); private slots: + void setPasswordButtonsText(); void setToxId(const QString& id); void copyIdClicked(); void onUserNameEdited(); From c236b8a1d28e49b96dcef7ee3447cdf2ace6c0a8 Mon Sep 17 00:00:00 2001 From: a68366 Date: Sat, 14 May 2016 15:09:14 +0300 Subject: [PATCH 2/2] refactor(profile): reorder statements --- src/widget/form/profileform.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/widget/form/profileform.cpp b/src/widget/form/profileform.cpp index 524e5a3fe..176fda442 100644 --- a/src/widget/form/profileform.cpp +++ b/src/widget/form/profileform.cpp @@ -393,16 +393,16 @@ void ProfileForm::onLogoutClicked() void ProfileForm::setPasswordButtonsText() { - if (!Nexus::getProfile()->isEncrypted()) - { - bodyUI->changePassButton->setText(tr("Set profile password", "button text")); - bodyUI->deletePassButton->setVisible(false); - } - else + if (Nexus::getProfile()->isEncrypted()) { bodyUI->changePassButton->setText(tr("Change password", "button text")); bodyUI->deletePassButton->setVisible(true); } + else + { + bodyUI->changePassButton->setText(tr("Set profile password", "button text")); + bodyUI->deletePassButton->setVisible(false); + } } void ProfileForm::onCopyQrClicked()