You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

87 lines
2.1 KiB
C++

#include "qmodnamedlg.h"
#include "QAbstractButton"
#pragma execution_character_set("utf-8")
QModNamedlg::QModNamedlg(QWidget *parent)
: QDialog(parent)
{
ui.setupUi(this);
setWindowFlags(Qt::WindowCloseButtonHint);
setWindowIcon(QIcon(":/image/leaper"));
connect(ui.m_pbOK, SIGNAL(clicked()), this, SLOT(onAccess()));
connect(ui.m_pbCancel, SIGNAL(clicked()), this, SLOT(reject()));
}
QModNamedlg::~QModNamedlg()
{
}
void QModNamedlg::SetModelsStr(QStringList &m_listModels)
{
m_strlist = m_listModels;
}
void QModNamedlg::changeEvent(QEvent *event)
{
switch (event->type())
{
case QEvent::LanguageChange:
ui.retranslateUi(this);
break;
default:
break;
}
QDialog::changeEvent(event);
}
QString QModNamedlg::getNewModelName() const
{
QString str_name = ui.lineEdit_2->text();
if (str_name.isEmpty())
return QString();
else
return str_name;
}
void QModNamedlg::setOldModelName(QString m_str)
{
ui.lineEdit->setText(m_str);
}
void QModNamedlg::setPixmap(QString strPic){
QPixmap m_Pix(strPic);
if (m_Pix.isNull())
ui.label_Pic->setPixmap(QPixmap(":/image/none.jpg").scaled(200, 200));
else
ui.label_Pic->setPixmap(m_Pix.scaled(200, 200));
}
Q_SLOT void QModNamedlg::onAccess()
{
QString str_name = ui.lineEdit_2->text();
if (str_name.isEmpty())
{
onMessageBox(QMessageBox::Information, tr("提示"), tr("新型号名不能为空!"), 0);
return;
}
if (m_strlist.contains(str_name))
{
onMessageBox(QMessageBox::Information, tr("提示"), tr("型号库中已包含该型号,请重新设置型号名!"), 0);
return;
}
QDialog::accept();
}
bool QModNamedlg::onMessageBox(QMessageBox::Icon ntype, QString strTitle, QString strAtl, int onlyOK)
{
QMessageBox::StandardButton button = QMessageBox::Ok;
if (onlyOK == 1)
button = QMessageBox::Cancel;
QMessageBox infobox(ntype, strTitle, strAtl, QMessageBox::Ok | button, this);
infobox.setWindowIcon(QIcon(":/image/leaper"));
infobox.setButtonText(QMessageBox::Ok, tr("确认"));
infobox.setButtonText(QMessageBox::Cancel, tr("取消"));
return (infobox.exec() == QMessageBox::Ok);
}