状态修改

This commit is contained in:
hm
2020-10-09 13:30:11 +08:00
parent 8d58cc6307
commit cfabeaaa2b
12 changed files with 123 additions and 38 deletions
+48 -1
View File
@@ -1,4 +1,4 @@
#include "StatusUI.h"
#include "StatusUI.h"
#include "ui_StatusUI.h"
StatusUI::StatusUI(QWidget *parent) :
@@ -6,9 +6,56 @@ StatusUI::StatusUI(QWidget *parent) :
ui(new Ui::StatusUI)
{
ui->setupUi(this);
//load qss
QFile file(":/qss/PowerSystem.qss");
file.open(QFile::ReadOnly);
QTextStream filetext(&file);
QString stylesheet = filetext.readAll();
this->setStyleSheet(stylesheet);
file.close();
setColor(ui->checkBox_1,state::success);
setColor(ui->checkBox_2,state::success);
setColor(ui->checkBox_3,state::success);
setColor(ui->checkBox_4,state::success);
setColor(ui->checkBox_5,state::warning);
setColor(ui->checkBox_6,state::success);
}
StatusUI::~StatusUI()
{
delete ui;
}
void StatusUI::setColor(QWidget *w,state s)
{
w->setProperty("state",s);
w->style()->unpolish(w);
w->style()->polish(w);
}
void StatusUI::setValue(QLabel *w,QString s)
{
w->setText(s);
}
void StatusUI::setHealthState(mavlink_sys_status_t *t)
{
uint32_t health = t->onboard_control_sensors_health;
setColor(ui->checkBox_1,((health & 0x0040) > 0)?(((health & 0x0001) > 0)?(state::success):(state::warning)):(state::failure));
setColor(ui->checkBox_2,((health & 0x0080) > 0)?(((health & 0x0002) > 0)?(state::success):(state::warning)):(state::failure));
setColor(ui->checkBox_3,((health & 0x0100) > 0)?(((health & 0x0004) > 0)?(state::success):(state::warning)):(state::failure));
setColor(ui->checkBox_4,((health & 0x0200) > 0)?(((health & 0x0008) > 0)?(state::success):(state::warning)):(state::failure));
setColor(ui->checkBox_5,((health & 0x0400) > 0)?(((health & 0x0010) > 0)?(state::success):(state::warning)):(state::failure));
setColor(ui->checkBox_6,((health & 0x0800) > 0)?(((health & 0x0020) > 0)?(state::success):(state::warning)):(state::failure));
}
+31 -1
View File
@@ -1,8 +1,17 @@
#ifndef STATUSUI_H
#ifndef STATUSUI_H
#define STATUSUI_H
#include <QWidget>
#include "QFile"
#include "QDir"
#include "QStyle"
#include "QTextStream"
#include "QLabel"
#include "mavlink.h"
namespace Ui {
class StatusUI;
}
@@ -12,9 +21,30 @@ class StatusUI : public QWidget
Q_OBJECT
public:
enum state{
success = 0,
failure = 1,
warning = 2,
};
explicit StatusUI(QWidget *parent = nullptr);
~StatusUI();
public slots:
void setHealthState(mavlink_sys_status_t *t);
private slots:
void setColor(QWidget *w,state s);
void setValue(QLabel *w,QString s);
private:
Ui::StatusUI *ui;
};
+9
View File
@@ -22,6 +22,15 @@ SOURCES += \
$$PWD/StatusUI.cpp
INCLUDEPATH += $$PWD/../mavlink \
$$PWD/../mavlink/ardupilotmega \
$$PWD/../mavlink/common \
$$PWD/../mavlink/icarous \
$$PWD/../mavlink/uAvionix \
$$PWD/../mavlink/XYK \
$$PWD/../mavlink/message_definitions
+22 -36
View File
@@ -14,66 +14,52 @@
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="2">
<widget class="QCheckBox" name="checkBox_5">
<item row="0" column="3">
<widget class="QCheckBox" name="checkBox_3">
<property name="text">
<string/>
<string>BMU</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QCheckBox" name="checkBox_2">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="0" column="2">
<item row="0" column="6">
<widget class="QCheckBox" name="checkBox_6">
<property name="text">
<string/>
<string>FL</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="checkBox_9">
<item row="0" column="5">
<widget class="QCheckBox" name="checkBox_5">
<property name="text">
<string/>
<string>CCM</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QCheckBox" name="checkBox_7">
<item row="3" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QCheckBox" name="checkBox_8">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QCheckBox" name="checkBox_4">
<property name="text">
<string/>
<string>惯导号</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="checkBox">
<widget class="QCheckBox" name="checkBox_1">
<property name="text">
<string/>
<string>内置惯导</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="checkBox_3">
<widget class="QCheckBox" name="checkBox_2">
<property name="text">
<string/>
<string>SBG</string>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QCheckBox" name="checkBox_4">
<property name="text">
<string>ECU</string>
</property>
</widget>
</item>
+1
View File
@@ -5,5 +5,6 @@
<qresource prefix="/img">
<file>fail.png</file>
<file>normal.png</file>
<file>warning.png</file>
</qresource>
</RCC>
+7
View File
@@ -32,6 +32,9 @@
image:url(:/img/fail.png);
}
.QLabel[state="2"] {
image:url(:/img/warning.png);
}
.QComboBox {
@@ -57,4 +60,8 @@
image:url(:/img/fail.png);
}
.QCheckBox::indicator[state="2"] {
image:url(:/img/warning.png);
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

+1
View File
@@ -5,5 +5,6 @@
<qresource prefix="/img">
<file>fail.png</file>
<file>normal.png</file>
<file>warning.png</file>
</qresource>
</RCC>
Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

+4
View File
@@ -857,6 +857,10 @@ void MainWindow::updateUI()//事件驱动式更新数据
toolsui->servosystem->setBUMState(&dlink->mavlinknode->vehicle.bmustate);
statusui->setHealthState(&dlink->mavlinknode->vehicle.sys_status);
}
void MainWindow::TotalDistance(double value)