mirror of
https://invent.kde.org/graphics/okular
synced 2024-10-02 14:14:10 +00:00
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
This commit is contained in:
parent
07dd3fe824
commit
dfce0d1fcd
|
@ -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 )
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue