Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 42 additions & 6 deletions ui/remoteviewwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1029,6 +1029,15 @@ void RemoteViewWidget::mousePressEvent(QMouseEvent *event)
{
m_currentMousePosition = mapToSource(QPointF(event->pos()));

// Initiate the middle mouse button panning that works regardless of the interaction mode
if (event->button() == Qt::MiddleButton) {
m_mouseDownPosition = event->pos() - QPoint(m_x, m_y);
m_cursorBeforeMmbPan = cursor();
setCursor(Qt::ClosedHandCursor);
QWidget::mousePressEvent(event);
return;
}

switch (m_interactionMode) {
case NoInteraction:
break;
Expand Down Expand Up @@ -1075,12 +1084,29 @@ void RemoteViewWidget::mouseReleaseEvent(QMouseEvent *event)
{
m_currentMousePosition = mapToSource(QPointF(event->pos()));

if (event->button() == Qt::MiddleButton) {
// In view interaction, set the open hand cursor if the user hasn't
// initiated LMB panning in the meantime. Otherwise, bring back the
// original cursor.
if (m_interactionMode == ViewInteraction) {
if (!(event->buttons() & Qt::LeftButton)) {
setCursor(Qt::OpenHandCursor);
}
} else {
setCursor(m_cursorBeforeMmbPan);
}
QWidget::mouseReleaseEvent(event);
return;
}

switch (m_interactionMode) {
case NoInteraction:
case ElementPicking:
break;
case ViewInteraction:
setCursor(Qt::OpenHandCursor);
if (!(event->buttons() & Qt::MiddleButton)) {
setCursor(Qt::OpenHandCursor);
}
break;
case Measuring:
if (event->buttons() & Qt::LeftButton)
Expand Down Expand Up @@ -1122,6 +1148,17 @@ void RemoteViewWidget::mouseMoveEvent(QMouseEvent *event)
{
m_currentMousePosition = mapToSource(QPointF(event->pos()));

auto handlePan = [this](QPoint mousePos) {
m_x = mousePos.x() - m_mouseDownPosition.x();
m_y = mousePos.y() - m_mouseDownPosition.y();
clampPanPosition();
updateUserViewport();
};

if (event->buttons() & Qt::MiddleButton) {
handlePan(event->pos());
}

switch (m_interactionMode) {
case NoInteraction:
case ElementPicking:
Expand All @@ -1130,18 +1167,17 @@ void RemoteViewWidget::mouseMoveEvent(QMouseEvent *event)
if (event->buttons() != Qt::LeftButton) {
break;
}
m_x = event->x() - m_mouseDownPosition.x();
m_y = event->y() - m_mouseDownPosition.y();
clampPanPosition();
updateUserViewport();
handlePan(event->pos());
break;
case Measuring:
if (event->buttons() & Qt::LeftButton) {
m_measurementEndPosition = mapToSource(event->pos());
}
break;
case InputRedirection:
sendMouseEvent(event);
if (!(event->buttons() & Qt::MiddleButton)) {
sendMouseEvent(event);
}
break;
case ColorPicking:
// label should be always fully inside the remoteviewwidget
Expand Down
1 change: 1 addition & 0 deletions ui/remoteviewwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ private slots:
QPointF m_currentMousePosition; // in view coordinates
QPoint m_measurementStartPosition; // in source coordinates
QPoint m_measurementEndPosition; // in source coordinates
QCursor m_cursorBeforeMmbPan;
bool m_hasMeasurement;
ObjectIdsFilterProxyModel *m_pickProxyModel;
VisibilityFilterProxyModel *m_invisibleItemsProxyModel;
Expand Down