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

Dileep Sankhla sankhla.dileep96 at gmail.com
Tue May 22 08:30:18 UTC 2018


Hello everyone,



> Basically, annotation color is set as a common attribute to all annotation
>> types at the end of the file and if we should bypass it with an if
>> condition that will set annotation color for type "typewriter" hardcoded
>> to
>> QColor(255,255,255,0).
>> I have tried harcoding it for inline note and in the appearance settings,
>> I
>> got a transparent color but as soon as I create a note, it's background
>> turns to white. and I find color: white in the appearance settings again.
>> Will it work for the typewriter then?
>>
>
> No, if it doesn't work for inline note it also won't work for typewriter.
> We have seen transparent background working in our Qt5 poppler demo
> https://cgit.kde.org/scratch/dileepsankhla/okular-gsoc2018-t
> ypewriter.git/tree/src/main.cpp#n24. So the alpha channel obviously gets
> lost somewhere inside Okular. Can you try to hunt the QColor down the stack
> and see where this happens?

The culprit is here: Okular::Annotation::store in core/annotations.cpp L753.

if ( d->m_style.color().isValid() )
        e.setAttribute( QStringLiteral("color"), d->m_style.color().name()
);

Here QColor::name converts our QColor(255,255,255,0) to #ffffff (white) and
we loose the alpha value. We can thus use:

e.setAttribute( QStringLiteral("color"),
d->m_style.color().name(QColor::HexArgb) );

QColor::HexArgb gives color name in #AARRGGBB format and hence we get our
color hex value as #00ffffff which tells that alpha channel is 0.

This is consistent with all other color values too and I will implement it
in my patch.

Thanks and Regards
Dileep


‌
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/okular-devel/attachments/20180522/a827d39b/attachment.html>


More information about the Okular-devel mailing list