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
This commit is contained in:
Pino Toscano 2007-12-16 23:39:40 +00:00
parent a8758221fe
commit e5c4c7c8c9
2 changed files with 33 additions and 7 deletions

View file

@ -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;

View file

@ -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;