diff --git a/core/document.cpp b/core/document.cpp index 40bb88c0a..35a92ed27 100644 --- a/core/document.cpp +++ b/core/document.cpp @@ -977,6 +977,32 @@ void DocumentPrivate::doContinueGooglesDocumentSearch(void *pagesToNotifySet, vo } } +QVariant DocumentPrivate::documentMetaData( const QString &key, const QVariant &option ) const +{ + if ( key == QLatin1String( "PaperColor" ) ) + { + bool giveDefault = option.toBool(); + // load paper color from Settings, or use the default color (white) + // if we were told to do so + QColor color; + if ( ( Settings::renderMode() == Settings::EnumRenderMode::Paper ) + && Settings::changeColors() ) + { + color = Settings::paperColor(); + } + else if ( giveDefault ) + { + color = Qt::white; + } + return color; + } + else if ( key == QLatin1String( "ZoomFactor" ) ) + { + return Settings::zoomFactor(); + } + return QVariant(); +} + Document::Document( QWidget *widget ) : QObject( widget ), d( new DocumentPrivate( this ) ) diff --git a/core/document_p.h b/core/document_p.h index 6e73f7113..3fc803e3e 100644 --- a/core/document_p.h +++ b/core/document_p.h @@ -102,6 +102,11 @@ class DocumentPrivate * the pixmap generation @p request. */ void requestDone( PixmapRequest * request ); + /** + * Request a particular metadata of the Document itself (ie, not something + * depending on the document type/backend). + */ + QVariant documentMetaData( const QString &key, const QVariant &option ) const; // member variables Document *m_parent; diff --git a/core/generator.cpp b/core/generator.cpp index 4b70d8831..883530728 100644 --- a/core/generator.cpp +++ b/core/generator.cpp @@ -286,6 +286,15 @@ void Generator::setAboutData( KAboutData* data ) d->m_componentData = d->m_about ? new KComponentData( d->m_about ) : 0; } +QVariant Generator::documentMetaData( const QString &key, const QVariant &option ) const +{ + Q_D( const Generator ); + if ( !d->m_document ) + return QVariant(); + + return d->m_document->documentMetaData( key, option ); +} + class PixmapRequest::Private { diff --git a/core/generator.h b/core/generator.h index adc3c0093..f191eaeb3 100644 --- a/core/generator.h +++ b/core/generator.h @@ -444,6 +444,12 @@ setAboutData( about ); */ void setAboutData( KAboutData* data ); + /** + * Request a meta data of the Document, if available, like an internal + * setting. + */ + QVariant documentMetaData( const QString &key, const QVariant &option = QVariant() ) const; + protected: /// @cond PRIVATE Generator( GeneratorPrivate &dd ); diff --git a/generators/chm/generator_chm.cpp b/generators/chm/generator_chm.cpp index 0a4c6f580..d425f2421 100644 --- a/generators/chm/generator_chm.cpp +++ b/generators/chm/generator_chm.cpp @@ -349,9 +349,10 @@ void CHMGenerator::additionalRequestData() Okular::TextPage* CHMGenerator::textPage( Okular::Page * page ) { + bool ok = true; syncLock.lock(); - double zoomP=Okular::Settings::zoomFactor(); - int zoom = qRound( zoomP * 100 ); + double zoomP = documentMetaData( "ZoomFactor" ).toInt( &ok ); + int zoom = ok ? qRound( zoomP * 100 ) : 100; m_syncGen->view()->resize(qRound( page->width() * zoomP ) , qRound( page->height() * zoomP )); preparePageForSyncOperation(zoom, m_file->getUrlForPage ( page->number() + 1 )); Okular::TextPage *tp=new Okular::TextPage(); diff --git a/generators/poppler/generator_pdf.cpp b/generators/poppler/generator_pdf.cpp index e2886cfea..65a8fdda1 100644 --- a/generators/poppler/generator_pdf.cpp +++ b/generators/poppler/generator_pdf.cpp @@ -36,9 +36,6 @@ #include #include -// local includes -#include "settings.h" - #include #ifdef HAVE_POPPLER_0_6 @@ -985,9 +982,8 @@ QVariant PDFGenerator::metaData( const QString & key, const QVariant & option ) bool PDFGenerator::reparseConfig() { - // load paper color from Settings or use the white default color - QColor color = ( (Okular::Settings::renderMode() == Okular::Settings::EnumRenderMode::Paper ) && - Okular::Settings::changeColors() ) ? Okular::Settings::paperColor() : Qt::white; + // 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.