更改配置文件存放位置,防止权限不够无法直接编辑

This commit is contained in:
yangjiaxuan 2024-01-05 17:24:10 +08:00
parent bff758e9de
commit d01a96a18f
3 changed files with 29 additions and 13 deletions

View File

@ -126,21 +126,23 @@ QString Dialog_logIn::GetProfileName()
return m_profileName; return m_profileName;
} }
QString Dialog_logIn::getCurrentExePath() QString Dialog_logIn::getConfigFilePath()
{ {
HGChar currentPath[256] = { 0 }; HGChar configPath[512];
HGBase_GetCurrentDir(currentPath, 256); HGBase_GetDocumentsPath(configPath, 512);
strcat(currentPath, "production-tool"); HGChar procName[512];
strcat(currentPath, "/"); HGBase_GetProcessName(procName, 512);
return getStdFileName(StdStringToUtf8(currentPath).c_str()); strcat(configPath, procName);
strcat(configPath, "/Profile/");
return getStdFileName(StdStringToUtf8(configPath).c_str());
} }
void Dialog_logIn::updateProfileFileList() void Dialog_logIn::updateProfileFileList()
{ {
ui->comboBox_filenameList->clear(); ui->comboBox_filenameList->clear();
QString currentExePath = getCurrentExePath(); QString configFilePath = getConfigFilePath();
QDir dir(currentExePath); QDir dir(configFilePath);
if (dir.exists()) if (dir.exists())
{ {
QFileInfoList fileList = dir.entryInfoList(QDir::Files); QFileInfoList fileList = dir.entryInfoList(QDir::Files);
@ -203,7 +205,7 @@ void Dialog_logIn::on_pbtn_login_clicked()
saveCfgValue("login", "rememberPassword", ui->checkBox_rememberPswd->isChecked()); saveCfgValue("login", "rememberPassword", ui->checkBox_rememberPswd->isChecked());
saveCfgValue("login", "showPassword", ui->checkBox_showPswd->isChecked()); saveCfgValue("login", "showPassword", ui->checkBox_showPswd->isChecked());
m_profileName = getCurrentExePath() + ui->comboBox_filenameList->currentText() + ".json"; m_profileName = getConfigFilePath() + ui->comboBox_filenameList->currentText() + ".json";
saveCfgValue("login", "profile", m_profileName); saveCfgValue("login", "profile", m_profileName);
m_accountName = account; m_accountName = account;
@ -254,9 +256,23 @@ void Dialog_logIn::on_pushButton_updateFilename_clicked()
void Dialog_logIn::on_pushButton_viewDirectory_clicked() void Dialog_logIn::on_pushButton_viewDirectory_clicked()
{ {
QString fileName = getCurrentExePath() + ui->comboBox_filenameList->currentText().toLocal8Bit() + ".json"; QString configName = ui->comboBox_filenameList->currentText();
QString fileName = getConfigFilePath();
if (!configName.isEmpty())
{
fileName = getConfigFilePath() + configName.toLocal8Bit() + ".json";
}
else
{
fileName.chop(1);
HGBase_CreateDir(fileName.toStdString().c_str());
}
QFileInfo fileInfo(fileName); QFileInfo fileInfo(fileName);
auto pathDir = fileInfo.path(); auto pathDir = fileInfo.path();
QString strFilePath = "file:///" + pathDir; QString strFilePath = "file:///" + pathDir;
QDesktopServices::openUrl(QUrl(strFilePath)); bool ret = QDesktopServices::openUrl(QUrl(strFilePath));
if (!ret)
QMessageBox::information(this, tr("Prompt"), tr("Profile is not exsits"));
} }

View File

@ -32,7 +32,7 @@ public:
QString GetProfileName(); QString GetProfileName();
private: private:
QString getCurrentExePath(); QString getConfigFilePath();
void updateProfileFileList(); void updateProfileFileList();
private slots: private slots:

View File

@ -1100,7 +1100,7 @@ public:
ret = helper_->io_control(IO_CTRL_CODE_GET_PC_DISTORTION_CHECK_VAL, &dis, &llen); ret = helper_->io_control(IO_CTRL_CODE_GET_PC_DISTORTION_CHECK_VAL, &dis, &llen);
break; break;
} }
else if (cnt == 10) else if (cnt == 20)
break; break;
if (is_distortion_get_image_abnormal) if (is_distortion_get_image_abnormal)