完善连接界面

This commit is contained in:
2020-06-13 21:23:53 +08:00
parent 8ee711f093
commit 0246ab4f69
2 changed files with 33 additions and 26 deletions
+2
View File
@@ -216,6 +216,8 @@ void Inputter::on_pushButton_ok_clicked()
else
{
//mac模式
//点数不能超过3个,而且间隔的数字不能大于255
}
currentValue = curentStr;
@@ -71,10 +71,6 @@ ConnectDialog::ConnectDialog(QWidget *parent) :
//读取ini文件,将连接列表加入,这样就能记录以前曾经连接过的接口了
}
ConnectDialog::~ConnectDialog()
@@ -138,6 +134,9 @@ void ConnectDialog::reBuildList(void)
ui->label_Param5->setText(tr(""));
ui->pushButton_param5->hide();
ui->label_Description->setText(tr("NetWork"));
}
ui->pushButton_usrName->setText(m_usrName.toString());
@@ -171,6 +170,7 @@ void ConnectDialog::setUsrName(QVariant value)
else
{
//查上一次的数据
bool isNew = true;
for(QJsonValue info: Connect_info) {
if (info.isObject()) {
@@ -184,11 +184,22 @@ void ConnectDialog::setUsrName(QVariant value)
m_Param4 = info.toObject().value("Param4");
m_Param5 = info.toObject().value("Param5");
isNew = false;
}
}
}
if(isNew == true)//新建一个新的连接
{
m_Type = ui->pushButton_type->text();
m_usrName = value;
m_Param1 = ui->pushButton_param1->text();
m_Param2 = ui->pushButton_param2->text();
m_Param3 = ui->pushButton_param3->text();
m_Param4 = ui->pushButton_param4->text();
m_Param5 = ui->pushButton_param5->text();
}
reBuildList();
@@ -199,28 +210,31 @@ void ConnectDialog::setUsrName(QVariant value)
void ConnectDialog::onUsrNameClicked(void)//英文输入
{
//查表
//选择
Selector *selector = new Selector(this);
selector->setGeometry(0,0,this->width(),this->height());
QStringList list;
//list.append(ui->pushButton_usrName->text());//将当前的这个加入
for(QJsonValue info: Connect_info) {
if (info.isObject()) {
//如果这个名称已经连接,那么将不会出现在列表里面
//xxx
list.append(info.toObject().value("Name").toString());
}
}
list.append("New");
if(!list.contains(ui->pushButton_usrName->text()))
{
list.prepend(ui->pushButton_usrName->text());
}
selector->setList(list,ui->pushButton_type->text());
list.append(tr("New"));
selector->setList(list,ui->pushButton_usrName->text());
connect(selector,SIGNAL(confirmValue(QVariant)),
this,SLOT(setUsrName(QVariant)));
@@ -235,24 +249,15 @@ void ConnectDialog::setType(QVariant value)
//载入默认值
if(m_Type.toString() == tr("SerialPort"))
{
m_usrName = tr("Port");
//m_usrName = tr("Port");
QString tiltle = this->windowTitle();
tiltle = tiltle.simplified();
tiltle = tiltle.replace(" ","");
QSettings *configIni = new QSettings("./connetconfig.ini", QSettings::IniFormat);
QString LastPortName = configIni->value("/"+tiltle+"/Port").toString();
foreach(QSerialPortInfo info, serialInfo->availablePorts())
{
if(info.portName() == LastPortName)
{
m_Param1 = LastPortName;
}
else
{
if(!info.isBusy())//不忙的话就加入
{
m_Param1 = info.portName();
}
}
}
m_Param2 = tr("115200");
@@ -262,7 +267,7 @@ void ConnectDialog::setType(QVariant value)
}
else if(m_Type.toString() == tr("UDP"))
{
m_usrName = tr("Net");
//m_usrName = tr("Net");
//根据上一次的网络连接号设置名称
//读取上一次的参数设置
@@ -604,7 +609,7 @@ void ConnectDialog::writeInfo(QVariant Name,
//重新刷新一下数组
//readInfo();
readInfo();
}