#include "AppInfoWidget.h" #include #include #include #include #include #include #include static const QString buildTime = "2024年11月21日"; AppInfoWidget::AppInfoWidget(QWidget *parent) : QWidget(parent) { initilaize(); initLayout(); refresh(); } void AppInfoWidget::initilaize() { /// 图标,版本号,更新内容,构建时间,当前环境,版权声明 m_vBoxLayout = new QVBoxLayout(this); m_iconLabel = new QLabel(this); m_iconLabel->setFixedSize(QSize(50, 50)); m_iconLabel->setScaledContents(true); QPixmap pixmap = QPixmap(":/resource/logo.png"); pixmap.scaled(m_iconLabel->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation); m_iconLabel->setPixmap(pixmap); m_gridLayout = new QGridLayout(); m_verNameLabel = new QLabel("软件版本:", this); m_verValueLabel = new QLabel(this); m_contentNameLabel = new QLabel("更新内容:", this); m_contentValueLabel = new QLabel(this); m_dateNameLabel = new QLabel("构建时间:", this); m_dateValueLabel = new QLabel(this); m_envNameLabel = new QLabel("当前环境:", this); m_envValueLabel = new QLabel(this); m_copyRightLabel = new QLabel("Copyright © 2022", this); m_hBoxLayout = new QHBoxLayout(); m_confirmButton = new PushButton("确认", this); setStyleSheet("QLabel {font-size: 14px;font:Normal;font-family: 'Microsoft YaHei UI';}"); } void AppInfoWidget::initLayout() { m_vBoxLayout->setContentsMargins(20, 20, 20, 20); m_vBoxLayout->addStretch(); m_vBoxLayout->addWidget(m_iconLabel, 0, Qt::AlignHCenter); m_vBoxLayout->addSpacing(50); m_vBoxLayout->addLayout(m_gridLayout); m_gridLayout->setAlignment(Qt::AlignHCenter); m_gridLayout->addWidget(m_verNameLabel, 0, 0, 1, 1, Qt::AlignRight); m_gridLayout->addWidget(m_verValueLabel, 0, 1, 1, 1, Qt::AlignLeft); m_gridLayout->addWidget(m_contentNameLabel, 1, 0, 1, 1, Qt::AlignRight); m_gridLayout->addWidget(m_contentValueLabel, 1, 1, 1, 1, Qt::AlignLeft); m_gridLayout->addWidget(m_dateNameLabel, 2, 0, 1, 1, Qt::AlignRight); m_gridLayout->addWidget(m_dateValueLabel, 2, 1, 1, 1, Qt::AlignLeft); m_gridLayout->addWidget(m_envNameLabel, 3, 0, 1, 1, Qt::AlignRight); m_gridLayout->addWidget(m_envValueLabel, 3, 1, 1, 1, Qt::AlignLeft); m_vBoxLayout->addSpacing(30); m_vBoxLayout->addWidget(m_copyRightLabel, 0, Qt::AlignHCenter); m_vBoxLayout->addStretch(); m_vBoxLayout->addLayout(m_hBoxLayout); m_hBoxLayout->setAlignment(Qt::AlignRight); m_hBoxLayout->addWidget(m_confirmButton); } void AppInfoWidget::refresh() { m_verValueLabel->setText(qApp->applicationVersion()); m_contentValueLabel->setText("问题修复、功能改进"); m_dateValueLabel->setText("2024年11月21日"); m_envValueLabel->setText(SysInfoExt::getCpuName()); m_confirmButton->hide(); }