Try drawing a freehand annotation on a pdf document (F6 and then the third icon from the top). You will see it appear while you draw. Then as you lift off the pen / release the mouse button, it will disappear very briefly, and then reappear. The bug is that the line also changes its width at the same moment. Here is what I think is happening: the line is drawn by two different parts of the code before and after you release the mouse button. While you draw, the line is drawn by a QPen object constructed in annotationtools.cpp:158. The pen width is const qreal penWidth = m_annotElement.attribute( QStringLiteral("width"), QStringLiteral("1.0") ).toDouble(); from three lines above. Once the mouse button is released, the line is redrawn by code somewhere else, and I haven't been able to find where. I don't know how the pen width is computed there. I played around with my screen resolution and it seems that the problem is that the first drawing code does not take screen resolution into account, while the second one does. I am interested in debugging this further, but I need some help: where is the code that draws the freehand annotation after the initial drawing is completed? I suppose that comparing the two will explain why the line widths differ. Reproducible: Always
Friendly ping :-)
On the initial drawing, the tool uses the configured size as a screen pen width in pixels. When the annotation is added to the document, it is rendered according to the zoom level. To fix it, you would have to take into account the current document zoom in the code you mentioned.
Thanks for the hint. I played around with this a little. It seems that the initial drawing code is buggier than I though. Simply multiplying the zoom factor to the pen width doesn't cut it. You can witness the problems without patching okular: go to Options -> set up Okular -> Annotations -> freehand --> edit and set the line width to something large, like 20. When I do this, the drawing becomes very blocky, the pen width is not constant anymore, and sometimes parts of what I draw are not shown. Any ideas? I may look some more into this, but currently I am out of ideas.
is this really frameworks only?
No, as I learned eventually this happens on master, too. Actually, on master it is worse, because there, the line-while-you-draw always has width 1, irrespective of what the line width settings say. Presumably that's because in annotationtools.cpp:153 it simply says const SmoothPath path( points, QPen(m_engineColor, 1) ); (the '1' is the width).
(In reply to Oliver Sander from comment #5) > No, as I learned eventually this happens on master, too. > > Actually, on master it is worse, because there, the line-while-you-draw > always has width 1, irrespective of what the line width settings say. > Presumably that's because in annotationtools.cpp:153 it simply says > > const SmoothPath path( points, QPen(m_engineColor, 1) ); > > (the '1' is the width). Oliver were you able to identify and resolve this issue within the code? Or can you confirm if this issue is still occurring or if this bug report can be marked as resolved, thanks.
What I said in comment 5 is still valid.
(In reply to Oliver Sander from comment #7) > What I said in comment 5 is still valid. Sorry I meant have you found a solution to the issue where you could provide a patch (merge request) to fix it.
Sorry, but I never found the time to try that.
(In reply to Oliver Sander from comment #9) > Sorry, but I never found the time to try that. I'm going to set this bug to needsinfo as you were the only one to report this issue. If you can, please test it, if not please let us know so we can close this bug report.
Dear Bug Submitter, This bug has been in NEEDSINFO status with no change for at least 15 days. Please provide the requested information as soon as possible and set the bug status as REPORTED. Due to regular bug tracker maintenance, if the bug is still in NEEDSINFO status with no change in 30 days the bug will be closed as RESOLVED > WORKSFORME due to lack of needed information. For more information about our bug triaging procedures please read the wiki located here: https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging If you have already provided the requested information, please mark the bug as REPORTED so that the KDE team knows that the bug is ready to be confirmed. Thank you for helping us make KDE software even better for everyone!
This bug has been in NEEDSINFO status with no change for at least 30 days. The bug is now closed as RESOLVED > WORKSFORME due to lack of needed information. For more information about our bug triaging procedures please read the wiki located here: https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging Thank you for helping us make KDE software even better for everyone!