Skip to content

Commit

Permalink
部分文件修改编码为65001并c/c++添加/utf-8
Browse files Browse the repository at this point in the history
  • Loading branch information
GengGode committed Aug 7, 2021
1 parent 9ef3113 commit 73ed050
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 56 deletions.
22 changes: 11 additions & 11 deletions GenshinImpactNaturalLaw/GenshinImpactNaturalLaw.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "GenshinImpactNaturalLaw.h"
#include "GenshinImpactNaturalLaw.h"

GenshinImpactNaturalLaw::GenshinImpactNaturalLaw(QWidget *parent)
: QMainWindow(parent)
Expand All @@ -12,15 +12,15 @@ GenshinImpactNaturalLaw::GenshinImpactNaturalLaw(QWidget *parent)

Tray = new QSystemTrayIcon(this);
Tray->setIcon(QIcon(QPixmap(":/icon/resource/icon/ICON.png")));
Tray->setToolTip(QString::fromUtf8("\345\244\251\347\220\206"));//天理
QString title = "天理";
QString text = "原神天理系统";
Tray->setToolTip(QString::fromUtf8("\345\244\251\347\220\206"));//天理
QString title = "天理";
QString text = "原神天理系统";
Tray->show();
connect(Tray, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(TrayMenuClickEvent(QSystemTrayIcon::ActivationReason)));
//"\345\244\251\347\220\206 \351\200\200\345\207\272 \346\230\276\347\244\272\344\270\273\347\225\214\351\235\242"
ShowMainAction = new QAction(QString::fromUtf8("\346\230\276\347\244\272\344\270\273\347\225\214\351\235\242"), this);//显示主界面

ShowMainAction = new QAction(QString::fromUtf8("\346\230\276\347\244\272\344\270\273\347\225\214\351\235\242"), this);//显示主界面
connect(ShowMainAction, SIGNAL(triggered()), this, SLOT(show()));
ExitAction = new QAction(QString::fromUtf8("\351\200\200\345\207\272"), this);//退出
ExitAction = new QAction(QString::fromUtf8("\351\200\200\345\207\272"), this);//退出
connect(ExitAction, SIGNAL(triggered()), this, SLOT(close()));

TrayMenu = new QMenu(this);
Expand All @@ -34,7 +34,7 @@ GenshinImpactNaturalLaw::GenshinImpactNaturalLaw(QWidget *parent)
Shadow_LabelPage->setOffset(0.0);
ui.label_Page_Rect->setGraphicsEffect(Shadow_LabelPage);

setAttribute(Qt::WA_TranslucentBackground, true); // 背景透明
setAttribute(Qt::WA_TranslucentBackground, true); // 背景透明
QGraphicsDropShadowEffect *shadow = new QGraphicsDropShadowEffect;
shadow->setOffset(0, 0);
shadow->setColor(QColor(15, 15, 15, 50));
Expand Down Expand Up @@ -270,9 +270,9 @@ void GenshinImpactNaturalLaw::TrayMenuClickEvent(QSystemTrayIcon::ActivationReas
{
switch (reason)
{
case QSystemTrayIcon::Trigger://单击托盘图标
case QSystemTrayIcon::Trigger://单击托盘图标
break;
case QSystemTrayIcon::DoubleClick://双击托盘图标
case QSystemTrayIcon::DoubleClick://双击托盘图标
this->showNormal();
break;
default:
Expand Down Expand Up @@ -304,7 +304,7 @@ void GenshinImpactNaturalLaw::ShowTopMainWidget()

void GenshinImpactNaturalLaw::ReceiveUniqueKeyMsg()
{
//还原显示窗口
//还原显示窗口

this->show();

Expand Down
3 changes: 3 additions & 0 deletions GenshinImpactNaturalLaw/GenshinImpactNaturalLaw.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@
<Link>
<UACExecutionLevel>RequireAdministrator</UACExecutionLevel>
</Link>
<ClCompile>
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'" Label="Configuration">
<ClCompile>
Expand Down
18 changes: 9 additions & 9 deletions GenshinImpactNaturalLaw/QtWidgetsSetting.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "QtWidgetsSetting.h"
#pragma execution_character_set("utf-8")
#include "QtWidgetsSetting.h"
//#pragma execution_character_set("utf-8")

QtWidgetsSetting::QtWidgetsSetting(QWidget *parent)
: QWidget(parent)
Expand Down Expand Up @@ -398,22 +398,22 @@ void QtWidgetsSetting::CheckOptions_CheckGameLauncher()
{
FileDialogPath = setting->launcher_install_path;
}
QString GameLauncherPath = QFileDialog::getExistingDirectory(this, "选择原神启动器所在目录", FileDialogPath, QFileDialog::ShowDirsOnly);
QString GameLauncherPath = QFileDialog::getExistingDirectory(this, "选择原神启动器所在目录", FileDialogPath, QFileDialog::ShowDirsOnly);

if (!GameLauncherPath.isEmpty())
{
QFileInfo file(GameLauncherPath+"/launcher.exe");
if (file.exists() == false)
{
emit ShowMessageBox();//未能找到游戏本体,请重新选择游戏本体路径
emit ShowMessageBox();//未能找到游戏本体,请重新选择游戏本体路径
return;
}
else
{
setting->launcher_install_path = GameLauncherPath;
if (!setting->tryGetGamePath())
{
emit ShowMessageBox();//未能找到游戏本体,请手动选择游戏本体路径
emit ShowMessageBox();//未能找到游戏本体,请手动选择游戏本体路径
return;
}
}
Expand All @@ -432,7 +432,7 @@ void QtWidgetsSetting::CheckOptions_CheckGame()
{
FileDialogPath = setting->game_install_path;
}
QString GamePath = QFileDialog::getOpenFileName(this, "选择原神所在目录", FileDialogPath, "应用程序 (*.exe);;");
QString GamePath = QFileDialog::getOpenFileName(this, "选择原神所在目录", FileDialogPath, "应用程序 (*.exe);;");
if (!GamePath.isEmpty())
{
setting->game_start_name = GamePath.section('/', -1);
Expand All @@ -453,22 +453,22 @@ void QtWidgetsSetting::CheckOptions_CheckModule()
{
FileDialogPath = setting->launcher_install_path;
}
QString GameLauncherPath = QFileDialog::getExistingDirectory(this, "选择原神启动器所在目录", FileDialogPath, QFileDialog::ShowDirsOnly);
QString GameLauncherPath = QFileDialog::getExistingDirectory(this, "选择原神启动器所在目录", FileDialogPath, QFileDialog::ShowDirsOnly);

if (!GameLauncherPath.isEmpty())
{
QFileInfo file(GameLauncherPath + "/launcher.exe");
if (file.exists() == false)
{
emit ShowMessageBox();//未能找到游戏本体,请重新选择游戏本体路径
emit ShowMessageBox();//未能找到游戏本体,请重新选择游戏本体路径
return;
}
else
{
setting->launcher_install_path = GameLauncherPath;
if (!setting->tryGetGamePath())
{
emit ShowMessageBox();//未能找到游戏本体,请手动选择游戏本体路径
emit ShowMessageBox();//未能找到游戏本体,请手动选择游戏本体路径
return;
}
}
Expand Down
3 changes: 2 additions & 1 deletion GenshinImpactNaturalLaw/QtWidgetsSetting.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <windows.h>
#include <vector>
#include <QUrl>
#include <QString>
#include <QFileInfo>
#include <QFileDialog>
#include <QApplication>
Expand Down Expand Up @@ -36,7 +37,7 @@ class QtWidgetsSetting : public QWidget
QPoint m_Move;
bool leftBtnClk = false;

QString KeyString1 = "当前版本:";
QString KeyString1 = "当前版本:";//QString::QStringLiteral("当前版本:");

QtWidgetsMessageBox *WidgetsMessageBox = nullptr;
QLabel *MainMaskLabel = nullptr;
Expand Down
10 changes: 5 additions & 5 deletions GenshinImpactNaturalLaw/UpdataModule.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "UpdataModule.h"
#include "UpdataModule.h"

UpdataModule::UpdataModule()
{
Expand Down Expand Up @@ -51,9 +51,9 @@ void UpdataModule::getFile()
allBits = downloadFile->size();

httpRequestAborted = false;
//尝试获取文件
//尝试获取文件
startRequest(downloadUrl);
//事件循环,防止在下载没完成前结束对象
//事件循环,防止在下载没完成前结束对象
}

void UpdataModule::startRequest(QUrl url)
Expand All @@ -67,7 +67,7 @@ void UpdataModule::startRequest(QUrl url)
req.setRawHeader("RANGE", tr("bytes=%1-").arg(allBits).toUtf8());//
}
downloadReply = downloadmanager.get(req);
//连接信号与槽
//连接信号与槽
if (downloadReply)
{
connect(downloadReply, SIGNAL(readyRead()), this, SLOT(downloadReadyRead()));
Expand Down Expand Up @@ -98,7 +98,7 @@ void UpdataModule::cancel()
}
void UpdataModule::downloadReadyRead()
{
//如果文件可以访问,下载
//如果文件可以访问,下载
if (downloadFile)
downloadFile->write(downloadReply->readAll());
FileBuff = FileBuff + QString(downloadReply->readAll());
Expand Down
60 changes: 30 additions & 30 deletions GenshinImpactNaturalLaw/UpdataModule.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#pragma once
#pragma once
#include <QDir>
#include <QFileInfo>
#include <QApplication>
Expand All @@ -20,65 +20,65 @@ class UpdataModule :public QObject
~UpdataModule();


// 设置要下载的url和文件名
// 设置要下载的url和文件名
void setData(QUrl url);
//开始下载
//开始下载
void getFile();
void startRequest(QUrl url);
//发生的错误代码
//发生的错误代码
//int lastError();
//返回是否有错误发生
//返回是否有错误发生
//bool errorValid();
//返回是否下载中
//返回是否下载中
//bool isRunning();
//返回是否下载完成
//返回是否下载完成
//bool isFinished();
//返回所下载文件的版本号
//返回所下载文件的版本号
QString getDownloadVersionCode();
//返回所下载文件的名字(带扩展名)
//返回所下载文件的名字(带扩展名)
//QString getFileName();
void cancel();
private:

//=====状态变量=====
bool bisFinished; //下载是否完成
bool bisRunning; //下载是否进行中
bool bisError; //是否有错误发生
int errorCode; //错误代码
int allBits = 0; //文件大小
//=====状态变量=====
bool bisFinished; //下载是否完成
bool bisRunning; //下载是否进行中
bool bisError; //是否有错误发生
int errorCode; //错误代码
int allBits = 0; //文件大小
bool httpRequestAborted;

//=====对象声明=====
//=====对象声明=====
VersionNumber version;

QString FileBuff;
QFile *downloadFile; //保存目标文件指针
QUrl downloadUrl; //下载地址Url
QString savePath; //文件存放路径
QString versionCode = ""; //所下载的文件版本号
QString fileName = ""; //所下载文件名
QNetworkReply *downloadReply; //网络应答指针
QNetworkAccessManager downloadmanager; //网络连接主类指针
QFile *downloadFile; //保存目标文件指针
QUrl downloadUrl; //下载地址Url
QString savePath; //文件存放路径
QString versionCode = ""; //所下载的文件版本号
QString fileName = ""; //所下载文件名
QNetworkReply *downloadReply; //网络应答指针
QNetworkAccessManager downloadmanager; //网络连接主类指针
signals:

//当错误发生时向外抛出错误信息
//当错误发生时向外抛出错误信息
void error(QNetworkReply::NetworkError);
//抛出下载进度(更新进度条)
//抛出下载进度(更新进度条)
void updateProgress(qint64 bytesSent, qint64 bytesTotal);
//下载结果 0成功 其他失败
//下载结果 0成功 其他失败
void downloadResult(int retCode);

void finish();

private slots:

//准备下载,读取数据
//准备下载,读取数据
void downloadReadyRead();
//下载完成
//下载完成
void downloadFinished();
//下载过程中发生错误
//下载过程中发生错误
void downloadError(QNetworkReply::NetworkError errorCode);
//下载过程进度条
//下载过程进度条
void downloadProgress(qint64 bytesSent, qint64 bytesTotal);
};

0 comments on commit 73ed050

Please sign in to comment.