连接界面根据类型确定连接方式
This commit is contained in:
@@ -15,6 +15,13 @@ LinkUI::LinkUI(QWidget *parent) :
|
|||||||
this->setStyleSheet(stylesheet);
|
this->setStyleSheet(stylesheet);
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
|
|
||||||
|
DeviceList.append(tr("DataLink"));
|
||||||
|
DeviceList.append(tr("RTK"));
|
||||||
|
DeviceList.append(tr("Emergecy"));
|
||||||
|
DeviceList.append(tr("Remote"));
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -23,48 +30,89 @@ LinkUI::~LinkUI()
|
|||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LinkUI::on_pushButton_Add_clicked()
|
void LinkUI::settabtiltle(QVariant value)
|
||||||
{
|
{
|
||||||
ConnectDialog *connectdialog = new ConnectDialog();
|
ui->tabWidget->setTabText(ui->tabWidget->currentIndex(),value.toString());
|
||||||
|
|
||||||
|
|
||||||
connect(connectdialog,SIGNAL(cancelSignal()),
|
|
||||||
this,SLOT(closeTab()));
|
|
||||||
|
|
||||||
connect(connectdialog,SIGNAL(usrNameChanged(QVariant)),
|
|
||||||
this,SLOT(settabtiltle(QVariant)));
|
|
||||||
|
|
||||||
connect(connectdialog,SIGNAL(connectSignal(QVariant,QVariant,QVariant,QVariant,QVariant,QVariant,QVariant,QVariant)),
|
|
||||||
this,SIGNAL(connectSignal(QVariant,QVariant,QVariant,QVariant,QVariant,QVariant,QVariant,QVariant)));
|
|
||||||
|
|
||||||
connect(this,SIGNAL(PortConnect(QVariant,QVariant,QVariant,QVariant,QVariant,QVariant,QVariant,QVariant)),
|
|
||||||
connectdialog,SLOT(PortConnected(QVariant,QVariant,QVariant,QVariant,QVariant,QVariant,QVariant,QVariant)));
|
|
||||||
|
|
||||||
|
|
||||||
int index = ui->tabWidget->insertTab(ui->tabWidget->currentIndex(),connectdialog,tr("New"));
|
|
||||||
ui->tabWidget->setCurrentIndex(index);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LinkUI::closeTab()
|
||||||
|
{
|
||||||
|
ui->tabWidget->removeTab(ui->tabWidget->currentIndex());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void LinkUI::on_commandClicked()
|
||||||
|
{
|
||||||
|
//找到消息的发送者
|
||||||
|
QPushButton *btn = qobject_cast<QPushButton *>(sender());
|
||||||
|
|
||||||
|
ConnectDialog *connectdialog = new ConnectDialog();
|
||||||
|
|
||||||
|
|
||||||
|
connect(connectdialog,SIGNAL(cancelSignal()),
|
||||||
|
this,SLOT(closeTab()));
|
||||||
|
|
||||||
|
connect(connectdialog,SIGNAL(usrNameChanged(QVariant)),
|
||||||
|
this,SLOT(settabtiltle(QVariant)));
|
||||||
|
|
||||||
|
connect(connectdialog,SIGNAL(connectSignal(QVariant,QVariant,QVariant,QVariant,QVariant,QVariant,QVariant,QVariant)),
|
||||||
|
this,SIGNAL(connectSignal(QVariant,QVariant,QVariant,QVariant,QVariant,QVariant,QVariant,QVariant)));
|
||||||
|
|
||||||
|
connect(this,SIGNAL(PortConnect(QVariant,QVariant,QVariant,QVariant,QVariant,QVariant,QVariant,QVariant)),
|
||||||
|
connectdialog,SLOT(PortConnected(QVariant,QVariant,QVariant,QVariant,QVariant,QVariant,QVariant,QVariant)));
|
||||||
|
|
||||||
|
|
||||||
|
int index = ui->tabWidget->insertTab(ui->tabWidget->currentIndex(),connectdialog,btn->text());
|
||||||
|
ui->tabWidget->setCurrentIndex(index);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void LinkUI::on_pushButton_SerialPort_clicked()
|
void LinkUI::on_pushButton_SerialPort_clicked()
|
||||||
{
|
{
|
||||||
ConnectDialog *connectdialog = new ConnectDialog();
|
//禁止除了自己之外在这个界面内所有按键
|
||||||
|
//将旧的按键全部删除
|
||||||
|
QObjectList Interface = ui->frame_InterfaceType->children();
|
||||||
|
|
||||||
|
foreach (QObject *obj, Interface) {
|
||||||
|
QPushButton *btn = qobject_cast<QPushButton *>(obj);
|
||||||
|
if(btn)
|
||||||
|
{
|
||||||
|
QPushButton *s = qobject_cast<QPushButton *>(sender());
|
||||||
|
|
||||||
|
if(btn != s)
|
||||||
|
btn->setEnabled(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QObjectList device = ui->frame_DeviceType->children();
|
||||||
|
|
||||||
|
foreach (QObject *obj, device) {
|
||||||
|
QPushButton *btn = qobject_cast<QPushButton *>(obj);
|
||||||
|
if(btn)
|
||||||
|
{
|
||||||
|
delete btn;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//根据现存的协议生成一个列表
|
||||||
|
for(QString info: DeviceList) {
|
||||||
|
|
||||||
|
QPushButton *btn = new QPushButton(ui->frame_DeviceType);
|
||||||
|
btn->setText(info);
|
||||||
|
|
||||||
|
btn->setFixedSize(200,80);
|
||||||
|
|
||||||
|
ui->frame_DeviceType->layout()->addWidget(btn);
|
||||||
|
|
||||||
|
|
||||||
connect(connectdialog,SIGNAL(cancelSignal()),
|
connect(btn,SIGNAL(clicked(bool)),
|
||||||
this,SLOT(closeTab()));
|
this,SLOT(on_commandClicked()));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
connect(connectdialog,SIGNAL(usrNameChanged(QVariant)),
|
|
||||||
this,SLOT(settabtiltle(QVariant)));
|
|
||||||
|
|
||||||
connect(connectdialog,SIGNAL(connectSignal(QVariant,QVariant,QVariant,QVariant,QVariant,QVariant,QVariant,QVariant)),
|
|
||||||
this,SIGNAL(connectSignal(QVariant,QVariant,QVariant,QVariant,QVariant,QVariant,QVariant,QVariant)));
|
|
||||||
|
|
||||||
connect(this,SIGNAL(PortConnect(QVariant,QVariant,QVariant,QVariant,QVariant,QVariant,QVariant,QVariant)),
|
|
||||||
connectdialog,SLOT(PortConnected(QVariant,QVariant,QVariant,QVariant,QVariant,QVariant,QVariant,QVariant)));
|
|
||||||
|
|
||||||
|
|
||||||
int index = ui->tabWidget->insertTab(ui->tabWidget->currentIndex(),connectdialog,tr("New"));
|
|
||||||
ui->tabWidget->setCurrentIndex(index);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LinkUI::on_pushButton_UDP_clicked()
|
void LinkUI::on_pushButton_UDP_clicked()
|
||||||
@@ -90,15 +138,3 @@ void LinkUI::on_pushButton_UDP_clicked()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void LinkUI::settabtiltle(QVariant value)
|
|
||||||
{
|
|
||||||
ui->tabWidget->setTabText(ui->tabWidget->currentIndex(),value.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
void LinkUI::closeTab()
|
|
||||||
{
|
|
||||||
ui->tabWidget->removeTab(ui->tabWidget->currentIndex());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -44,8 +44,7 @@ private slots:
|
|||||||
|
|
||||||
void settabtiltle(QVariant value);
|
void settabtiltle(QVariant value);
|
||||||
void closeTab();
|
void closeTab();
|
||||||
|
void on_commandClicked();
|
||||||
void on_pushButton_Add_clicked();
|
|
||||||
|
|
||||||
void on_pushButton_SerialPort_clicked();
|
void on_pushButton_SerialPort_clicked();
|
||||||
|
|
||||||
@@ -53,6 +52,11 @@ private slots:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::LinkUI *ui;
|
Ui::LinkUI *ui;
|
||||||
|
|
||||||
|
|
||||||
|
QStringList DeviceList;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // LINKUI_H
|
#endif // LINKUI_H
|
||||||
|
|||||||
@@ -36,19 +36,6 @@
|
|||||||
<string>Add</string>
|
<string>Add</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QGridLayout" name="gridLayout_2">
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
<item row="1" column="0">
|
|
||||||
<widget class="QPushButton" name="pushButton_SerialPort">
|
|
||||||
<property name="minimumSize">
|
|
||||||
<size>
|
|
||||||
<width>200</width>
|
|
||||||
<height>80</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>SerialPort</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="2">
|
<item row="1" column="2">
|
||||||
<spacer name="horizontalSpacer">
|
<spacer name="horizontalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
@@ -75,17 +62,66 @@
|
|||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="1" column="0">
|
||||||
<widget class="QPushButton" name="pushButton_UDP">
|
<widget class="QFrame" name="frame_InterfaceType">
|
||||||
<property name="minimumSize">
|
<property name="frameShape">
|
||||||
<size>
|
<enum>QFrame::StyledPanel</enum>
|
||||||
<width>200</width>
|
|
||||||
<height>80</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="frameShadow">
|
||||||
<string>UDP</string>
|
<enum>QFrame::Raised</enum>
|
||||||
</property>
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout_3">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QPushButton" name="pushButton_SerialPort">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>200</width>
|
||||||
|
<height>80</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>SerialPort</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QPushButton" name="pushButton_UDP">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>200</width>
|
||||||
|
<height>80</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>UDP</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<spacer name="verticalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QFrame" name="frame_DeviceType">
|
||||||
|
<property name="frameShape">
|
||||||
|
<enum>QFrame::StyledPanel</enum>
|
||||||
|
</property>
|
||||||
|
<property name="frameShadow">
|
||||||
|
<enum>QFrame::Raised</enum>
|
||||||
|
</property>
|
||||||
|
<layout class="QGridLayout" name="gridLayout_4"/>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
|||||||
@@ -8,9 +8,6 @@ DLink::DLink(QObject *parent) : QObject(parent)
|
|||||||
{
|
{
|
||||||
qDebug() << "Dlink " << QThread::currentThreadId();
|
qDebug() << "Dlink " << QThread::currentThreadId();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//采用插件导入的方式(plugin)
|
//采用插件导入的方式(plugin)
|
||||||
|
|
||||||
//mavlink协议节点
|
//mavlink协议节点
|
||||||
|
|||||||
Reference in New Issue
Block a user