fix some quirks in screen overlays

This commit is contained in:
ArsenArsen 2018-02-13 21:17:05 +01:00
parent 9ccc7d2533
commit 85d57fcc70
No known key found for this signature in database
GPG Key ID: 683D2F43B0CA4BD2
3 changed files with 22 additions and 11 deletions

View File

@ -241,12 +241,11 @@ void CropScene::mouseMoved(QGraphicsSceneMouseEvent *e, QPointF cursorPos, QPoin
}
}
updatePoly();
e->accept();
}
}
prevButtons = buttons;
QGraphicsScene::mouseMoveEvent(e);
setMagVisibility(!proxyMenu->sceneBoundingRect().contains(cursorPos));
}
void CropScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) {
@ -258,7 +257,7 @@ void CropScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *e) {
done(true);
prevButtons = Qt::NoButton;
if (!(e->modifiers() & Qt::ControlModifier)) QGraphicsScene::mouseReleaseEvent(e);
if (e->modifiers() & Qt::ControlModifier) e->accept();
}
void CropScene::mousePressEvent(QGraphicsSceneMouseEvent *e) {
@ -267,7 +266,7 @@ void CropScene::mousePressEvent(QGraphicsSceneMouseEvent *e) {
if (item && item != proxyMenu) removeItem(item);
}
if (!(e->modifiers() & Qt::ControlModifier)) QGraphicsScene::mousePressEvent(e);
if (e->modifiers() & Qt::ControlModifier) e->accept();
}
void CropScene::addDrawingAction(QMenuBar *menu, QString name, QString icon, std::function<DrawItem *()> item) {
@ -286,7 +285,7 @@ void CropScene::keyReleaseEvent(QKeyEvent *event) {
settings::settings().setValue("crophint", enabled);
}
if (!(event->modifiers() & Qt::ControlModifier)) QGraphicsScene::keyReleaseEvent(event);
if (event->modifiers() & Qt::ControlModifier) event->accept();
}

View File

@ -69,7 +69,6 @@ void ScreenOverlay::mouseMoveEvent(QGraphicsSceneMouseEvent *e) {
QCursor::setPos(views()[0]->mapToGlobal(cursorPos().toPoint()));
} else
setCursorPos(e->scenePos());
cursorItem->setPos(cursorPos());
updateMag();
mouseMoved(e, cursorPos(), delta);
}
@ -87,11 +86,21 @@ void ScreenOverlay::moveMouseBy(QPoint delta) {
}
void ScreenOverlay::hideMag() {
magnifier->setVisible(false);
cursorItem->setVisible(false);
magnifierBox->setVisible(false);
magnifierHint->setVisible(false);
magnifierHintBox->setVisible(false);
setMagVisibility(false);
}
void ScreenOverlay::setMagVisibility(bool visible) {
magnifier->setVisible(visible);
cursorItem->setVisible(visible);
magnifierBox->setVisible(visible);
magnifierHint->setVisible(visible);
magnifierHintBox->setVisible(visible);
for (auto *view : views())
view->setCursor(visible ? Qt::BlankCursor : Qt::ArrowCursor);
}
void ScreenOverlay::showMag() {
setMagVisibility(true);
}
void ScreenOverlay::updateMagnifierGrid() {
@ -147,6 +156,7 @@ void ScreenOverlay::updateMag() {
if (bottomRight.y() > sceneRect().bottom())
magnifierPos -= QPointF(0, 130 + magnifierHintBox->boundingRect().height());
magnifier->setPos(magnifierPos);
cursorItem->setPos(cursorPos());
}
void ScreenOverlay::setHighlight(QColor highlight) {

View File

@ -33,6 +33,8 @@ public slots:
void loadSettings();
void updateMag();
void hideMag();
void showMag();
void setMagVisibility(bool visible);
void moveMouse(QPoint newPoint);
void moveMouseBy(QPoint delta);