From 7bc4dd06bc53ae961026cc6f02e7acbf6f35313d Mon Sep 17 00:00:00 2001 From: karliss Date: Thu, 16 May 2019 15:17:38 +0300 Subject: [PATCH] Always enter mouse drag mode when clicking on overview widget. (#1539) Fixes #1503. --- src/widgets/OverviewView.cpp | 32 ++++++++++++-------------------- src/widgets/OverviewView.h | 5 ----- 2 files changed, 12 insertions(+), 25 deletions(-) diff --git a/src/widgets/OverviewView.cpp b/src/widgets/OverviewView.cpp index 3a719169..09b8855c 100644 --- a/src/widgets/OverviewView.cpp +++ b/src/widgets/OverviewView.cpp @@ -82,29 +82,21 @@ void OverviewView::paintEvent(QPaintEvent *event) p.drawRect(rangeRect); } -bool OverviewView::mouseContainsRect(QMouseEvent *event) -{ - if (rangeRect.contains(event->pos())) { - mouseActive = true; - initialDiff = QPointF(event->localPos().x() - rangeRect.x(), event->localPos().y() - rangeRect.y()); - return true; - } - return false; -} - void OverviewView::mousePressEvent(QMouseEvent *event) { - if (mouseContainsRect(event)) { - return; + mouseActive = true; + if (rangeRect.contains(event->pos())) { + initialDiff = QPointF(event->localPos().x() - rangeRect.x(), event->localPos().y() - rangeRect.y()); + } else { + qreal w = rangeRect.width(); + qreal h = rangeRect.height(); + qreal x = event->localPos().x() - w / 2; + qreal y = event->localPos().y() - h / 2; + rangeRect = QRectF(x, y, w, h); + initialDiff = QPointF(w / 2, h / 2); + viewport()->update(); + emit mouseMoved(); } - qreal w = rangeRect.width(); - qreal h = rangeRect.height(); - qreal x = event->localPos().x() - w / 2; - qreal y = event->localPos().y() - h / 2; - rangeRect = QRectF(x, y, w, h); - viewport()->update(); - emit mouseMoved(); - mouseContainsRect(event); } void OverviewView::mouseReleaseEvent(QMouseEvent *event) diff --git a/src/widgets/OverviewView.h b/src/widgets/OverviewView.h index c620b936..5c638028 100644 --- a/src/widgets/OverviewView.h +++ b/src/widgets/OverviewView.h @@ -105,11 +105,6 @@ private: virtual GraphView::EdgeConfiguration edgeConfiguration(GraphView::GraphBlock &from, GraphView::GraphBlock *to) override; - /** - * @brief if the mouse is in the rect in Overview. - */ - bool mouseContainsRect(QMouseEvent *event); - /** * @brief base background color changing depending on the theme */