From 8178e71bce4b5c149857dd756eca137899b4f3a3 Mon Sep 17 00:00:00 2001
From: zhanmingkan <496160012@qq.com>
Date: 星期一, 11 五月 2026 13:51:14 +0800
Subject: [PATCH] 提交

---
 mainwindow.cpp |  542 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 542 insertions(+), 0 deletions(-)

diff --git a/mainwindow.cpp b/mainwindow.cpp
new file mode 100644
index 0000000..6b3d78a
--- /dev/null
+++ b/mainwindow.cpp
@@ -0,0 +1,542 @@
+锘�#include "mainwindow.h"
+#include "ui_mainwindow.h"
+#include "qaesencryption.h"
+
+#include <QClipboard>
+#include <QDateTime>
+#include <QDebug>
+#include <QFileDialog>
+#include <QMessageBox>
+#include <QProcess>
+
+MainWindow::MainWindow(QWidget *parent)
+    : QMainWindow(parent)
+    , ui(new Ui::MainWindow)
+{
+    ui->setupUi(this);
+    setFixedSize(680, 600);
+}
+
+MainWindow::~MainWindow()
+{
+    delete ui;
+}
+
+QString MainWindow::toUpperAndLower(QString src)
+{
+    for(int i = 0; i < src.count(); i++) {
+        QChar curC = src.at(i);
+        if(curC.isUpper()) {
+            curC = curC.toLower();
+        } else if(curC.isLower()){
+            curC = curC.toUpper();
+        }
+        src[i] = curC;
+    }
+    return src;
+}
+
+QString MainWindow::EncodebyBase64(const QString &src)//涓枃瀛楃杞琤yte64
+{
+    QByteArray text = src.toLocal8Bit();
+    QByteArray by = text.toBase64();
+    QString str = QString(by);
+    str = toUpperAndLower(str);
+    return str;
+}
+
+QString MainWindow::DecodebyBase64(const QString &src)
+{
+    QString str = toUpperAndLower(src); // 澶у皬鍐欒В瀵�
+    QByteArray text = str.toLocal8Bit();
+    QByteArray by = text.fromBase64(text);
+    return QString::fromLocal8Bit(by);
+}
+
+QString MainWindow::EncryptData(const QString &src, QCryptographicHash::Algorithm algo)
+{
+    //1.鍒涘缓鍔犲瘑瀵硅薄
+     QCryptographicHash hash(algo);
+     //2.鏀惧叆瑕佸姞鍏ョ殑鏁版嵁
+     hash.addData(src.toUtf8());
+     //3.鑾峰彇鍔犲瘑鐨勭粨鏋�
+     QByteArray  arr = hash.result();
+     QString result = arr.toHex();
+     return result;
+}
+
+QString MainWindow::AES_encryption(const QString &data, const QString &key)// AES鍔犲瘑
+{
+    //AES_128瑕佹眰key闀垮害16锛孉ES_192瑕佹眰key闀垮害24锛孉ES_256瑕佹眰key闀垮害32
+    QAESEncryption encryption(QAESEncryption::AES_256, QAESEncryption::ECB, QAESEncryption::PKCS7);
+    QByteArray enBA = encryption.encode(data.toUtf8(), key.toUtf8());
+    return QString::fromLatin1(enBA.toBase64());
+}
+
+QString MainWindow::AES_decryption(const QString &data, const QString &key)// AES瑙e瘑
+{
+    QAESEncryption encryption(QAESEncryption::AES_256, QAESEncryption::ECB, QAESEncryption::PKCS7);
+    QByteArray  enBA = QByteArray::fromBase64(data.toUtf8());
+    QByteArray deBA = encryption.decode(enBA, key.toUtf8());
+    return QString::fromLatin1(QAESEncryption::RemovePadding(deBA, QAESEncryption::PKCS7));
+}
+
+QString MainWindow::getEncrypt(const QString &data, QString key)
+{
+    QString str_encode_text;
+    QString b64code = EncodebyBase64(data);
+    QString hashkey64 = EncryptData(key,QCryptographicHash::Sha256);
+    QString hashkey32 = EncryptData(hashkey64,QCryptographicHash::Md5);
+    QString AEScode = AES_encryption(b64code,hashkey32);
+    str_encode_text = EncodebyBase64(AEScode);
+    return str_encode_text;
+}
+
+QString MainWindow::getDecrypt(const QString &data, QString key)
+{
+    QString decodedText;
+    QString b64result = DecodebyBase64(data);
+    QString hashkey64 = EncryptData(key,QCryptographicHash::Sha256);
+    QString hashkey32 = EncryptData(hashkey64,QCryptographicHash::Md5);
+    QString AESresult = AES_decryption(b64result,hashkey32);
+    decodedText = DecodebyBase64(AESresult);
+    return decodedText;
+}
+
+void MainWindow::changeUIstate()
+{
+    if(localinfo.Username==""){
+        ui->pushButton_accreditall->setEnabled(false);
+        ui->pushButton_accreditcell->setEnabled(false);
+        ui->pushButton_accreditaquifer->setEnabled(false);
+        ui->pushButton_accreditpipe->setEnabled(false);
+        ui->pushButton_accreditnetwork->setEnabled(false);
+        ui->pushButton_deaccreditall->setEnabled(false);
+        ui->pushButton_dateset->setEnabled(false);
+        ui->pushButton_adddate->setEnabled(false);
+        ui->pushButton_reducedate->setEnabled(false);
+        ui->pushButton_setversion->setEnabled(false);
+        ui->pushButton_setproid->setEnabled(false);
+        ui->lineEdit_setversion->setEnabled(false);
+        ui->lineEdit_setproid->setEnabled(false);
+
+        ui->lineEdit_basenum->setText("");
+        ui->lineEdit_baseuuid->setText("");
+        ui->lineEdit_biosnum->setText("");
+        ui->lineEdit_cpunum->setText("");
+        ui->lineEdit_username->setText("");
+        ui->lineEdit_date->setText("");
+        ui->label_iscell->setText("");
+        ui->label_isaquifer->setText("");
+        ui->label_ispipe->setText("");
+        ui->label_isnetwork->setText("");
+        ui->lineEdit_version->setText("");
+        ui->lineEdit_setversion->setText("");
+        ui->lineEdit_proid->setText("");
+        ui->lineEdit_setproid->setText("");
+    }else{
+        ui->pushButton_accreditall->setEnabled(true);
+        ui->pushButton_accreditcell->setEnabled(true);
+        ui->pushButton_accreditaquifer->setEnabled(true);
+        ui->pushButton_accreditpipe->setEnabled(true);
+        ui->pushButton_accreditnetwork->setEnabled(true);
+        ui->pushButton_deaccreditall->setEnabled(true);
+        ui->pushButton_dateset->setEnabled(true);
+        ui->pushButton_adddate->setEnabled(true);
+        ui->pushButton_reducedate->setEnabled(true);
+        ui->pushButton_setversion->setEnabled(true);
+        ui->pushButton_setproid->setEnabled(true);
+        ui->lineEdit_setversion->setEnabled(true);
+        ui->lineEdit_setproid->setEnabled(true);
+
+        ui->lineEdit_basenum->setText(localinfo.Baseboard_Serialnumber);
+        ui->lineEdit_baseuuid->setText(localinfo.Baseboard_Uuid);
+        ui->lineEdit_biosnum->setText(localinfo.Bios_Serialnumber);
+        ui->lineEdit_cpunum->setText(localinfo.CPU_Processorid);
+        ui->lineEdit_username->setText(localinfo.Username);
+        ui->lineEdit_date->setText(localinfo.LicensedDuration_end);
+        ui->lineEdit_version->setText(localinfo.Versionid);
+        ui->lineEdit_proid->setText(localinfo.Productid);
+        ui->label_iscell->setText(localinfo.IsEnabled_cell==0?QStringLiteral("鏈縺娲�"):QStringLiteral("宸叉縺娲�"));
+        ui->label_isaquifer->setText(localinfo.IsEnabled_aquifer==0?QStringLiteral("鏈縺娲�"):QStringLiteral("宸叉縺娲�"));
+        ui->label_ispipe->setText(localinfo.IsEnabled_pipe==0?QStringLiteral("鏈縺娲�"):QStringLiteral("宸叉縺娲�"));
+        ui->label_isnetwork->setText(localinfo.IsEnabled_network==0?QStringLiteral("鏈縺娲�"):QStringLiteral("宸叉縺娲�"));
+    }
+    if(licenseinfo.Username==""){
+        ui->lineEdit_basenum_2->setText("");
+        ui->lineEdit_baseuuid_2->setText("");
+        ui->lineEdit_biosnum_2->setText("");
+        ui->lineEdit_cpunum_2->setText("");
+        ui->lineEdit_username_2->setText("");
+        ui->lineEdit_date_2->setText("");
+        ui->label_iscell_2->setText("");
+        ui->label_isaquifer_2->setText("");
+        ui->label_ispipe_2->setText("");
+        ui->label_isnetwork_2->setText("");
+        ui->lineEdit_version_2->setText("");
+        ui->lineEdit_proid_2->setText("");
+    }else{
+        ui->lineEdit_basenum_2->setText(licenseinfo.Baseboard_Serialnumber);
+        ui->lineEdit_baseuuid_2->setText(licenseinfo.Baseboard_Uuid);
+        ui->lineEdit_biosnum_2->setText(licenseinfo.Bios_Serialnumber);
+        ui->lineEdit_cpunum_2->setText(licenseinfo.CPU_Processorid);
+        ui->lineEdit_username_2->setText(licenseinfo.Username);
+        ui->lineEdit_date_2->setText(licenseinfo.LicensedDuration_end);
+        ui->lineEdit_version_2->setText(licenseinfo.Versionid);
+        ui->lineEdit_setversion->setText(licenseinfo.Versionid);
+        ui->lineEdit_proid_2->setText(licenseinfo.Productid);
+        ui->lineEdit_setproid->setText(licenseinfo.Productid);
+        ui->label_iscell_2->setText(licenseinfo.IsEnabled_cell==0?QStringLiteral("鏈縺娲�"):QStringLiteral("宸叉縺娲�"));
+        ui->label_isaquifer_2->setText(licenseinfo.IsEnabled_aquifer==0?QStringLiteral("鏈縺娲�"):QStringLiteral("宸叉縺娲�"));
+        ui->label_ispipe_2->setText(licenseinfo.IsEnabled_pipe==0?QStringLiteral("鏈縺娲�"):QStringLiteral("宸叉縺娲�"));
+        ui->label_isnetwork_2->setText(licenseinfo.IsEnabled_network==0?QStringLiteral("鏈縺娲�"):QStringLiteral("宸叉縺娲�"));
+    }
+}
+
+void MainWindow::on_pushButton_decrypt_clicked()
+{
+    QString encryptlocalid = ui->textEdit_localid->toPlainText();
+    QString localid = getDecrypt(encryptlocalid,key);
+    QByteArray localidbyte = localid.toLocal8Bit();
+    QJsonParseError err_rpt;
+    QJsonDocument localidjsondoc(QJsonDocument::fromJson(localidbyte, &err_rpt));//瀛楃涓叉牸寮忓寲涓篔SON
+    if(err_rpt.error != QJsonParseError::NoError)
+    {
+        localinfo = LicenseInfo();
+        licenseinfo = LicenseInfo();
+        workingjsondoc = QJsonDocument();
+        ui->textEdit_licensekey->setPlainText("");
+        changeUIstate();
+        qDebug() << QStringLiteral("localid JSON鏍煎紡閿欒");
+        QMessageBox msgbox(QMessageBox::Information,QStringLiteral(""),QStringLiteral("瑙f瀽澶辫触锛屼笉鏄竴涓纭殑璁惧ID搴忓垪"),QMessageBox::Ok);
+        msgbox.setButtonText(QMessageBox::Ok,QStringLiteral("纭畾"));
+        msgbox.exec();
+    }
+    else    //JSON鏍煎紡姝g‘
+    {
+        QMessageBox msgbox(QMessageBox::Information,QStringLiteral(""),QStringLiteral("瑙f瀽鎴愬姛"),QMessageBox::Ok);
+        msgbox.setButtonText(QMessageBox::Ok,QStringLiteral("纭畾"));
+        msgbox.exec();
+        ui->textEdit_licensekey->setPlainText(ui->textEdit_localid->toPlainText());
+        workingjsondoc = QJsonDocument(QJsonDocument::fromJson(localidbyte));
+
+        QJsonObject localid_Obj = localidjsondoc.object();
+        localinfo.Baseboard_Serialnumber = localid_Obj.value("Baseboard_Serialnumber").toString();
+        localinfo.Baseboard_Uuid = localid_Obj.value("Baseboard_Uuid").toString();
+        localinfo.Bios_Serialnumber = localid_Obj.value("Bios_Serialnumber").toString();
+        localinfo.CPU_Processorid = localid_Obj.value("CPU_Processorid").toString();
+        localinfo.Username = localid_Obj.value("Username").toString();
+        localinfo.IsEnabled_cell = localid_Obj.value("IsEnabled_cell").toInt();
+        localinfo.IsEnabled_aquifer = localid_Obj.value("IsEnabled_aquifer").toInt();
+        localinfo.IsEnabled_pipe = localid_Obj.value("IsEnabled_pipe").toInt();
+        localinfo.IsEnabled_network = localid_Obj.value("IsEnabled_network").toInt();
+        localinfo.LicensedDuration_end = localid_Obj.value("LicensedDuration_end").toString();
+        localinfo.LicensedDuration_start = localid_Obj.value("LicensedDuration_start").toString();
+        localinfo.Productid = localid_Obj.value("Productid").toString();
+        localinfo.Versionid = localid_Obj.value("Versionid").toString();
+
+        licenseinfo = LicenseInfo(localinfo);
+        changeUIstate();
+    }
+}
+
+void MainWindow::on_pushButton_accreditall_clicked()
+{
+    QJsonObject licensekey_Obj = workingjsondoc.object();
+    licensekey_Obj["IsEnabled_cell"] = 1;
+    licensekey_Obj["IsEnabled_aquifer"] = 1;
+    licensekey_Obj["IsEnabled_pipe"] = 1;
+    licensekey_Obj["IsEnabled_network"] = 1;
+    workingjsondoc.setObject(licensekey_Obj);
+    QByteArray jsonbytearray = workingjsondoc.toJson();
+    ui->textEdit_licensekey->setPlainText("");
+    ui->textEdit_licensekey->setPlainText(getEncrypt(QString(jsonbytearray),key));
+    setLicenseinfo(licensekey_Obj);
+}
+
+void MainWindow::on_pushButton_accreditcell_clicked()
+{
+    QJsonObject licensekey_Obj = workingjsondoc.object();
+    licensekey_Obj["IsEnabled_cell"] = 1;
+    workingjsondoc.setObject(licensekey_Obj);
+    QByteArray jsonbytearray = workingjsondoc.toJson();
+    ui->textEdit_licensekey->setPlainText("");
+    ui->textEdit_licensekey->setPlainText(getEncrypt(QString(jsonbytearray),key));
+    setLicenseinfo(licensekey_Obj);
+}
+
+void MainWindow::on_pushButton_accreditaquifer_clicked()
+{
+    QJsonObject licensekey_Obj = workingjsondoc.object();
+    licensekey_Obj["IsEnabled_aquifer"] = 1;
+    workingjsondoc.setObject(licensekey_Obj);
+    QByteArray jsonbytearray = workingjsondoc.toJson();
+    ui->textEdit_licensekey->setPlainText(getEncrypt(QString(jsonbytearray),key));
+    setLicenseinfo(licensekey_Obj);
+}
+
+void MainWindow::on_pushButton_accreditpipe_clicked()
+{
+    QJsonObject licensekey_Obj = workingjsondoc.object();
+    licensekey_Obj["IsEnabled_pipe"] = 1;
+    workingjsondoc.setObject(licensekey_Obj);
+    QByteArray jsonbytearray = workingjsondoc.toJson();
+    ui->textEdit_licensekey->setPlainText("");
+    ui->textEdit_licensekey->setPlainText(getEncrypt(QString(jsonbytearray),key));
+    setLicenseinfo(licensekey_Obj);
+}
+
+void MainWindow::on_pushButton_accreditnetwork_clicked()
+{
+    QJsonObject licensekey_Obj = workingjsondoc.object();
+    licensekey_Obj["IsEnabled_network"] = 1;
+    workingjsondoc.setObject(licensekey_Obj);
+    QByteArray jsonbytearray = workingjsondoc.toJson();
+    ui->textEdit_licensekey->setPlainText("");
+    ui->textEdit_licensekey->setPlainText(getEncrypt(QString(jsonbytearray),key));
+    setLicenseinfo(licensekey_Obj);
+}
+
+void MainWindow::on_pushButton_deaccreditall_clicked()
+{
+    QJsonObject licensekey_Obj = workingjsondoc.object();
+    licensekey_Obj["IsEnabled_cell"] = 0;
+    licensekey_Obj["IsEnabled_aquifer"] = 0;
+    licensekey_Obj["IsEnabled_pipe"] = 0;
+    licensekey_Obj["IsEnabled_network"] = 0;
+    workingjsondoc.setObject(licensekey_Obj);
+    QByteArray jsonbytearray = workingjsondoc.toJson();
+    ui->textEdit_licensekey->setPlainText("");
+    ui->textEdit_licensekey->setPlainText(getEncrypt(QString(jsonbytearray),key));
+    setLicenseinfo(licensekey_Obj);
+}
+
+void MainWindow::on_pushButton_copykey_clicked()
+{
+    QClipboard* clip = QApplication::clipboard();
+    clip->setText(ui->textEdit_licensekey->toPlainText());
+    QMessageBox msgbox(QMessageBox::Information,tr(""),QStringLiteral("澶嶅埗鎴愬姛"),QMessageBox::Ok);
+    msgbox.setButtonText(QMessageBox::Ok,QStringLiteral("纭畾"));
+    msgbox.exec();
+}
+
+void MainWindow::on_pushButton_clicked()
+{
+    if(ui->dockWidget->isHidden()){
+        ui->dockWidget->show();
+        setFixedSize(680, 600);
+    }else{
+        ui->dockWidget->hide();
+        setFixedSize(340, 600);
+    }
+}
+
+void MainWindow::setLicenseinfo(const QJsonObject licensekey_Obj)
+{
+    licenseinfo.Baseboard_Serialnumber = licensekey_Obj.value("Baseboard_Serialnumber").toString();
+    licenseinfo.Baseboard_Uuid = licensekey_Obj.value("Baseboard_Uuid").toString();
+    licenseinfo.Bios_Serialnumber = licensekey_Obj.value("Bios_Serialnumber").toString();
+    licenseinfo.CPU_Processorid = licensekey_Obj.value("CPU_Processorid").toString();
+    licenseinfo.Username = licensekey_Obj.value("Username").toString();
+    licenseinfo.IsEnabled_cell = licensekey_Obj.value("IsEnabled_cell").toInt();
+    licenseinfo.IsEnabled_aquifer = licensekey_Obj.value("IsEnabled_aquifer").toInt();
+    licenseinfo.IsEnabled_pipe = licensekey_Obj.value("IsEnabled_pipe").toInt();
+    licenseinfo.IsEnabled_network = licensekey_Obj.value("IsEnabled_network").toInt();
+    licenseinfo.LicensedDuration_end = licensekey_Obj.value("LicensedDuration_end").toString();
+    licenseinfo.LicensedDuration_start = licensekey_Obj.value("LicensedDuration_start").toString();
+    licenseinfo.Productid = licensekey_Obj.value("Productid").toString();
+    licenseinfo.Versionid = licensekey_Obj.value("Versionid").toString();
+    changeUIstate();
+}
+
+QString MainWindow::getLocalID()
+{
+    QString localid = "";
+    LicenseInfo localinfo;
+    //鏌ヨ绯荤粺鐢ㄦ埛鍚�
+    localinfo.Username = qgetenv("USER"); // Linux绯荤粺
+    if (localinfo.Username.isEmpty())
+        localinfo.Username = qgetenv("USERNAME"); // Windows绯荤粺
+    //鏌ヨCPU搴忓垪鍙�
+    localinfo.CPU_Processorid = getWindowsInfo("wmic cpu get processorid");
+    //鏌ヨ涓绘澘搴忓垪鍙�
+    localinfo.Baseboard_Serialnumber = getWindowsInfo("wmic baseboard get serialnumber");
+    //鏌ヨBIOS搴忓垪鍙�
+    localinfo.Bios_Serialnumber = getWindowsInfo("wmic bios get serialnumber");
+    //鏌ヨ涓绘澘鍞竴鏍囪瘑
+    localinfo.Baseboard_Uuid = getWindowsInfo("wmic csproduct get uuid");
+
+    QJsonDocument json_doc;//鍒涘缓json鏂囦欢
+    QJsonObject json_obj;//鍒涘缓json瀵硅薄
+    json_obj.insert("Username",localinfo.Username);
+    json_obj.insert("CPU_Processorid",localinfo.CPU_Processorid);
+    json_obj.insert("Bios_Serialnumber",localinfo.Bios_Serialnumber);
+    json_obj.insert("Baseboard_Serialnumber",localinfo.Baseboard_Serialnumber);
+    json_obj.insert("Baseboard_Uuid",localinfo.Baseboard_Uuid);
+    json_obj.insert("IsEnabled_cell",localinfo.IsEnabled_cell);
+    json_obj.insert("IsEnabled_aquifer",localinfo.IsEnabled_aquifer);
+    json_obj.insert("IsEnabled_pipe",localinfo.IsEnabled_pipe);
+    json_obj.insert("IsEnabled_network",localinfo.IsEnabled_network);
+    json_obj.insert("LicensedDuration_start",localinfo.LicensedDuration_start);
+    json_obj.insert("LicensedDuration_end",localinfo.LicensedDuration_end);
+    json_obj.insert("Productid",localinfo.Productid);
+    json_obj.insert("Versionid",localinfo.Versionid);
+    json_doc.setObject(json_obj);//灏唈son瀵硅薄杞负json鏂囦欢
+    QByteArray jsonbytearray = json_doc.toJson();
+    localid = QString(jsonbytearray);
+    return localid;
+}
+
+QString MainWindow::getWindowsInfo(const QString &cmd)
+{
+    QProcess p;				//鍚姩澶栭儴绋嬪簭
+    p.start(cmd);			//涓�浣撳紡鍚姩锛屼笉鍒嗙锛屼富绋嬪簭閫�鍑哄垯鍚姩绋嬪簭閫�鍑�,浣跨敤close鍏抽棴
+    //p.startDetached(cmd)	//鍒嗙寮忓惎鍔紝涓荤▼搴忛��鍑哄悗锛屽閮ㄧ▼搴忕户缁繍琛屻��
+    p.waitForFinished(-1);	//瓒呮椂绛夊緟锛岃缃负-1锛岀洿鍒版墽琛屽畬鎴愩��
+    QString result = QString::fromLocal8Bit(p.readAllStandardOutput());
+    QStringList list = cmd.split(" ");
+    result = result.remove(list.last(), Qt::CaseInsensitive);
+    result = result.replace("\r", "");
+    result = result.replace("\n", "");
+    result = result.simplified();
+    p.close();
+    return result;
+}
+
+
+void MainWindow::on_pushButton_getId_clicked()
+{
+    QString localid = getLocalID();
+    QString encryptid = getEncrypt(localid,key);
+    ui->textEdit_localid->setText(encryptid);
+
+    localinfo = LicenseInfo();
+    licenseinfo = LicenseInfo();
+    workingjsondoc = QJsonDocument();
+    ui->textEdit_licensekey->setPlainText("");
+    changeUIstate();
+}
+
+void MainWindow::on_pushButton_import_clicked()
+{
+    QString filename = QFileDialog::getOpenFileName(this,QStringLiteral("瀵煎叆瀵嗛挜"),"","TXT(*.txt)");
+    if ( filename.isEmpty() )
+        return;
+
+    QFile file(filename);
+
+    if(!file.exists()){
+        QMessageBox msgBox(QMessageBox::Information, QStringLiteral("璀﹀憡"), QStringLiteral("鏂囦欢涓嶅瓨鍦紒"));
+        msgBox.setButtonText(QMessageBox::Yes,QStringLiteral("纭畾"));
+        msgBox.exec();
+        return;
+    }
+
+    if (!file.open(QIODevice::ReadOnly | QIODevice::Text)){
+        QMessageBox msgBox(QMessageBox::Information, QStringLiteral("璀﹀憡"), QStringLiteral("鏃犳硶鎵撳紑鏂囦欢锛�"));
+        msgBox.setButtonText(QMessageBox::Yes,QStringLiteral("纭畾"));
+        msgBox.exec();
+        return;
+    }
+    ui->textEdit_localid->setPlainText("");
+    QTextStream stream(&file);
+    while (!stream.atEnd()) {
+        QString str = stream.readLine();
+        ui->textEdit_localid->setPlainText(ui->textEdit_localid->toPlainText()+str);
+    }
+    file.close();
+}
+
+void MainWindow::on_pushButton_export_clicked()
+{
+    QString filepath = QFileDialog::getSaveFileName(this, QStringLiteral("瀵煎嚭鏂囨湰"),
+                                                    "/license", tr("TXT(*.txt)"));
+    if(filepath.split(".").last()=="txt")
+    {
+        QTextEdit textEdit;
+        textEdit.append(ui->textEdit_licensekey->toPlainText());
+
+        QFile file(filepath);
+        if(file.open(QFile::WriteOnly | QIODevice::Text))
+        {
+            QTextStream ts(&file);
+            //ts.setCodec("UTF-8");
+            ts<<textEdit.document()->toPlainText();
+            file.close();
+            QMessageBox msgbox(QMessageBox::Information,QStringLiteral("鎻愮ず"),QStringLiteral("瀵煎嚭鎴愬姛"));
+            msgbox.setButtonText(QMessageBox::Yes,QStringLiteral("纭畾"));
+            msgbox.exec();
+        }
+    }
+}
+
+void MainWindow::on_pushButton_dateset_clicked()
+{
+    QJsonObject licensekey_Obj = workingjsondoc.object();
+    QDateTime currentdate = QDateTime::currentDateTime();
+    QString currentdatestr = currentdate.toString("yyyy-MM-dd hh:mm:ss");
+    licensekey_Obj["LicensedDuration_end"] = currentdatestr;
+    workingjsondoc.setObject(licensekey_Obj);
+    QByteArray jsonbytearray = workingjsondoc.toJson();
+    ui->textEdit_licensekey->setPlainText("");
+    ui->textEdit_licensekey->setPlainText(getEncrypt(QString(jsonbytearray),key));
+    setLicenseinfo(licensekey_Obj);
+}
+
+void MainWindow::on_pushButton_adddate_clicked()
+{
+    QJsonObject licensekey_Obj = workingjsondoc.object();
+    QDateTime licensedate = QDateTime::fromString(licensekey_Obj["LicensedDuration_end"].toString(),"yyyy-MM-dd hh:mm:ss");
+    if(licensedate.isNull()){
+        qDebug()<<"licenseTime is Null";
+        licensedate = QDateTime::currentDateTime();
+    }
+    QDateTime newlicensedate = licensedate.addMonths(1);
+    QString licensedatestr = newlicensedate.toString("yyyy-MM-dd hh:mm:ss");
+    licensekey_Obj["LicensedDuration_end"] = licensedatestr;
+    workingjsondoc.setObject(licensekey_Obj);
+    QByteArray jsonbytearray = workingjsondoc.toJson();
+    ui->textEdit_licensekey->setPlainText("");
+    ui->textEdit_licensekey->setPlainText(getEncrypt(QString(jsonbytearray),key));
+    setLicenseinfo(licensekey_Obj);
+}
+
+void MainWindow::on_pushButton_reducedate_clicked()
+{
+    QJsonObject licensekey_Obj = workingjsondoc.object();
+    QDateTime licensedate = QDateTime::fromString(licensekey_Obj["LicensedDuration_end"].toString(),"yyyy-MM-dd hh:mm:ss");
+    if(licensedate.isNull()){
+        qDebug()<<"licenseTime is Null";
+        licensedate = QDateTime::currentDateTime();
+    }
+    QDateTime newlicensedate = licensedate.addMonths(-1);
+    QString licensedatestr = newlicensedate.toString("yyyy-MM-dd hh:mm:ss");
+    licensekey_Obj["LicensedDuration_end"] = licensedatestr;
+    workingjsondoc.setObject(licensekey_Obj);
+    QByteArray jsonbytearray = workingjsondoc.toJson();
+    ui->textEdit_licensekey->setPlainText("");
+    ui->textEdit_licensekey->setPlainText(getEncrypt(QString(jsonbytearray),key));
+    setLicenseinfo(licensekey_Obj);
+}
+
+void MainWindow::on_pushButton_setproid_clicked()
+{
+    QJsonObject licensekey_Obj = workingjsondoc.object();
+    licensekey_Obj["Productid"] = ui->lineEdit_setproid->text();
+    workingjsondoc.setObject(licensekey_Obj);
+    QByteArray jsonbytearray = workingjsondoc.toJson();
+    ui->textEdit_licensekey->setPlainText("");
+    ui->textEdit_licensekey->setPlainText(getEncrypt(QString(jsonbytearray),key));
+    setLicenseinfo(licensekey_Obj);
+}
+
+void MainWindow::on_pushButton_setversion_clicked()
+{
+    QJsonObject licensekey_Obj = workingjsondoc.object();
+    licensekey_Obj["Versionid"] = ui->lineEdit_setversion->text();
+    workingjsondoc.setObject(licensekey_Obj);
+    QByteArray jsonbytearray = workingjsondoc.toJson();
+    ui->textEdit_licensekey->setPlainText("");
+    ui->textEdit_licensekey->setPlainText(getEncrypt(QString(jsonbytearray),key));
+    setLicenseinfo(licensekey_Obj);
+}

--
Gitblit v1.9.1