code_production/app/HGProductionTool/dialog_accountmanage.cpp

117 lines
3.1 KiB
C++
Raw Normal View History

2022-12-14 06:39:22 +00:00
#include "dialog_accountmanage.h"
#include "ui_dialog_accountmanage.h"
#include "dialog_rootfuntion.h"
#include "mainwindow.h"
#include <QMessageBox>
2023-08-31 02:50:43 +00:00
Dialog_accountManage::Dialog_accountManage(QWidget *parent) :
2022-12-14 06:39:22 +00:00
QDialog(parent),
ui(new Ui::Dialog_accountManage)
{
ui->setupUi(this);
setWindowFlags(Qt::Dialog | Qt::WindowCloseButtonHint);
2022-12-28 06:57:00 +00:00
QFont ft;
ft.setPointSize(15);
this->setFont(ft);
2022-12-14 06:39:22 +00:00
HGChar* userNameList[100];
HGUInt count = 0;
2023-08-31 02:50:43 +00:00
//HGPdtToolDb_GetUserList(pdtToolDbuserMgr, userNameList, 100, &count);
2022-12-14 06:39:22 +00:00
for (int i = 0; i < count; ++i)
{
ui->listWidget->addItem(QString(userNameList[i]));
}
ui->listWidget->setCurrentRow(0);
2023-08-31 02:50:43 +00:00
//HGPdtToolDb_ReleaseUserList(userNameList, count);
2022-12-14 06:39:22 +00:00
}
Dialog_accountManage::~Dialog_accountManage()
{
delete ui;
}
void Dialog_accountManage::on_pbtn_newAccount_clicked()
{
Dialog_rootFuntion dlg(false, this);
if (dlg.exec())
{
2023-08-31 02:50:43 +00:00
// HGResult ret = HGPdtToolDb_CreateUser(m_pdtToolDbuserMgr, dlg.getAccount().toStdString().c_str(), dlg.getPassword().toStdString().c_str());
// if (ret == HGBASE_ERR_OK)
// {
// ui->listWidget->addItem(dlg.getAccount());
// }
// else
// {
// QMessageBox::information(this, tr("tips"), tr("create user failed: ") + MainWindow::getLogInfo(ret));
// }
2022-12-14 06:39:22 +00:00
}
}
void Dialog_accountManage::on_pbtn_destroyAccount_clicked()
{
QString userName = ui->listWidget->currentItem()->text();
QMessageBox msg(QMessageBox::Question, tr("Question"),
tr("Are you sure to destroy: ") + userName,
QMessageBox::Yes | QMessageBox::No, this);
msg.setButtonText(QMessageBox::Yes, tr("yes"));
msg.setButtonText(QMessageBox::No, tr("no"));
msg.exec();
if (msg.clickedButton() == msg.button(QMessageBox::Yes))
{
2023-08-31 02:50:43 +00:00
// HGResult ret = HGPdtToolDb_DestroyUser(m_pdtToolDbuserMgr, userName.toStdString().c_str());
// if(ret == HGBASE_ERR_OK)
// {
// ui->listWidget->takeItem(ui->listWidget->currentRow());
// }
// else
// {
// QMessageBox::information(this, tr("tips"), tr("destroy user failed: ") + MainWindow::getLogInfo(ret));
// }
2022-12-14 06:39:22 +00:00
}
else
{
return;
}
}
void Dialog_accountManage::on_pbtn_changePwd_clicked()
{
Dialog_rootFuntion dlg(true, this);
if (dlg.exec())
{
QString userName = ui->listWidget->currentItem()->text();
2023-08-31 02:50:43 +00:00
// HGResult ret = HGPdtToolDb_SetPassword(m_pdtToolDbuserMgr, userName.toStdString().c_str(), dlg.getPassword().toStdString().c_str());
// if(ret == HGBASE_ERR_OK)
// {
// QMessageBox::information(this, tr("tips"), tr("change password succeed"));
// }
// else
// {
// QMessageBox::information(this, tr("tips"), tr("change password failed: ") + MainWindow::getLogInfo(ret));
// }
2022-12-14 06:39:22 +00:00
}
}
void Dialog_accountManage::on_pbtn_exit_clicked()
{
close();
}
void Dialog_accountManage::on_listWidget_itemDoubleClicked(QListWidgetItem *item)
{
(void)item;
on_pbtn_changePwd_clicked();
}