状态修改
This commit is contained in:
@@ -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));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user