|
|
|
@ -57,37 +57,26 @@ DialogSetup::DialogSetup(QWidget * parent) : QDialog(parent) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!g_conf_path.config_path.isEmpty()) {
|
|
|
|
|
// 如果配置文件存储路径非空
|
|
|
|
|
QDir* dirinfo = new QDir(g_conf_path.config_path);
|
|
|
|
|
if (!dirinfo->exists())
|
|
|
|
|
if (!dirinfo->exists()) {
|
|
|
|
|
// 如果文件夹信息不存在
|
|
|
|
|
delete dirinfo, dirinfo = nullptr;
|
|
|
|
|
dirinfo->setNameFilters(QStringList("*.txt"));
|
|
|
|
|
g_conf_path.config_path = "D:/conf";
|
|
|
|
|
}
|
|
|
|
|
dirinfo->setNameFilters(QStringList("conf.txt"));
|
|
|
|
|
QStringList fileList = dirinfo->entryList(QDir::Files);
|
|
|
|
|
fileList.removeOne(".");
|
|
|
|
|
fileList.removeOne("..");
|
|
|
|
|
ui.comboBox_config_path->clear();
|
|
|
|
|
|
|
|
|
|
ui.comboBox_config_path->addItems(fileList);
|
|
|
|
|
if (!g_conf_path.config_name.isEmpty())
|
|
|
|
|
ui.comboBox_config_path->setCurrentText(g_conf_path.config_name);
|
|
|
|
|
else {
|
|
|
|
|
g_conf_path.config_name = "conf.txt";
|
|
|
|
|
ui.comboBox_config_path->setCurrentText(g_conf_path.config_name);
|
|
|
|
|
}
|
|
|
|
|
// 更换选择文件
|
|
|
|
|
connect(ui.comboBox_config_path, SIGNAL(currentIndexChanged(int)), this, SLOT(onComboBoxConfSelect(int)));
|
|
|
|
|
delete dirinfo, dirinfo = nullptr;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
// 如果路径空
|
|
|
|
|
g_conf_path.config_path = "D:/conf";
|
|
|
|
|
if (!g_conf_path.config_name.isEmpty()) {
|
|
|
|
|
ui.comboBox_model_path->setCurrentText(g_conf_path.config_name);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
g_conf_path.config_name = "conf.txt";
|
|
|
|
|
ui.comboBox_model_path->addItem(g_conf_path.config_name);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
ui.comboBox_config_path->addItem(g_conf_path.config_path);
|
|
|
|
|
// 更换选择文件
|
|
|
|
|
connect(ui.comboBox_config_path, SIGNAL(currentIndexChanged(int)), this, SLOT(onComboBoxConfSelect(int)));
|
|
|
|
|
|
|
|
|
|
if (!g_sys_conf.model_path.isEmpty()) {
|
|
|
|
|
// 如果曾经选择过模型文件夹
|
|
|
|
@ -105,8 +94,6 @@ DialogSetup::DialogSetup(QWidget * parent) : QDialog(parent) {
|
|
|
|
|
// 如果曾选择过模型,则在comboBox显示选择模型的文件名
|
|
|
|
|
ui.comboBox_model_path->setCurrentText(g_sys_conf.model_name);
|
|
|
|
|
}
|
|
|
|
|
// 更换模型事件
|
|
|
|
|
connect(ui.comboBox_model_path, SIGNAL(currentIndexChanged(int)), this, SLOT(onComboBoxSelect(int)));
|
|
|
|
|
delete dirinfo, dirinfo = nullptr;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
@ -116,6 +103,8 @@ DialogSetup::DialogSetup(QWidget * parent) : QDialog(parent) {
|
|
|
|
|
ui.comboBox_model_path->addItem(g_sys_conf.model_name);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 更换模型事件
|
|
|
|
|
connect(ui.comboBox_model_path, SIGNAL(currentIndexChanged(int)), this, SLOT(onComboBoxSelect(int)));
|
|
|
|
|
|
|
|
|
|
if (!g_conf_path.save_pics_path.isEmpty()) {
|
|
|
|
|
// 如果配置文件里保存图片路径非空
|
|
|
|
@ -128,8 +117,6 @@ DialogSetup::DialogSetup(QWidget * parent) : QDialog(parent) {
|
|
|
|
|
ui.comboBox_save_pics_path->clear();
|
|
|
|
|
ui.comboBox_save_pics_path->addItem(g_conf_path.save_pics_path);
|
|
|
|
|
|
|
|
|
|
// 更换选择文件
|
|
|
|
|
connect(ui.comboBox_save_pics_path, SIGNAL(currentIndexChanged(int)), this, SLOT(onComboBoxPicsPathSelect(int)));
|
|
|
|
|
delete dirinfo, dirinfo = nullptr;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
@ -141,6 +128,9 @@ DialogSetup::DialogSetup(QWidget * parent) : QDialog(parent) {
|
|
|
|
|
ui.comboBox_save_pics_path->setCurrentText(dirPath);
|
|
|
|
|
g_conf_path.save_pics_path = dirPath;
|
|
|
|
|
}
|
|
|
|
|
// 更换选择文件
|
|
|
|
|
connect(ui.comboBox_save_pics_path, SIGNAL(currentIndexChanged(int)), this, SLOT(onComboBoxPicsPathSelect(int)));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch (g_sys_conf.save)
|
|
|
|
|
{
|
|
|
|
@ -171,12 +161,14 @@ void DialogSetup::onComboBoxPicsPathSelect(int index) {
|
|
|
|
|
QString cp = ui.comboBox_save_pics_path->currentText();
|
|
|
|
|
//QMessageBox::information(this, QStringLiteral("提示"), QStringLiteral("您选择的项为") + cp, NULL);
|
|
|
|
|
g_conf_path.save_pics_path = cp;
|
|
|
|
|
write_conf_path();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DialogSetup::onComboBoxConfSelect(int index) {
|
|
|
|
|
QString cp = ui.comboBox_config_path->currentText();
|
|
|
|
|
//QMessageBox::information(this, QStringLiteral("提示"), QStringLiteral("您选择的项为") + cp, NULL);
|
|
|
|
|
g_conf_path.config_name = cp;
|
|
|
|
|
g_conf_path.config_path = cp;
|
|
|
|
|
write_conf_path();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DialogSetup::onComboBoxSelect(int index) {
|
|
|
|
@ -334,7 +326,6 @@ void DialogSetup::on_pushButton_save_released()
|
|
|
|
|
g_sys_conf.filter[i] = (lineEdit_filter_mat[i]->text()).toInt();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
write_conf_path();
|
|
|
|
|
write_config();
|
|
|
|
|
QMessageBox::information(NULL, QStringLiteral("提示"), QStringLiteral("保存参数成功,部分配置需要重启程序后生效"), QMessageBox::Ok);
|
|
|
|
|
}
|
|
|
|
@ -367,35 +358,32 @@ void DialogSetup::on_toolButton_choose_config_path_released() {
|
|
|
|
|
dirName = "D:/conf";
|
|
|
|
|
else
|
|
|
|
|
dirName = g_conf_path.config_path;
|
|
|
|
|
|
|
|
|
|
ui.comboBox_config_path->addItem(dirName);
|
|
|
|
|
|
|
|
|
|
g_conf_path.config_path = dirName;
|
|
|
|
|
g_conf_path.config_name = "conf.txt";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QDir* dirinfo = new QDir(dirName);
|
|
|
|
|
if (!dirinfo->exists())
|
|
|
|
|
delete dirinfo, dirinfo = nullptr;
|
|
|
|
|
dirinfo->setNameFilters(QStringList("*.txt"));
|
|
|
|
|
|
|
|
|
|
dirinfo->setNameFilters(QStringList("conf.txt"));
|
|
|
|
|
QStringList fileList = dirinfo->entryList(QDir::Files);
|
|
|
|
|
|
|
|
|
|
if (fileList.count() == 0) {
|
|
|
|
|
g_conf_path.config_path = "D:/conf";
|
|
|
|
|
g_conf_path.config_name = "conf.txt";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
g_conf_path.config_path = dirName;
|
|
|
|
|
g_conf_path.config_name = ui.comboBox_config_path->currentText();
|
|
|
|
|
dirName = "D:/conf";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fileList.removeOne(".");
|
|
|
|
|
fileList.removeOne("..");
|
|
|
|
|
//fileList.removeOne(".");
|
|
|
|
|
//fileList.removeOne("..");
|
|
|
|
|
|
|
|
|
|
ui.comboBox_config_path->clear();
|
|
|
|
|
ui.comboBox_config_path->addItems(fileList);
|
|
|
|
|
connect(ui.comboBox_config_path, SIGNAL(currentIndexChanged(int)), this, SLOT(onComboBoxConfSelect(int)));
|
|
|
|
|
QFileInfo fileInfo(dirName);
|
|
|
|
|
|
|
|
|
|
if (fileInfo.isDir() && ui.comboBox_config_path->findText(fileInfo.absoluteFilePath())) {
|
|
|
|
|
ui.comboBox_config_path->addItem(fileInfo.absoluteFilePath());
|
|
|
|
|
ui.comboBox_config_path->setCurrentText(fileInfo.absoluteFilePath());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_conf_path.config_path = dirName;
|
|
|
|
|
connect(ui.comboBox_config_path, SIGNAL(currentIndexChanged(int)), this, SLOT(onComboBoxConfSelect(int)));
|
|
|
|
|
write_conf_path();
|
|
|
|
|
delete dirinfo, dirinfo = nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -463,6 +451,7 @@ void DialogSetup::on_toolButton_choose_save_pics_path_released() {
|
|
|
|
|
connect(ui.comboBox_save_pics_path, SIGNAL(currentIndexChanged(int)), this, SLOT(onComboBoxPicsPathSelect(int)));
|
|
|
|
|
|
|
|
|
|
delete dirinfo, dirinfo = nullptr;
|
|
|
|
|
write_conf_path();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void DialogSetup::on_toolButton_choose_path_jpg_released() {
|
|
|
|
@ -510,13 +499,13 @@ void DialogSetup::write_conf_path() {
|
|
|
|
|
if (cfg_file.good()) {
|
|
|
|
|
char buf[256];
|
|
|
|
|
memset(buf, 0, 256);
|
|
|
|
|
sprintf(buf, "CONF_PATH=%s\n", g_conf_path.config_path.toStdString().c_str());
|
|
|
|
|
cfg_file.write(buf, strlen(buf));
|
|
|
|
|
memset(buf, 0, 256);
|
|
|
|
|
sprintf(buf, "CONF_NAME=%s\n", g_conf_path.config_name.toStdString().c_str());
|
|
|
|
|
sprintf(buf, "CONF_PATH=%s\n", g_conf_path.config_path.toLocal8Bit().constData());
|
|
|
|
|
cfg_file.write(buf, strlen(buf));
|
|
|
|
|
//memset(buf, 0, 256);
|
|
|
|
|
//sprintf(buf, "CONF_NAME=%s\n", g_conf_path.config_name.toStdString().c_str());
|
|
|
|
|
//cfg_file.write(buf, strlen(buf));
|
|
|
|
|
memset(buf, 0, 256);
|
|
|
|
|
sprintf(buf, "SAVE_PICS_PATH=%s\n", g_conf_path.save_pics_path.toStdString().c_str());
|
|
|
|
|
sprintf(buf, "SAVE_PICS_PATH=%s\n", g_conf_path.save_pics_path.toLocal8Bit().constData());
|
|
|
|
|
cfg_file.write(buf, strlen(buf));
|
|
|
|
|
}
|
|
|
|
|
cfg_file.close();
|
|
|
|
@ -524,8 +513,8 @@ void DialogSetup::write_conf_path() {
|
|
|
|
|
void DialogSetup::write_config()
|
|
|
|
|
{
|
|
|
|
|
std::fstream cfg_file;
|
|
|
|
|
QString cfg_path = g_conf_path.config_path + "/" + g_conf_path.config_name;
|
|
|
|
|
cfg_file.open(cfg_path.toStdString().c_str(), std::ios::out | std::ios::trunc);
|
|
|
|
|
QString cfg_path = g_conf_path.config_path + "/conf.txt";
|
|
|
|
|
cfg_file.open(cfg_path.toLocal8Bit().constData(), std::ios::out | std::ios::trunc);
|
|
|
|
|
if (cfg_file.good())
|
|
|
|
|
{
|
|
|
|
|
char buf[256];
|
|
|
|
@ -578,7 +567,7 @@ void DialogSetup::write_config()
|
|
|
|
|
sprintf(buf, "MODELPATH=%s\n", g_sys_conf.model_path.toStdString().c_str());
|
|
|
|
|
cfg_file.write(buf, strlen(buf));
|
|
|
|
|
memset(buf, 0, 256);
|
|
|
|
|
sprintf(buf, "MODELNAME=%s\n", g_sys_conf.model_name.toStdString().c_str());
|
|
|
|
|
sprintf(buf, "MODELNAME=%s\n", g_sys_conf.model1_name.toStdString().c_str());
|
|
|
|
|
cfg_file.write(buf, strlen(buf));
|
|
|
|
|
memset(buf, 0, 256);
|
|
|
|
|
sprintf(buf, "JPGPATH=%s\n", g_sys_conf.model_jpg_path.toStdString().c_str());
|
|
|
|
|