Refactor InputObject(EventFilter and VirtualKeyboard).
This commit is contained in:
@@ -4,22 +4,23 @@
|
||||
|
||||
#include <QVBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QtWidgets/QLineEdit>
|
||||
#include "components/ULineEdit.h"
|
||||
#include "models/User.h"
|
||||
#include "log/UserOperationLog.h"
|
||||
#include "ChangePasswordFormDialog.h"
|
||||
|
||||
ChangePasswordFormDialog::ChangePasswordFormDialog(QWidget* parent, Qt::WindowFlags f)
|
||||
: GUIFormBaseDialog(parent, f)
|
||||
, mLEPasswd(new QLineEdit(this))
|
||||
, mLENewPasswd(new QLineEdit(this))
|
||||
, mLEConfirmPasswd(new QLineEdit(this))
|
||||
, mLblError(new QLabel(this))
|
||||
: GUIFormBaseDialog(parent, f)
|
||||
, mLEPasswd(new ULineEdit(this))
|
||||
, mLENewPasswd(new ULineEdit(this))
|
||||
, mLEConfirmPasswd(new ULineEdit(this))
|
||||
, mLblError(new QLabel(this))
|
||||
{
|
||||
initLayout();
|
||||
}
|
||||
|
||||
void ChangePasswordFormDialog::initLayout() {
|
||||
void ChangePasswordFormDialog::initLayout()
|
||||
{
|
||||
auto layout = new QVBoxLayout(mFormWidget);
|
||||
layout->setSpacing(10);
|
||||
// add title
|
||||
@@ -67,33 +68,36 @@ void ChangePasswordFormDialog::initLayout() {
|
||||
}
|
||||
|
||||
|
||||
bool ChangePasswordFormDialog::updateReferenceData() {
|
||||
if (mLEPasswd->text().isEmpty())
|
||||
{
|
||||
mLblError->setText(tr("Please enter your old password!"));
|
||||
return false;
|
||||
}
|
||||
if (mLENewPasswd->text().length() < 6) {
|
||||
mLblError->setText(tr("New password should at least 6 characters!"));
|
||||
return false;
|
||||
}
|
||||
QString encryptPwd = User::getEncryptedPassword(mLEPasswd->text());
|
||||
if (encryptPwd != User::Current()->getPassword())
|
||||
{
|
||||
mLblError->setText(tr("Wrong password!"));
|
||||
return false;
|
||||
}
|
||||
if (mLENewPasswd->text() != mLEConfirmPasswd->text())
|
||||
{
|
||||
mLblError->setText(tr("Your new password does not match!"));
|
||||
return false;
|
||||
}
|
||||
User::Current()->setPassword(User::getEncryptedPassword(mLENewPasswd->text()));
|
||||
if (!User::Current()->submitChange()) {
|
||||
mLblError->setText(tr("Database update error!"));
|
||||
User::Current()->restorePassword(encryptPwd);
|
||||
return false;
|
||||
}
|
||||
LOG_USER_OPERATION(ChangePassword);
|
||||
return true;
|
||||
bool ChangePasswordFormDialog::updateReferenceData()
|
||||
{
|
||||
if (mLEPasswd->text().isEmpty())
|
||||
{
|
||||
mLblError->setText(tr("Please enter your old password!"));
|
||||
return false;
|
||||
}
|
||||
if (mLENewPasswd->text().length() < 6)
|
||||
{
|
||||
mLblError->setText(tr("New password should at least 6 characters!"));
|
||||
return false;
|
||||
}
|
||||
QString encryptPwd = User::getEncryptedPassword(mLEPasswd->text());
|
||||
if (encryptPwd != User::Current()->getPassword())
|
||||
{
|
||||
mLblError->setText(tr("Wrong password!"));
|
||||
return false;
|
||||
}
|
||||
if (mLENewPasswd->text() != mLEConfirmPasswd->text())
|
||||
{
|
||||
mLblError->setText(tr("Your new password does not match!"));
|
||||
return false;
|
||||
}
|
||||
User::Current()->setPassword(User::getEncryptedPassword(mLENewPasswd->text()));
|
||||
if (!User::Current()->submitChange())
|
||||
{
|
||||
mLblError->setText(tr("Database update error!"));
|
||||
User::Current()->restorePassword(encryptPwd);
|
||||
return false;
|
||||
}
|
||||
LOG_USER_OPERATION(ChangePassword);
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user