| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- #include "dialogchangepass.h"
- #include "ui_dialogchangepass.h"
- #include "wsnumchk.h"
- #include "respchangepass.h"
- #include <QtGui>
- DialogChangePass::DialogChangePass(QWidget *parent) :
- QDialog(parent),
- ui(new Ui::DialogChangePass)
- {
- ui->setupUi(this);
- ui->buttonBox->button(QDialogButtonBox::Ok)->setText("更改");
- ui->buttonBox->button(QDialogButtonBox::Cancel)->setText("关闭");
- }
- DialogChangePass::~DialogChangePass()
- {
- delete ui;
- }
- void DialogChangePass::setUserHash(QString userHash)
- {
- this->userHash = userHash;
- }
- void DialogChangePass::setHost(QString host)
- {
- this->host = host;
- }
- void DialogChangePass::on_buttonBox_accepted()
- {
- this->ui->buttonBox->setEnabled(false);
- WSNumChk *client = new WSNumChk(this->host);
- QString oldPass = this->ui->oldPassEdit->text();
- QString newPass = this->ui->newPassEdit->text();
- QString json = client->changePass(oldPass,newPass,this->userHash);
- bool ok = false;
- if(json.isEmpty())
- {
- QMessageBox::information(this,"结果","网络连接失败!",QMessageBox::Ok);
- }
- else
- {
- RespChangePass *response = new RespChangePass(json);
- if(response->getRtnCode()==1)
- {
- this->ui->oldPassEdit->setText("");
- this->ui->newPassEdit->setText("");
- this->ui->newPass2Edit->setText("");
- ok = true;
- QMessageBox::information(this,"结果","密码修改成功!",QMessageBox::Ok);
- }
- else if(response->getRtnCode()==-1)
- {
- QMessageBox::information(this,"结果","登录超时,请重新登录!",QMessageBox::Ok);
- }
- else
- {
- QMessageBox::information(this,"结果","发生错误,密码修改不成功!",QMessageBox::Ok);
- }
- delete response;
- }
- this->ui->buttonBox->setEnabled(true);
- if(ok)
- this->close();
- delete client;
- }
|