diff options
Diffstat (limited to 'src/server/connectionframe')
-rw-r--r-- | src/server/connectionframe/connectionframe.cpp | 50 | ||||
-rw-r--r-- | src/server/connectionframe/connectionframe.h | 3 |
2 files changed, 28 insertions, 25 deletions
diff --git a/src/server/connectionframe/connectionframe.cpp b/src/server/connectionframe/connectionframe.cpp index e8d8349..c2bba70 100644 --- a/src/server/connectionframe/connectionframe.cpp +++ b/src/server/connectionframe/connectionframe.cpp @@ -60,6 +60,8 @@ static QString style_disconnected( static QIcon *term = nullptr, *cam = nullptr, *eye = nullptr, *lock = nullptr; +static const int START_DRAG_DISTANCE = 40; + bool ConnectionFrame::paintDisabled = false; /** @@ -218,26 +220,6 @@ void ConnectionFrame::updateLabels() } /** - * Handle mouse release event on frame. - * Check if frame was clicked or moved, if not moved enough, the event is handled as click. - * @param event - */ -void ConnectionFrame::mouseReleaseEvent(QMouseEvent* event) -{ - event->accept(); - if (event->button() == Qt::LeftButton) { - QApplication::setOverrideCursor(QCursor(Qt::OpenHandCursor)); - // Only recognize a move if the distance is larger than _startDragDistance - if ((this->pos() - _previousPosition).manhattanLength() > _startDragDistance ) { - emit frameMoved(this); - } else { - move(_previousPosition); - emit clicked(this); - } - } -} - -/** * Handle if mouse reaches frame. * @param event */ @@ -263,18 +245,17 @@ void ConnectionFrame::leaveEvent(QEvent* event) */ void ConnectionFrame::mousePressEvent(QMouseEvent *event) { + event->accept(); if (event->button() == Qt::RightButton) { // Menu... - } else { + } else if (event->button() == Qt::LeftButton) { _clickPoint = event->pos(); _previousPosition = this->pos(); QApplication::setOverrideCursor(QCursor(Qt::ClosedHandCursor)); } // On click, the window has to be on the top-level. - activateWindow(); raise(); update(); - event->accept(); } /** @@ -283,9 +264,32 @@ void ConnectionFrame::mousePressEvent(QMouseEvent *event) */ void ConnectionFrame::mouseMoveEvent(QMouseEvent *event) { + event->accept(); QApplication::setOverrideCursor(QCursor(Qt::ClosedHandCursor)); move(mapToParent(event->pos() - _clickPoint)); + if ((this->pos() - _previousPosition).manhattanLength() > START_DRAG_DISTANCE) { + emit frameMoving(this); + } +} + +/** + * Handle mouse release event on frame. + * Check if frame was clicked or moved, if not moved enough, the event is handled as click. + * @param event + */ +void ConnectionFrame::mouseReleaseEvent(QMouseEvent* event) +{ event->accept(); + QApplication::setOverrideCursor(QCursor(Qt::OpenHandCursor)); + if (event->button() == Qt::LeftButton) { + // Only recognize a move if the distance is larger than _startDragDistance + if ((this->pos() - _previousPosition).manhattanLength() > START_DRAG_DISTANCE) { + emit frameMoved(this); + } else { + move(_previousPosition); + emit clicked(this); + } + } } /** diff --git a/src/server/connectionframe/connectionframe.h b/src/server/connectionframe/connectionframe.h index ba5f235..1d004e6 100644 --- a/src/server/connectionframe/connectionframe.h +++ b/src/server/connectionframe/connectionframe.h @@ -41,8 +41,6 @@ private: bool _isTutor; bool _isFromRoomplan; - static const int _startDragDistance = 40; - void showDefaultThumb(); void calcDesiredThumbSize(const QSize &frameSize); QLabel* addIcon(const QIcon* icon); @@ -85,6 +83,7 @@ protected: void timerEvent(QTimerEvent* event); signals: + void frameMoving(ConnectionFrame* frame); void frameMoved(ConnectionFrame* frame); void doubleClicked(ConnectionFrame* frame); void clicked(ConnectionFrame* frame); |