Commit 2c8dd719 authored by Albert Astals Cid's avatar Albert Astals Cid
Browse files

Convert the poppler annotation popup to Okular annotation window

Not having this is not as bad as it sounds since for most of the
annotations where the style makes sense this is currently already being
converted by AnnotationPrivate::setAnnotationProperties but the plan is
to stop passing xml between poppler annotations and okular annotations
because that's just plain bad
parent 2b639579
...@@ -290,7 +290,7 @@ static Okular::Annotation::LineEffect okularLineEffectFromAnnotationLineEffect(P ...@@ -290,7 +290,7 @@ static Okular::Annotation::LineEffect okularLineEffectFromAnnotationLineEffect(P
return Okular::Annotation::NoEffect; return Okular::Annotation::NoEffect;
} }
Okular::Annotation *createAnnotationFromPopplerAnnotation(Poppler::Annotation *popplerAnnotation, bool *doDelete) Okular::Annotation *createAnnotationFromPopplerAnnotation(Poppler::Annotation *popplerAnnotation, const Poppler::Page &popplerPage, bool *doDelete)
{ {
Okular::Annotation *okularAnnotation = nullptr; Okular::Annotation *okularAnnotation = nullptr;
*doDelete = true; *doDelete = true;
...@@ -437,7 +437,19 @@ Okular::Annotation *createAnnotationFromPopplerAnnotation(Poppler::Annotation *p ...@@ -437,7 +437,19 @@ Okular::Annotation *createAnnotationFromPopplerAnnotation(Poppler::Annotation *p
okularStyle.setLineEffect(okularLineEffectFromAnnotationLineEffect(popplerStyle.lineEffect())); okularStyle.setLineEffect(okularLineEffectFromAnnotationLineEffect(popplerStyle.lineEffect()));
okularStyle.setEffectIntensity(popplerStyle.effectIntensity()); okularStyle.setEffectIntensity(popplerStyle.effectIntensity());
// TODO clone window // Convert the poppler annotation popup to Okular annotation window
Okular::Annotation::Window &okularWindow = okularAnnotation->window();
const Poppler::Annotation::Popup popplerPopup = popplerAnnotation->popup();
// This assumes that both "flags" int mean the same, but since we don't use the flags in okular anywhere it's not really that important
okularWindow.setFlags(popplerPopup.flags());
const QRectF popplerGeometry = popplerPopup.geometry();
const QSize popplerPageSize = popplerPage.pageSize();
okularWindow.setTopLeft(Okular::NormalizedPoint(popplerGeometry.top(), popplerGeometry.left(), popplerPageSize.width(), popplerPageSize.height()));
okularWindow.setWidth(popplerGeometry.width());
okularWindow.setHeight(popplerGeometry.height());
okularWindow.setTitle(popplerPopup.title());
okularWindow.setSummary(popplerPopup.summary());
// TODO clone revisions // TODO clone revisions
if (tieToOkularAnn) { if (tieToOkularAnn) {
okularAnnotation->setNativeId(QVariant::fromValue(popplerAnnotation)); okularAnnotation->setNativeId(QVariant::fromValue(popplerAnnotation));
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
#include "config-okular-poppler.h" #include "config-okular-poppler.h"
#include "core/annotations.h" #include "core/annotations.h"
extern Okular::Annotation *createAnnotationFromPopplerAnnotation(Poppler::Annotation *popplerAnnotation, bool *doDelete); extern Okular::Annotation *createAnnotationFromPopplerAnnotation(Poppler::Annotation *popplerAnnotation, const Poppler::Page &popplerPage, bool *doDelete);
class PopplerAnnotationProxy : public Okular::AnnotationProxy class PopplerAnnotationProxy : public Okular::AnnotationProxy
{ {
......
...@@ -1737,7 +1737,7 @@ void PDFGenerator::addAnnotations(Poppler::Page *popplerPage, Okular::Page *page ...@@ -1737,7 +1737,7 @@ void PDFGenerator::addAnnotations(Poppler::Page *popplerPage, Okular::Page *page
for (Poppler::Annotation *a : popplerAnnotations) { for (Poppler::Annotation *a : popplerAnnotations) {
bool doDelete = true; bool doDelete = true;
Okular::Annotation *newann = createAnnotationFromPopplerAnnotation(a, &doDelete); Okular::Annotation *newann = createAnnotationFromPopplerAnnotation(a, *popplerPage, &doDelete);
if (newann) { if (newann) {
page->addAnnotation(newann); page->addAnnotation(newann);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment