149 lines
5.4 KiB
C++
149 lines
5.4 KiB
C++
#include "aboutdialog.h"
|
|
#include "ui_aboutdialog.h"
|
|
#include <QVBoxLayout>
|
|
#include <QHBoxLayout>
|
|
#include <QPushButton>
|
|
#include <QLabel>
|
|
#include <QRegularExpression>
|
|
#include <QSizePolicy>
|
|
#include <QDesktopServices>
|
|
#include "xatom-helper.h"
|
|
#include "gsettingswrapper.h"
|
|
#include "./component/mylabel.h"
|
|
#include "../common/utils.h"
|
|
|
|
#define SUPPORT "<a href=\"mailto://support@kylinos.cn\">support@kylinos.cn</a>"
|
|
|
|
AboutDialog::AboutDialog(QWidget *parent) :
|
|
QDialog(parent),
|
|
ui(new Ui::AboutDialog)
|
|
{
|
|
ui->setupUi(this);
|
|
|
|
// 添加窗管协议
|
|
MotifWmHints hints;
|
|
hints.flags = MWM_HINTS_FUNCTIONS | MWM_HINTS_DECORATIONS;
|
|
hints.functions = MWM_FUNC_ALL;
|
|
hints.decorations = MWM_DECOR_BORDER;
|
|
XAtomHelper::getInstance()->setWindowMotifHint(winId(), hints);
|
|
|
|
// 设置背景色
|
|
this->setAutoFillBackground(true);
|
|
QPalette palette = this->palette();
|
|
palette.setColor(QPalette::Background, palette.color(QPalette::Base));
|
|
this->setPalette(palette);
|
|
|
|
this->setFixedWidth(420);
|
|
this->setMinimumHeight(420);
|
|
QSizePolicy sizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
|
|
this->setSizePolicy(sizePolicy);
|
|
|
|
// 顶行,关闭按钮
|
|
QPushButton *closeBtn = new QPushButton;
|
|
closeBtn->setToolTip(tr("Close"));
|
|
closeBtn->setProperty("isWindowButton", 0x2);
|
|
closeBtn->setProperty("useIconHighlightEffect", 0x8);
|
|
closeBtn->setFixedSize(30, 30);
|
|
closeBtn->setFlat(true);
|
|
closeBtn->setIcon(QIcon::fromTheme("window-close-symbolic"));
|
|
QHBoxLayout *hlayoutLine1 = new QHBoxLayout;
|
|
hlayoutLine1->addStretch();
|
|
hlayoutLine1->addWidget(closeBtn);
|
|
connect(closeBtn, &QPushButton::clicked, this, &AboutDialog::close);
|
|
|
|
// 第二行,备份还原图标
|
|
QLabel *backupIconLabel = new QLabel;
|
|
QIcon titleIcon = QIcon::fromTheme("yhkylin-backup-tools");
|
|
backupIconLabel->setPixmap(titleIcon.pixmap(titleIcon.actualSize(QSize(96, 96))));
|
|
GSettingsWrapper::connectUkuiStyleSchema(backupIconLabel, QSize(96, 96));
|
|
QHBoxLayout *hlayoutLine2 = new QHBoxLayout;
|
|
hlayoutLine2->addStretch();
|
|
hlayoutLine2->addWidget(backupIconLabel);
|
|
hlayoutLine2->addStretch();
|
|
|
|
// 第三行,工具名称
|
|
MyLabel *toolName = new MyLabel;
|
|
toolName->setFixedHeight(36);
|
|
toolName->setDeplayText(tr("Backup & Restore"));
|
|
toolName->setFontSize(28);
|
|
toolName->setIsOriginal(true);
|
|
QHBoxLayout *hlayoutLine3 = new QHBoxLayout;
|
|
hlayoutLine3->addStretch();
|
|
hlayoutLine3->addWidget(toolName);
|
|
hlayoutLine3->addStretch();
|
|
|
|
// 第四行,工具版本
|
|
MyLabel *toolVersion = new MyLabel;
|
|
toolName->setFixedHeight(36);
|
|
toolVersion->setDeplayText(tr("version: ") + getBackupVersion());
|
|
toolVersion->setIsOriginal(true);
|
|
QHBoxLayout *hlayoutLine4 = new QHBoxLayout;
|
|
hlayoutLine4->addStretch();
|
|
hlayoutLine4->addWidget(toolVersion);
|
|
hlayoutLine4->addStretch();
|
|
|
|
// 第五行,简介
|
|
MyLabel *introduction = new MyLabel;
|
|
introduction->setFixedWidth(356);
|
|
introduction->setIsOriginal(true);
|
|
introduction->setWordWrap(true);
|
|
introduction->setSizePolicy(sizePolicy);
|
|
// 麒麟备份还原工具是一款支持系统备份还原和数据备份还原的工具,当用户数据损坏或系统遭受攻击时能够通过该工具灵活的还原到备份节点的状态。针对国产软硬件平台开展了大量的优化和创新。
|
|
introduction->setDeplayText(tr("The backup tool is a tool that supports system backup and data backup. "
|
|
"When the user data is damaged or the system is attacked, the tool can flexibly restore "
|
|
"the status of the backup node. A lot of optimization and innovation have been "
|
|
"carried out for domestic hardware and software platforms."));
|
|
QHBoxLayout *hlayoutLine5 = new QHBoxLayout;
|
|
hlayoutLine5->addStretch();
|
|
hlayoutLine5->addWidget(introduction);
|
|
hlayoutLine5->addStretch();
|
|
|
|
// 第六行,服务与支持团队
|
|
MyLabel *serviceAndSupport = new MyLabel;
|
|
serviceAndSupport->setIsOriginal(true);
|
|
serviceAndSupport->setDeplayText(tr("Service & Support: %1").arg(SUPPORT));
|
|
serviceAndSupport->setAlignment(Qt::AlignCenter);
|
|
serviceAndSupport->setContextMenuPolicy(Qt::NoContextMenu);
|
|
QHBoxLayout *hlayoutLine6 = new QHBoxLayout;
|
|
hlayoutLine6->addStretch();
|
|
hlayoutLine6->addWidget(serviceAndSupport);
|
|
hlayoutLine6->addStretch();
|
|
|
|
QVBoxLayout *vlayout = new QVBoxLayout;
|
|
vlayout->addLayout(hlayoutLine1);
|
|
vlayout->addLayout(hlayoutLine2);
|
|
vlayout->addLayout(hlayoutLine3);
|
|
vlayout->addLayout(hlayoutLine4);
|
|
vlayout->addLayout(hlayoutLine5);
|
|
vlayout->addSpacing(20);
|
|
vlayout->addLayout(hlayoutLine6);
|
|
vlayout->addSpacing(20);
|
|
vlayout->addStretch();
|
|
this->setLayout(vlayout);
|
|
this->adjustSize();
|
|
|
|
connect(serviceAndSupport, &QLabel::linkActivated, this, [=](const QString url) {
|
|
QDesktopServices::openUrl(QUrl(url));
|
|
});
|
|
|
|
}
|
|
|
|
QString AboutDialog::getBackupVersion()
|
|
{
|
|
QString version;
|
|
Utils::executeCMD("dpkg -l yhkylin-backup-tools | grep yhkylin-backup-tools", version);
|
|
// "ii yhkylin-backup-tools 4.0.13-kylin72 amd64 YHkylin backup tools\n"
|
|
QStringList fields = version.split(QRegularExpression("[ \t]+"));
|
|
if (fields.size() >= 3)
|
|
version = fields.at(2);
|
|
else
|
|
version = "none";
|
|
|
|
return version;
|
|
}
|
|
|
|
AboutDialog::~AboutDialog()
|
|
{
|
|
delete ui;
|
|
}
|