顶层界面ok
This commit is contained in:
@@ -16,16 +16,13 @@ ConnectDialog::ConnectDialog(QWidget *parent) :
|
||||
this->setStyleSheet(stylesheet);
|
||||
file.close();
|
||||
|
||||
//载入上一次的连接数据
|
||||
//读取配置文件
|
||||
//配置文件是json,可扩展性比较好
|
||||
readInfo();
|
||||
|
||||
|
||||
|
||||
connect(ui->pushButton_usrName,SIGNAL(clicked()),
|
||||
this,SLOT(onUsrNameClicked()));
|
||||
|
||||
connect(ui->pushButton_type,SIGNAL(clicked()),
|
||||
this,SLOT(onTypeClicked()));
|
||||
|
||||
//连接信号
|
||||
connect(ui->pushButton_param1,SIGNAL(clicked()),
|
||||
this,SLOT(onParam1Clicked()));
|
||||
|
||||
@@ -43,35 +40,6 @@ ConnectDialog::ConnectDialog(QWidget *parent) :
|
||||
|
||||
connect(ui->pushButton_Connect,SIGNAL(clicked()),
|
||||
this,SLOT(onConnectClicked()));
|
||||
|
||||
|
||||
|
||||
//读取配置文件
|
||||
//配置文件是json,可扩展性比较好
|
||||
|
||||
|
||||
//默认串口
|
||||
//m_usrName = tr("New");
|
||||
//m_Type = tr("SerialPort");
|
||||
|
||||
serialInfo = new QSerialPortInfo();
|
||||
foreach(QSerialPortInfo info, serialInfo->availablePorts())
|
||||
{
|
||||
if(!info.isBusy())
|
||||
m_Param1 = info.portName();
|
||||
}
|
||||
|
||||
|
||||
m_Param2 = tr("115200");
|
||||
m_Param3 = tr("8");
|
||||
m_Param4 = tr("NONE");
|
||||
m_Param5 = tr("1");
|
||||
|
||||
emit usrNameChanged(m_usrName);
|
||||
reBuildList();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
ConnectDialog::~ConnectDialog()
|
||||
@@ -82,21 +50,62 @@ ConnectDialog::~ConnectDialog()
|
||||
void ConnectDialog::setInterface(QVariant value)
|
||||
{
|
||||
m_Type = value;
|
||||
setInit(m_Type,m_usrName);
|
||||
}
|
||||
|
||||
void ConnectDialog::setDevice(QVariant value)
|
||||
{
|
||||
m_usrName = value;
|
||||
setInit(m_Type,m_usrName);
|
||||
}
|
||||
|
||||
void ConnectDialog::setInit(QVariant inter, QVariant device)
|
||||
{
|
||||
m_Type = inter;
|
||||
m_usrName = device;
|
||||
|
||||
//根据名字查找上一次的连接,如果不存在,那么载入默认值
|
||||
|
||||
//查上一次的数据
|
||||
bool isNew = true;
|
||||
for(QJsonValue info: Connect_info) {
|
||||
if (info.isObject()) {
|
||||
|
||||
if(info.toObject().value("Name") == m_usrName)
|
||||
{
|
||||
m_Param1 = info.toObject().value("Param1");
|
||||
m_Param2 = info.toObject().value("Param2");
|
||||
m_Param3 = info.toObject().value("Param3");
|
||||
m_Param4 = info.toObject().value("Param4");
|
||||
m_Param5 = info.toObject().value("Param5");
|
||||
|
||||
isNew = false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if(isNew == true)//新建一个新的连接
|
||||
{
|
||||
//根据接口类型新建一个界面
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
//重建列表
|
||||
//usrname type local port remote port none close
|
||||
//usrname type com baud Len Parity Stop close
|
||||
void ConnectDialog::reBuildList(void)
|
||||
{
|
||||
|
||||
|
||||
ui->pushButton_param1->show();
|
||||
ui->pushButton_param2->show();
|
||||
ui->pushButton_param3->show();
|
||||
|
||||
@@ -92,6 +92,7 @@ public slots:
|
||||
void setInterface(QVariant value);
|
||||
void setDevice(QVariant value);
|
||||
|
||||
void setInit(QVariant inter,QVariant device);
|
||||
|
||||
private:
|
||||
Ui::ConnectDialog *ui;
|
||||
|
||||
@@ -16,12 +16,16 @@ LinkUI::LinkUI(QWidget *parent) :
|
||||
file.close();
|
||||
|
||||
|
||||
//读取接口列表
|
||||
InterfaceList.append(tr("SerialPort"));
|
||||
InterfaceList.append(tr("Multicast"));
|
||||
InterfaceList.append(tr("Unicast"));
|
||||
|
||||
//读取设备列表
|
||||
DeviceList.append(tr("DataLink"));
|
||||
DeviceList.append(tr("RTK"));
|
||||
DeviceList.append(tr("Emergecy"));
|
||||
DeviceList.append(tr("Remote"));
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -84,9 +88,10 @@ void LinkUI::on_commandClicked()
|
||||
ConnectDialog *connectdialog = new ConnectDialog();
|
||||
|
||||
//设置参数
|
||||
connectdialog->setDevice(DeviceString);
|
||||
connectdialog->setInterface(InterfaceString);
|
||||
//connectdialog->setDevice(DeviceString);
|
||||
//connectdialog->setInterface(InterfaceString);
|
||||
|
||||
connectdialog->setInit(InterfaceString,DeviceString);
|
||||
|
||||
connect(connectdialog,SIGNAL(cancelSignal()),
|
||||
this,SLOT(closeTab()));
|
||||
@@ -143,7 +148,7 @@ void LinkUI::on_pushButton_SerialPort_clicked()
|
||||
}
|
||||
}
|
||||
|
||||
//根据现存的协议生成一个列表
|
||||
//根据现存的设备生成一个列表
|
||||
for(QString info: DeviceList) {
|
||||
QPushButton *btn = new QPushButton(ui->frame_DeviceType);
|
||||
btn->setText(info);
|
||||
@@ -206,7 +211,7 @@ void LinkUI::on_pushButton_UDP_clicked()
|
||||
}
|
||||
}
|
||||
|
||||
//根据现存的协议生成一个列表
|
||||
//根据现存的设备生成一个列表
|
||||
for(QString info: DeviceList) {
|
||||
|
||||
QPushButton *btn = new QPushButton(ui->frame_DeviceType);
|
||||
|
||||
@@ -60,7 +60,7 @@ private:
|
||||
int SerialPortCount = 0;
|
||||
int UDPCount = 0;
|
||||
|
||||
|
||||
QStringList InterfaceList;
|
||||
QStringList DeviceList;
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user