78 lines
2.0 KiB
C++
78 lines
2.0 KiB
C++
|
#include "aboutdialog.h"
|
||
|
#include "ui_aboutdialog.h"
|
||
|
|
||
|
#include <QPixmap>
|
||
|
#include <QIcon>
|
||
|
#include <QPushButton>
|
||
|
#include <QStandardItemModel>
|
||
|
#include <QDate>
|
||
|
#include <QFont>
|
||
|
|
||
|
#define MAJOR_VERSION 1
|
||
|
#define MINOR_VERSION 0
|
||
|
#define BUILD_VERSION 0
|
||
|
|
||
|
AboutDialog::AboutDialog(QWidget *parent)
|
||
|
: QDialog(parent)
|
||
|
, ui(new Ui::AboutDialog)
|
||
|
{
|
||
|
ui->setupUi(this);
|
||
|
|
||
|
this->setWindowIcon(QIcon(":/images/icon.png"));
|
||
|
this->setWindowTitle(tr("About EMU Configurer Kit"));
|
||
|
|
||
|
QPixmap pixmap(":/images/hj-net.png");
|
||
|
pixmap = pixmap.scaled(250, 75, Qt::KeepAspectRatio, Qt::SmoothTransformation); // 按比例缩放
|
||
|
ui->label_logo->setPixmap(pixmap);
|
||
|
|
||
|
ui->buttonBox->clear();
|
||
|
QPushButton *okButton = ui->buttonBox->addButton(QDialogButtonBox::Ok);
|
||
|
okButton->setFixedSize(100, 30);
|
||
|
|
||
|
QFont font("Arial", 14, QFont::Bold);
|
||
|
ui->productName->setFont(font);
|
||
|
ui->productName->setText(QString(tr("Configurer Kit for EMU Host")));
|
||
|
|
||
|
QStandardItemModel *model = new QStandardItemModel(this);
|
||
|
|
||
|
QString version = QString(tr("Version %1.%2.%3")).arg(MAJOR_VERSION).arg(MINOR_VERSION).arg(BUILD_VERSION);
|
||
|
|
||
|
QString formattedDate;
|
||
|
QDate date = QDate::fromString(__DATE__, "MMM dd yyyy");
|
||
|
if (date.isValid())
|
||
|
{
|
||
|
formattedDate = date.toString("yyyy-MM-dd"); // 输出格式: 2024-11-12
|
||
|
formattedDate += QString(" %1").arg(__TIME__);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
formattedDate = "Invalid Date";
|
||
|
}
|
||
|
|
||
|
QString compileDate = QString(tr("Compiled on %1"))
|
||
|
.arg(formattedDate);
|
||
|
|
||
|
// 添加一些字符串到模型中
|
||
|
QStringList stringList;
|
||
|
stringList << version
|
||
|
<< compileDate;
|
||
|
|
||
|
// 将每个字符串作为 QStandardItem 添加到模型中
|
||
|
for (const QString &str : stringList)
|
||
|
{
|
||
|
QStandardItem *item = new QStandardItem(str);
|
||
|
model->appendRow(item);
|
||
|
}
|
||
|
|
||
|
// 将模型设置到 QListView
|
||
|
ui->listView->setModel(model);
|
||
|
|
||
|
setFixedSize(640, 480);
|
||
|
|
||
|
}
|
||
|
|
||
|
AboutDialog::~AboutDialog()
|
||
|
{
|
||
|
delete ui;
|
||
|
}
|