Queries regarding adding a new 'typewriter' annotation tool to the toolbar

Tobias Deiminger haxtibal at posteo.de
Sun May 20 11:38:42 UTC 2018


Hi,

this one is about saving the actual annotation (rather then the tool 
configuration).

Am Freitag, 18. Mai 2018, 17:04:09 CEST schrieb Dileep Sankhla:
> 4. In Okular::Annotation::Style::setColor(const QColor &color), it sets
> d->m_color = color (see tree/core/annotations.cpp. Here d is just a 
> pointer
> to a class Private). Does it save color in some config/xml file as the
> previously set annotation color is always there whenever you close and 
> open
> okular?

Yes, it does. For quite some time, saving annotations to an external XML 
file (called "docdata") was the only option to persist annotations. 
Thanks to a major piece of work in an extra branch 
"dont-use-docdata-for-annots-and-forms", we now have a second option 
where we can save the annotation into a PDF file as its native  PDF 
representation. Please see branch [0] and merge commit [1], and related 
bug reports / reviews [2], [3], [4], [5]. You'll learn a lot from it.

If docdata is used instead of PDF, it looks like this:

~$ okular somerawtext.txt   # Create inline note, exit okular

~$ cat .local/share/okular/docdata/24.somerawtext.txt.xml
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE documentInfo>
<documentInfo url="/home/tobias/somerawtext.txt">
  <pageList>
   <page number="0">
    <annotationList>
     <annotation type="1">
      <base creationDate="2018-05-20T11:13:09" author="Tobias Deiminger" 
contents="This is a inline note with white background." 
modifyDate="2018-05-20T11:13:09" 
uniqueName="okular-{2aa99524-e7a1-450d-b440-0b1821e42919}" flags="4" 
color="#ffffff">
       <boundary t="0.164103" r="0.899824" b="0.202853" l="0.251282"/>
       <penStyle ycr="0" spaces="0" style="1" marks="3" xcr="0" 
width="0"/>
       <window summary="Haftnotiz" top="0" flags="-1" left="0" height="0" 
title="" width="0"/>
      </base>
      <text type="1" font="Noto Sans,12,-1,0,50,0,0,0,0,0,Regular" 
icon="Comment"/>
     </annotation>
    </annotationList>
   </page>
  </pageList>
  <generalInfo>
   <history>
    <current viewport="0;C2:0.499145:0.438462:1"/>
   </history>
   <views>
    <view name="PageView">
     <zoom value="0.975" mode="1"/>
    </view>
   </views>
  </generalInfo>
</documentInfo>

> I'm unable to find class Private.

class Annotation::Style has a "d-pointer" to it's implementation, that's 
a well known C++ idiom [6]. The d-pointer is initialized on construction 
of Annotation::Style with a new instance of a class 
Annotation::Style::Private. class Annotation::Style::Private is defined 
in annotations.cpp L177.

Which IDE do you use? Doesn't it support source code navigation? I'm 
mostly using Eclipse, it takes me to the definition of "class Private" 
by pressing F3. But this should even be possible with vim + ctags.

[0] 
https://cgit.kde.org/okular.git/log/?h=dont-use-docdata-for-annots-and-forms
[1] 
https://cgit.kde.org/okular.git/commit/?id=3957683d7651494a7bc48b26e6b113161e9a888c
[2] https://bugs.kde.org/show_bug.cgi?id=151614
[3] https://bugs.kde.org/show_bug.cgi?id=315552
[4] https://bugs.kde.org/show_bug.cgi?id=301774
[5] https://git.reviewboard.kde.org/r/124069/
[6] https://en.wikipedia.org/wiki/Opaque_pointer


More information about the Okular-devel mailing list