界面已经可以随动
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#include "propertyui.h"
|
||||
#include "ui_propertyui.h"
|
||||
|
||||
|
||||
#include <iterator>
|
||||
#include <QMetaObject>
|
||||
|
||||
|
||||
|
||||
@@ -134,7 +134,12 @@ propertyui::propertyui(QWidget *parent) :
|
||||
|
||||
void propertyui::on_comboBox_friendlyName_currentTextChanged(const QString &arg1)
|
||||
{
|
||||
m_command = ui->comboBox_friendlyName->currentData().toInt();
|
||||
|
||||
rebuildUI(arg1);
|
||||
|
||||
WayPointPropertyUpdate();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -166,8 +171,12 @@ void propertyui::on_radioButton_clicked()
|
||||
}
|
||||
|
||||
ui->comboBox_Frame->setCurrentText(FrameType::StrByType(type));
|
||||
}
|
||||
|
||||
//属性赋值
|
||||
m_frame = type;
|
||||
WayPointPropertyUpdate();
|
||||
|
||||
}
|
||||
|
||||
void propertyui::on_pushButton_ShowAll_clicked()
|
||||
{
|
||||
@@ -187,6 +196,26 @@ void propertyui::on_pushButton_ShowAll_clicked()
|
||||
}
|
||||
|
||||
|
||||
void propertyui::on_pushButton_Last_clicked()
|
||||
{
|
||||
if(m_seq > 0)
|
||||
emit ReadOtherPoint(m_seq - 1);
|
||||
}
|
||||
|
||||
void propertyui::on_pushButton_Next_clicked()
|
||||
{
|
||||
emit ReadOtherPoint(m_seq +1);
|
||||
}
|
||||
|
||||
void propertyui::on_lineEdit_Alt_textChanged(const QString &arg1)
|
||||
{
|
||||
m_z = arg1.toFloat();
|
||||
WayPointPropertyUpdate();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void propertyui::clearLayout(QLayout *layout)
|
||||
{
|
||||
QLayoutItem *item;
|
||||
@@ -205,7 +234,7 @@ void propertyui::clearLayout(QLayout *layout)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//还需要修正
|
||||
void propertyui::rebuildUI(QString CMD)
|
||||
{
|
||||
//QJsonValue info
|
||||
@@ -248,26 +277,169 @@ void propertyui::rebuildUI(QString CMD)
|
||||
Label->setText(i->label());
|
||||
QLabel *Unit = new QLabel();
|
||||
Unit->setText(i->units());
|
||||
ui->frame_Param->layout()->addWidget(Label);
|
||||
|
||||
|
||||
if(i->enumStrings().size() != 0)
|
||||
{
|
||||
QComboBox *combox = new QComboBox();
|
||||
combox->setObjectName("param" + QString::number(i->param()));
|
||||
combox->addItems(i->enumStrings());
|
||||
ui->frame_Param->layout()->addWidget(Label);
|
||||
ui->frame_Param->layout()->addWidget(combox);
|
||||
connect(combox,SIGNAL(currentIndexChanged(int)),
|
||||
this,SLOT(WayPointPropertyUpdate()));
|
||||
}
|
||||
else
|
||||
{
|
||||
QLineEdit *param = new QLineEdit();
|
||||
param->setObjectName("param" + QString::number(i->param()));
|
||||
param->setText(QString::number(i->defaultValue(),'f',i->decimalPlaces()));
|
||||
|
||||
ui->frame_Param->layout()->addWidget(Label);
|
||||
ui->frame_Param->layout()->addWidget(param);
|
||||
connect(param,SIGNAL(textChanged(QString)),
|
||||
this,SLOT(WayPointPropertyUpdate()));
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void propertyui::WayPointPropertyUpdate(void)
|
||||
{
|
||||
m_command = ui->comboBox_friendlyName->currentData().toInt();
|
||||
m_frame = ui->comboBox_Frame->currentIndex();
|
||||
|
||||
QObjectList Widgets = ui->frame_Param->children();
|
||||
for(QList<QObject*>::iterator i = Widgets.begin();i != Widgets.end();i++)
|
||||
{
|
||||
QObject *item = *i;
|
||||
QString ClassName = item->metaObject()->className();
|
||||
if((ClassName == "QLineEdit")||(ClassName == "QComboBox"))
|
||||
{
|
||||
if(item->objectName().size() > 0)
|
||||
{
|
||||
if(item->objectName() == "param1")
|
||||
{
|
||||
if(ClassName == "QComboBox")
|
||||
{
|
||||
QComboBox *combox = qobject_cast<QComboBox *>(item);
|
||||
m_param1 = combox->currentIndex();
|
||||
}
|
||||
else if(ClassName == "QLineEdit")
|
||||
{
|
||||
QLineEdit *lineedit = qobject_cast<QLineEdit *>(item);
|
||||
m_param1 = lineedit->text().toFloat();
|
||||
}
|
||||
}
|
||||
else if(item->objectName() == "param2")
|
||||
{
|
||||
if(ClassName == "QComboBox")
|
||||
{
|
||||
QComboBox *combox = qobject_cast<QComboBox *>(item);
|
||||
m_param2 = combox->currentIndex();
|
||||
}
|
||||
else if(ClassName == "QLineEdit")
|
||||
{
|
||||
QLineEdit *lineedit = qobject_cast<QLineEdit *>(item);
|
||||
m_param2 = lineedit->text().toFloat();
|
||||
}
|
||||
}
|
||||
else if(item->objectName() == "param3")
|
||||
{
|
||||
if(ClassName == "QComboBox")
|
||||
{
|
||||
QComboBox *combox = qobject_cast<QComboBox *>(item);
|
||||
m_param3 = combox->currentIndex();
|
||||
}
|
||||
else if(ClassName == "QLineEdit")
|
||||
{
|
||||
QLineEdit *lineedit = qobject_cast<QLineEdit *>(item);
|
||||
m_param3 = lineedit->text().toFloat();
|
||||
}
|
||||
}
|
||||
else if(item->objectName() == "param4")
|
||||
{
|
||||
if(ClassName == "QComboBox")
|
||||
{
|
||||
QComboBox *combox = qobject_cast<QComboBox *>(item);
|
||||
m_param4 = combox->currentIndex();
|
||||
}
|
||||
else if(ClassName == "QLineEdit")
|
||||
{
|
||||
QLineEdit *lineedit = qobject_cast<QLineEdit *>(item);
|
||||
m_param4 = lineedit->text().toFloat();
|
||||
}
|
||||
}
|
||||
else if(item->objectName() == "param5")
|
||||
{
|
||||
if(ClassName == "QComboBox")
|
||||
{
|
||||
QComboBox *combox = qobject_cast<QComboBox *>(item);
|
||||
m_x = combox->currentIndex();
|
||||
}
|
||||
else if(ClassName == "QLineEdit")
|
||||
{
|
||||
QLineEdit *lineedit = qobject_cast<QLineEdit *>(item);
|
||||
m_x = lineedit->text().toFloat();
|
||||
}
|
||||
}
|
||||
else if(item->objectName() == "param6")
|
||||
{
|
||||
if(ClassName == "QComboBox")
|
||||
{
|
||||
QComboBox *combox = qobject_cast<QComboBox *>(item);
|
||||
m_y = combox->currentIndex();
|
||||
}
|
||||
else if(ClassName == "QLineEdit")
|
||||
{
|
||||
QLineEdit *lineedit = qobject_cast<QLineEdit *>(item);
|
||||
m_y = lineedit->text().toFloat();
|
||||
}
|
||||
}
|
||||
else if(item->objectName() == "param7")
|
||||
{
|
||||
if(ClassName == "QComboBox")
|
||||
{
|
||||
QComboBox *combox = qobject_cast<QComboBox *>(item);
|
||||
m_z = combox->currentIndex();
|
||||
}
|
||||
else if(ClassName == "QLineEdit")
|
||||
{
|
||||
QLineEdit *lineedit = qobject_cast<QLineEdit *>(item);
|
||||
m_z = lineedit->text().toFloat();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
qDebug() << m_param1
|
||||
<< m_param2
|
||||
<< m_param3
|
||||
<< m_param4
|
||||
<< m_x
|
||||
<< m_y
|
||||
<< m_z
|
||||
<< m_seq
|
||||
<< m_group
|
||||
<< m_command
|
||||
<< m_target_system
|
||||
<< m_target_component
|
||||
<< m_frame
|
||||
<< m_current
|
||||
<< m_autocontinue
|
||||
<< m_mission_type ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void propertyui::setWayPointProperty(float param1,float param2,float param3,float param4,
|
||||
int32_t x,int32_t y,float z,
|
||||
uint16_t seq,
|
||||
@@ -699,3 +871,5 @@ bool propertyui::loadJsonInfo(const QJsonObject& jsonObject, bool requireFullObj
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -169,15 +169,15 @@ public:
|
||||
~propertyui();
|
||||
|
||||
|
||||
Q_PROPERTY(QString category READ category NOTIFY propertyChanged )
|
||||
Q_PROPERTY(QString description READ description NOTIFY propertyChanged )
|
||||
Q_PROPERTY(bool friendlyEdit READ friendlyEdit NOTIFY propertyChanged )
|
||||
Q_PROPERTY(QString friendlyName READ friendlyName NOTIFY propertyChanged )
|
||||
Q_PROPERTY(QString rawName READ rawName NOTIFY propertyChanged )
|
||||
Q_PROPERTY(bool isStandaloneCoordinate READ isStandaloneCoordinate NOTIFY propertyChanged )
|
||||
Q_PROPERTY(bool specifiesCoordinate READ specifiesCoordinate NOTIFY propertyChanged )
|
||||
Q_PROPERTY(bool specifiesAltitudeOnly READ specifiesAltitudeOnly NOTIFY propertyChanged )
|
||||
Q_PROPERTY(int command READ intCommand NOTIFY propertyChanged )
|
||||
Q_PROPERTY(QString category READ category CONSTANT)
|
||||
Q_PROPERTY(QString description READ description CONSTANT)
|
||||
Q_PROPERTY(bool friendlyEdit READ friendlyEdit CONSTANT)
|
||||
Q_PROPERTY(QString friendlyName READ friendlyName CONSTANT)
|
||||
Q_PROPERTY(QString rawName READ rawName CONSTANT)
|
||||
Q_PROPERTY(bool isStandaloneCoordinate READ isStandaloneCoordinate CONSTANT)
|
||||
Q_PROPERTY(bool specifiesCoordinate READ specifiesCoordinate CONSTANT)
|
||||
Q_PROPERTY(bool specifiesAltitudeOnly READ specifiesAltitudeOnly CONSTANT)
|
||||
Q_PROPERTY(int command READ intCommand CONSTANT)
|
||||
|
||||
MAV_CMD command(void) const { return _command; }
|
||||
int intCommand(void) const { return (int)_command; }
|
||||
@@ -214,7 +214,21 @@ public slots:
|
||||
|
||||
Q_SIGNALS:
|
||||
|
||||
void propertyChanged(void);
|
||||
|
||||
|
||||
void ReadOtherPoint(uint16_t seq);
|
||||
|
||||
void WayPointPropertyChanged(float param1,float param2,float param3,float param4,
|
||||
int32_t x,int32_t y,float z,
|
||||
uint16_t seq,
|
||||
uint16_t group,
|
||||
uint16_t command,
|
||||
uint8_t target_system,
|
||||
uint8_t target_component,
|
||||
uint8_t frame,
|
||||
uint8_t current,
|
||||
uint8_t autocontinue,
|
||||
uint8_t mission_type);
|
||||
|
||||
|
||||
|
||||
@@ -229,6 +243,18 @@ private slots:
|
||||
|
||||
void on_pushButton_ShowAll_clicked();
|
||||
|
||||
void on_pushButton_Last_clicked();
|
||||
|
||||
void on_pushButton_Next_clicked();
|
||||
|
||||
void on_lineEdit_Alt_textChanged(const QString &arg1);
|
||||
|
||||
|
||||
|
||||
void WayPointPropertyUpdate(void);
|
||||
|
||||
|
||||
|
||||
private:
|
||||
QString _loadErrorString(const QString& errorString) const;
|
||||
bool _infoAvailable(const QString& key) const { return _infoMap.contains(key); }
|
||||
|
||||
@@ -107,20 +107,10 @@
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="lineEdit_Param1"/>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="lineEdit_Param2"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_Param2">
|
||||
<property name="text">
|
||||
<string>Param2</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="lineEdit"/>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_Param1">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Param1</string>
|
||||
</property>
|
||||
@@ -270,12 +260,12 @@
|
||||
<slot>setEnabled(bool)</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>48</x>
|
||||
<y>464</y>
|
||||
<x>52</x>
|
||||
<y>301</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>186</x>
|
||||
<y>466</y>
|
||||
<y>303</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
|
||||
Reference in New Issue
Block a user