Commit e5c4c7c8 authored by Pino Toscano's avatar Pino Toscano

Properly apply the Document AA options when loading a document, or when asked...

Properly apply the Document AA options when loading a document, or when asked to reload our configuration.

svn path=/trunk/KDE/kdegraphics/okular/; revision=749281
parent a8758221
......@@ -453,10 +453,7 @@ bool PDFGenerator::init(QVector<Okular::Page*> & pagesVector, const QString &wal
loadPages(pagesVector, 0, false);
#ifdef HAVE_POPPLER_0_6
pdfdoc->setRenderHint(Poppler::Document::Antialiasing);
pdfdoc->setRenderHint(Poppler::Document::TextAntialiasing);
#endif
setAAOptions();
// the file has been loaded correctly
return true;
......@@ -991,25 +988,52 @@ QVariant PDFGenerator::metaData( const QString & key, const QVariant & option )
bool PDFGenerator::reparseConfig()
{
if ( !pdfdoc )
return false;
bool somethingchanged = false;
// load paper color
QColor color = documentMetaData( "PaperColor", true ).value< QColor >();
// if paper color is changed we have to rebuild every visible pixmap in addition
// to the outputDevice. it's the 'heaviest' case, other effect are just recoloring
// over the page rendered on 'standard' white background.
if ( pdfdoc && color != pdfdoc->paperColor() )
if ( color != pdfdoc->paperColor() )
{
userMutex()->lock();
pdfdoc->setPaperColor(color);
userMutex()->unlock();
return true;
somethingchanged = true;
}
return false;
bool aaChanged = setAAOptions();
somethingchanged = somethingchanged || aaChanged;
return somethingchanged;
}
void PDFGenerator::addPages( KConfigDialog * )
{
}
bool PDFGenerator::setAAOptions()
{
bool changed = false;
#ifdef HAVE_POPPLER_0_6
Poppler::Document::RenderHints oldhints = pdfdoc->renderHints();
#define SET_HINT(hintname, hintdefvalue, hintflag) \
{ \
bool newhint = documentMetaData(hintname, hintdefvalue).toBool(); \
if (newhint != (oldhints & hintflag)) \
{ \
pdfdoc->setRenderHint(hintflag); \
changed = true; \
} \
}
SET_HINT("GraphicsAntialias", true, Poppler::Document::Antialiasing)
SET_HINT("TextAntialias", true, Poppler::Document::TextAntialiasing)
#undef SET_HINT
#endif
return changed;
}
Okular::ExportFormat::List PDFGenerator::exportFormats() const
{
static Okular::ExportFormat::List formats;
......
......@@ -115,6 +115,8 @@ class PDFGenerator : public Okular::Generator, public Okular::ConfigInterface, p
Okular::TextPage * abstractTextPage(const QList<Poppler::TextBox*> &text, double height, double width, int rot);
bool setAAOptions();
// poppler dependant stuff
Poppler::Document *pdfdoc;
......
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