Skip to content

Commit

Permalink
refactor(tier4_state_rviz_plugin): optimize button color logic in pai…
Browse files Browse the repository at this point in the history
…ntEvent()

Signed-off-by: KhalilSelyan <[email protected]>
  • Loading branch information
KhalilSelyan authored and xmfcx committed Sep 11, 2024
1 parent 4c5326e commit ca422f5
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions common/tier4_state_rviz_plugin/src/custom_button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,16 @@ void CustomElevatedButton::paintEvent(QPaintEvent *)
if (!isEnabled()) {
buttonColor = disabledBgColor;
currentTextColor = disabledTextColor;
}
if (isPressed) {
buttonColor = pressedColor;
} else if (isChecked) {
buttonColor = checkedColor;
} else if (isHovered) {
buttonColor = hoverColor;
} else {
buttonColor = backgroundColor;
if (isPressed) {
buttonColor = pressedColor;

Check warning on line 100 in common/tier4_state_rviz_plugin/src/custom_button.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_state_rviz_plugin/src/custom_button.cpp#L100

Added line #L100 was not covered by tests
} else if (isChecked) {
buttonColor = checkedColor;

Check warning on line 102 in common/tier4_state_rviz_plugin/src/custom_button.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_state_rviz_plugin/src/custom_button.cpp#L102

Added line #L102 was not covered by tests
} else if (isHovered) {
buttonColor = hoverColor;

Check warning on line 104 in common/tier4_state_rviz_plugin/src/custom_button.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_state_rviz_plugin/src/custom_button.cpp#L104

Added line #L104 was not covered by tests
} else {
buttonColor = backgroundColor;

Check warning on line 106 in common/tier4_state_rviz_plugin/src/custom_button.cpp

View check run for this annotation

Codecov / codecov/patch

common/tier4_state_rviz_plugin/src/custom_button.cpp#L106

Added line #L106 was not covered by tests
}
}

int cornerRadius = height() / 2; // Making the corner radius proportional to the height
Expand Down

0 comments on commit ca422f5

Please sign in to comment.