diff --git a/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/include/controllertabs.h b/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/include/controllertabs.h index 09c828d17c9d0eb75f98c8411fa3f2065505fc24..ea1ba09875bd8d3b8a591474e555731620b03bbf 100644 --- a/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/include/controllertabs.h +++ b/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/include/controllertabs.h @@ -138,10 +138,6 @@ private: bool m_should_search_pose_data_for_object_name = false; QMutex m_should_search_pose_data_for_object_name_mutex; - // The color for normal and highlighted tabs - QColor m_tab_text_colour_normal; - QColor m_tab_text_colour_highlight; - // Mutex for the highlighting of the active controller QMutex m_change_highlighted_controller_mutex; diff --git a/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/src/controllertabs.cpp b/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/src/controllertabs.cpp index 2c873aa4ca2e562ad92977010e2a16fe59c2b64c..485e9ef6ea70b828dda84b4906aa83951c9245a3 100644 --- a/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/src/controllertabs.cpp +++ b/dfall_ws/src/dfall_pkg/GUI_Qt/flyingAgentGUI/src/controllertabs.cpp @@ -44,10 +44,6 @@ ControllerTabs::ControllerTabs(QWidget *parent) : ui->setupUi(this); - // Specify the color for normal and highlighted tabs - m_tab_text_colour_normal = Qt::black; - m_tab_text_colour_highlight = QColor(40,120,40); - // Set all the frame to be the inactive colouring setAllFramesToControllerIsOffColouring(); @@ -440,6 +436,8 @@ void ControllerTabs::controllerUsedChangedCallback(const std_msgs::Int32& msg) void ControllerTabs::setControllerEnabled(int new_controller) { + // Define the tab text highlight colour locally + const static QColor tab_text_colour_highlight = QColor(40,120,40); // Define the on string and style sheet setting locally const static QString style_sheet_string_for_on = "background-color:rgb(40,120,40);"; const static QString text_for_controller_isOn = "A\nC\nT\nI\nV\nE"; @@ -457,7 +455,7 @@ void ControllerTabs::setControllerEnabled(int new_controller) { case DEFAULT_CONTROLLER: { - setTextColourOfTabLabel( m_tab_text_colour_highlight , ui->default_tab ); + setTextColourOfTabLabel( tab_text_colour_highlight , ui->default_tab ); ui->frame_isCurrentController_default->setStyleSheet(style_sheet_string_for_on); ui->label_isCurrentController_default->setText(text_for_controller_isOn); break; @@ -469,7 +467,7 @@ void ControllerTabs::setControllerEnabled(int new_controller) } case STUDENT_CONTROLLER: { - setTextColourOfTabLabel( m_tab_text_colour_highlight , ui->student_tab ); + setTextColourOfTabLabel( tab_text_colour_highlight , ui->student_tab ); ui->frame_isCurrentController_student->setStyleSheet(style_sheet_string_for_on); ui->label_isCurrentController_student->setText(text_for_controller_isOn); break; @@ -481,35 +479,35 @@ void ControllerTabs::setControllerEnabled(int new_controller) } case REMOTE_CONTROLLER: { - setTextColourOfTabLabel( m_tab_text_colour_highlight , ui->remote_tab ); + setTextColourOfTabLabel( tab_text_colour_highlight , ui->remote_tab ); ui->frame_isCurrentController_remote->setStyleSheet(style_sheet_string_for_on); ui->label_isCurrentController_remote->setText(text_for_controller_isOn); break; } case TUNING_CONTROLLER: { - setTextColourOfTabLabel( m_tab_text_colour_highlight , ui->tuning_tab ); + setTextColourOfTabLabel( tab_text_colour_highlight , ui->tuning_tab ); ui->frame_isCurrentController_tuning->setStyleSheet(style_sheet_string_for_on); ui->label_isCurrentController_tuning->setText(text_for_controller_isOn); break; } case PICKER_CONTROLLER: { - setTextColourOfTabLabel( m_tab_text_colour_highlight , ui->picker_tab ); + setTextColourOfTabLabel( tab_text_colour_highlight , ui->picker_tab ); ui->frame_isCurrentController_picker->setStyleSheet(style_sheet_string_for_on); ui->label_isCurrentController_picker->setText(text_for_controller_isOn); break; } case TEMPLATE_CONTROLLER: { - setTextColourOfTabLabel( m_tab_text_colour_highlight , ui->template_tab ); + setTextColourOfTabLabel( tab_text_colour_highlight , ui->template_tab ); ui->frame_isCurrentController_template->setStyleSheet(style_sheet_string_for_on); ui->label_isCurrentController_template->setText(text_for_controller_isOn); break; } case CSONE_CONTROLLER: { - setTextColourOfTabLabel( m_tab_text_colour_highlight , ui->csone_tab ); + setTextColourOfTabLabel( tab_text_colour_highlight , ui->csone_tab ); ui->frame_isCurrentController_csone->setStyleSheet(style_sheet_string_for_on); ui->label_isCurrentController_csone->setText(text_for_controller_isOn); break; @@ -540,17 +538,20 @@ void ControllerTabs::setTextColourOfTabLabel(QColor color , QWidget * tab_widget void ControllerTabs::setAllTabLabelsToNormalColouring() { + // Define the tab text normal colour locally + const static QColor tab_text_colour_normal = Qt::black; + // Lock the mutex m_change_highlighted_controller_mutex.lock(); // Set all the colours to normal - setTextColourOfTabLabel( m_tab_text_colour_normal , ui->default_tab ); - setTextColourOfTabLabel( m_tab_text_colour_normal , ui->student_tab ); - setTextColourOfTabLabel( m_tab_text_colour_normal , ui->picker_tab ); - setTextColourOfTabLabel( m_tab_text_colour_normal , ui->tuning_tab ); - setTextColourOfTabLabel( m_tab_text_colour_normal , ui->remote_tab ); - setTextColourOfTabLabel( m_tab_text_colour_normal , ui->template_tab ); - setTextColourOfTabLabel( m_tab_text_colour_normal , ui->csone_tab ); + setTextColourOfTabLabel( tab_text_colour_normal , ui->default_tab ); + setTextColourOfTabLabel( tab_text_colour_normal , ui->student_tab ); + setTextColourOfTabLabel( tab_text_colour_normal , ui->picker_tab ); + setTextColourOfTabLabel( tab_text_colour_normal , ui->tuning_tab ); + setTextColourOfTabLabel( tab_text_colour_normal , ui->remote_tab ); + setTextColourOfTabLabel( tab_text_colour_normal , ui->template_tab ); + setTextColourOfTabLabel( tab_text_colour_normal , ui->csone_tab ); // Unlock the mutex m_change_highlighted_controller_mutex.unlock(); @@ -684,12 +685,16 @@ void ControllerTabs::setAgentIDsToCoordinate(QVector<int> agentIDs , bool should // SUBSCRIBERS // > For receiving message that the instant controller was changed + m_change_highlighted_controller_mutex.lock(); controllerUsedSubscriber = agent_base_nodeHandle.subscribe("FlyingAgentClient/ControllerUsed", 1, &ControllerTabs::controllerUsedChangedCallback, this); + m_change_highlighted_controller_mutex.unlock(); } else { // Unsubscribe + m_change_highlighted_controller_mutex.lock(); controllerUsedSubscriber.shutdown(); + m_change_highlighted_controller_mutex.unlock(); // Set all tabs to be normal colours setAllTabLabelsToNormalColouring();