更新模块
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

52 lines
1.2 KiB

#include <QApplication>
#include <QFile>
#include <QTextStream>
//#include <QDebug>
#include "updaterdialog.h"
/**
* @brief 加载更新器暗色样式。
*
* 设计意图:样式资源不存在时只输出提示,不阻塞更新主流程。
* 资源风险:QFile 为栈对象,函数退出自动关闭;读取失败时保留 Qt 默认样式。
*/
void loadQss()
{
QFile f(":qdarkstyle/dark/darkstyle.qss");
// QFile f(":qdarkstyle/light/lightstyle.qss");
if(!f.exists())
{
printf("Unable to set stylesheet, file not found\n");
}
else
{
f.open(QFile::ReadOnly | QFile::Text);
QTextStream ts(&f);
qApp->setStyleSheet(ts.readAll());
}
}
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
loadQss();
// 参数由主程序启动更新器时传入,数量不足时进入手动输入模式,避免访问 argv 越界。
if(argc >= 5)
{
APPNAME = argv[1];
APPVERSION = argv[2];
APPDATE = argv[3];
MODIFYCNT = argv[4];
}
else
{
APPNAME = "";
APPVERSION = "0";
}
UpdaterDialog w;
w.show();
return a.exec();
}