Always enter mouse drag mode when clicking on overview widget. (#1539)

Fixes #1503.
This commit is contained in:
karliss 2019-05-16 15:17:38 +03:00 committed by Florian Märkl
parent 5a59546009
commit 7bc4dd06bc
2 changed files with 12 additions and 25 deletions

View File

@ -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();
mouseContainsRect(event);
}
}
void OverviewView::mouseReleaseEvent(QMouseEvent *event)

View File

@ -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
*/