mirror of
https://invent.kde.org/graphics/okular
synced 2024-10-04 06:59:32 +00:00
Add a method for generators to know some metadata of the document
adapted the poppler and the chm generators to use that, instead of fiddling with the settings class svn path=/trunk/KDE/kdegraphics/okular/; revision=712614
This commit is contained in:
parent
1b02168dce
commit
78e2377a87
|
@ -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 ) )
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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 );
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -36,9 +36,6 @@
|
|||
#include <okular/core/sourcereference.h>
|
||||
#include <okular/core/textpage.h>
|
||||
|
||||
// local includes
|
||||
#include "settings.h"
|
||||
|
||||
#include <config-okular-poppler.h>
|
||||
|
||||
#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.
|
||||
|
|
Loading…
Reference in a new issue