Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Graphics
Okular
Commits
46f80343
Commit
46f80343
authored
Aug 07, 2022
by
Nikola Nikolic
Committed by
Albert Astals Cid
Aug 09, 2022
Browse files
Prevent annotations from being moved over the page border
BUG: 397222
parent
0b5623c6
Pipeline
#215526
passed with stage
in 8 minutes and 54 seconds
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
part/pageviewmouseannotation.cpp
View file @
46f80343
...
...
@@ -460,7 +460,25 @@ void MouseAnnotation::performCommand(const QPoint newPos)
QPointF
normalizedRotatedMouseDelta
(
rotateInRect
(
QPointF
(
mouseDelta
.
x
()
/
pageViewItemRect
.
width
(),
mouseDelta
.
y
()
/
pageViewItemRect
.
height
()),
m_focusedAnnotation
.
pageViewItem
->
page
()
->
rotation
()));
if
(
isMoved
())
{
m_document
->
translatePageAnnotation
(
m_focusedAnnotation
.
pageNumber
,
m_focusedAnnotation
.
annotation
,
Okular
::
NormalizedPoint
(
normalizedRotatedMouseDelta
.
x
(),
normalizedRotatedMouseDelta
.
y
()));
Okular
::
NormalizedPoint
delta
(
normalizedRotatedMouseDelta
.
x
(),
normalizedRotatedMouseDelta
.
y
());
const
Okular
::
NormalizedRect
annotRect
=
m_focusedAnnotation
.
annotation
->
boundingRectangle
();
// if moving annot to the left && delta.x is big enough to move annot outside the page
if
(
delta
.
x
<
0
&&
(
annotRect
.
left
+
delta
.
x
)
<
0
)
{
delta
.
x
=
-
annotRect
.
left
;
// update delta.x to move annot only to the left edge of the page
}
// similar checks for right, top and bottom
if
(
delta
.
x
>
0
&&
(
annotRect
.
right
+
delta
.
x
)
>
1
)
{
delta
.
x
=
1
-
annotRect
.
right
;
}
if
(
delta
.
y
<
0
&&
(
annotRect
.
top
+
delta
.
y
)
<
0
)
{
delta
.
y
=
-
annotRect
.
top
;
}
if
(
delta
.
y
>
0
&&
(
annotRect
.
bottom
+
delta
.
y
)
>
1
)
{
delta
.
y
=
1
-
annotRect
.
bottom
;
}
m_document
->
translatePageAnnotation
(
m_focusedAnnotation
.
pageNumber
,
m_focusedAnnotation
.
annotation
,
delta
);
}
else
if
(
isResized
())
{
QPointF
delta1
,
delta2
;
handleToAdjust
(
normalizedRotatedMouseDelta
,
delta1
,
delta2
,
m_handle
,
m_focusedAnnotation
.
pageViewItem
->
page
()
->
rotation
());
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment