修正软件结构,按照UI2.0进行解密UI布局
This commit is contained in:
@@ -0,0 +1,257 @@
|
||||
#include "LinkUI.h"
|
||||
#include "ui_LinkUI.h"
|
||||
|
||||
LinkUI::LinkUI(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::LinkUI)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
|
||||
QVector<QString> v;
|
||||
|
||||
v << "Port"
|
||||
<< "COM1"
|
||||
<< "115200"
|
||||
<< "None"
|
||||
<< "Odd"
|
||||
<< "Close";
|
||||
|
||||
|
||||
QVector<QString> v2;
|
||||
v2 << "UDP"
|
||||
<< "192.168.1.10"
|
||||
<< "6061"
|
||||
<< "192.168.0.1"
|
||||
<< "6060"
|
||||
<< "Close";
|
||||
|
||||
|
||||
Conneters.insert("DataLink",v);
|
||||
Conneters.insertMulti("RTK",v2);
|
||||
|
||||
|
||||
reBuildList();
|
||||
}
|
||||
|
||||
|
||||
LinkUI::~LinkUI()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
//重建列表
|
||||
//usrname type local port remote port close
|
||||
//usrname type com baud Parity check close
|
||||
void LinkUI::reBuildList(void)
|
||||
{
|
||||
ui->listWidget->clear();
|
||||
for (QMap<QString,QVector<QString>>::iterator i = Conneters.begin();i != Conneters.end(); ++i)
|
||||
{
|
||||
QString usrName = i.key();
|
||||
QVector<QString> Info = i.value();
|
||||
|
||||
QWidget *widget = new QWidget(ui->listWidget);
|
||||
|
||||
|
||||
QPushButton *m_usrName = new QPushButton(widget);
|
||||
QPushButton *m_Type = new QPushButton(widget);
|
||||
QPushButton *m_Param1 = new QPushButton(widget);
|
||||
QPushButton *m_Param2 = new QPushButton(widget);
|
||||
QPushButton *m_Param3 = new QPushButton(widget);
|
||||
QPushButton *m_Param4 = new QPushButton(widget);
|
||||
QPushButton *m_Close = new QPushButton(widget);
|
||||
|
||||
m_usrName->setText(usrName);
|
||||
//m_Type->setText(Info.at(0));
|
||||
m_Param1->setText(Info.at(1));
|
||||
m_Param2->setText(Info.at(2));
|
||||
m_Param3->setText(Info.at(3));
|
||||
m_Param4->setText(Info.at(4));
|
||||
m_Close->setText(Info.at(5));
|
||||
|
||||
m_Type->setIconSize(QSize(40,40));
|
||||
if(Info.at(0) == "UDP")
|
||||
{
|
||||
m_Type->setIcon(QIcon(":/img/Net.png"));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Type->setIcon(QIcon(":/img/Port.png"));
|
||||
}
|
||||
|
||||
|
||||
m_usrName->setMinimumHeight(60);
|
||||
m_Type->setMinimumHeight(60);
|
||||
m_Param1->setMinimumHeight(60);
|
||||
m_Param2->setMinimumHeight(60);
|
||||
m_Param3->setMinimumHeight(60);
|
||||
m_Param4->setMinimumHeight(60);
|
||||
|
||||
m_Close->setMinimumHeight(60);
|
||||
m_Close->setMinimumWidth(60);
|
||||
m_Close->setMaximumHeight(60);
|
||||
m_Close->setMaximumWidth(60);
|
||||
|
||||
QHBoxLayout *layout = new QHBoxLayout;
|
||||
|
||||
layout->setMargin(0);
|
||||
layout->setSpacing(6);
|
||||
|
||||
|
||||
layout->addWidget(m_usrName);
|
||||
layout->addWidget(m_Type);
|
||||
layout->addWidget(m_Param1);
|
||||
layout->addWidget(m_Param2);
|
||||
layout->addWidget(m_Param3);
|
||||
layout->addWidget(m_Param4);
|
||||
layout->addWidget(m_Close);
|
||||
widget->setLayout(layout);
|
||||
|
||||
|
||||
connect(m_usrName,SIGNAL(clicked(bool)),
|
||||
this,SLOT(onUsrNameClicked()));
|
||||
|
||||
connect(m_Type,SIGNAL(clicked(bool)),
|
||||
this,SLOT(onTypeClicked()));
|
||||
|
||||
connect(m_Param1,SIGNAL(clicked(bool)),
|
||||
this,SLOT(onParam1Clicked()));
|
||||
|
||||
connect(m_Param2,SIGNAL(clicked(bool)),
|
||||
this,SLOT(onParam2Clicked()));
|
||||
|
||||
connect(m_Param3,SIGNAL(clicked(bool)),
|
||||
this,SLOT(onParam3Clicked()));
|
||||
|
||||
connect(m_Param4,SIGNAL(clicked(bool)),
|
||||
this,SLOT(onParam4Clicked()));
|
||||
|
||||
connect(m_Close,SIGNAL(clicked(bool)),
|
||||
this,SLOT(onCloseClicked()));
|
||||
|
||||
|
||||
|
||||
//创建自定义的item
|
||||
//将widget作为列表的item
|
||||
QListWidgetItem *ITEM = new QListWidgetItem();
|
||||
|
||||
|
||||
QSize size = ITEM->sizeHint();
|
||||
ITEM->setSizeHint(QSize(size.width(), 70));
|
||||
ui->listWidget->addItem(ITEM);
|
||||
widget->setSizeIncrement(size.width(), 70);
|
||||
|
||||
ui->listWidget->setItemWidget(ITEM, widget);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void LinkUI::onUsrNameClicked(void)//英文输入
|
||||
{
|
||||
Inputter *inputter = new Inputter(this);
|
||||
inputter->setGeometry(0,0,this->width(),this->height());
|
||||
|
||||
inputter->setDecimalPlaces(0);
|
||||
|
||||
//connect(inputter,SIGNAL(confirmValue(QVariant)),
|
||||
// this,SLOT(setAltitude(QVariant)));
|
||||
|
||||
inputter->show();
|
||||
}
|
||||
|
||||
void LinkUI::onTypeClicked(void)//选择器
|
||||
{
|
||||
Selector *selector = new Selector(this);
|
||||
selector->setGeometry(0,0,this->width(),this->height());
|
||||
|
||||
QStringList list;
|
||||
|
||||
list << "PORT"
|
||||
<< "UDP";
|
||||
|
||||
selector->setList(list);
|
||||
|
||||
// connect(selector,SIGNAL(confirmValue(QVariant)),
|
||||
// this,SLOT(setFriendlyName(QVariant)));
|
||||
|
||||
selector->show();
|
||||
}
|
||||
|
||||
void LinkUI::onParam1Clicked(void)//name/localaddr 串口-选择 udp-输入
|
||||
{
|
||||
Selector *selector = new Selector(this);
|
||||
selector->setGeometry(0,0,this->width(),this->height());
|
||||
|
||||
|
||||
|
||||
//selector->setList(list,ui->pushButton_friendlyName->text());
|
||||
|
||||
// connect(selector,SIGNAL(confirmValue(QVariant)),
|
||||
// this,SLOT(setFriendlyName(QVariant)));
|
||||
|
||||
selector->show();
|
||||
}
|
||||
|
||||
void LinkUI::onParam2Clicked(void)//baud/localport 串口-输入 udp-输入
|
||||
{
|
||||
Inputter *inputter = new Inputter(this);
|
||||
inputter->setGeometry(0,0,this->width(),this->height());
|
||||
inputter->setInputType(1);
|
||||
inputter->setDecimalPlaces(0);
|
||||
|
||||
//connect(inputter,SIGNAL(confirmValue(QVariant)),
|
||||
// this,SLOT(setAltitude(QVariant)));
|
||||
|
||||
inputter->show();
|
||||
}
|
||||
|
||||
void LinkUI::onParam3Clicked(void)//parity/remote addr 串口-选择 udp-输入
|
||||
{
|
||||
Inputter *inputter = new Inputter(this);
|
||||
inputter->setGeometry(0,0,this->width(),this->height());
|
||||
inputter->setInputType(1);
|
||||
inputter->setDecimalPlaces(0);
|
||||
|
||||
//connect(inputter,SIGNAL(confirmValue(QVariant)),
|
||||
// this,SLOT(setAltitude(QVariant)));
|
||||
|
||||
inputter->show();
|
||||
}
|
||||
|
||||
void LinkUI::onParam4Clicked(void)//check/remote port 串口-选择 udp-输入
|
||||
{
|
||||
Inputter *inputter = new Inputter(this);
|
||||
inputter->setGeometry(0,0,this->width(),this->height());
|
||||
inputter->setInputType(1);
|
||||
inputter->setDecimalPlaces(0);
|
||||
|
||||
//connect(inputter,SIGNAL(confirmValue(QVariant)),
|
||||
// this,SLOT(setAltitude(QVariant)));
|
||||
|
||||
inputter->show();
|
||||
}
|
||||
|
||||
void LinkUI::onCloseClicked(void)//关闭本条
|
||||
{
|
||||
//断开连接
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
#ifndef LINKUI_H
|
||||
#define LINKUI_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "QMap"
|
||||
#include "QVector"
|
||||
#include "QPushButton"
|
||||
#include <QListWidgetItem>
|
||||
|
||||
#include "multiselector.h"
|
||||
#include "Selector.h"
|
||||
#include "Inputter.h"
|
||||
|
||||
|
||||
|
||||
namespace Ui {
|
||||
class LinkUI;
|
||||
}
|
||||
|
||||
class LinkUI : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit LinkUI(QWidget *parent = nullptr);
|
||||
~LinkUI();
|
||||
|
||||
signals:
|
||||
void clicked(QString);
|
||||
|
||||
private slots:
|
||||
|
||||
void reBuildList(void);
|
||||
|
||||
void onUsrNameClicked(void);
|
||||
void onTypeClicked(void);
|
||||
void onParam1Clicked(void);
|
||||
void onParam2Clicked(void);
|
||||
void onParam3Clicked(void);
|
||||
void onParam4Clicked(void);
|
||||
void onCloseClicked(void);
|
||||
|
||||
|
||||
|
||||
private:
|
||||
Ui::LinkUI *ui;
|
||||
|
||||
|
||||
//...
|
||||
//usr type (name/addr) (baud/port) ()
|
||||
|
||||
|
||||
QMap<QString,QVector<QString>> Conneters;//type <name addr ...>
|
||||
|
||||
};
|
||||
|
||||
#endif // LINKUI_H
|
||||
@@ -0,0 +1,35 @@
|
||||
|
||||
|
||||
|
||||
|
||||
INCLUDEPATH += $$PWD/../../../ComponentUI/Inputter
|
||||
INCLUDEPATH += $$PWD/../../../ComponentUI/MultiSelector
|
||||
INCLUDEPATH += $$PWD/../../../ComponentUI/Selector
|
||||
|
||||
FORMS += \
|
||||
$$PWD/LinkUI.ui
|
||||
|
||||
HEADERS += \
|
||||
$$PWD/LinkUI.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/LinkUI.cpp
|
||||
|
||||
RESOURCES += \
|
||||
$$PWD/LinkUIRes.qrc
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>LinkUI</class>
|
||||
<widget class="QWidget" name="LinkUI">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>854</width>
|
||||
<height>568</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<property name="leftMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QListWidget" name="listWidget"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,6 @@
|
||||
<RCC>
|
||||
<qresource prefix="/img">
|
||||
<file>Net.png</file>
|
||||
<file>Port.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 6.4 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 43 KiB |
Reference in New Issue
Block a user