From d1fd48364860eb13f12cb2dc22acd9a5504c9519 Mon Sep 17 00:00:00 2001 From: Hoop77 <p.badenhoop@gmx.de> Date: Thu, 17 May 2018 14:35:58 +0200 Subject: [PATCH] CommandGui buttons instead of checkbox --- modules/catkin_ws/src/CMakeLists.txt | 2 +- .../catkin_ws/src/PCGui/PCGui/CommandGui.qml | 20 ++++++++++++++----- .../PCGui/include/CommandGui/SignalConsumer.h | 17 +++++++++++----- .../PCGui/PCGui/src/CommandGui/CommandGui.cpp | 19 ++++++++++++------ 4 files changed, 41 insertions(+), 17 deletions(-) diff --git a/modules/catkin_ws/src/CMakeLists.txt b/modules/catkin_ws/src/CMakeLists.txt index 3421623b..581e61db 120000 --- a/modules/catkin_ws/src/CMakeLists.txt +++ b/modules/catkin_ws/src/CMakeLists.txt @@ -1 +1 @@ -/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 diff --git a/modules/catkin_ws/src/PCGui/PCGui/CommandGui.qml b/modules/catkin_ws/src/PCGui/PCGui/CommandGui.qml index 7173a386..9e63cc47 100644 --- a/modules/catkin_ws/src/PCGui/PCGui/CommandGui.qml +++ b/modules/catkin_ws/src/PCGui/PCGui/CommandGui.qml @@ -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 } diff --git a/modules/catkin_ws/src/PCGui/PCGui/include/CommandGui/SignalConsumer.h b/modules/catkin_ws/src/PCGui/PCGui/include/CommandGui/SignalConsumer.h index efefa1ea..d75360e0 100644 --- a/modules/catkin_ws/src/PCGui/PCGui/include/CommandGui/SignalConsumer.h +++ b/modules/catkin_ws/src/PCGui/PCGui/include/CommandGui/SignalConsumer.h @@ -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 = [] {}; diff --git a/modules/catkin_ws/src/PCGui/PCGui/src/CommandGui/CommandGui.cpp b/modules/catkin_ws/src/PCGui/PCGui/src/CommandGui/CommandGui.cpp index 2f81c9cf..bd52892b 100644 --- a/modules/catkin_ws/src/PCGui/PCGui/src/CommandGui/CommandGui.cpp +++ b/modules/catkin_ws/src/PCGui/PCGui/src/CommandGui/CommandGui.cpp @@ -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( -- GitLab