Skip to content
Snippets Groups Projects
Commit d1fd4836 authored by Hoop77's avatar Hoop77 Committed by lenoelda
Browse files

CommandGui buttons instead of checkbox

parent 8ebf734a
No related merge requests found
/opt/ros/lunar/share/catkin/cmake/toplevel.cmake
\ No newline at end of file
/opt/ros/kinetic/share/catkin/cmake/toplevel.cmake
\ No newline at end of file
......@@ -40,23 +40,33 @@ ApplicationWindow {
}
// --- enablePlatoon ---
CheckBox {
id: enablePlatoonCheckbox
objectName: "enablePlatoonCheckbox"
text: "Platoon enabled"
Button {
id: enablePlatoonButton
objectName: "enablePlatoonButton"
text: "Enable Platoon"
anchors.left: hostLabel.left
anchors.top: hostLabel.bottom
anchors.topMargin: 20
}
Button {
id: disablePlatoonButton
objectName: "disablePlatoonButton"
text: "Disable Platoon"
anchors.left: enablePlatoonButton.right
anchors.leftMargin: 15
anchors.verticalCenter: enablePlatoonButton.verticalCenter
}
// --- platoonSpeed ---
Label {
id: platoonSpeedLabel
text: "Platoon Speed:"
anchors.left: hostLabel.left
anchors.top: enablePlatoonCheckbox.bottom
anchors.top: enablePlatoonButton.bottom
anchors.topMargin: 20
}
......
......@@ -22,8 +22,11 @@ public:
void setOnHostChanged(const Callback & callback)
{ onHostChanged = callback; }
void setOnEnablePlatoonChanged(const Callback & callback)
{ onEnablePlatoonChanged = callback; }
void setOnEnablePlatoon(const Callback & callback)
{ onEnablePlatoon = callback; }
void setOnDisablePlatoon(const Callback & callback)
{ onDisablePlatoon = callback; }
void setOnPlatoonSpeedChanged(const Callback & callback)
{ onPlatoonSpeedChanged = callback; }
......@@ -39,8 +42,11 @@ public slots:
void hostChanged()
{ onHostChanged(); };
void enablePlatoonChanged()
{ onEnablePlatoonChanged(); }
void enablePlatoon()
{ onEnablePlatoon(); }
void disablePlatoon()
{ onDisablePlatoon(); }
void platoonSpeedChanged()
{ onPlatoonSpeedChanged(); }
......@@ -54,7 +60,8 @@ public slots:
private:
Callback onHostChanged = [] {};
Callback onEnablePlatoonChanged = [] {};
Callback onEnablePlatoon = [] {};
Callback onDisablePlatoon = [] {};
Callback onPlatoonSpeedChanged = [] {};
Callback onInnerPlatoonDistanceChanged = [] {};
Callback onSpeedChanged = [] {};
......
......@@ -44,7 +44,8 @@ int main(int argc, char * argv[])
auto root = engine.rootObjects()[0];
auto hostTextField = root->findChild<QObject *>("hostTextField");
auto setHostButton = root->findChild<QObject *>("setHostButton");
auto enablePlatoonCheckBox = root->findChild<QObject *>("enablePlatoonCheckbox");
auto enablePlatoonButton = root->findChild<QObject *>("enablePlatoonButton");
auto disablePlatoonButton = root->findChild<QObject *>("disablePlatoonButton");
auto platoonSpeedTextField = root->findChild<QObject *>("platoonSpeedTextField");
auto setPlatoonSpeedButton = root->findChild<QObject *>("setPlatoonSpeedButton");
auto innerPlatoonDistanceTextField = root->findChild<QObject *>("innerPlatoonDistanceTextField");
......@@ -53,7 +54,8 @@ int main(int argc, char * argv[])
auto setSpeedButton = root->findChild<QObject *>("setSpeedButton");
QObject::connect(setHostButton, SIGNAL(clicked()), &consumer, SLOT(hostChanged()));
QObject::connect(enablePlatoonCheckBox, SIGNAL(clicked()), &consumer, SLOT(enablePlatoonChanged()));
QObject::connect(enablePlatoonButton, SIGNAL(clicked()), &consumer, SLOT(enablePlatoon()));
QObject::connect(disablePlatoonButton, SIGNAL(clicked()), &consumer, SLOT(disablePlatoon()));
QObject::connect(setPlatoonSpeedButton, SIGNAL(clicked()), &consumer, SLOT(platoonSpeedChanged()));
QObject::connect(setInnerPlatoonDistanceButton, SIGNAL(clicked()), &consumer, SLOT(innerPlatoonDistanceChanged()));
QObject::connect(setSpeedButton, SIGNAL(clicked()), &consumer, SLOT(speedChanged()));
......@@ -65,11 +67,16 @@ int main(int argc, char * argv[])
commandSender.setHost(host);
});
consumer.setOnEnablePlatoonChanged(
[&commandSender, &enablePlatoonCheckBox]
consumer.setOnEnablePlatoon(
[&commandSender]
{
auto checked = enablePlatoonCheckBox->property("checked").toBool();
commandSender.enablePlatoon(checked);
commandSender.enablePlatoon(true);
});
consumer.setOnDisablePlatoon(
[&commandSender]
{
commandSender.enablePlatoon(false);
});
consumer.setOnPlatoonSpeedChanged(
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment