59 lines
2.1 KiB
C++
59 lines
2.1 KiB
C++
#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本软件采用了Qt,Qt是The Qt Company的产品,采用LGPL协议发布。\n");
|
||
inf_str += QString::fromLocal8Bit("本软件采用了MiniBlink,MiniBlink是珠海独角兽科技有限公司的产品,采用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;
|
||
}
|