添加check说明功能
This commit is contained in:
+163
-18
@@ -18,6 +18,7 @@ const char* CheckUI::_HeightJsonKey = "Height";
|
||||
|
||||
const char* CheckUI::_TextJsonKey = "Text";
|
||||
const char* CheckUI::_rowJsonKey = "row";
|
||||
const char* CheckUI::_descriptionJsonKey = "description";
|
||||
const char* CheckUI::_columnJsonKey = "column";
|
||||
|
||||
|
||||
@@ -73,8 +74,30 @@ CheckUI::~CheckUI()
|
||||
|
||||
void CheckUI::reBuild(void)
|
||||
{
|
||||
ui->gridLayout_Check->setSpacing(spacing);
|
||||
//将旧的按键全部删除
|
||||
QObjectList olist = ui->frame_check->children();
|
||||
|
||||
foreach (QObject *obj, olist) {
|
||||
QPushButton *btn = qobject_cast<QPushButton *>(obj);
|
||||
if(btn)
|
||||
{
|
||||
disconnect(btn,SIGNAL(clicked(bool)),
|
||||
this,SLOT(on_commandClicked()));
|
||||
delete btn;
|
||||
}
|
||||
|
||||
QLabel *lab = qobject_cast<QLabel *>(obj);
|
||||
if(lab)
|
||||
{
|
||||
delete lab;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//添加新的按键
|
||||
ui->gridLayout_Check->setSpacing(spacing);
|
||||
for(QJsonValue info: infoArray) {
|
||||
if (!info.isObject()) {
|
||||
return;
|
||||
@@ -95,6 +118,18 @@ void CheckUI::reBuild(void)
|
||||
btn->style()->unpolish(btn);
|
||||
btn->style()->polish(btn);
|
||||
|
||||
|
||||
QLabel *lab = new QLabel(ui->frame_check);
|
||||
|
||||
lab->adjustSize();
|
||||
lab->setWordWrap(true);
|
||||
|
||||
lab->setText(info.toObject().find(_descriptionJsonKey).value().toString());
|
||||
|
||||
ui->gridLayout_Check->addWidget(lab,
|
||||
info.toObject().find(_rowJsonKey).value().toInt(),
|
||||
info.toObject().find(_columnJsonKey).value().toInt() + 1);
|
||||
|
||||
connect(btn,SIGNAL(clicked(bool)),
|
||||
this,SLOT(on_commandClicked()));
|
||||
}
|
||||
@@ -157,7 +192,6 @@ void CheckUI::loadCommandJson(QJsonObject json)
|
||||
|
||||
emit cmd_long(param1,param2, param3,param4,param5,param6,param7,command,confirm);
|
||||
|
||||
feedback(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -166,20 +200,47 @@ void CheckUI::loadCommandJson(QJsonObject json)
|
||||
}
|
||||
|
||||
|
||||
void CheckUI::feedback(bool flag)
|
||||
{
|
||||
QObjectList list = ui->frame_check->children();
|
||||
|
||||
foreach (QObject *obj, list)
|
||||
{
|
||||
QPushButton *btn = qobject_cast<QPushButton *>(obj);
|
||||
if(btn)
|
||||
{
|
||||
//qDebug() << btn->text();
|
||||
}
|
||||
}
|
||||
void CheckUI::commandAccepted(bool flag,uint16_t command,uint8_t result)
|
||||
{
|
||||
//找到消息的发送者
|
||||
QObjectList list = ui->frame_check->children();
|
||||
|
||||
for(QJsonValue info: infoArray) {
|
||||
if (!info.isObject()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(command == info.toObject().find(_commandJsonKey).value().toInt())
|
||||
{
|
||||
foreach (QObject *obj, list)
|
||||
{
|
||||
QPushButton *btn = qobject_cast<QPushButton *>(obj);
|
||||
if(btn)
|
||||
{
|
||||
if(btn->text() == info.toObject().find(_TextJsonKey).value().toString())
|
||||
{
|
||||
if(flag)
|
||||
{
|
||||
btn->setProperty("state",CheckState::Pass);
|
||||
}
|
||||
else
|
||||
{
|
||||
btn->setProperty("state",CheckState::Fail);
|
||||
}
|
||||
btn->style()->unpolish(btn);
|
||||
btn->style()->polish(btn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void CheckUI::RecieveMsg(mavlink_message_t msg)
|
||||
{
|
||||
switch (msg.msgid) {
|
||||
@@ -255,8 +316,26 @@ void CheckUI::addVehicles(int sysid, int compid)
|
||||
{
|
||||
ui->pushButton_Vehicle->setText(tr("Vehicle %1").arg(sysid));
|
||||
|
||||
loadCommandJson(CheckFiles.value(sysid));
|
||||
reBuild();
|
||||
//检查是否有专属的检查文件,如果有,那么载入,如果没有载入通用的检查文件
|
||||
if(CheckFiles.contains(sysid))
|
||||
{
|
||||
loadCommandJson(CheckFiles.value(sysid));
|
||||
reBuild();
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << tr("not Contains special check file") << sysid;
|
||||
if(CheckFiles.contains(0xFFFF))//默认文件
|
||||
{
|
||||
loadCommandJson(CheckFiles.value(0xFFFF));
|
||||
reBuild();
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << tr("not Contains Default check file") << sysid;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -314,6 +393,7 @@ void CheckUI::LoadCheckFiles(QString path)
|
||||
|
||||
void CheckUI::setVehicle(QVariant value)
|
||||
{
|
||||
ui->pushButton_Vehicle->setText(value.toString());
|
||||
//从新载入一次文件
|
||||
LoadCheckFiles("./checks");
|
||||
|
||||
@@ -356,9 +436,7 @@ void CheckUI::on_pushButton_Vehicle_clicked()
|
||||
QStringList list;
|
||||
list.clear();
|
||||
|
||||
QHash<int,QString>::iterator ite;
|
||||
|
||||
for(ite=Vehicles.begin(); ite!=Vehicles.end();++ite)//每一个key下面都是一个设备的所有参数
|
||||
for(QHash<int,QString>::iterator ite=Vehicles.begin(); ite!=Vehicles.end();++ite)//每一个key下面都是一个设备的所有参数
|
||||
{
|
||||
list.append(tr("Vehicle %1").arg(ite.key()));
|
||||
}
|
||||
@@ -370,3 +448,70 @@ void CheckUI::on_pushButton_Vehicle_clicked()
|
||||
selector->show();
|
||||
}
|
||||
}
|
||||
|
||||
void CheckUI::on_pushButton_Previous_clicked()
|
||||
{
|
||||
if(!ui->pushButton_Vehicle->text().isEmpty())
|
||||
{
|
||||
int index = ui->pushButton_Vehicle->text().indexOf(' ');
|
||||
QString selectid = ui->pushButton_Vehicle->text().mid(index);
|
||||
int vehicle = selectid.toInt();
|
||||
|
||||
qDebug() << vehicle
|
||||
<< Vehicles.keys()
|
||||
<< Vehicles.values();
|
||||
|
||||
bool isLast = false;
|
||||
for(QHash<int,QString>::const_iterator ite=Vehicles.begin(); ite!=Vehicles.end();(isLast)?(ite--):(ite++))//每一个key下面都是一个设备的所有参数
|
||||
{
|
||||
qDebug() << ite.value()
|
||||
<< "isLast" << isLast;
|
||||
if(isLast)
|
||||
{
|
||||
setVehicle(tr("Vehicle %1").arg(ite.key()));
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(ite.key() == vehicle)
|
||||
{
|
||||
isLast = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CheckUI::on_pushButton_Next_clicked()
|
||||
{
|
||||
if(!ui->pushButton_Vehicle->text().isEmpty())
|
||||
{
|
||||
int index = ui->pushButton_Vehicle->text().indexOf(' ');
|
||||
QString selectid = ui->pushButton_Vehicle->text().mid(index);
|
||||
int vehicle = selectid.toInt();
|
||||
|
||||
qDebug() << vehicle
|
||||
<< Vehicles.keys()
|
||||
<< Vehicles.values();
|
||||
|
||||
bool isNext = false;
|
||||
for(QHash<int,QString>::iterator ite=Vehicles.begin(); ite!=Vehicles.end();++ite)//每一个key下面都是一个设备的所有参数
|
||||
{
|
||||
qDebug() << ite.value()
|
||||
<< "Next" << isNext;
|
||||
if(isNext)
|
||||
{
|
||||
|
||||
setVehicle(tr("Vehicle %1").arg(ite.key()));
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(ite.key() == vehicle)
|
||||
{
|
||||
isNext = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,12 +55,13 @@ signals:
|
||||
|
||||
public slots:
|
||||
|
||||
void feedback(bool flag);
|
||||
void RecieveMsg(mavlink_message_t msg);
|
||||
|
||||
void addVehicles(int sysid, int compid);
|
||||
|
||||
|
||||
void commandAccepted(bool flag,uint16_t command,uint8_t result);
|
||||
|
||||
private slots:
|
||||
|
||||
void setVehicle(QVariant value);
|
||||
@@ -72,6 +73,10 @@ private slots:
|
||||
|
||||
void on_pushButton_Vehicle_clicked();
|
||||
|
||||
void on_pushButton_Previous_clicked();
|
||||
|
||||
void on_pushButton_Next_clicked();
|
||||
|
||||
protected:
|
||||
|
||||
QJsonObject parseCheckfiles(const QString& jsonFilename);
|
||||
@@ -118,6 +123,7 @@ private:
|
||||
|
||||
static const char* _TextJsonKey;
|
||||
static const char* _rowJsonKey;
|
||||
static const char* _descriptionJsonKey;
|
||||
static const char* _columnJsonKey;
|
||||
|
||||
|
||||
|
||||
+13
-13
@@ -96,6 +96,19 @@
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="1">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>511</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<layout class="QGridLayout" name="gridLayout_Check">
|
||||
<property name="leftMargin">
|
||||
@@ -112,19 +125,6 @@
|
||||
</property>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>511</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
|
||||
@@ -197,7 +197,42 @@ void CommandUI::loadCommandJson(const QString& jsonFilename)
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CommandUI::commandAccepted(bool flag,uint16_t command,uint8_t result)
|
||||
{
|
||||
//找到消息的发送者
|
||||
QObjectList list = ui->groupBox_Command->children();
|
||||
|
||||
for(QJsonValue info: CMD_infoArray) {
|
||||
if (!info.isObject()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(command == info.toObject().find(_commandJsonKey).value().toInt())
|
||||
{
|
||||
foreach (QObject *obj, list)
|
||||
{
|
||||
QPushButton *btn = qobject_cast<QPushButton *>(obj);
|
||||
if(btn)
|
||||
{
|
||||
if(btn->text() == info.toObject().find(_TextJsonKey).value().toString())
|
||||
{
|
||||
if(flag)
|
||||
{
|
||||
btn->setProperty("state",state::success);
|
||||
}
|
||||
else
|
||||
{
|
||||
btn->setProperty("state",state::failure);
|
||||
}
|
||||
btn->style()->unpolish(btn);
|
||||
btn->style()->polish(btn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -37,6 +37,11 @@ public:
|
||||
explicit CommandUI(QWidget *parent = nullptr);
|
||||
~CommandUI();
|
||||
|
||||
public slots:
|
||||
|
||||
void commandAccepted(bool flag,uint16_t command,uint8_t result);
|
||||
|
||||
|
||||
|
||||
signals:
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ include(./CharInputter/CharInputter.pri)
|
||||
include(./Inputter/Inputter.pri)
|
||||
include(./Multiselector/Multiselector.pri)
|
||||
include(./Selector/Selector.pri)
|
||||
|
||||
include(./Confirm/Confirm.pri)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
#include "Confirm.h"
|
||||
#include "ui_Confirm.h"
|
||||
|
||||
Confirm::Confirm(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::Confirm)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
//load qss
|
||||
QFile file(":/qss/Inputter.qss");
|
||||
file.open(QFile::ReadOnly);
|
||||
QTextStream filetext(&file);
|
||||
QString stylesheet = filetext.readAll();
|
||||
this->setStyleSheet(stylesheet);
|
||||
file.close();
|
||||
|
||||
|
||||
}
|
||||
|
||||
Confirm::~Confirm()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
bool Confirm::event(QEvent *event)
|
||||
{
|
||||
if(event->type() == QEvent::Leave)
|
||||
{
|
||||
this->close();
|
||||
}
|
||||
return QWidget::event(event);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Confirm::on_pushButton_Cancel_clicked()
|
||||
{
|
||||
emit confirmValue(false);
|
||||
}
|
||||
|
||||
void Confirm::on_pushButton_Accept_clicked()
|
||||
{
|
||||
emit confirmValue(true);
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
#ifndef CONFIRM_H
|
||||
#define CONFIRM_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "QDebug" `
|
||||
#include "QFile"
|
||||
|
||||
namespace Ui {
|
||||
class Confirm;
|
||||
}
|
||||
|
||||
class Confirm : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit Confirm(QWidget *parent = nullptr);
|
||||
~Confirm();
|
||||
|
||||
|
||||
signals:
|
||||
|
||||
void confirmValue(QVariant);
|
||||
|
||||
protected:
|
||||
|
||||
bool event(QEvent *event);
|
||||
|
||||
private slots:
|
||||
void on_pushButton_Cancel_clicked();
|
||||
|
||||
void on_pushButton_Accept_clicked();
|
||||
|
||||
private:
|
||||
Ui::Confirm *ui;
|
||||
};
|
||||
|
||||
#endif // CONFIRM_H
|
||||
@@ -0,0 +1,28 @@
|
||||
|
||||
|
||||
RESOURCES += \
|
||||
$$PWD/ConfirmRes.qrc
|
||||
|
||||
FORMS += \
|
||||
$$PWD/Confirm.ui
|
||||
|
||||
HEADERS += \
|
||||
$$PWD/Confirm.h
|
||||
|
||||
SOURCES += \
|
||||
$$PWD/Confirm.cpp
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
|
||||
|
||||
QListWidget {
|
||||
background-color: #F0FFFF;
|
||||
border-width: 2px;
|
||||
border-color: darkkhaki;
|
||||
border-style: solid;
|
||||
border-radius: 5;
|
||||
padding: 3px;
|
||||
font: 20px;
|
||||
}
|
||||
|
||||
QListWidget::Item {
|
||||
height: 60;
|
||||
}
|
||||
|
||||
|
||||
QScrollBar{
|
||||
width:60;
|
||||
background-color:palegoldenrod;
|
||||
}
|
||||
|
||||
.QPushButton {
|
||||
background-color: #FFFFFF;
|
||||
border-width: 2px;
|
||||
border-color: darkkhaki;
|
||||
border-style: solid;
|
||||
border-radius: 5;
|
||||
padding: 3px;
|
||||
font :15px;
|
||||
}
|
||||
|
||||
.QPushButton:pressed {
|
||||
background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
|
||||
stop: 0 #dadbde, stop: 1 #f6f7fa);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>Confirm</class>
|
||||
<widget class="QWidget" name="Confirm">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>345</width>
|
||||
<height>385</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="1" column="0">
|
||||
<widget class="QPushButton" name="pushButton_Cancel">
|
||||
<property name="text">
|
||||
<string>Cancel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QPushButton" name="pushButton_Accept">
|
||||
<property name="text">
|
||||
<string>Accept</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QLabel" name="label_Description">
|
||||
<property name="text">
|
||||
<string>Notice:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -0,0 +1,5 @@
|
||||
<RCC>
|
||||
<qresource prefix="/qss">
|
||||
<file>Confirm.qss</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
@@ -104,6 +104,10 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
connect(commandUI,SIGNAL(cmd_long(float,float,float,float,float,float,float,uint16_t,uint8_t)),
|
||||
dlink->mavlinknode->Commander,SLOT(WriteCmd_long(float,float,float,float,float,float,float,uint16_t,uint8_t)),Qt::DirectConnection);
|
||||
|
||||
|
||||
connect(dlink->mavlinknode->Commander,SIGNAL(commandAccepted(bool,uint16_t,uint8_t)),
|
||||
commandUI,SLOT(commandAccepted(bool,uint16_t,uint8_t)),Qt::DirectConnection);
|
||||
|
||||
//check ----- dlink
|
||||
connect(checkUI,SIGNAL(cmd_long(float,float,float,float,float,float,float,uint16_t,uint8_t)),
|
||||
dlink->mavlinknode->Commander,SLOT(WriteCmd_long(float,float,float,float,float,float,float,uint16_t,uint8_t)),Qt::DirectConnection);
|
||||
|
||||
@@ -4,7 +4,7 @@ TEMPLATE = subdirs
|
||||
|
||||
CONFIG += ordered
|
||||
|
||||
SUBDIRS += Skin
|
||||
#SUBDIRS += Skin
|
||||
SUBDIRS += opmap
|
||||
SUBDIRS += Cockpit
|
||||
|
||||
|
||||
@@ -171,11 +171,12 @@ void commandprocess::Parse(mavlink_message_t msg)
|
||||
{
|
||||
status.transmit.isWaitingforACK = false;
|
||||
|
||||
emit commandAccepted(true,command_ack.command);//广播指令已经接受的反馈
|
||||
emit commandAccepted(true,command_ack.command,command_ack.result);//广播指令反馈
|
||||
}
|
||||
else
|
||||
{
|
||||
//拒绝该指令
|
||||
emit commandAccepted(false,command_ack.command,command_ack.result);//广播指令反馈
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -244,7 +245,7 @@ void commandprocess::WriteStateMachine(void)
|
||||
//清除指令
|
||||
if(status.transmit.type == 0)
|
||||
{
|
||||
emit commandAccepted(false,cmd_int.command);
|
||||
emit commandAccepted(false,cmd_int.command,0);
|
||||
|
||||
cmd_int.param1 = 0;
|
||||
cmd_int.param2 = 0;
|
||||
@@ -260,7 +261,7 @@ void commandprocess::WriteStateMachine(void)
|
||||
}
|
||||
else if(status.transmit.type == 1)
|
||||
{
|
||||
emit commandAccepted(false,cmd_long.command);
|
||||
emit commandAccepted(false,cmd_long.command,0);
|
||||
|
||||
cmd_long.param1 = 0;
|
||||
cmd_long.param2 = 0;
|
||||
|
||||
@@ -121,7 +121,7 @@ signals:
|
||||
|
||||
|
||||
|
||||
void commandAccepted(bool flag,uint16_t id);
|
||||
void commandAccepted(bool flag,uint16_t command,uint8_t result);
|
||||
|
||||
private:
|
||||
bool running_flag = false;
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user