Skip to content

Commit

Permalink
Fix Qt 5.15 API deprecation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
rhaschke committed Sep 16, 2023
1 parent d560273 commit 91f3069
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/rviz/default_plugin/tools/interaction_tool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ int InteractionTool::processMouseEvent(ViewportMouseEvent& event)
bool need_selection_update = context_->getFrameCount() > last_selection_frame_count_;

// We are dragging if a button was down and is still down
Qt::MouseButtons buttons = event.buttons_down & (Qt::LeftButton | Qt::RightButton | Qt::MidButton);
Qt::MouseButtons buttons = event.buttons_down & (Qt::LeftButton | Qt::RightButton | Qt::MiddleButton);
if (event.type == QEvent::MouseButtonPress)
buttons &= ~event.acting_button;
bool dragging = buttons != 0;
Expand Down
5 changes: 5 additions & 0 deletions src/rviz/render_panel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,13 @@ void RenderPanel::wheelEvent(QWheelEvent* event)
int last_x = mouse_x_;
int last_y = mouse_y_;

#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
mouse_x_ = event->position().x();
mouse_y_ = event->position().y();
#else
mouse_x_ = event->x();
mouse_y_ = event->y();
#endif

if (context_)
{
Expand Down
2 changes: 1 addition & 1 deletion src/rviz/view_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ QString ViewController::formatClassId(const QString& class_id)

QVariant ViewController::getViewData(int column, int role) const
{
if (role == Qt::TextColorRole)
if (role == Qt::ForegroundRole)
return QVariant();

if (is_active_)
Expand Down
13 changes: 9 additions & 4 deletions src/rviz/viewport_mouse_event.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,14 @@ class ViewportMouseEvent
: panel(p)
, viewport(vp)
, type(e->type())
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
, x(e->position().x())
, y(e->position().y())
#else
, x(e->x())
, y(e->y())
, wheel_delta(e->delta())
#endif
, wheel_delta(e->angleDelta().y())
, acting_button(Qt::NoButton)
, buttons_down(e->buttons())
, modifiers(e->modifiers())
Expand All @@ -93,7 +98,7 @@ class ViewportMouseEvent
}
bool middle()
{
return buttons_down & Qt::MidButton;
return buttons_down & Qt::MiddleButton;
}
bool right()
{
Expand Down Expand Up @@ -121,7 +126,7 @@ class ViewportMouseEvent
}
bool middleUp()
{
return type == QEvent::MouseButtonRelease && acting_button == Qt::MidButton;
return type == QEvent::MouseButtonRelease && acting_button == Qt::MiddleButton;
}
bool rightUp()
{
Expand All @@ -134,7 +139,7 @@ class ViewportMouseEvent
}
bool middleDown()
{
return type == QEvent::MouseButtonPress && acting_button == Qt::MidButton;
return type == QEvent::MouseButtonPress && acting_button == Qt::MiddleButton;
}
bool rightDown()
{
Expand Down

0 comments on commit 91f3069

Please sign in to comment.