From dfce0d1fcd158d62d2536d69c19b151878f2fd9a Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Sun, 25 Nov 2007 12:49:30 +0000 Subject: [PATCH] centralize the way we know whether a generator is configurable, and properly manage i18n loading in that case svn path=/trunk/KDE/kdegraphics/okular/; revision=741325 --- core/document.cpp | 21 ++++++++++++++++----- core/document_p.h | 10 ++++++++-- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/core/document.cpp b/core/document.cpp index fd743261e..9eebcc766 100644 --- a/core/document.cpp +++ b/core/document.cpp @@ -488,6 +488,16 @@ void DocumentPrivate::cacheExportFormats() m_exportCached = true; } +ConfigInterface* DocumentPrivate::generatorConfig( GeneratorInfo& info ) +{ + if ( info.configChecked ) + return info.config; + + info.config = qobject_cast< Okular::ConfigInterface * >( info.generator ); + info.configChecked = true; + return info.config; +} + void DocumentPrivate::saveDocumentInfo() const { if ( m_docFileName.isEmpty() ) @@ -665,10 +675,10 @@ void DocumentPrivate::slotGeneratorConfigChanged( const QString& ) // reparse generator config and if something changed clear Pages bool configchanged = false; - QHash< QString, GeneratorInfo >::const_iterator it = m_loadedGenerators.constBegin(), itEnd = m_loadedGenerators.constEnd(); + QHash< QString, GeneratorInfo >::iterator it = m_loadedGenerators.begin(), itEnd = m_loadedGenerators.end(); for ( ; it != itEnd; ++it ) { - Okular::ConfigInterface * iface = qobject_cast< Okular::ConfigInterface * >( it.value().generator ); + Okular::ConfigInterface * iface = generatorConfig( it.value() ); if ( iface ) { bool it_changed = iface->reparseConfig(); @@ -1314,7 +1324,7 @@ void Document::closeDocument() QHash< QString, GeneratorInfo >::const_iterator genIt = d->m_loadedGenerators.constFind( d->m_generatorName ); Q_ASSERT( genIt != d->m_loadedGenerators.constEnd() ); - if ( !genIt.value().catalogName.isEmpty() ) + if ( !genIt.value().catalogName.isEmpty() && !genIt.value().config ) KGlobal::locale()->removeCatalog( genIt.value().catalogName ); } d->m_generator = 0; @@ -2417,12 +2427,13 @@ void Document::fillConfigDialog( KConfigDialog * dialog ) QHash< QString, GeneratorInfo >::iterator itEnd = d->m_loadedGenerators.end(); for ( ; it != itEnd; ++it ) { - Okular::ConfigInterface * iface = qobject_cast< Okular::ConfigInterface * >( it.value().generator ); + Okular::ConfigInterface * iface = d->generatorConfig( it.value() ); if ( iface ) { iface->addPages( dialog ); - it.value().hasConfig = true; pagesAdded = true; + if ( !it.value().catalogName.isEmpty() ) + KGlobal::locale()->insertCatalog( it.value().catalogName ); } } if ( pagesAdded ) diff --git a/core/document_p.h b/core/document_p.h index d055bf4d7..700e6ed22 100644 --- a/core/document_p.h +++ b/core/document_p.h @@ -32,16 +32,21 @@ class KTemporaryFile; struct AllocatedPixmap; struct RunningSearch; +namespace Okular { +class ConfigInterface; +} + struct GeneratorInfo { GeneratorInfo() - : generator( 0 ), library( 0 ), hasConfig( false ) + : generator( 0 ), library( 0 ), config( 0 ), configChecked( false ) {} Okular::Generator * generator; KLibrary * library; QString catalogName; - bool hasConfig : 1; + Okular::ConfigInterface * config; + bool configChecked : 1; }; namespace Okular { @@ -84,6 +89,7 @@ class DocumentPrivate void unloadGenerator( const GeneratorInfo& info ); void cacheExportFormats(); void setRotationInternal( int r, bool notify ); + ConfigInterface* generatorConfig( GeneratorInfo& info ); // private slots void saveDocumentInfo() const;