|
@@ -1,4 +1,4 @@
|
|
|
-#include "AppConfig.h"
|
|
|
+锘�#include "AppConfig.h"
|
|
|
|
|
|
#include <QProcess>
|
|
|
#include <QDesktopWidget>
|
|
@@ -43,15 +43,15 @@ void Sleep(long mSeconds)
|
|
|
|
|
|
QString AppConfig::APPID = "{a1db97ad-b8ed-11e9-a297-0235d2b38928}";
|
|
|
int AppConfig::VERSION = 1;
|
|
|
-QString AppConfig::VERSION_NAME = "2.1.4";
|
|
|
+QString AppConfig::VERSION_NAME = "2.1.5";
|
|
|
|
|
|
MainWindow *AppConfig::gMainWindow = NULL;
|
|
|
QRect AppConfig::gMainWindowRect;
|
|
|
|
|
|
QRect AppConfig::gScreenRect;
|
|
|
|
|
|
-bool AppConfig::gVideoKeepAspectRatio = true; //按比例显示
|
|
|
-bool AppConfig::gVideoHardDecoder = false; //硬解解码
|
|
|
+bool AppConfig::gVideoKeepAspectRatio = true; //鎸夋瘮渚嬫樉绀�
|
|
|
+bool AppConfig::gVideoHardDecoder = false; //纭�В瑙g爜
|
|
|
QString AppConfig::gVideoFilePath;
|
|
|
|
|
|
QString AppConfig::AppDataPath_Main;
|
|
@@ -78,9 +78,9 @@ void AppConfig::InitAllDataPath()
|
|
|
{
|
|
|
|
|
|
#if defined(WIN32)
|
|
|
- ///windows数据存储在C盘的数据目录下
|
|
|
+ ///windows鏁版嵁瀛樺偍鍦–鐩樼殑鏁版嵁鐩�綍涓�
|
|
|
QFileInfo fileInfo(QCoreApplication::applicationFilePath());
|
|
|
- QString exeFileName = fileInfo.baseName(); //当前程序名字
|
|
|
+ QString exeFileName = fileInfo.baseName(); //褰撳墠绋嬪簭鍚嶅瓧
|
|
|
|
|
|
QString dataPath = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
|
|
|
if (dataPath.right(exeFileName.length()) == exeFileName)
|
|
@@ -94,7 +94,7 @@ void AppConfig::InitAllDataPath()
|
|
|
}
|
|
|
|
|
|
#else
|
|
|
- ///Linux则放在程序所在目录下的data目录下
|
|
|
+ ///Linux鍒欐斁鍦ㄧ▼搴忔墍鍦ㄧ洰褰曚笅鐨刣ata鐩�綍涓�
|
|
|
QFileInfo fileInfo(QCoreApplication::applicationFilePath());
|
|
|
|
|
|
QString dataPath = fileInfo.absoluteDir().path();
|
|
@@ -280,7 +280,7 @@ void AppConfig::saveConfigInfoToFile()
|
|
|
// QJsonObject object;
|
|
|
// object.insert("config", dataObject);
|
|
|
|
|
|
- //最外层是大括号所以是object
|
|
|
+ //鏈€澶栧眰鏄�ぇ鎷�彿鎵€浠ユ槸object
|
|
|
json.setObject(dataObject);
|
|
|
|
|
|
QString jsonStr = json.toJson(QJsonDocument::Compact);
|
|
@@ -313,9 +313,9 @@ void AppConfig::InitLogFile()
|
|
|
qint64 t1 = fileInfo.created().toMSecsSinceEpoch();
|
|
|
qint64 t2 = QDateTime::currentMSecsSinceEpoch();
|
|
|
|
|
|
- qint64 t = (t2 - t1) / 1000; //文件创建到现在的时间(单位:秒)
|
|
|
+ qint64 t = (t2 - t1) / 1000; //鏂囦欢鍒涘缓鍒扮幇鍦ㄧ殑鏃堕棿锛堝崟浣嶏細绉掞級
|
|
|
|
|
|
- if (t >= (24*3600*3)) //删除3天前的日志文件
|
|
|
+ if (t >= (24*3600*3)) //鍒犻櫎3澶╁墠鐨勬棩蹇楁枃浠�
|
|
|
// if (t >= (60*20))
|
|
|
{
|
|
|
QFile::remove(fileInfo.absoluteFilePath());
|
|
@@ -378,19 +378,19 @@ QString AppConfig::getSizeInfo(qint64 size)
|
|
|
int pee = 1024;
|
|
|
|
|
|
char ch[10]={0};
|
|
|
- if (size > (pee*pee*pee)) //大于1G
|
|
|
+ if (size > (pee*pee*pee)) //澶т簬1G
|
|
|
{
|
|
|
sprintf(ch,"%dGB",(int)(size*1.0/pee/pee/pee+0.5));
|
|
|
}
|
|
|
- else if (size > (pee*pee)) //大于1M
|
|
|
+ else if (size > (pee*pee)) //澶т簬1M
|
|
|
{
|
|
|
sprintf(ch,"%dMB",size/pee/pee);
|
|
|
}
|
|
|
- else if (size > pee) //大于1K
|
|
|
+ else if (size > pee) //澶т簬1K
|
|
|
{
|
|
|
sprintf(ch,"%dKB",size/pee);
|
|
|
}
|
|
|
- else //小于1KB
|
|
|
+ else //灏忎簬1KB
|
|
|
{
|
|
|
sprintf(ch,"%dB",size);
|
|
|
}
|
|
@@ -438,12 +438,12 @@ QImage AppConfig::ImagetoGray( QImage image)
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
|
-//拷贝文件夹:
|
|
|
+//鎷疯礉鏂囦欢澶癸細
|
|
|
bool AppConfig::copyDirectoryFiles(const QString &fromDir, const QString &toDir, bool coverFileIfExist)
|
|
|
{
|
|
|
QDir sourceDir(fromDir);
|
|
|
QDir targetDir(toDir);
|
|
|
- if(!targetDir.exists()){ /**< 如果目标目录不存在,则进行创建 */
|
|
|
+ if(!targetDir.exists()){ /**< 濡傛灉鐩�爣鐩�綍涓嶅瓨鍦�紝鍒欒繘琛屽垱寤� */
|
|
|
if(!targetDir.mkdir(targetDir.absolutePath()))
|
|
|
return false;
|
|
|
}
|
|
@@ -453,18 +453,18 @@ bool AppConfig::copyDirectoryFiles(const QString &fromDir, const QString &toDir,
|
|
|
if(fileInfo.fileName() == "." || fileInfo.fileName() == "..")
|
|
|
continue;
|
|
|
|
|
|
- if(fileInfo.isDir()){ /**< 当为目录时,递归的进行copy */
|
|
|
+ if(fileInfo.isDir()){ /**< 褰撲负鐩�綍鏃讹紝閫掑綊鐨勮繘琛宑opy */
|
|
|
if(!copyDirectoryFiles(fileInfo.filePath(),
|
|
|
targetDir.filePath(fileInfo.fileName()),
|
|
|
coverFileIfExist))
|
|
|
return false;
|
|
|
}
|
|
|
- else{ /**< 当允许覆盖操作时,将旧文件进行删除操作 */
|
|
|
+ else{ /**< 褰撳厑璁歌�鐩栨搷浣滄椂锛屽皢鏃ф枃浠惰繘琛屽垹闄ゆ搷浣� */
|
|
|
if(coverFileIfExist && targetDir.exists(fileInfo.fileName())){
|
|
|
targetDir.remove(fileInfo.fileName());
|
|
|
}
|
|
|
|
|
|
- /// 进行文件copy
|
|
|
+ /// 杩涜�鏂囦欢copy
|
|
|
if(!QFile::copy(fileInfo.filePath(),
|
|
|
targetDir.filePath(fileInfo.fileName()))){
|
|
|
return false;
|
|
@@ -493,18 +493,18 @@ bool AppConfig::removeDirectory(QString dirName)
|
|
|
if(fileInfo.isDir()){
|
|
|
tmpdir = dirName + ("/") + fileInfo.fileName();
|
|
|
removeDirectory(tmpdir);
|
|
|
- dir.rmdir(fileInfo.fileName()); /**< 移除子目录 */
|
|
|
+ dir.rmdir(fileInfo.fileName()); /**< 绉婚櫎瀛愮洰褰� */
|
|
|
}
|
|
|
else if(fileInfo.isFile()){
|
|
|
QFile tmpFile(fileInfo.fileName());
|
|
|
- dir.remove(tmpFile.fileName()); /**< 删除临时文件 */
|
|
|
+ dir.remove(tmpFile.fileName()); /**< 鍒犻櫎涓存椂鏂囦欢 */
|
|
|
}
|
|
|
else{
|
|
|
;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- dir.cdUp(); /**< 返回上级目录,因为只有返回上级目录,才可以删除这个目录 */
|
|
|
+ dir.cdUp(); /**< 杩斿洖涓婄骇鐩�綍锛屽洜涓哄彧鏈夎繑鍥炰笂绾х洰褰曪紝鎵嶅彲浠ュ垹闄よ繖涓�洰褰� */
|
|
|
if(dir.exists(dirName)){
|
|
|
if(!dir.rmdir(dirName))
|
|
|
return false;
|
|
@@ -521,7 +521,7 @@ bool AppConfig::removeDirectory(QString dirName)
|
|
|
SHELLEXECUTEINFO sei;
|
|
|
TCHAR szModule [MAX_PATH],szComspec[MAX_PATH],szParams [MAX_PATH];
|
|
|
|
|
|
- // 获得文件名.
|
|
|
+ // 鑾峰緱鏂囦欢鍚�.
|
|
|
if((GetModuleFileName(0,szModule,MAX_PATH)!=0) &&
|
|
|
(GetShortPathName(szModule,szModule,MAX_PATH)!=0) &&
|
|
|
(GetEnvironmentVariable(L"COMSPEC",szComspec,MAX_PATH)!=0))
|
|
@@ -530,7 +530,7 @@ bool AppConfig::removeDirectory(QString dirName)
|
|
|
QString dirPath = QCoreApplication::applicationFilePath();
|
|
|
dirPath.replace("/","\\");
|
|
|
dirPath = "\"" + dirPath + "\"";
|
|
|
- // 设置命令参数.
|
|
|
+ // 璁剧疆鍛戒护鍙傛暟.
|
|
|
lstrcpy(szParams, L"/c ");
|
|
|
lstrcat(szParams, (WCHAR*)dirPath.utf16());
|
|
|
lstrcat(szParams, L" > nul");
|
|
@@ -539,7 +539,7 @@ bool AppConfig::removeDirectory(QString dirName)
|
|
|
// lstrcat(szParams, szModule);
|
|
|
// lstrcat(szParams, L" > nul");
|
|
|
|
|
|
- // 设置结构成员.
|
|
|
+ // 璁剧疆缁撴瀯鎴愬憳.
|
|
|
sei.cbSize = sizeof(sei);
|
|
|
sei.hwnd = 0;
|
|
|
sei.lpVerb = L"Open";
|
|
@@ -549,15 +549,15 @@ bool AppConfig::removeDirectory(QString dirName)
|
|
|
sei.nShow = SW_HIDE;
|
|
|
sei.fMask = SEE_MASK_NOCLOSEPROCESS;
|
|
|
|
|
|
- // 执行shell命令.
|
|
|
+ // 鎵ц�shell鍛戒护.
|
|
|
if(ShellExecuteEx(&sei))
|
|
|
{
|
|
|
- // 设置命令行进程的执行级别为空闲执行,使本程序有足够的时间从内存中退出.
|
|
|
+ // 璁剧疆鍛戒护琛岃繘绋嬬殑鎵ц�绾у埆涓虹┖闂叉墽琛�,浣挎湰绋嬪簭鏈夎冻澶熺殑鏃堕棿浠庡唴瀛樹腑閫€鍑�.
|
|
|
SetPriorityClass(sei.hProcess,IDLE_PRIORITY_CLASS);
|
|
|
SetPriorityClass(GetCurrentProcess(),REALTIME_PRIORITY_CLASS);
|
|
|
SetThreadPriority(GetCurrentThread(),THREAD_PRIORITY_TIME_CRITICAL);
|
|
|
|
|
|
- // 通知Windows资源浏览器,本程序文件已经被删除.
|
|
|
+ // 閫氱煡Windows璧勬簮娴忚�鍣�,鏈�▼搴忔枃浠跺凡缁忚�鍒犻櫎.
|
|
|
SHChangeNotify(SHCNE_DELETE,SHCNF_PATH,(WCHAR*)dirPath.utf16(),0);
|
|
|
return TRUE;
|
|
|
}
|
|
@@ -579,8 +579,8 @@ bool AppConfig::removeDirectory(QString dirName)
|
|
|
QString filePath = QString("%1/%2").arg(dirPath).arg(Appconfig::AppExeName);
|
|
|
QString runAppCmd = QString("open -a \""+filePath+"\" \n");
|
|
|
|
|
|
- fileOut<<QString("ping -c 4 -t 2 baidu.com \n"); //延时2秒
|
|
|
- fileOut<<runAppCmd; //启动程序
|
|
|
+ fileOut<<QString("ping -c 4 -t 2 baidu.com \n"); //寤舵椂2绉�
|
|
|
+ fileOut<<runAppCmd; //鍚�姩绋嬪簭
|
|
|
|
|
|
file.close();
|
|
|
}
|
|
@@ -590,7 +590,7 @@ bool AppConfig::removeDirectory(QString dirName)
|
|
|
p.start("bash");
|
|
|
p.waitForStarted();
|
|
|
p.write(QString("chmod a+x \""+bashFilePath+"\" \n").toUtf8());
|
|
|
- p.write(QString("\""+bashFilePath+"\" &\n").toUtf8()); //后台运行
|
|
|
+ p.write(QString("\""+bashFilePath+"\" &\n").toUtf8()); //鍚庡彴杩愯�
|
|
|
// p.write(QString("open -a \""+bashFilePath+"\" \n").toUtf8());
|
|
|
p.closeWriteChannel();
|
|
|
p.waitForFinished();
|