Files
OfficeAssistant_Win10/OfficeAssistant_msvc/settingsscreen.cpp
2023-08-01 09:04:53 +08:00

59 lines
2.1 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include "settingsscreen.h"
#include "config.h"
#include <QCryptographicHash>
#include "netio.h"
SettingsScreen::SettingsScreen(QWidget *parent)
: QWidget(parent)
{
ui.setupUi(this);
autoStart = new SwitchButton(ADD_AUTOSTART,this);
addDesktopLink = new QPushButton(this);
addDesktopLink->setText(QString::fromLocal8Bit("创建桌面快捷方式"));
connect(addDesktopLink, &QPushButton::pressed, this, &SettingsScreen::createShortCut);
layout = new QHBoxLayout(this);
left = new QVBoxLayout(this);
addDesktopLink_label = new QLabel(QString::fromLocal8Bit("添加桌面快捷方式"),this);
autoStart_label = new QLabel(QString::fromLocal8Bit("开机启动"),this);
autoStart->setMaximumSize(100, 50);
autoStart->setMinimumSize(50, 25);
left->addWidget(autoStart_label);
left->addWidget(autoStart);
left->addWidget(addDesktopLink_label);
left->addWidget(addDesktopLink);
left->setAlignment(Qt::AlignCenter);
left->setMargin(0);
layout->addLayout(left);
information = new QLabel;
QString device_id = QCryptographicHash::hash(getMachineGUID().toUtf8(), QCryptographicHash::Md5).toHex();
QString inf_str = QString::fromLocal8Bit("硬件ID:\n");
inf_str += device_id;
inf_str+= QString::fromLocal8Bit("\n本软件采用了QtQt是The Qt Company的产品采用LGPL协议发布。\n");
inf_str += QString::fromLocal8Bit("本软件采用了MiniBlinkMiniBlink是珠海独角兽科技有限公司的产品采用Apache 2.0协议发布。\n");
information->setText(inf_str);
layout->addWidget(information);
}
void SettingsScreen::createShortCut() {
QString deskTopPath = QStandardPaths::writableLocation(QStandardPaths::DesktopLocation);
deskTopPath = deskTopPath + QString::fromLocal8Bit("/办公助手.lnk");
QString srcFile = QApplication::applicationFilePath();
QFile::link(srcFile, deskTopPath);
}
SettingsScreen::~SettingsScreen()
{
left->removeWidget(autoStart);
left->removeWidget(addDesktopLink);
left->removeWidget(addDesktopLink_label);
left->removeWidget(autoStart_label);
delete autoStart;
delete addDesktopLink;
delete addDesktopLink_label;
delete autoStart_label;
layout->removeItem(left);
delete left;
layout->removeWidget(information);
delete information;
delete layout;
}