-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5442c95
commit 9acff22
Showing
11 changed files
with
194 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#include "checklist.h" | ||
#include "ui_checklist.h" | ||
#include "pprz_dispatcher.h" | ||
#include "gcs_utils.h" | ||
#include "AircraftManager.h" | ||
#include "dispatcher_ui.h" | ||
#include "chatbubble.h" | ||
#include <QtWidgets> | ||
#include <QDebug> | ||
#include <ostream> | ||
|
||
Checklist::Checklist(QString ac_id, QWidget *parent) : | ||
QFrame(parent), | ||
ui(new Ui::Checklist) | ||
{ | ||
// Get the settings | ||
auto settings_path = appConfig()->value("SETTINGS_PATH").toString(); | ||
QSettings settings(settings_path, QSettings::IniFormat); | ||
pprzlink_id = settings.value("pprzlink/id").toString(); | ||
|
||
// Setup the UI | ||
ui->setupUi(this); | ||
|
||
QList<ChecklistItem*> checklist = AircraftManager::get()->getAircraft(ac_id)->getChecklist(); | ||
for(auto item: checklist) { | ||
if(item->type == "checkbox") { | ||
auto widget_item = new QCheckBox(item->description); | ||
if(item->value == "true") { | ||
widget_item->setChecked(true); | ||
} | ||
ui->verticalLayout->addWidget(widget_item); | ||
|
||
connect(widget_item, &QCheckBox::toggled, this, | ||
[=](bool state) { | ||
item->value = (state)? QString("true") : QString("false"); | ||
sendMessage(ac_id, item); | ||
}); | ||
} | ||
else if(item->type == "text") { | ||
auto widget_item = new QHBoxLayout(); | ||
auto widget_label = new QLabel(item->description); | ||
auto widget_input = new QLineEdit(); | ||
widget_item->addWidget(widget_label); | ||
widget_item->addWidget(widget_input); | ||
ui->verticalLayout->addLayout(widget_item); | ||
|
||
connect(widget_input, &QLineEdit::returnPressed, this, | ||
[=]() { | ||
item->value = widget_input->text(); | ||
sendMessage(ac_id, item); | ||
}); | ||
} | ||
} | ||
|
||
setAutoFillBackground(true); | ||
} | ||
|
||
void Checklist::sendMessage(QString ac_id, ChecklistItem *item) { | ||
auto msgDef = PprzDispatcher::get()->getDict()->getDefinition("INFO_MSG_GROUND"); | ||
pprzlink::Message pprz_msg(msgDef); | ||
pprz_msg.addField("dest", ac_id); | ||
pprz_msg.addField("source", pprzlink_id); | ||
pprz_msg.addField("msg", "[PFC] " + item->name + ": " + item->value); | ||
PprzDispatcher::get()->sendMessage(pprz_msg); | ||
} | ||
|
||
Checklist::~Checklist() | ||
{ | ||
delete ui; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#ifndef CHECKLIST_H | ||
#define CHECKLIST_H | ||
|
||
#include <QFrame> | ||
#include "airframe.h" | ||
|
||
namespace Ui { | ||
class Checklist; | ||
} | ||
|
||
class Checklist : public QFrame | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
explicit Checklist(QString ac_id, QWidget *parent = nullptr); | ||
~Checklist(); | ||
|
||
private: | ||
void sendMessage(QString ac_id, ChecklistItem *item); | ||
|
||
QString pprzlink_id; | ||
Ui::Checklist *ui; | ||
}; | ||
|
||
#endif // CHECKLIST_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ui version="4.0"> | ||
<class>Checklist</class> | ||
<widget class="QFrame" name="Checklist"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>0</x> | ||
<y>0</y> | ||
<width>350</width> | ||
<height>30</height> | ||
</rect> | ||
</property> | ||
<property name="minimumSize"> | ||
<size> | ||
<width>350</width> | ||
<height>30</height> | ||
</size> | ||
</property> | ||
<property name="windowTitle"> | ||
<string>Form</string> | ||
</property> | ||
<property name="frameShape"> | ||
<enum>QFrame::StyledPanel</enum> | ||
</property> | ||
<property name="frameShadow"> | ||
<enum>QFrame::Sunken</enum> | ||
</property> | ||
<layout class="QVBoxLayout" name="verticalLayout"> | ||
<property name="rightMargin"> | ||
<number>9</number> | ||
</property> | ||
<item> | ||
<widget class="QLabel" name="label"> | ||
<property name="styleSheet"> | ||
<string notr="true">font-weight:bold;</string> | ||
</property> | ||
<property name="text"> | ||
<string>Checklist</string> | ||
</property> | ||
</widget> | ||
</item> | ||
</layout> | ||
</widget> | ||
<resources/> | ||
<connections/> | ||
</ui> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters