Need help regarding heading into the Okular Feature: 388450
Tobias Deiminger
haxtibal at posteo.de
Sat Feb 17 10:43:09 UTC 2018
Hi Dileep!
@all: Please check if the following is correct
> But now the problem is I'm confused inside the large codebase
Don't worry! I guess this has happened to almost everybody here a few
times :)
> I'm trying to get an idea from the annotations that remains glued to
> the pageview and do scroll with the scrollbar
There's an critical difference between your popup annotation windows and
the "glued annotations": The popup windows are real, independent widgets
(AnnotWindow<-QFrame<-QWidget). But the glued ones are just "dumb"
pixmaps mostly rendered by the poppler generator, while all logic &
drawing is done by the (too-)mighty PageView (a QAbstractScrollArea
widget). Imho, this disqualifies them a bit as "similar code example".
Most "glued annotations" are rendered by the poppler library along with
text and other PDF objects into, simplest case, one big QImage per page
(see PDFGenerator::image [0], rendering thread). The page QImage is
converted to a QPixmap and gets painted at once in
PagePainter::paintCroppedPageOnPainter [1]. Okular just knows the
annotations position rectangles, so that the PageView widget can overlay
some basic UI functionality like tooltips and selection rectangles.
There are interesting exceptions, e.g. stamp annotations. Poppler can't
render them, so as kind of workaround [2] Okular does that on its own.
Stamps are drawn in the seciton "5 -- MIXED FLOW. Draw ANNOTATIONS
[OPAQUE ONES] on ACTIVE PAINTER" - "draw StampAnnotation" [3]. So,
rendered by okular, scrolling with the page - that's a bit closer to
what you want. But otoh, those stamps are still only dumb QPixmaps,
handled by the PageView widget.
Your popup note input dialog is a real independent widget (good so!)
with user input logic + state. See class AnnotWindow, and
PageView::openAnnotationWindow. This widget implements the "open state"
of annotations, which is a term from PDF standard ISO 32000 [4]. Chapter
12.5.1, "Annotations - General" describes the open and closed state in
detail, I think that's a good reading for you.
Btw., I found README.internals.png [5] to be a brief and good overview
of Okulars design when I first touched Okular.
Sorry for not providing concrete solution hints. Hopefully it helped to
at least gain more insight into the problem.
Cheers
Tobias
[0]
https://cgit.kde.org/okular.git/tree/generators/poppler/generator_pdf.cpp?h=v17.12.2#n950
[1]
https://cgit.kde.org/okular.git/tree/ui/pagepainter.cpp?h=v17.12.2#n265
[2] https://bugs.kde.org/show_bug.cgi?id=383651
[3]
https://cgit.kde.org/okular.git/tree/ui/pagepainter.cpp?h=v17.12.2#n741
[4]
https://wwwimages2.adobe.com/content/dam/acom/en/devnet/pdf/PDF32000_2008.pdf
[5] https://cgit.kde.org/okular.git/tree/README.internals.png?h=v17.12.2
More information about the Okular-devel
mailing list