#include "aboutform.h"
#include "ui_aboutform.h"
#include "defines.h"
#include "global.h"

AboutForm::AboutForm(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::AboutForm)
{
    ui->setupUi(this);

    setWindowTitle("About");

    QPixmap pixmap(":/images/logo.png"); // 假设图片在资源文件中
    ui->labelLogo->setPixmap(pixmap);
    ui->labelLogo->resize(pixmap.size());

    //
    ui->labelTitle->setAlignment(Qt::AlignHCenter);
    ui->labelTitle->setText(QString("<p style=\"font-size: 18px;\">关于差示扫描量热仪数据分析软件</p>"));


    QString ConCompleTime = QString("%1 %2").arg(__DATE__).arg(__TIME__);

    QString aboutText = QString(
                "<p>软件版本：%1</p>"
                "<p>版权所有 © 2025 山东云唐智能科技有限公司 保留所有权</p>"
                "<br>"
                "<p style=\"font-size: 10px;\">本软件基于 Qt 框架开发，Qt 遵循 "
                "<a href='https://www.gnu.org/licenses/lgpl-3.0.html'>LGPL 协议</a>。</p>"
                "<p style=\"font-size: 10px;\">Qt 官网：<a href='https://www.qt.io'>www.qt.io</a></p>")
            .arg(qApp->applicationVersion());

    ui->labelContent->setAlignment(Qt::AlignTop | Qt::AlignLeft);
    ui->labelContent->setTextFormat(Qt::RichText);
    ui->labelContent->setText(aboutText);
    ui->labelContent->setStyleSheet("p { line-height: 1em; }");
    ui->labelContent->setOpenExternalLinks(true); // 允许用户点击链接

    ui->pushButtonClose->setToolTip(ConCompleTime);
}

AboutForm::~AboutForm()
{
    delete ui;
}

void AboutForm::on_pushButtonClose_clicked()
{
    hide();
}
