Store all annotation color attributes as ARGB string
ClosedPublic

Authored by tobiasdeiminger on Sep 4 2018, 9:00 PM.

Details

Summary

This is mainly preparation for D15204 (typewriter), where storing RGB won't be sufficient any longer.
Typewriter will need transparent background (alpha=0x00), which can only be expressed as ARGB string.

Current code handles name format identical for all annotations. It doesn't hurt to store all annotations in ARGB format, so instead of introducing special handling for typewriter, let's store all annotation color attributes as ARGB string.

Note: In case of previously existing okularpartrc, configuration will be reused without conversion. New color format will be written when new settings are saved. This has no bad effect.

Test Plan
  • when [Reviews] section in okularpartrc is initially generated, all annotation color attributes are in #AARRGGBB format
  • saving into archive stores color with alpha channel (#AARRGGBB), for all kind of annotations

Diff Detail

Repository
R223 Okular
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
tobiasdeiminger created this revision.Sep 4 2018, 9:00 PM
Restricted Application added a project: Okular. · View Herald TranscriptSep 4 2018, 9:00 PM
Restricted Application added a subscriber: okular-devel. · View Herald Transcript
tobiasdeiminger requested review of this revision.Sep 4 2018, 9:00 PM
sander added a subscriber: sander.Sep 5 2018, 7:05 PM

I cannot reproduce Part 1 of your test plan. When I delete my okularpartrc and start Okular (with the patch), then the freshly created okularpartrc file contains all colors as RGB, not ARGB. This doesn't seem to have any negative consequences, however.

Part 2 seems to work alright.

I cannot reproduce Part 1 of your test plan. When I delete my okularpartrc and start Okular (with the patch), then the freshly created okularpartrc file

When is your new okularpartrc created exactly? Afaikt, it should not be created right on startup, but only when you modify some tool in the config dialog.

contains all colors as RGB, not ARGB.

Strange, for me it works. New okularpartrc looks like this

AnnotationTools=<tool id="1" type="note-linked"><engine hoverIcon="tool-note" color="#ffff00" type="PickPoint"><annotation icon="Note" color="#ffffff00" type="Text"/></engine><shortcut>1</shortcut></tool> [...]

Are you sure you looked at <annotation color="...">, and not at <engine color="...">? The first one is what matters.

This doesn't seem to have any negative consequences, however.

Existing annotations don't consider alpha channel, so you don't notice it for now. But it would have negative consequence for typewriter.

sander added a comment.Sep 6 2018, 4:02 PM

When is your new okularpartrc created exactly? Afaikt, it should not be created right on startup, but only when you modify some tool in the config dialog.

No. It is created right at program startup. I don't even have to open a document.

Are you sure you looked at <annotation color="...">, and not at <engine color="...">? The first one is what matters.

Yes.

Existing annotations don't consider alpha channel, so you don't notice it for now. But it would have negative consequence for typewriter.

I wanted to check that the new ARGB code handles an existing okularpartrc with RGB colors correctly. And it does.

So what now? The patch seems to do something reasonable, but it does not do what you claim it does.

So what now? The patch seems to do something reasonable, but it does not do what you claim it does.

It must work, else we couldn't go on. I've got sneaking suspicion, a wrong tools.xml is loaded in your setup. Can you watch okular in strace

$ strace -e openat /devroot/usr/bin/okular 2>&1 | grep -F tools.xml
openat(AT_FDCWD, "/devroot/usr/share/okular/tools.xml", O_RDONLY|O_CLOEXEC) = 10

Does okular really take the new patched tools.xml from your development installation? Or does it maybe load that one from your distro, which would be wrong and explain the misbehavior.

sander added a comment.Sep 6 2018, 8:12 PM

It really does take the file tools.xml from my development installation (tested with strace). Indeed, I deliberately purged my distro's okular from my computer a while ago, to avoid confusions like this.

sander accepted this revision.Sep 7 2018, 10:45 AM

Okay, my difficulties in reproducing the described behavior are explained now: I had an old file okularpartrc in .kde/share/config/, and the Kdelibs4ConfigMigrator kept migrating from that old file every time is started Okular without an okularpartrc. With that old file removed everything works as intended.

This revision is now accepted and ready to land.Sep 7 2018, 10:45 AM
tobiasdeiminger edited the summary of this revision. (Show Details)Sep 7 2018, 11:19 AM

I'm going to push, and want to do it on behalf of @dileepsankhla who did the original work. I.e. my Phab revision, but git commit author should be him.
Has anybody tried with arc land? Will this work?

$ git commit --amend --author="Original Author <email@address.com>"
$ arc land

Thank you Tobias for making it landable. Please go ahead :)

This revision was automatically updated to reflect the committed changes.