Skip to content

Commit

Permalink
Fix being able to create guides when Guides Locked is checked
Browse files Browse the repository at this point in the history
Closes #54
  • Loading branch information
mitchcurtis committed Jun 8, 2018
1 parent 63bccdf commit 6fe9a3a
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/imagecanvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1059,7 +1059,7 @@ void ImageCanvas::resizeRulers()

void ImageCanvas::updatePressedRuler()
{
mPressedRuler = rulerAtCursorPos();
mPressedRuler = !guidesLocked() ? rulerAtCursorPos() : nullptr;
}

Ruler *ImageCanvas::rulerAtCursorPos()
Expand Down
2 changes: 2 additions & 0 deletions tests/testhelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ void TestHelper::initTestCase()
QVERIFY(app.settings()->isGridVisible());
app.settings()->setRulersVisible(false);
QVERIFY(!app.settings()->areRulersVisible());
app.settings()->setGuidesLocked(false);
QVERIFY(!app.settings()->areGuidesLocked());

// However, this should never change.
QVERIFY(!app.settings()->loadLastOnStartup());
Expand Down
19 changes: 19 additions & 0 deletions tests/tst_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3134,6 +3134,25 @@ void tst_App::rulersAndGuides()
QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, cursorWindowPos);
QCOMPARE(project->guides().isEmpty(), true);
QCOMPARE(window->cursor().shape(), Qt::ArrowCursor);

// Shouldn't be possible to create a guide when Guides Locked is checked.
app.settings()->setGuidesLocked(true);

// Try to drag a guide out.
setCursorPosInPixels(QPoint(50, rulerThickness / 2));
QTest::mouseMove(window, cursorWindowPos);
QVERIFY(!canvas->pressedRuler());

QTest::mousePress(window, Qt::LeftButton, Qt::NoModifier, cursorWindowPos);
QVERIFY(!canvas->pressedRuler());

setCursorPosInPixels(QPoint(50, rulerThickness + 10));
QTest::mouseMove(window, cursorWindowPos);
QTest::mouseRelease(window, Qt::LeftButton, Qt::NoModifier, cursorWindowPos);
QVERIFY(!canvas->pressedRuler());
QCOMPARE(project->guides().size(), 0);

app.settings()->setGuidesLocked(false);
}

void tst_App::recentFiles()
Expand Down

0 comments on commit 6fe9a3a

Please sign in to comment.