AppInfoWidget.cpp 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. #include "AppInfoWidget.h"
  2. #include <Widgets/Button.h>
  3. #include <helper/SysInfoExt.h>
  4. #include <QBoxLayout>
  5. #include <QGridLayout>
  6. #include <QLabel>
  7. #include <QApplication>
  8. #include <QPixmap>
  9. static const QString buildTime = "2024年11月22日";
  10. AppInfoWidget::AppInfoWidget(QWidget *parent) : QWidget(parent)
  11. {
  12. initilaize();
  13. initLayout();
  14. refresh();
  15. }
  16. void AppInfoWidget::initilaize()
  17. {
  18. /// 图标,版本号,更新内容,构建时间,当前环境,版权声明
  19. m_vBoxLayout = new QVBoxLayout(this);
  20. m_iconLabel = new QLabel(this);
  21. m_iconLabel->setFixedSize(QSize(50, 50));
  22. m_iconLabel->setScaledContents(true);
  23. QPixmap pixmap = QPixmap(":/resource/logo.png");
  24. pixmap.scaled(m_iconLabel->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
  25. m_iconLabel->setPixmap(pixmap);
  26. m_gridLayout = new QGridLayout();
  27. m_verNameLabel = new QLabel("软件版本:", this);
  28. m_verValueLabel = new QLabel(this);
  29. m_contentNameLabel = new QLabel("更新内容:", this);
  30. m_contentValueLabel = new QLabel(this);
  31. m_dateNameLabel = new QLabel("构建时间:", this);
  32. m_dateValueLabel = new QLabel(this);
  33. m_envNameLabel = new QLabel("当前环境:", this);
  34. m_envValueLabel = new QLabel(this);
  35. m_copyRightLabel = new QLabel("Copyright © 2022", this);
  36. m_hBoxLayout = new QHBoxLayout();
  37. m_confirmButton = new PushButton("确认", this);
  38. setStyleSheet("QLabel {font-size: 14px;font:Normal;font-family: 'Microsoft YaHei UI';}");
  39. }
  40. void AppInfoWidget::initLayout()
  41. {
  42. m_vBoxLayout->setContentsMargins(20, 20, 20, 20);
  43. m_vBoxLayout->addStretch();
  44. m_vBoxLayout->addWidget(m_iconLabel, 0, Qt::AlignHCenter);
  45. m_vBoxLayout->addSpacing(50);
  46. m_vBoxLayout->addLayout(m_gridLayout);
  47. m_gridLayout->setAlignment(Qt::AlignHCenter);
  48. m_gridLayout->addWidget(m_verNameLabel, 0, 0, 1, 1, Qt::AlignRight);
  49. m_gridLayout->addWidget(m_verValueLabel, 0, 1, 1, 1, Qt::AlignLeft);
  50. m_gridLayout->addWidget(m_contentNameLabel, 1, 0, 1, 1, Qt::AlignRight);
  51. m_gridLayout->addWidget(m_contentValueLabel, 1, 1, 1, 1, Qt::AlignLeft);
  52. m_gridLayout->addWidget(m_dateNameLabel, 2, 0, 1, 1, Qt::AlignRight);
  53. m_gridLayout->addWidget(m_dateValueLabel, 2, 1, 1, 1, Qt::AlignLeft);
  54. m_gridLayout->addWidget(m_envNameLabel, 3, 0, 1, 1, Qt::AlignRight);
  55. m_gridLayout->addWidget(m_envValueLabel, 3, 1, 1, 1, Qt::AlignLeft);
  56. m_vBoxLayout->addSpacing(30);
  57. m_vBoxLayout->addWidget(m_copyRightLabel, 0, Qt::AlignHCenter);
  58. m_vBoxLayout->addStretch();
  59. m_vBoxLayout->addLayout(m_hBoxLayout);
  60. m_hBoxLayout->setAlignment(Qt::AlignRight);
  61. m_hBoxLayout->addWidget(m_confirmButton);
  62. }
  63. void AppInfoWidget::refresh()
  64. {
  65. m_verValueLabel->setText(qApp->applicationVersion());
  66. m_contentValueLabel->setText("问题修复、功能改进");
  67. m_dateValueLabel->setText("2024年11月22日");
  68. m_envValueLabel->setText(SysInfoExt::getCpuName());
  69. m_confirmButton->hide();
  70. }