2026-09-08 17:08:58 +08:00
|
|
|
#include "MainWindow.h"
|
|
|
|
|
|
|
|
|
|
#include <QApplication>
|
|
|
|
|
#include <QCryptographicHash>
|
|
|
|
|
#include <QFile>
|
|
|
|
|
#include <QFont>
|
|
|
|
|
#include <QLabel>
|
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
|
|
|
|
|
|
#include "../Common/ConfigHelper.h"
|
|
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
|
|
QString configValue(const QString& key, const QString& fallback = QString())
|
|
|
|
|
{
|
|
|
|
|
const QString value = ConfigHelper::instance().getValue(QString(), key).trimmed();
|
|
|
|
|
return value.isEmpty() ? fallback : value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString readDllVersion(const QString& dllPath)
|
|
|
|
|
{
|
|
|
|
|
QFile file(dllPath);
|
|
|
|
|
if (!file.exists())
|
|
|
|
|
return QStringLiteral("missing");
|
|
|
|
|
|
|
|
|
|
if (!file.open(QIODevice::ReadOnly))
|
|
|
|
|
return QStringLiteral("unreadable");
|
|
|
|
|
|
|
|
|
|
const QByteArray data = file.read(1024);
|
|
|
|
|
file.close();
|
|
|
|
|
return QString::fromUtf8(QCryptographicHash::hash(data, QCryptographicHash::Sha256).toHex().left(8));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
|
|
MainWindow::MainWindow(QWidget* parent)
|
|
|
|
|
: QWidget(parent)
|
|
|
|
|
{
|
|
|
|
|
this->setWindowTitle("SimCAE Demo MainApp");
|
|
|
|
|
this->resize(600, 400);
|
|
|
|
|
|
|
|
|
|
const QString appVersion = configValue(QStringLiteral("current_version"), QStringLiteral("unknown"));
|
|
|
|
|
const QString product = configValue(QStringLiteral("product_code"),
|
|
|
|
|
configValue(QStringLiteral("app_id"), QStringLiteral("unknown")));
|
|
|
|
|
const QString channel = configValue(QStringLiteral("channel"), QStringLiteral("stable"));
|
|
|
|
|
const QString apiBaseUrl = configValue(QStringLiteral("api_base_url"), QStringLiteral("not configured"));
|
|
|
|
|
const QString tokenState = configValue(QStringLiteral("client_token")).isEmpty()
|
|
|
|
|
? QStringLiteral("missing")
|
|
|
|
|
: QStringLiteral("configured");
|
|
|
|
|
const QString dllVersion = readDllVersion(QApplication::applicationDirPath() + "/plugins/demo_plugin.dll");
|
|
|
|
|
|
|
|
|
|
QVBoxLayout* layout = new QVBoxLayout(this);
|
|
|
|
|
QLabel* label = new QLabel(QString(
|
|
|
|
|
"Software Running Successfully\n"
|
|
|
|
|
"Product: %1\n"
|
|
|
|
|
"Version: %2\n"
|
|
|
|
|
"Channel: %3\n"
|
|
|
|
|
"Server: %4\n"
|
|
|
|
|
"Update Client Token: %5\n"
|
|
|
|
|
"DLL Version: %6")
|
|
|
|
|
.arg(product, appVersion, channel, apiBaseUrl, tokenState, dllVersion));
|
|
|
|
|
QFont font = label->font();
|
|
|
|
|
font.setPointSize(13);
|
|
|
|
|
label->setFont(font);
|
|
|
|
|
label->setAlignment(Qt::AlignCenter);
|
|
|
|
|
|
|
|
|
|
layout->addWidget(label);
|
|
|
|
|
this->setLayout(layout);
|
|
|
|
|
}
|