Proper fix for the infinite loop that had occurred to the Overview (#1156)

This commit is contained in:
Vanellope 2019-02-03 16:54:28 +09:00 committed by xarkes
parent 1ee1d7d948
commit 85a57f9e17
2 changed files with 15 additions and 2 deletions

View File

@ -74,11 +74,19 @@ void OverviewView::paintEvent(QPaintEvent *event)
p.drawRect(rangeRect); p.drawRect(rangeRect);
} }
void OverviewView::mousePressEvent(QMouseEvent *event) bool OverviewView::mouseContainsRect(QMouseEvent *event)
{ {
if (rangeRect.contains(event->pos())) { if (rangeRect.contains(event->pos())) {
mouseActive = true; mouseActive = true;
initialDiff = QPointF(event->localPos().x() - rangeRect.x(), event->localPos().y() - rangeRect.y()); 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; return;
} }
qreal w = rangeRect.width(); qreal w = rangeRect.width();
@ -88,7 +96,7 @@ void OverviewView::mousePressEvent(QMouseEvent *event)
rangeRect = QRectF(x, y, w, h); rangeRect = QRectF(x, y, w, h);
viewport()->update(); viewport()->update();
emit mouseMoved(); emit mouseMoved();
GraphView::mousePressEvent(event); mouseContainsRect(event);
} }
void OverviewView::mouseReleaseEvent(QMouseEvent *event) void OverviewView::mouseReleaseEvent(QMouseEvent *event)

View File

@ -98,6 +98,11 @@ private:
*/ */
void adjustScale(); void adjustScale();
/**
* @brief if the mouse is in the rect in Overview.
*/
bool mouseContainsRect(QMouseEvent *event);
/** /**
* @brief base background color changing depending on the theme * @brief base background color changing depending on the theme
*/ */