改进部分代码

This commit is contained in:
feiyangqingyun
2021-01-31 20:20:58 +08:00
parent dd9d83d690
commit 5789d8c08c
18 changed files with 2214 additions and 1246 deletions

View File

@@ -14,7 +14,8 @@ bool App::HexData2 = false;
void App::readConfig()
{
if (!checkConfig()) {
if (!QUIHelper::checkIniFile(App::ConfigFile)) {
writeConfig();
return;
}
@@ -47,48 +48,3 @@ void App::writeConfig()
set.setValue("HexData2", App::HexData2);
set.endGroup();
}
void App::newConfig()
{
#if (QT_VERSION <= QT_VERSION_CHECK(5,0,0))
#endif
writeConfig();
}
bool App::checkConfig()
{
//如果配置文件大小为0,则以初始值继续运行,并生成配置文件
QFile file(App::ConfigFile);
if (file.size() == 0) {
newConfig();
return false;
}
//如果配置文件不完整,则以初始值继续运行,并生成配置文件
if (file.open(QFile::ReadOnly)) {
bool ok = true;
while (!file.atEnd()) {
QString line = file.readLine();
line = line.replace("\r", "");
line = line.replace("\n", "");
QStringList list = line.split("=");
if (list.count() == 2) {
if (list.at(1) == "") {
ok = false;
break;
}
}
}
if (!ok) {
newConfig();
return false;
}
} else {
newConfig();
return false;
}
return true;
}