summaryrefslogtreecommitdiffstats
path: root/src/server/connectionframe/connectionframe.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/connectionframe/connectionframe.cpp')
-rw-r--r--src/server/connectionframe/connectionframe.cpp50
1 files changed, 27 insertions, 23 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);
+ }
+ }
}
/**