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

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;
}
QString Dialog_logIn::getCurrentExePath()
QString Dialog_logIn::getConfigFilePath()
{
HGChar currentPath[256] = { 0 };
HGBase_GetCurrentDir(currentPath, 256);
strcat(currentPath, "production-tool");
strcat(currentPath, "/");
return getStdFileName(StdStringToUtf8(currentPath).c_str());
HGChar configPath[512];
HGBase_GetDocumentsPath(configPath, 512);
HGChar procName[512];
HGBase_GetProcessName(procName, 512);
strcat(configPath, procName);
strcat(configPath, "/Profile/");
return getStdFileName(StdStringToUtf8(configPath).c_str());
}
void Dialog_logIn::updateProfileFileList()
{
ui->comboBox_filenameList->clear();
QString currentExePath = getCurrentExePath();
QDir dir(currentExePath);
QString configFilePath = getConfigFilePath();
QDir dir(configFilePath);
if (dir.exists())
{
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", "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);
m_accountName = account;
@ -254,9 +256,23 @@ void Dialog_logIn::on_pushButton_updateFilename_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);
auto pathDir = fileInfo.path();
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();
private:
QString getCurrentExePath();
QString getConfigFilePath();
void updateProfileFileList();
private slots:

View File

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