code_app/app/scanner/dialog_feedback.cpp

70 lines
2.0 KiB
C++

#include "dialog_feedback.h"
#include "ui_dialog_feedback.h"
#include <QMessageBox>
Dialog_Feedback::Dialog_Feedback(class VersionDll *versionDll, QWidget *parent) :
QDialog(parent)
, ui(new Ui::Dialog_Feedback)
, m_versionDll(versionDll)
{
ui->setupUi(this);
setWindowTitle(tr("feedback"));
setWindowFlags(Qt::Dialog | Qt::WindowCloseButtonHint);
ui->textEdit->setPlaceholderText(tr("Please leave your valuable comments and suggestions (required field)."));
ui->lineEdit->setPlaceholderText(tr("Please leave your phone number, QQ or email address (required field)."));
}
Dialog_Feedback::~Dialog_Feedback()
{
delete ui;
}
void Dialog_Feedback::on_pbtn_submit_clicked()
{
const HGChar *oemName = nullptr;
#if defined(OEM_HANWANG)
oemName = HGVERSION_OEMNAME_HANVON;
#elif defined(OEM_LISICHENG)
oemName = HGVERSION_OEMNAME_LANXUM;
#elif defined(OEM_CANGTIAN)
oemName = HGVERSION_OEMNAME_CUMTENN;
#elif defined(OEM_ZHONGJING)
oemName = HGVERSION_OEMNAME_MICROTEK;
#elif defined(OEM_ZIGUANG)
oemName = HGVERSION_OEMNAME_UNIS;
#else
oemName = HGVERSION_OEMNAME_HUAGO;
#endif
QString feedback = ui->textEdit->toPlainText();
QString contact = ui->lineEdit->text();
if(ui->textEdit->document()->isEmpty())
{
QMessageBox::critical(this, tr("error"), tr("Comments and suggestions cannot be empty."));
return;
}
if(ui->lineEdit->text().isEmpty())
{
QMessageBox::critical(this, tr("error"), tr("The contact information column cannot be empty."));
return;
}
HGResult ret = m_versionDll->PostUserFeedback(HGVERSION_APPNAME_SCANNER, oemName, "feedback", feedback.toStdString().c_str(), contact.toStdString().c_str());
if(HGBASE_ERR_OK == ret)
{
QMessageBox::information(this, tr("tip"), tr("submit succeed."));
}
else
{
QMessageBox::critical(this, tr("error"), tr("submit failed."));
}
close();
}
void Dialog_Feedback::on_pbtn_cancel_clicked()
{
close();
}