代码语言:javascript复制
QGridLayout *mainLayout = new QGridLayout(this);
mainLayout->setSpacing(15);//设置按钮之间的距离
// 产品名称
mainLayout->addWidget(new QLabel(QStringLiteral("项目APP名称:"), this), 0, 0, 1, 1);
m_productNameEdit = new QLineEdit(this);
m_productNameEdit->setText("TestLicAPP");
mainLayout->addWidget(m_productNameEdit, 0, 1, 1, 5);
// 机器码
mainLayout->addWidget(new QLabel(QStringLiteral("随机码:"), this), 1, 0, 1, 1);
QRegExp rx("(A-Za-z0-9){4}(-(A-Za-z0-9){4}){3}");
QRegExpValidator *pReg = new QRegExpValidator(rx, this);
m_clientSignatureEdit = new QLineEdit(this);
m_clientSignatureEdit->setValidator(pReg);
//m_clientSignatureEdit->setInputMask("XXXX-XXXX-XXXX-XXXX;X");
// 获取机器码
PcSignature identifier_out;
FUNCTION_RETURN ret = generate_user_pc_signature(identifier_out, ETHERNET);
if (FUNC_RET_OK == ret) {
printf("机器码为:%sn", identifier_out);
}
else {
printf("获取机器码失败!n");
}
m_clientSignatureEdit->setText(QString(identifier_out));
mainLayout->addWidget(m_clientSignatureEdit, 1, 1, 1, 5);
// 有效期
mainLayout->addWidget(new QLabel(QStringLiteral("有效期:"), this), 2, 0, 1, 1);
m_beginDateEdit = new QDateEdit(QDate::currentDate(), this);
m_beginDateEdit->setCalendarPopup(true);
mainLayout->addWidget(m_beginDateEdit, 2, 1, 1, 1);
QLabel *label = new QLabel(QStringLiteral("至"), this);
label->setFixedWidth(20);
mainLayout->addWidget(label, 2, 2, 1, 1);
m_endDateEdit = new QDateEdit(QDate::currentDate().addMonths(1), this);
m_endDateEdit->setCalendarPopup(true);
mainLayout->addWidget(m_endDateEdit, 2, 3, 1, 1);
// Liscense输出目录
mainLayout->addWidget(new QLabel(QStringLiteral("受权输出:"), this), 3, 0, 1, 1);
m_outputFileNameEdit = new QLineEdit(QApplication::applicationDirPath() "/License.ini",this);
QPushButton *fileNameBtn = new QPushButton("...", this);
//fileNameBtn->setFixedWidth(48);
connect(fileNameBtn, &QPushButton::clicked, [this]() {
QString fileName = QFileDialog::getSaveFileName(this, QStringLiteral("Liscense另存为"), m_outputFileNameEdit->text(), ".lic");
if (!fileName.isEmpty()) {
m_outputFileNameEdit->setText(fileName);
}
});
// 输出签名
mainLayout->addWidget(new QLabel(QStringLiteral("加密签名输出:"), this), 4, 0, 1, 1);
signEdit = new QLineEdit(this);
//signEdit->setMaximumWidth(500);
mainLayout->addWidget(signEdit, 4, 1, 1, 5);
QWidget *subWidget = new QWidget(this);
QHBoxLayout *subLayout = new QHBoxLayout(subWidget);
subLayout->setMargin(0);
subLayout->addWidget(m_outputFileNameEdit);
subLayout->addWidget(fileNameBtn);
mainLayout->addWidget(subWidget, 3, 1, 1, 5);
//
m_buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Close, Qt::Horizontal, this);
m_buttonBox->button(QDialogButtonBox::Ok)->setText(QStringLiteral("确定"));
m_buttonBox->button(QDialogButtonBox::Close)->setText(QStringLiteral("关闭"));
connect(m_buttonBox, &QDialogButtonBox::accepted, this, &EngiLicenseGenerator::createLicense);
connect(m_buttonBox, &QDialogButtonBox::rejected, this, &EngiLicenseGenerator::close);
mainLayout->addWidget(m_buttonBox, 5, 1, 1, 5);