修复多台同型号设备连接的配置项bug

This commit is contained in:
yangjiaxuan 2022-10-23 15:15:16 +08:00
parent 6f9d5de778
commit b6ae4f2bf4
4 changed files with 18 additions and 11 deletions

View File

@ -1,4 +1,4 @@
#include "config.h"
#include "config.h"
#include <iostream>
#include <fstream>
#include <stdio.h>
@ -284,12 +284,12 @@ int config::save_2_file(QString file, const void* buf, size_t l)
}
int config::find_config(QString dev_name, std::vector<DEVCFG>& cfgs)
{
std::string name(config::device_to_config_dev_name(dev_name));
std::string name = dev_name.toStdString();
int ind = -1;
for(size_t i = 0; i < cfgs.size(); ++i)
{
if(cfgs[i].m_deviceName == name)
if(cfgs[i].m_originDeviceName == name)
{
ind = i;
break;

View File

@ -140,7 +140,7 @@ void device_menu::deviceMenuUpdate(const std::vector<DEVCFG>* dev_cfgs, std::str
child = group_action_->addAction(QString::fromStdString((*dev_cfgs)[i].schemes[j].m_schemeTitle));
else
child = group_action_->addAction(QString::fromStdString((*dev_cfgs)[i].schemes[j].m_schemeName));
child->setProperty(ACTION_DEVICE_NAME_PROPERTY, pm.menu->title());
child->setProperty(ACTION_DEVICE_NAME_PROPERTY, QVariant(QString::fromStdString((*dev_cfgs)[i].m_originDeviceName)));
child->setCheckable(true);
if(curDeviceName == (*dev_cfgs)[i].m_originDeviceName)

View File

@ -54,7 +54,7 @@ void hg_settingdialog::initUi()
{
updateOpt();
createUI();
setWindowTitle(schemes_ ? QString::fromStdString(schemes_->m_deviceName) : tr("set"));
setWindowTitle(schemes_ ? QString::fromStdString(schemes_->m_originDeviceName) : tr("set"));
setWindowFlags(Qt::Dialog | Qt::WindowCloseButtonHint);
resize(690, height());
}

View File

@ -1,4 +1,4 @@
#include "mainwindow.h"
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QDockWidget>
#include <QFileDialog>
@ -2842,13 +2842,20 @@ void MainWindow::on_act_scannerSettings_triggered()
}
DEVCFG cfg;
std::vector<DEVCFG>::iterator it = std::find(dev_schemes_.begin(), dev_schemes_.end(), cur_dev_.name());
cfg.m_deviceName = cur_dev_.name();
if(it != dev_schemes_.end())
int m = 0;
for(; m < (int)dev_schemes_.size(); ++m)
{
cfg = *it;
dev_schemes_.erase(it);
std::string t = dev_schemes_[m].m_originDeviceName;
cfg.m_deviceName = cur_dev_.name();
if(strcmp(t.c_str(), cur_dev_.name().c_str()) == 0)
{
cfg = dev_schemes_[m];
dev_schemes_.erase(dev_schemes_.begin() + m);
break;
}
}
hg_settingdialog dlg(cur_dev_.handle(), this, &cfg);
dlg.set_config_file(&m_config);
dlg.exec();